完成4.0.1历史浏览记录优化 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/852
This commit is contained in:
@ -2,8 +2,6 @@ package com.gh.gamecenter.collection;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
@ -13,6 +11,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.util.DialogHelper;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
@ -33,6 +32,8 @@ import org.json.JSONObject;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
@ -43,9 +44,11 @@ import io.reactivex.schedulers.Schedulers;
|
||||
public class ArticleAdapter extends ListAdapter<NewsEntity> {
|
||||
|
||||
private OnListClickListener mListListener;
|
||||
private ArticleViewModel mViewModel;
|
||||
|
||||
public ArticleAdapter(Context context, OnListClickListener listListener) {
|
||||
public ArticleAdapter(Context context, ArticleViewModel viewModel, OnListClickListener listListener) {
|
||||
super(context);
|
||||
mViewModel = viewModel;
|
||||
mListListener = listListener;
|
||||
}
|
||||
|
||||
@ -103,12 +106,15 @@ public class ArticleAdapter extends ListAdapter<NewsEntity> {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.NEWS_IMAGE1:
|
||||
initNewsImage1ViewHolder((NewsImage1ViewHolder) holder, position);
|
||||
addLongClickListenerIfNeed(holder, mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.NEWS_IMAGE2:
|
||||
initNewsImage2ViewHolder((NewsImage2ViewHolder) holder, position);
|
||||
addLongClickListenerIfNeed(holder, mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.NEWS_IMAGE3:
|
||||
initNewsImage3ViewHolder((NewsImage3ViewHolder) holder, position);
|
||||
addLongClickListenerIfNeed(holder, mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.LOADING:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
@ -118,6 +124,24 @@ public class ArticleAdapter extends ListAdapter<NewsEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
private void addLongClickListenerIfNeed(RecyclerView.ViewHolder holder, NewsEntity newsEntity) {
|
||||
if (ArticleFragment.HISTORY.equals(mViewModel.type)) {
|
||||
holder.itemView.setOnLongClickListener(v -> {
|
||||
DialogHelper.showDialog(holder.itemView.getContext(),
|
||||
"删除记录",
|
||||
"删除浏览记录将不可回复,确定删除吗?",
|
||||
"确定",
|
||||
"取消",
|
||||
() -> {
|
||||
mViewModel.removeHistory(newsEntity);
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
false, "", "");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
Reference in New Issue
Block a user