Skip to content

Commit

Permalink
Revert "切分出分支1.2.1"
Browse files Browse the repository at this point in the history
This reverts commit a09bb81
  • Loading branch information
xuexiangjys committed Nov 17, 2022
1 parent a09bb81 commit 491d9f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.xuexiang.xuidemo"
minSdkVersion 17
targetSdkVersion build_versions.target_sdk
versionCode 22
versionName "1.2.1"
versionCode 21
versionName "1.2.0"

multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ public XRecyclerAdapter(T[] data) {
/**
* 构建自定义的ViewHolder
*
* @param parent 父布局
* @param viewType view类型
* @return ViewHolder
* @param parent
* @param viewType
* @return
*/
@NonNull
protected abstract V getViewHolder(@NonNull ViewGroup parent, int viewType);

/**
* 绑定数据
*
* @param holder ViewHolder
* @param holder
* @param position 索引
* @param item 列表项
*/
Expand All @@ -99,7 +99,7 @@ public XRecyclerAdapter(T[] data) {
*
* @param parent 父布局
* @param layoutId 布局ID
* @return 加载的布局
* @return
*/
protected View inflateView(ViewGroup parent, @LayoutRes int layoutId) {
return LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
Expand All @@ -113,35 +113,22 @@ public V onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int position = getItemPosition(holder);
mClickListener.onItemClick(holder.itemView, getItem(position), position);
mClickListener.onItemClick(holder.itemView, getItem(holder.getLayoutPosition()), holder.getLayoutPosition());
}
});
}
if (mLongClickListener != null) {
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final int position = getItemPosition(holder);
mLongClickListener.onItemLongClick(holder.itemView, getItem(position), position);
mLongClickListener.onItemLongClick(holder.itemView, getItem(holder.getLayoutPosition()), holder.getLayoutPosition());
return true;
}
});
}
return holder;
}

/**
* 获取item的位置,这里默认使用getLayoutPosition来进行获取,可以重写这个方法
*
* @param holder ViewHolder
* @return 位置
*/
protected int getItemPosition(V holder) {
return holder.getLayoutPosition();
}


@Override
public void onBindViewHolder(@NonNull V holder, int position) {
bindData(holder, position, mData.get(position));
Expand Down

0 comments on commit 491d9f7

Please sign in to comment.