Search in sources :

Example 1 with RightMenuAdapter

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();
}
Also used : RightMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter) LeftMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.LeftMenuAdapter) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Lesson(pri.weiqiang.liyujapanese.mvp.bean.dic.Lesson)

Example 2 with RightMenuAdapter

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();
}
Also used : RightMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter) LeftMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.LeftMenuAdapter) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Lesson(pri.weiqiang.liyujapanese.mvp.bean.dic.Lesson)

Aggregations

DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)2 Lesson (pri.weiqiang.liyujapanese.mvp.bean.dic.Lesson)2 LeftMenuAdapter (pri.weiqiang.liyujapanese.ui.adapter.LeftMenuAdapter)2 RightMenuAdapter (pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter)2