From 025d874cf1a1aa4b931a5aefa3bca51bb1f35319 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Tue, 21 Aug 2018 13:40:22 +0300 Subject: [PATCH] change todos --- .../java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java | 3 +-- .../gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java b/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java index 87532c15..087e35f0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java +++ b/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; } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java index fc1c6f80..754aff18 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboardAdapter.java @@ -32,13 +32,16 @@ public class EmojiKeyboardAdapter extends RecyclerView.Adapter 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(); + emojiAnimation.start(); } - holder.emojiButton.setOnClickListener(view -> listener.onEmojiClick(view, position)); } @Override