Browse Source

change column span lookup method

pull/45/head
Thodoris1999 6 years ago
parent
commit
3ec7f70ee5
  1. 22
      app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java

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

@ -223,22 +223,20 @@ 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
public int getSpanSize(int position) { public int getSpanSize(int position) {
int idToCheck; switch (emojis[position].getSrc()) {
if (getContext().getResources().getDrawable(emojis[position].getSrc()) instanceof AnimationDrawable) { case R.drawable.emoji_wav:
String frameResourceName = getResources().getResourceEntryName(emojis[position].getSrc()) + "_f0"; return 4;
idToCheck = getResources().getIdentifier(frameResourceName, "drawable", getContext().getPackageName()); case R.drawable.emoji_band:
} else { return 3;
idToCheck = emojis[position].getSrc(); case R.drawable.emoji_pcsleep:
} return 2;
BitmapFactory.Options options = new BitmapFactory.Options(); default:
options.inJustDecodeBounds = true; return 1;
BitmapFactory.decodeResource(getResources(), idToCheck, options); }
return options.outWidth / 70 + 1;
} }
} }
} }

Loading…
Cancel
Save