Search in sources :

Example 66 with GridView

use of android.widget.GridView in project ChatKeyboard by CPPAlien.

the class EmoticonsPageView method updateView.

private void updateView() {
    if (mEmoticonSetBeanList == null)
        return;
    if (mEmoticonsViewPagerAdapter == null) {
        mEmoticonsViewPagerAdapter = new EmoticonsViewPagerAdapter();
        setAdapter(mEmoticonsViewPagerAdapter);
        setOnPageChangeListener(new PageChangeListener());
    }
    int screenWidth = Utils.getDisplayWidthPixels(mContext);
    int maxPagerHeight = mHeight;
    mEmoticonPageViews.clear();
    mEmoticonsViewPagerAdapter.notifyDataSetChanged();
    for (EmoticonSetBean bean : mEmoticonSetBeanList) {
        List<EmoticonBean> emoticonList = bean.getEmoticonList();
        if (emoticonList != null) {
            int emoticonSetSum = emoticonList.size();
            int row = bean.getRow();
            int line = bean.getLine();
            int del = bean.isShowDelBtn() ? 1 : 0;
            int everyPageMaxSum = row * line - del;
            int pageCount = getPageCount(bean);
            mMaxEmoticonSetPageCount = Math.max(mMaxEmoticonSetPageCount, pageCount);
            int start = 0;
            int end = everyPageMaxSum > emoticonSetSum ? emoticonSetSum : everyPageMaxSum;
            RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            gridParams.addRule(SoftListenLayout.CENTER_VERTICAL);
            int itemHeight = Math.min((screenWidth - (bean.getRow() - 1) * Utils.dip2px(mContext, bean.getHorizontalSpacing())) / bean.getRow(), (maxPagerHeight - (bean.getLine() - 1) * Utils.dip2px(mContext, bean.getVerticalSpacing())) / bean.getLine());
            for (int i = 0; i < pageCount; i++) {
                RelativeLayout rl = new RelativeLayout(mContext);
                GridView gridView = new GridView(mContext);
                gridView.setNumColumns(bean.getRow());
                gridView.setBackgroundColor(Color.TRANSPARENT);
                gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
                gridView.setCacheColorHint(0);
                gridView.setHorizontalSpacing(Utils.dip2px(mContext, bean.getHorizontalSpacing()));
                gridView.setVerticalSpacing(Utils.dip2px(mContext, bean.getVerticalSpacing()));
                gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
                gridView.setGravity(Gravity.CENTER);
                gridView.setVerticalScrollBarEnabled(false);
                List<EmoticonBean> list = new ArrayList<>();
                for (int j = start; j < end; j++) {
                    list.add(emoticonList.get(j));
                }
                if (bean.isShowDelBtn()) {
                    int count = bean.getLine() * bean.getRow();
                    while (list.size() < count - 1) {
                        list.add(null);
                    }
                    list.add(new EmoticonBean(EmoticonBean.FACE_TYPE_DEL, "drawable://icon_del", null, null));
                } else {
                    int count = bean.getLine() * bean.getRow();
                    while (list.size() < count) {
                        list.add(null);
                    }
                }
                EmoticonsAdapter adapter = new EmoticonsAdapter(mContext, list, bean.isShownName());
                adapter.setHeight(itemHeight, Utils.dip2px(mContext, bean.getItemPadding()));
                gridView.setAdapter(adapter);
                rl.addView(gridView, gridParams);
                mEmoticonPageViews.add(rl);
                adapter.setOnItemListener(this);
                start = everyPageMaxSum + i * everyPageMaxSum;
                end = everyPageMaxSum + (i + 1) * everyPageMaxSum;
                if (end >= emoticonSetSum) {
                    end = emoticonSetSum;
                }
            }
        }
    }
    mEmoticonsViewPagerAdapter.notifyDataSetChanged();
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) ArrayList(java.util.ArrayList) EmoticonSetBean(cn.hadcn.keyboard.emoticon.EmoticonSetBean) ColorDrawable(android.graphics.drawable.ColorDrawable) RelativeLayout(android.widget.RelativeLayout) GridView(android.widget.GridView)

Example 67 with GridView

use of android.widget.GridView in project ChatKeyboard by CPPAlien.

the class MediaPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.media_page, container, false);
    GridView grid = (GridView) layout.findViewById(R.id.media_grid);
    grid.setColumnWidth(mColumnWidth);
    grid.setAdapter(gridAdapterList.get(position));
    container.addView(layout);
    return layout;
}
Also used : LayoutInflater(android.view.LayoutInflater) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View)

Example 68 with GridView

use of android.widget.GridView in project Presentation by feelinglucky.

the class PinsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.pins, null);
    mPinsGridView = (GridView) view.findViewById(R.id.pins);
    mPinsAdapter = new PinsAdapter(getActivity(), mPinsAdapterListener);
    mSwipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    return view;
}
Also used : PinsAdapter(com.gracecode.android.presentation.adapter.PinsAdapter) GridView(android.widget.GridView) View(android.view.View)

Example 69 with GridView

use of android.widget.GridView in project KJFrameForAndroid by kymjs.

the class EmojiPageFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);
    sGrid.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(R.id.emoji_titile_input);
            if (position + 1 != datas.size()) {
                InputHelper.input(editText, (Emojicon) parent.getAdapter().getItem(position));
            } else {
                InputHelper.backspace(editText);
            }
        }
    });
    sGrid.setSelector(new ColorDrawable(Color.TRANSPARENT));
    return sGrid;
}
Also used : EmojiGridAdapter(org.kymjs.emoji.adapter.EmojiGridAdapter) EditText(android.widget.EditText) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ColorDrawable(android.graphics.drawable.ColorDrawable) Emojicon(org.kymjs.emoji.model.Emojicon) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 70 with GridView

use of android.widget.GridView in project SmartAndroidSource by jaychou2012.

the class PullToRefreshGridView method createRefreshableView.

@Override
protected final GridView createRefreshableView(Context context, AttributeSet attrs) {
    final GridView gv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        gv = new InternalGridViewSDK9(context, attrs);
    } else {
        gv = new InternalGridView(context, attrs);
    }
    // Use Generated ID (from res/values/ids.xml)
    gv.setId(getResources().getIdentifier("gridview", "id", context.getPackageName()));
    // gv.setId(R.id.gridview);
    return gv;
}
Also used : GridView(android.widget.GridView)

Aggregations

GridView (android.widget.GridView)142 View (android.view.View)86 AdapterView (android.widget.AdapterView)64 TextView (android.widget.TextView)42 ImageView (android.widget.ImageView)30 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)14 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)11 SuppressLint (android.annotation.SuppressLint)10 ArrayList (java.util.ArrayList)9 LayoutInflater (android.view.LayoutInflater)8 WindowManager (android.view.WindowManager)7 Button (android.widget.Button)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 ListView (android.widget.ListView)6 LinearLayout (android.widget.LinearLayout)5 Bundle (android.os.Bundle)4 ViewTreeObserver (android.view.ViewTreeObserver)4 ArrayAdapter (android.widget.ArrayAdapter)4