use of com.lingtuan.firefly.chat.adapter.ChatFaceAdapter in project SmartMesh_Android by SmartMeshFoundation.
the class FaceUtils method bindFaceToGridView.
/**
* @param pageCount Total number of pages
* @param isGif Group is a GIF
* @param faceIds The item resource files array
* @param pageItemCount Total number of items per page
* Binding expression images to the corresponding item
*/
private void bindFaceToGridView(int pageCount, final boolean isGif, Integer[] faceIds, String[] faceNameIds, final int pageItemCount) {
ArrayList<GridView> pageViews = new ArrayList<>();
GridView gridView;
for (int i = 0; i < pageCount; i++) {
gridView = new GridView(mContext);
// GIF group four big expressions in a row, or buy into six small expression
gridView.setNumColumns(isGif ? 4 : 6);
gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gridView.setHorizontalSpacing(isGif ? 15 : 10);
gridView.setVerticalSpacing(isGif ? 15 : 10);
gridView.setGravity(Gravity.CENTER);
gridView.setSelector(R.drawable.scrollview_item_bg);
gridView.setPadding(0, 10, 0, 10);
gridView.setAdapter(new ChatFaceAdapter(faceIds, faceNameIds, mContext, i, isGif));
final int page = i;
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (itemListener != null) {
// pageItemCount-1 In order to take off to delete the item
if (isGif) {
// Click on the GIF need to send out directly
itemListener.onItemListener(page, (page * pageItemCount) + position, isGif, false);
} else {
itemListener.onItemListener(page, page * (pageItemCount - 1) + position, isGif, position == pageItemCount - 1);
}
}
}
});
pageViews.add(gridView);
}
mViewPager.setAdapter(new ChatFacePagerAdapter(pageViews));
indicator.setViewPager(mViewPager);
}
Aggregations