com.mikepenz.fastadapter.items.AbstractItem类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(68)

本文整理了Java中com.mikepenz.fastadapter.items.AbstractItem类的一些代码示例,展示了AbstractItem类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractItem类的具体详情如下:
包路径:com.mikepenz.fastadapter.items.AbstractItem
类名称:AbstractItem

AbstractItem介绍

[英]Created by mikepenz on 14.07.15. Implements the general methods of the IItem interface to speed up development.
[中]由mikepenz于2015年7月14日创建。实现IItem接口的通用方法以加快开发。

代码示例

代码示例来源:origin: mikepenz/AboutLibraries

/**
 * binds the data of this item onto the viewHolder
 *
 * @param holder the viewHolder of this item
 */
@Override
public void bindView(final ViewHolder holder, List<Object> payloads) {
  super.bindView(holder, payloads);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * If this item equals to the given identifier
 *
 * @param id identifier
 * @return true if identifier equals id, false otherwise
 */
@Override
public boolean equals(int id) {
  return id == getIdentifier();
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * generates a view by the defined LayoutRes and pass the LayoutParams from the parent
 *
 * @param ctx
 * @param parent
 * @return
 */
@Override
public View generateView(Context ctx, ViewGroup parent) {
  VH viewHolder = getViewHolder(createView(ctx, parent));
  //as we already know the type of our ViewHolder cast it to our type
  bindView(viewHolder, Collections.EMPTY_LIST);
  //return the bound and generatedView
  return viewHolder.itemView;
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * Generates a ViewHolder from this Item with the given parent
 *
 * @param parent
 * @return
 */
@Override
public VH getViewHolder(ViewGroup parent) {
  return getViewHolder(createView(parent.getContext(), parent));
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * this method is called by generateView(Context ctx), generateView(Context ctx, ViewGroup parent) and getViewHolder(ViewGroup parent)
 * it will generate the View from the layout, overwrite this if you want to implement your view creation programatically
 *
 * @param ctx
 * @param parent
 * @return
 */
public View createView(Context ctx, @Nullable ViewGroup parent) {
  return LayoutInflater.from(ctx).inflate(getLayoutRes(), parent, false);
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  if (!super.equals(o)) return false;
  TestItem testItem = (TestItem) o;
  return Objects.equals(name, testItem.name);
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  viewHolder.text.setText(letter);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * generates a view by the defined LayoutRes
 *
 * @param ctx
 * @return
 */
@Override
public View generateView(Context ctx) {
  VH viewHolder = getViewHolder(createView(ctx, null));
  //as we already know the type of our ViewHolder cast it to our type
  bindView(viewHolder, Collections.EMPTY_LIST);
  //return the bound view
  return viewHolder.itemView;
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * If this item equals to the given object
 *
 * @param o
 * @return
 */
@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  AbstractItem<?, ?> that = (AbstractItem<?, ?>) o;
  return getIdentifier() == that.getIdentifier();
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public void bindView(ViewHolder holder, List<Object> payloads) {
  super.bindView(holder, payloads);
  if (isEnabled()) {
    holder.itemView.setBackgroundResource(FastAdapterUIUtils.getSelectableBackground(holder.itemView.getContext()));
  }
}

代码示例来源:origin: mikepenz/FastAdapter

/**
   * the hashCode implementation
   *
   * @return
   */
  @Override
  public int hashCode() {
    return Long.valueOf(getIdentifier()).hashCode();
  }
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  //get the context
  Context ctx = viewHolder.itemView.getContext();
  //define our data for the view
  viewHolder.imageName.setText(mName);
  viewHolder.imageDescription.setText(mDescription);
  viewHolder.imageView.setImageBitmap(null);
  //we pre-style our heart :D
  style(viewHolder.imageLovedOn, mStarred ? 1 : 0);
  style(viewHolder.imageLovedOff, mStarred ? 0 : 1);
  //load glide
  Glide.with(ctx).load(mImageUrl).animate(R.anim.alpha_on).into(viewHolder.imageView);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * If this item equals to the given object
 *
 * @param o
 * @return
 */
@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  AbstractItem<?, ?> that = (AbstractItem<?, ?>) o;
  return mIdentifier == that.getIdentifier();
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  //set the text for the name
  StringHolder.applyTo(name, viewHolder.name);
  //set the text for the description or hide
  StringHolder.applyToOrHide(description, viewHolder.description);
  viewHolder.swipeResultContent.setVisibility(swipedDirection != 0 ? View.VISIBLE : View.GONE);
  viewHolder.itemContent.setVisibility(swipedDirection != 0 ? View.GONE : View.VISIBLE);
  CharSequence swipedAction = null;
  CharSequence swipedText = null;
  if (swipedDirection != 0) {
    swipedAction = viewHolder.itemView.getContext().getString(R.string.action_undo);
    swipedText = swipedDirection == ItemTouchHelper.LEFT ? "Removed" : "Archived";
    viewHolder.swipeResultContent.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), swipedDirection == ItemTouchHelper.LEFT ? R.color.md_red_900 : R.color.md_blue_900));
  }
  viewHolder.swipedAction.setText(swipedAction == null ? "" : swipedAction);
  viewHolder.swipedText.setText(swipedText == null ? "" : swipedText);
  viewHolder.swipedActionRunnable = this.swipedAction;
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  viewHolder.radioButton.setChecked(isSelected());
  //set the text for the name
  StringHolder.applyTo(name, viewHolder.name);
  //set the text for the description or hide
  StringHolder.applyToOrHide(description, viewHolder.description);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  viewHolder.checkBox.setChecked(isSelected());
  //set the text for the name
  StringHolder.applyTo(name, viewHolder.name);
  //set the text for the description or hide
  StringHolder.applyToOrHide(description, viewHolder.description);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  //define our data for the view
  viewHolder.image.setIcon(new IconicsDrawable(viewHolder.image.getContext(), mIcon));
  viewHolder.name.setText(mIcon.getName());
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public void bindView(ViewHolder holder, List<Object> payloads) {
  super.bindView(holder, payloads);
  if (isEnabled()) {
    holder.itemView.setBackgroundResource(FastAdapterUIUtils.getSelectableBackground(holder.itemView.getContext()));
  }
  mName.applyTo(holder.name);
  ImageHolder.applyToOrSetGone(mAvatar, holder.avatar);
  ImageHolder.applyToOrSetGone(mIcon, holder.icon);
}

代码示例来源:origin: mikepenz/FastAdapter

/**
 * binds the data of this item onto the viewHolder
 *
 * @param viewHolder the viewHolder of this item
 */
@Override
public void bindView(SimpleImageItem.ViewHolder viewHolder, List<Object> payloads) {
  super.bindView(viewHolder, payloads);
  //get the context
  Context ctx = viewHolder.itemView.getContext();
  //define our data for the view
  viewHolder.imageName.setText(mName);
  viewHolder.imageDescription.setText(mDescription);
  viewHolder.imageView.setImageBitmap(null);
  //set the background for the item
  int color = UIUtils.getThemeColor(ctx, R.attr.colorPrimary);
  viewHolder.view.clearAnimation();
  viewHolder.view.setForeground(FastAdapterUIUtils.getSelectablePressedBackground(ctx, FastAdapterUIUtils.adjustAlpha(color, 100), 50, true));
  //load glide
  Glide.clear(viewHolder.imageView);
  Glide.with(ctx).load(mImageUrl).animate(R.anim.alpha_on).into(viewHolder.imageView);
}

代码示例来源:origin: mikepenz/FastAdapter

@Override
public void bindView(ViewHolder holder, List<Object> payloads) {
  super.bindView(holder, payloads);
  if (isEnabled()) {
    holder.itemView.setBackgroundResource(FastAdapterUIUtils.getSelectableBackground(holder.itemView.getContext()));
  }
  mName.applyTo(holder.name);
  mDescription.applyTo(holder.description);
  ImageHolder.applyToOrSetGone(mAvatar, holder.avatar);
  ImageHolder.applyToOrSetGone(mIcon, holder.icon);
}

相关文章

微信公众号

最新文章

更多