Search in sources :

Example 1 with SwipeItemLayout

use of com.aitsuki.swipe.SwipeItemLayout in project 91Pop by DanteAndroid.

the class FavoriteActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_favorite);
    ButterKnife.bind(this);
    deleteAlertDialog = DialogUtils.initLodingDialog(this, "删除中,请稍后...");
    initToolBar(toolbar);
    toolbar.setContentInsetStartWithNavigation(0);
    // Setup contentView == SwipeRefreshView
    contentView.setOnRefreshListener(this);
    List<UnLimit91PornItem> mUnLimit91PornItemList = new ArrayList<>();
    mUnLimit91Adapter = new FavoriteAdapter(R.layout.item_right_menu_delete, mUnLimit91PornItemList);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mUnLimit91Adapter);
    mUnLimit91Adapter.setEmptyView(R.layout.empty_view, recyclerView);
    mUnLimit91Adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            goToPlayVideo((UnLimit91PornItem) adapter.getItem(position));
        }
    });
    mUnLimit91Adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            SwipeItemLayout swipeItemLayout = (SwipeItemLayout) view.getParent();
            swipeItemLayout.close();
            if (view.getId() == R.id.right_menu_delete) {
                UnLimit91PornItem unLimit91PornItem = (UnLimit91PornItem) adapter.getItem(position);
                if (unLimit91PornItem == null || unLimit91PornItem.getVideoResult() == null) {
                    showMessage("信息错误,无法删除", TastyToast.WARNING);
                    return;
                }
                presenter.deleteFavorite(unLimit91PornItem.getVideoResult().getVideoId());
            }
        }
    });
    mUnLimit91Adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {

        @Override
        public void onLoadMoreRequested() {
            presenter.loadRemoteFavoriteData(false);
        }
    }, recyclerView);
    helper = new LoadViewHelper(recyclerView);
    helper.setListener(new OnLoadViewListener() {

        @Override
        public void onRetryClick() {
            presenter.loadRemoteFavoriteData(false);
        }
    });
    boolean needRefresh = dataManager.isFavoriteNeedRefresh();
    presenter.loadRemoteFavoriteData(needRefresh);
}
Also used : ArrayList(java.util.ArrayList) SwipeItemLayout(com.aitsuki.swipe.SwipeItemLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) SwipeMenuRecyclerView(com.aitsuki.swipe.SwipeMenuRecyclerView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnLoadViewListener(com.helper.loadviewhelper.help.OnLoadViewListener) FavoriteAdapter(com.dante.adapter.FavoriteAdapter) LoadViewHelper(com.helper.loadviewhelper.load.LoadViewHelper) UnLimit91PornItem(com.dante.data.model.UnLimit91PornItem)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 View (android.view.View)1 BindView (butterknife.BindView)1 SwipeItemLayout (com.aitsuki.swipe.SwipeItemLayout)1 SwipeMenuRecyclerView (com.aitsuki.swipe.SwipeMenuRecyclerView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 FavoriteAdapter (com.dante.adapter.FavoriteAdapter)1 UnLimit91PornItem (com.dante.data.model.UnLimit91PornItem)1 OnLoadViewListener (com.helper.loadviewhelper.help.OnLoadViewListener)1 LoadViewHelper (com.helper.loadviewhelper.load.LoadViewHelper)1 ArrayList (java.util.ArrayList)1