| | |
| | | package cn.com.basic.face.widget.checkin;
|
| | |
|
| | | import android.content.Context;
|
| | | import android.support.v7.widget.RecyclerView;
|
| | | import android.util.AttributeSet;
|
| | |
|
| | | import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
|
| | |
| | | refresh(list, append);
|
| | | }
|
| | |
|
| | | public void refresh(List list, boolean append) {
|
| | | public void refresh(List theNewList, boolean append) {
|
| | | if (append) {
|
| | | List oldList = adapter.getList();
|
| | | List newList = new ArrayList();
|
| | | if (adapter.getList().size() > 0 && adapter.getList().get(adapter.getList().size()-1) instanceof Integer && ((int)adapter.getList().get(adapter.getList().size()-1))== CommonVariables.Page.hasMorePages) {
|
| | | adapter.getList().remove(adapter.getList().size() - 1);
|
| | | if (oldList.size() > 0 && oldList.get(oldList.size()-1) instanceof Integer &&
|
| | | ((int)oldList.get(oldList.size()-1))== CommonVariables.Page.hasMorePages) {
|
| | | oldList.remove(oldList.size() - 1);
|
| | | }
|
| | | if (adapter.getList().size() > 0 && adapter.getList().get(adapter.getList().size()-1) instanceof
|
| | | Integer && ((int)adapter.getList().get(adapter.getList().size()-1))== CommonVariables.Page.noMorePage) {
|
| | | adapter.getList().remove(adapter.getList().size() - 1);
|
| | | if (oldList.size() > 0 && oldList.get(oldList.size()-1) instanceof
|
| | | Integer && ((int)oldList.get(oldList.size()-1))== CommonVariables.Page.noMorePage) {
|
| | | oldList.remove(oldList.size() - 1);
|
| | | }
|
| | | newList.addAll(adapter.getList());
|
| | | newList.addAll(list);
|
| | | adapter.setList(newList);
|
| | | if (oldList.size() > 0) {
|
| | | this.scrollToPosition(oldList.size()-1);
|
| | | }
|
| | | oldList.addAll(theNewList);
|
| | | } else {
|
| | | adapter.setList(list);
|
| | | adapter.setList(theNewList);
|
| | | }
|
| | | this.setAdapter(adapter);
|
| | | adapter.notifyDataSetChanged();
|
| | | }
|
| | |
|
| | |
|
| | | }
|