Search in sources :

Example 1 with StaggeredGridAdapter

use of pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter in project LiYuJapanese by 54wall.

the class FavLessonFragment method setData.

@Override
public void setData(List<LessonFav> data) {
    Log.e(TAG, "setData!!!!!!");
    lessonFavList = data;
    staggeredGridAdapter = new StaggeredGridAdapter(getActivity(), data);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(staggeredGridAdapter);
    staggeredGridAdapter.setOnItemClickLitener(new OnItemClickLitener() {

        @Override
        public void onItemClick(View view, int position) {
            staggeredGridAdapter.notifyItemRemoved(position);
            ((MainActivity) getActivity()).switchFavWord(staggeredGridAdapter.getItemLessonId(position), false);
        }

        @Override
        public void onItemLongClick(View view, final int position) {
        }
    });
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(mRecyclerView);
}
Also used : OnItemClickLitener(pri.weiqiang.liyujapanese.ui.adapter.stagger.OnItemClickLitener) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) StaggeredGridAdapter(pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) FavLessonFragmentView(pri.weiqiang.liyujapanese.mvp.view.dic.FavLessonFragmentView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with StaggeredGridAdapter

use of pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter in project MyJapanese by 54wall.

the class FavLessonFragment method setData.

@Override
public void setData(List<LessonFav> data) {
    Log.e(TAG, "setData!!!!!!");
    lessonFavList = data;
    staggeredGridAdapter = new StaggeredGridAdapter(getActivity(), data);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(staggeredGridAdapter);
    staggeredGridAdapter.setOnItemClickLitener(new OnItemClickLitener() {

        @Override
        public void onItemClick(View view, int position) {
            staggeredGridAdapter.notifyItemRemoved(position);
            ((MainActivity) getActivity()).switchFavWord(staggeredGridAdapter.getItemLessonId(position), false);
        }

        @Override
        public void onItemLongClick(View view, final int position) {
        }
    });
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(mRecyclerView);
}
Also used : OnItemClickLitener(pri.weiqiang.liyujapanese.ui.adapter.stagger.OnItemClickLitener) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) StaggeredGridAdapter(pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) FavLessonFragmentView(pri.weiqiang.liyujapanese.mvp.view.dic.FavLessonFragmentView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

View (android.view.View)2 ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)2 BindView (butterknife.BindView)2 FavLessonFragmentView (pri.weiqiang.liyujapanese.mvp.view.dic.FavLessonFragmentView)2 StaggeredGridAdapter (pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter)2 OnItemClickLitener (pri.weiqiang.liyujapanese.ui.adapter.stagger.OnItemClickLitener)2