Android Open Source - EmojiEverywhere Emojicon Grid Fragment






From Project

Back to project page EmojiEverywhere.

License

The source code is released under:

GNU General Public License

If you think the Android project EmojiEverywhere listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package emojicon;
//from  w  w w. j ava  2 s .c  o m
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import emoji.sithagi.com.emojieverywhere.R;
import emojicon.emoji.Emojicon;
import emojicon.emoji.People;


/**
 * @author Chathura Wijesinghe (cdanasiri@gmail.com)
 */
public class EmojiconGridFragment extends Fragment implements AdapterView.OnItemClickListener {
    private OnEmojiconClickedListener mOnEmojiconClickedListener;
    private Emojicon[] mData;

    protected static EmojiconGridFragment newInstance(Emojicon[] emojicons) {
        EmojiconGridFragment emojiGridFragment = new EmojiconGridFragment();
        Bundle args = new Bundle();
        args.putSerializable("emojicons", emojicons);
        emojiGridFragment.setArguments(args);
        return emojiGridFragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.emojicon_grid, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
        mData = getArguments() == null ? People.DATA : (Emojicon[]) getArguments().getSerializable("emojicons");
        gridView.setAdapter(new EmojiAdapter(view.getContext(), mData));
        gridView.setOnItemClickListener(this);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putSerializable("emojicons", mData);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnEmojiconClickedListener) {
            mOnEmojiconClickedListener = (OnEmojiconClickedListener) activity;
        } else {
            throw new IllegalArgumentException(activity + " must implement interface " + OnEmojiconClickedListener.class.getSimpleName());
        }
    }

    @Override
    public void onDetach() {
        mOnEmojiconClickedListener = null;
        super.onDetach();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if (mOnEmojiconClickedListener != null) {
            mOnEmojiconClickedListener.onEmojiconClicked((Emojicon) parent.getItemAtPosition(position));
        }
    }

    public interface OnEmojiconClickedListener {
        void onEmojiconClicked(Emojicon emojicon);
    }
}




Java Source Code List

emoji.sithagi.com.emojieverywhere.EmijiView.java
emoji.sithagi.com.emojieverywhere.EmojiHorizontalScrollView.java
emojicon.EmojiAdapter.java
emojicon.EmojiconEditText.java
emojicon.EmojiconGridFragment.java
emojicon.EmojiconHandler.java
emojicon.EmojiconSpan.java
emojicon.EmojiconTextView.java
emojicon.EmojiconsFragment.java
emojicon.emoji.Emojicon.java
emojicon.emoji.Nature.java
emojicon.emoji.Objects.java
emojicon.emoji.People.java
emojicon.emoji.Places.java
emojicon.emoji.Symbols.java