use of com.dante.adapter.FavoriteAdapter 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);
}
Aggregations