use of com.vondear.tools.adapter.AdapterContactCity in project RxTools by vondear.
the class ActivityContact method initView.
private void initView() {
mRxTitle.setLeftFinish(mContext);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
final PinnedHeaderDecoration decoration = new PinnedHeaderDecoration();
decoration.registerTypePinnedHeader(1, new PinnedHeaderDecoration.PinnedHeaderCreator() {
@Override
public boolean create(RecyclerView parent, int adapterPosition) {
return true;
}
});
mRecyclerView.addItemDecoration(decoration);
new Thread(new Runnable() {
@Override
public void run() {
Type listType = new TypeToken<ArrayList<ModelContactCity>>() {
}.getType();
Gson gson = new Gson();
final List<ModelContactCity> list = gson.fromJson(ModelContactCity.DATA, listType);
Collections.sort(list, new ComparatorLetter());
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapterContactCity = new AdapterContactCity(mContext, list);
mRecyclerView.setAdapter(mAdapterContactCity);
}
});
}
}).start();
mSideBarView.setOnTouchLetterChangeListener(new WaveSideBarView.OnTouchLetterChangeListener() {
@Override
public void onLetterChange(String letter) {
int pos = mAdapterContactCity.getLetterPosition(letter);
if (pos != -1) {
mRecyclerView.scrollToPosition(pos);
LinearLayoutManager mLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
mLayoutManager.scrollToPositionWithOffset(pos, 0);
}
}
});
}
Aggregations