Browse Source

change todos

pull/45/head
Thodoris1999 6 years ago
parent
commit
025d874cf1
  1. 3
      app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java
  2. 9
      app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java

3
app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java

@ -158,7 +158,6 @@ public class EmojiKeyboard extends LinearLayout {
RecyclerView emojiRecyclerview = findViewById(R.id.emoji_recyclerview);
emojiRecyclerview.setHasFixedSize(true);
// TODO: More meaningful span count for grid
GridLayoutManager emojiLayoutManager = new GridLayoutManager(context, 6);
emojiLayoutManager.setSpanSizeLookup(new EmojiColumnSpanLookup());
emojiRecyclerview.setLayoutManager(emojiLayoutManager);
@ -224,6 +223,7 @@ public class EmojiKeyboard extends LinearLayout {
}
}
// TODO: add span size to Emoji class so it takes constant time to find span size
class EmojiColumnSpanLookup extends GridLayoutManager.SpanSizeLookup {
@Override
@ -238,7 +238,6 @@ public class EmojiKeyboard extends LinearLayout {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), idToCheck, options);
// TODO: piexel density sensitive column span lookup
return options.outWidth / 70 + 1;
}
}

9
app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java

@ -32,13 +32,16 @@ public class EmojiKeyboardAdapter extends RecyclerView.Adapter<EmojiKeyboardAdap
@Override
public void onBindViewHolder(@NonNull EmojiViewHolder holder, int position) {
holder.emojiButton.setImageResource(emojiIds[position].getSrc());
holder.emojiButton.setOnClickListener(view -> listener.onEmojiClick(view, position));
}
@Override
public void onViewAttachedToWindow(@NonNull EmojiViewHolder holder) {
holder.emojiButton.setImageResource(emojiIds[holder.getAdapterPosition()].getSrc());
if (holder.emojiButton.getDrawable() instanceof AnimationDrawable) {
AnimationDrawable emojiAnimation = (AnimationDrawable) holder.emojiButton.getDrawable();
if (!emojiAnimation.isRunning())
emojiAnimation.start();
}
holder.emojiButton.setOnClickListener(view -> listener.onEmojiClick(view, position));
}
@Override

Loading…
Cancel
Save