完成4.0.1历史浏览记录优化 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/852
This commit is contained in:
@ -1,10 +1,6 @@
|
||||
package com.gh.gamecenter.collection;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import kotlin.Pair;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@ -12,22 +8,25 @@ import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
import com.gh.common.syncpage.ISyncAdapterHandler;
|
||||
import com.gh.common.util.CollectionUtils;
|
||||
import com.gh.common.util.DialogHelper;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadType;
|
||||
import com.gh.gamecenter.databinding.CommunityAnswerItemBinding;
|
||||
import com.gh.gamecenter.qa.answer.CommunityAnswerItemViewHolder;
|
||||
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity;
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.qa.entity.Questions;
|
||||
import com.gh.gamecenter.qa.questions.detail.AnswerViewHolder;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import kotlin.Pair;
|
||||
|
||||
/**
|
||||
* Created by khy on 22/12/17.
|
||||
*/
|
||||
@ -39,14 +38,12 @@ public class AnswerAdapter extends ListAdapter<AnswerEntity> implements ISyncAda
|
||||
private AnswerViewModel mListViewModel;
|
||||
|
||||
private String mEntrance;
|
||||
private AnswerFragment.Type mType;
|
||||
|
||||
public AnswerAdapter(Context context, AnswerViewModel viewModel, AnswerFragment.Type type, OnListClickListener listClickListener, String entrance) {
|
||||
public AnswerAdapter(Context context, AnswerViewModel viewModel, OnListClickListener listClickListener, String entrance) {
|
||||
super(context);
|
||||
mListViewModel = viewModel;
|
||||
mListClickListener = listClickListener;
|
||||
mEntrance = entrance;
|
||||
this.mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -77,37 +74,45 @@ public class AnswerAdapter extends ListAdapter<AnswerEntity> implements ISyncAda
|
||||
CommunityAnswerItemViewHolder viewHolder = (CommunityAnswerItemViewHolder) holder;
|
||||
AnswerEntity entity = mEntityList.get(position);
|
||||
String path;
|
||||
if (mType == AnswerFragment.Type.COLLECTION) {
|
||||
if (AnswerFragment.COLLECTION.equals(mListViewModel.getType())) {
|
||||
path = "我的收藏-回答列表";
|
||||
} else if (mType == AnswerFragment.Type.HISTORY) {
|
||||
} else if (AnswerFragment.HISTORY.equals(mListViewModel.getType())) {
|
||||
path = "浏览记录-回答列表";
|
||||
viewHolder.itemView.setOnLongClickListener(v -> {
|
||||
DialogHelper.showDialog(holder.itemView.getContext(),
|
||||
"删除记录",
|
||||
"删除浏览记录将不可回复,确定删除吗?",
|
||||
"确定",
|
||||
"取消",
|
||||
() -> {
|
||||
mListViewModel.removeHistory(entity);
|
||||
},
|
||||
() -> {
|
||||
},
|
||||
false, "", "");
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
path = "插入回答-收藏回答列表";
|
||||
}
|
||||
viewHolder.bindAnswerItem(entity, mEntrance, path);
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (entity.getActive()) {
|
||||
mContext.startActivity(AnswerDetailActivity.getIntent(mContext, entity.getId(), mEntrance, path));
|
||||
} else {
|
||||
showDeleteDialog(entity.getId());
|
||||
}
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (entity.getActive()) {
|
||||
mContext.startActivity(AnswerDetailActivity.getIntent(mContext, entity.getId(), mEntrance, path));
|
||||
} else {
|
||||
showDeleteDialog(entity.getId());
|
||||
}
|
||||
|
||||
if (!entity.getRead()) {
|
||||
entity.setRead(true);
|
||||
notifyItemChanged(position);
|
||||
mListViewModel.postCollectionAnswerRead(entity.getId());
|
||||
}
|
||||
if (!entity.getRead()) {
|
||||
entity.setRead(true);
|
||||
notifyItemChanged(position);
|
||||
mListViewModel.postCollectionAnswerRead(entity.getId());
|
||||
}
|
||||
});
|
||||
viewHolder.getBinding().title.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Questions questions = entity.getQuestions();
|
||||
mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, questions.getId(), mEntrance, path));
|
||||
}
|
||||
viewHolder.getBinding().title.setOnClickListener(v -> {
|
||||
Questions questions = entity.getQuestions();
|
||||
mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, questions.getId(), mEntrance, path));
|
||||
});
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
|
||||
Reference in New Issue
Block a user