Skip to content

Commit

Permalink
添加记忆选择的位置的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
XinYiWorld committed May 26, 2017
1 parent 347fd28 commit f618b6e
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 136 additions & 18 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.xinyi.czsuperadapter.ICRUDAdapter;
import com.xinyi.czsuperadapter.interfaces.IAddTypeMaker;
import com.xinyi.czsuperadapter.interfaces.IMemoryPosition;
import com.xinyi.czsuperadapter.interfaces.IRemoveTypeMaker;

/**
Expand All @@ -24,7 +25,7 @@
* 4)点击事件与刷新冲突(未解决)
*/

public class CZSuperAdapter<T> extends ICRUDAdapter<T> implements IAddTypeMaker,IRemoveTypeMaker {
public class CZSuperAdapter<T> extends ICRUDAdapter<T> implements IAddTypeMaker,IRemoveTypeMaker,IMemoryPosition {
private static final String TAG = "CZSuperAdapter";
private RecyclerView recyclerView;
private MultiTypeMaker mNormalTypeMaker;
Expand All @@ -34,6 +35,11 @@ public class CZSuperAdapter<T> extends ICRUDAdapter<T> implements IAddTypeMaker,
private CommonViewHolder.OnItemClickListener onItemClickListener;
private CommonViewHolder.OnItemLongClickListener onItemLongClickListener;


//记忆位置
private int previousSelectPosition = -1;


@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
Expand Down Expand Up @@ -332,4 +338,21 @@ public void setOnItemClickListener(final CommonViewHolder.OnItemClickListener li
public void setOnItemLongClickListener(final CommonViewHolder.OnItemLongClickListener listener) {
this.onItemLongClickListener = listener;
}

//记忆位置(默认调用mNormalTypeMaker的方法,后期调用根据项目需求可以复写。)
@Override
public int getPreviousSelectPosition() {
return mNormalTypeMaker.getPreviousSelectPosition();
}

@Override
public void setPreviousSelectPosition(int previousSelectPosition) {
this.previousSelectPosition = previousSelectPosition;
mNormalTypeMaker.setPreviousSelectPosition(previousSelectPosition);
}

@Override
public void selectPosition(final int position){
mNormalTypeMaker.selectPosition(position);
}
}
Loading

0 comments on commit f618b6e

Please sign in to comment.