use of pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter in project MyJapanese by 54wall.
the class LessonsFragment method setData.
@Override
public void setData(List<Book> data) {
// 来自initAdapter
mBookList = data;
leftAdapter = new LeftMenuAdapter(getActivity(), data);
rightAdapter = new RightMenuAdapter(getActivity(), data);
rightAdapter.setOnItemClickListener(new RightMenuAdapter.OnItemClickListener() {
@Override
public void onClick(Lesson item) {
Log.e(TAG, "lesson:" + item.getTitle());
SharedPreferenceManager.getInstance().putString(Constants.CURRENT_LESSON, item.getTitle());
SharedPreferenceManager.getInstance().putInt(Constants.CURRENT_LESSON_ID, item.getId());
((MainActivity) getActivity()).switchWords(item.getTitle(), false);
}
});
mRightMenu.setAdapter(rightAdapter);
mRightMenu.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
mLeftMenu.setAdapter(leftAdapter);
leftAdapter.addItemSelectedListener(this);
// 设置初始滚动位置
Log.e(TAG, "CURRENT_LESSON_ID:" + SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
mRightMenu.scrollToPosition(SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
initHeadView();
}
use of pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter in project LiYuJapanese by 54wall.
the class LessonsFragment method setData.
@Override
public void setData(List<Book> data) {
// 来自initAdapter
mBookList = data;
leftAdapter = new LeftMenuAdapter(getActivity(), data);
rightAdapter = new RightMenuAdapter(getActivity(), data);
rightAdapter.setOnItemClickListener(new RightMenuAdapter.OnItemClickListener() {
@Override
public void onClick(Lesson item) {
Log.e(TAG, "lesson:" + item.getTitle());
SharedPreferenceManager.getInstance().putString(Constants.CURRENT_LESSON, item.getTitle());
SharedPreferenceManager.getInstance().putInt(Constants.CURRENT_LESSON_ID, item.getId());
((MainActivity) getActivity()).switchWords(item.getTitle(), false);
}
});
mRightMenu.setAdapter(rightAdapter);
mRightMenu.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
mLeftMenu.setAdapter(leftAdapter);
leftAdapter.addItemSelectedListener(this);
// 设置初始滚动位置
Log.e(TAG, "CURRENT_LESSON_ID:" + SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
mRightMenu.scrollToPosition(SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
initHeadView();
}
Aggregations