Search in sources :

Example 1 with SmileyAdapter

use of me.yluo.ruisiapp.adapter.SmileyAdapter in project Ruisi by freedom10086.

the class MySmileyPicker method init.

private void init() {
    View v = LayoutInflater.from(mContext).inflate(R.layout.my_smiley_view, null);
    TabLayout tab = v.findViewById(R.id.mytab);
    RecyclerView recyclerView = v.findViewById(R.id.recyclerView);
    getSmileys();
    tab.addTab(tab.newTab().setText("贴吧"));
    tab.addTab(tab.newTab().setText("金馆长"));
    tab.addTab(tab.newTab().setText("AC娘"));
    RecyclerView.LayoutManager layoutManager = new GridLayoutManager(mContext, 7, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new SmileyAdapter(mContext, (v1, position) -> {
        ImageView img = (ImageView) v1;
        smileyClick(img.getDrawable(), position);
        dismiss();
    }, smileys);
    tab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            changeSmiley(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
    recyclerView.setAdapter(adapter);
    setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.rec_solid_primary_bg));
    setFocusable(true);
    setContentView(v);
}
Also used : Context(android.content.Context) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LayoutInflater(android.view.LayoutInflater) ContextCompat(android.support.v4.content.ContextCompat) Pair(android.util.Pair) ImageView(android.widget.ImageView) PopupWindow(android.widget.PopupWindow) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Drawable(android.graphics.drawable.Drawable) ViewGroup(android.view.ViewGroup) R(me.yluo.ruisiapp.R) ArrayList(java.util.ArrayList) TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) SmileyAdapter(me.yluo.ruisiapp.adapter.SmileyAdapter) View(android.view.View) Log(android.util.Log) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SmileyAdapter(me.yluo.ruisiapp.adapter.SmileyAdapter) TabLayout(android.support.design.widget.TabLayout) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

Context (android.content.Context)1 Drawable (android.graphics.drawable.Drawable)1 TabLayout (android.support.design.widget.TabLayout)1 ContextCompat (android.support.v4.content.ContextCompat)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Log (android.util.Log)1 Pair (android.util.Pair)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 PopupWindow (android.widget.PopupWindow)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 R (me.yluo.ruisiapp.R)1 SmileyAdapter (me.yluo.ruisiapp.adapter.SmileyAdapter)1