Java Code Examples for com.vanniktech.emoji.emoji.Emoji#getBase()

The following examples show how to use com.vanniktech.emoji.emoji.Emoji#getBase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VariantEmojiManager.java    From Emoji with Apache License 2.0 6 votes vote down vote up
@Override @NonNull public Emoji getVariant(final Emoji desiredEmoji) {
  if (variantsList.isEmpty()) {
    initFromSharedPreferences();
  }

  final Emoji baseEmoji = desiredEmoji.getBase();

  for (int i = 0; i < variantsList.size(); i++) {
    final Emoji emoji = variantsList.get(i);

    if (baseEmoji.equals(emoji.getBase())) {
      return emoji;
    }
  }

  return desiredEmoji;
}
 
Example 2
Source File: VariantEmojiManager.java    From Emoji with Apache License 2.0 6 votes vote down vote up
@Override public void addVariant(@NonNull final Emoji newVariant) {
  final Emoji newVariantBase = newVariant.getBase();

  for (int i = 0; i < variantsList.size(); i++) {
    final Emoji variant = variantsList.get(i);

    if (variant.getBase().equals(newVariantBase)) {
      if (variant.equals(newVariant)) {
        return; // Same skin-tone was used.
      } else {
        variantsList.remove(i);
        variantsList.add(newVariant);

        return;
      }
    }
  }

  variantsList.add(newVariant);
}
 
Example 3
Source File: RecentEmojiManager.java    From Emoji with Apache License 2.0 6 votes vote down vote up
void add(final Emoji emoji, final long timestamp) {
  final Iterator<Data> iterator = emojis.iterator();

  final Emoji emojiBase = emoji.getBase();

  while (iterator.hasNext()) {
    final Data data = iterator.next();
    if (data.emoji.getBase().equals(emojiBase)) { // Do the comparison by base so that skin tones are only saved once.
      iterator.remove();
    }
  }

  emojis.add(0, new Data(emoji, timestamp));

  if (emojis.size() > MAX_RECENTS) {
    emojis.remove(MAX_RECENTS);
  }
}