コード例 #1
0
  public int sortAlpha_WebToBottom(Channel item1, Channel item2) {
    boolean isWeb1 =
        (item1.channelType().equals(ChannelType.Web)
            || item1.channelType().equals(ChannelType.URL));
    boolean isWeb2 =
        (item2.channelType().equals(ChannelType.Web)
            || item2.channelType().equals(ChannelType.URL));

    String label1 = item1.channelType().getLabel();
    String label2 = item2.channelType().getLabel();

    int weight1 = item1.channelType().getWeight();
    int weight2 = item2.channelType().getWeight();
    int compareFirst = ObjectUtils.compare(weight1, weight2);

    if (isWeb1 && isWeb2) {
      return 0;
    } else {
      if (compareFirst == 0 || (weight1 > 3 && weight2 > 3)) {
        if (isWeb2) {
          return -1;
        } else {
          return label1.compareTo(label2);
        }
      } else {
        return compareFirst;
      }
    }
  }
コード例 #2
0
 /**
  * Set the Channel Intent link content.
  *
  * @param holder {@link Channel} {@link BaseViewHolder}
  * @param channel {@link Channel} data
  */
 @SuppressLint("NewApi")
 private void bindItemViewData(ItemViewHolder holder, Channel channel) {
   Context context = holder.view.getContext();
   ChannelType channelType = channel.channelType();
   holder.itemImage.setImageDrawable(
       getChannelIconDrawable(context, channel, getChannelBackgroundColor(context, channelType)));
   holder.itemLabel.setText(ObjectUtils.capitalize(channel.label()));
 }