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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations