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. 11
      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); RecyclerView emojiRecyclerview = findViewById(R.id.emoji_recyclerview);
emojiRecyclerview.setHasFixedSize(true); emojiRecyclerview.setHasFixedSize(true);
// TODO: More meaningful span count for grid
GridLayoutManager emojiLayoutManager = new GridLayoutManager(context, 6); GridLayoutManager emojiLayoutManager = new GridLayoutManager(context, 6);
emojiLayoutManager.setSpanSizeLookup(new EmojiColumnSpanLookup()); emojiLayoutManager.setSpanSizeLookup(new EmojiColumnSpanLookup());
emojiRecyclerview.setLayoutManager(emojiLayoutManager); 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 { class EmojiColumnSpanLookup extends GridLayoutManager.SpanSizeLookup {
@Override @Override
@ -238,7 +238,6 @@ public class EmojiKeyboard extends LinearLayout {
BitmapFactory.Options options = new BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), idToCheck, options); BitmapFactory.decodeResource(getResources(), idToCheck, options);
// TODO: piexel density sensitive column span lookup
return options.outWidth / 70 + 1; return options.outWidth / 70 + 1;
} }
} }

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

@ -32,13 +32,16 @@ public class EmojiKeyboardAdapter extends RecyclerView.Adapter<EmojiKeyboardAdap
@Override @Override
public void onBindViewHolder(@NonNull EmojiViewHolder holder, int position) { 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) { if (holder.emojiButton.getDrawable() instanceof AnimationDrawable) {
AnimationDrawable emojiAnimation = (AnimationDrawable) holder.emojiButton.getDrawable(); AnimationDrawable emojiAnimation = (AnimationDrawable) holder.emojiButton.getDrawable();
if (!emojiAnimation.isRunning()) emojiAnimation.start();
emojiAnimation.start();
} }
holder.emojiButton.setOnClickListener(view -> listener.onEmojiClick(view, position));
} }
@Override @Override

Loading…
Cancel
Save