// Path: prismoji/src/main/java/com/apradanas/prismoji/emoji/Emoji.java
// public final class Emoji implements Serializable {
//     private static final long serialVersionUID = 3L;
// 
//     @NonNull
//     private final String unicode;
//     @DrawableRes
//     private final int resource;
//     @NonNull
//     private List<Emoji> variants;
//     @SuppressWarnings("PMD.ImmutableField")
//     @Nullable
//     private Emoji base;
// 
//     public Emoji(@NonNull final int[] codePoints, @DrawableRes final int resource) {
//         this(codePoints, resource, new Emoji[0]);
//     }
// 
//     public Emoji(final int codePoint, @DrawableRes final int resource) {
//         this(codePoint, resource, new Emoji[0]);
//     }
// 
//     public Emoji(@NonNull final int[] codePoints, @DrawableRes final int resource, final Emoji... variants) {
//         this.unicode = new String(codePoints, 0, codePoints.length);
//         this.resource = resource;
//         this.variants = Arrays.asList(variants);
// 
//         for (final Emoji variant : variants) {
//             variant.base = this;
//         }
//     }
// 
//     public Emoji(final int codePoint, @DrawableRes final int resource, final Emoji... variants) {
//         this(new int[]{codePoint}, resource, variants);
//     }
// 
//     @NonNull
//     public String getUnicode() {
//         return unicode;
//     }
// 
//     @DrawableRes
//     public int getResource() {
//         return resource;
//     }
// 
//     @NonNull
//     public List<Emoji> getVariants() {
//         return new ArrayList<>(variants);
//     }
// 
//     @NonNull
//     public Emoji getBase() {
//         Emoji result = this;
// 
//         while (result.base != null) {
//             result = result.base;
//         }
// 
//         return result;
//     }
// 
//     public int getLength() {
//         return unicode.length();
//     }
// 
//     public boolean hasVariants() {
//         return !variants.isEmpty();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
// 
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final Emoji emoji = (Emoji) o;
// 
//         return resource == emoji.resource
//                 && unicode.equals(emoji.unicode)
//                 && variants.equals(emoji.variants);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = unicode.hashCode();
//         result = 31 * result + resource;
//         result = 31 * result + variants.hashCode();
//         return result;
//     }
// }
// 
// Path: prismoji/src/main/java/com/apradanas/prismoji/listeners/OnEmojiClickedListener.java
// public interface OnEmojiClickedListener {
//     void onEmojiClicked(final Emoji emoji);
// }


import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import com.apradanas.prismoji.emoji.Emoji;
import com.apradanas.prismoji.listeners.OnEmojiClickedListener;
import java.util.List;
import static android.view.View.MeasureSpec.makeMeasureSpec;
            final ImageView emojiImage = (ImageView) inflater.inflate(R.layout.emoji_item, imageContainer, false);
            final ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) emojiImage.getLayoutParams();
            final int margin = Utils.dpToPx(clickedImage.getContext(), MARGIN);

            // Use the same size for Emojis as in the picker.
            layoutParams.width = clickedImage.getWidth();
            layoutParams.setMargins(margin, margin, margin, margin);
            emojiImage.setImageResource(variant.getResource());

            emojiImage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {
                    if (listener != null) {
                        listener.onEmojiClicked(variant);
                    }
                }
            });

            imageContainer.addView(emojiImage);
        }

        content.measure(makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable(clickedImage.getContext().getResources(), (Bitmap) null));

        final int[] location = new int[2];
        clickedImage.getLocationOnScreen(location);

        final int x = location[0] - popupWindow.getContentView().getMeasuredWidth() / 2 + clickedImage.getWidth() / 2;
// Path: prismoji/src/main/java/com/apradanas/prismoji/emoji/Emoji.java
// public final class Emoji implements Serializable {
//     private static final long serialVersionUID = 3L;
// 
//     @NonNull
//     private final String unicode;
//     @DrawableRes
//     private final int resource;
//     @NonNull
//     private List<Emoji> variants;
//     @SuppressWarnings("PMD.ImmutableField")
//     @Nullable
//     private Emoji base;
// 
//     public Emoji(@NonNull final int[] codePoints, @DrawableRes final int resource) {
//         this(codePoints, resource, new Emoji[0]);
//     }
// 
//     public Emoji(final int codePoint, @DrawableRes final int resource) {
//         this(codePoint, resource, new Emoji[0]);
//     }
// 
//     public Emoji(@NonNull final int[] codePoints, @DrawableRes final int resource, final Emoji... variants) {
//         this.unicode = new String(codePoints, 0, codePoints.length);
//         this.resource = resource;
//         this.variants = Arrays.asList(variants);
// 
//         for (final Emoji variant : variants) {
//             variant.base = this;
//         }
//     }
// 
//     public Emoji(final int codePoint, @DrawableRes final int resource, final Emoji... variants) {
//         this(new int[]{codePoint}, resource, variants);
//     }
// 
//     @NonNull
//     public String getUnicode() {
//         return unicode;
//     }
// 
//     @DrawableRes
//     public int getResource() {
//         return resource;
//     }
// 
//     @NonNull
//     public List<Emoji> getVariants() {
//         return new ArrayList<>(variants);
//     }
// 
//     @NonNull
//     public Emoji getBase() {
//         Emoji result = this;
// 
//         while (result.base != null) {
//             result = result.base;
//         }
// 
//         return result;
//     }
// 
//     public int getLength() {
//         return unicode.length();
//     }
// 
//     public boolean hasVariants() {
//         return !variants.isEmpty();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
// 
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final Emoji emoji = (Emoji) o;
// 
//         return resource == emoji.resource
//                 && unicode.equals(emoji.unicode)
//                 && variants.equals(emoji.variants);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = unicode.hashCode();
//         result = 31 * result + resource;
//         result = 31 * result + variants.hashCode();
//         return result;
//     }
// }
// 
// Path: prismoji/src/main/java/com/apradanas/prismoji/listeners/OnEmojiClickedListener.java
// public interface OnEmojiClickedListener {
//     void onEmojiClicked(final Emoji emoji);
// }


// Path: prismoji/src/main/java/com/apradanas/prismoji/PrismojiVariantPopup.java
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import com.apradanas.prismoji.emoji.Emoji;
import com.apradanas.prismoji.listeners.OnEmojiClickedListener;
import java.util.List;
import static android.view.View.MeasureSpec.makeMeasureSpec;

            final ImageView emojiImage = (ImageView) inflater.inflate(R.layout.emoji_item, imageContainer, false);
            final ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) emojiImage.getLayoutParams();
            final int margin = Utils.dpToPx(clickedImage.getContext(), MARGIN);

            // Use the same size for Emojis as in the picker.
            layoutParams.width = clickedImage.getWidth();
            layoutParams.setMargins(margin, margin, margin, margin);
            emojiImage.setImageResource(variant.getResource());

            emojiImage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {
                    if (listener != null) {
                        listener.onEmojiClicked(variant);
                    }
                }
            });

            imageContainer.addView(emojiImage);
        }

        content.measure(makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new BitmapDrawable(clickedImage.getContext().getResources(), (Bitmap) null));

        final int[] location = new int[2];
        clickedImage.getLocationOnScreen(location);

        final int x = location[0] - popupWindow.getContentView().getMeasuredWidth() / 2 + clickedImage.getWidth() / 2;
        final int y = location[1] - popupWindow.getContentView().getMeasuredHeight();