|
@@ -48,22 +48,27 @@ public class ContactsPager extends BasePager {
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((GridLayoutManager) mLayoutManager).setSpanCount(1);
|
|
|
- ((GridLayoutManager) mLayoutManager).onItemsChanged(mRecyclerView);
|
|
|
- mRecyclerAdapter.setViewType(0);
|
|
|
- mRecyclerAdapter.setDataList(mRecentList);
|
|
|
- mRecyclerAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(mContext, 1);
|
|
|
+ mRecyclerView.setHasFixedSize(true);
|
|
|
+ mRecyclerView.setLayoutManager(mLayoutManager);
|
|
|
+
|
|
|
+ mRecyclerAdapter = new ContactsRecyclerAdapter(mContext, 0, recentList);
|
|
|
+ mRecyclerAdapter.setListOnClickListener(listener);
|
|
|
+ mRecyclerView.setAdapter(mRecyclerAdapter);
|
|
|
}
|
|
|
});
|
|
|
mContactButton.setOnClickListener(new View.OnClickListener() {
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- ((GridLayoutManager) mLayoutManager).setSpanCount(2);
|
|
|
- ((GridLayoutManager) mLayoutManager).onItemsChanged(mRecyclerView);
|
|
|
- mRecyclerAdapter.setViewType(1);
|
|
|
- mRecyclerAdapter.setDataList(mContactsList);
|
|
|
- mRecyclerAdapter.notifyDataSetChanged();
|
|
|
+ RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(mContext, 2);
|
|
|
+ mRecyclerView.setHasFixedSize(true);
|
|
|
+ mRecyclerView.setLayoutManager(mLayoutManager);
|
|
|
+
|
|
|
+ mRecyclerAdapter = new ContactsRecyclerAdapter(mContext, 1, contactsList);
|
|
|
+ mRecyclerAdapter.setListOnClickListener(listener);
|
|
|
+ mRecyclerView.setAdapter(mRecyclerAdapter);
|
|
|
}
|
|
|
});
|
|
|
}
|