Exemplo n.º 1
0
  public void init(
      List<EaseEmojiconGroupEntity> emojiconGroupList,
      int emijiconColumns,
      int bigEmojiconColumns) {
    if (emojiconGroupList == null) {
      throw new RuntimeException("emojiconGroupList is null");
    }

    this.groupEntities = emojiconGroupList;
    this.emojiconColumns = emijiconColumns;
    this.bigEmojiconColumns = bigEmojiconColumns;

    viewpages = new ArrayList<View>();
    for (int i = 0; i < groupEntities.size(); i++) {
      EaseEmojiconGroupEntity group = groupEntities.get(i);
      List<EaseEmojicon> groupEmojicons = group.getEmojiconList();
      totalEmojiconList.addAll(groupEmojicons);
      List<View> gridViews = getGroupGridViews(group);
      if (i == 0) {
        firstGroupPageSize = gridViews.size();
      }
      maxPageCount = Math.max(gridViews.size(), maxPageCount);
      viewpages.addAll(gridViews);
    }

    pagerAdapter = new EmojiconPagerAdapter(viewpages);
    setAdapter(pagerAdapter);
    setOnPageChangeListener(new EmojiPagerChangeListener());

    if (pagerViewListener != null) {
      pagerViewListener.onPagerViewInited(maxPageCount, firstGroupPageSize);
    }
  }
Exemplo n.º 2
0
 /**
  * 获取pager数量
  *
  * @param emojiconList
  * @return
  */
 private int getPageSize(EaseEmojiconGroupEntity groupEntity) {
   List<EaseEmojicon> emojiconList = groupEntity.getEmojiconList();
   int itemSize = emojiconColumns * emojiconRows - 1;
   int totalSize = emojiconList.size();
   Type emojiType = groupEntity.getType();
   if (emojiType == Type.BIG_EXPRESSION) {
     itemSize = bigEmojiconColumns * bigEmojiconRows;
   }
   int pageSize = totalSize % itemSize == 0 ? totalSize / itemSize : totalSize / itemSize + 1;
   return pageSize;
 }
Exemplo n.º 3
0
  /**
   * 获取表情组的gridview list
   *
   * @param groupEntity
   * @return
   */
  public List<View> getGroupGridViews(EaseEmojiconGroupEntity groupEntity) {
    List<EaseEmojicon> emojiconList = groupEntity.getEmojiconList();
    int itemSize = emojiconColumns * emojiconRows - 1;
    int totalSize = emojiconList.size();
    Type emojiType = groupEntity.getType();
    if (emojiType == Type.BIG_EXPRESSION) {
      itemSize = bigEmojiconColumns * bigEmojiconRows;
    }
    int pageSize = totalSize % itemSize == 0 ? totalSize / itemSize : totalSize / itemSize + 1;
    List<View> views = new ArrayList<View>();
    for (int i = 0; i < pageSize; i++) {
      View view = View.inflate(context, R.layout.ease_expression_gridview, null);
      GridView gv = (GridView) view.findViewById(R.id.gridview);
      if (emojiType == Type.BIG_EXPRESSION) {
        gv.setNumColumns(bigEmojiconColumns);
      } else {
        gv.setNumColumns(emojiconColumns);
      }
      List<EaseEmojicon> list = new ArrayList<EaseEmojicon>();
      if (i != pageSize - 1) {
        list.addAll(emojiconList.subList(i * itemSize, (i + 1) * itemSize));
      } else {
        list.addAll(emojiconList.subList(i * itemSize, totalSize));
      }
      if (emojiType != Type.BIG_EXPRESSION) {
        EaseEmojicon deleteIcon = new EaseEmojicon();
        deleteIcon.setEmojiText(EaseSmileUtils.DELETE_KEY);
        list.add(deleteIcon);
      }
      final EmojiconGridAdapter gridAdapter = new EmojiconGridAdapter(context, 1, list, emojiType);
      gv.setAdapter(gridAdapter);
      gv.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              EaseEmojicon emojicon = gridAdapter.getItem(position);
              if (pagerViewListener != null) {
                String emojiText = emojicon.getEmojiText();
                if (emojiText != null && emojiText.equals(EaseSmileUtils.DELETE_KEY)) {
                  pagerViewListener.onDeleteImageClicked();
                } else {
                  pagerViewListener.onExpressionClicked(emojicon);
                }
              }
            }
          });

      views.add(view);
    }
    return views;
  }