diff --git a/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsAdapter.java b/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsAdapter.java index 8df52a348d..7786a85267 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsAdapter.java @@ -1,11 +1,7 @@ package com.gh.gamecenter.qa.myqa; -import android.app.Activity; import android.content.Context; - import androidx.recyclerview.widget.RecyclerView; - -import android.content.Intent; import android.view.View; import android.view.ViewGroup; @@ -13,11 +9,9 @@ import com.gh.base.OnListClickListener; import com.gh.common.constant.ItemViewType; import com.gh.gamecenter.R; import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; -import com.gh.gamecenter.databinding.CommunityQuestionItemBinding; +import com.gh.gamecenter.qa.newest.AskQuestionsNewViewHolder; import com.gh.gamecenter.qa.entity.Questions; import com.gh.gamecenter.baselist.ListAdapter; -import com.gh.gamecenter.qa.questions.CommunityQuestionViewHolder; -import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity; /** * Created by khy on 20/12/17. @@ -26,11 +20,10 @@ import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity; class ConcernQuestionsAdapter extends ListAdapter { private OnListClickListener mListClickListener; - private String mEntrance = ""; - public ConcernQuestionsAdapter(Context context, String entrance, OnListClickListener listClickListener) { + + public ConcernQuestionsAdapter(Context context, OnListClickListener listClickListener) { super(context); - mEntrance = entrance; mListClickListener = listClickListener; } @@ -48,8 +41,8 @@ class ConcernQuestionsAdapter extends ListAdapter { view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false); return new FooterViewHolder(view, mListClickListener); case ItemViewType.ITEM_BODY: - view = mLayoutInflater.inflate(R.layout.community_question_item, parent, false); - return new CommunityQuestionViewHolder(CommunityQuestionItemBinding.bind(view)); + view = mLayoutInflater.inflate(R.layout.ask_questions_new_item, parent, false); + return new AskQuestionsNewViewHolder(view, mListClickListener); default: return null; } @@ -59,14 +52,8 @@ class ConcernQuestionsAdapter extends ListAdapter { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (getItemViewType(position)) { case ItemViewType.ITEM_BODY: - Questions questions = mEntityList.get(position); - ((CommunityQuestionViewHolder) holder).bindMyQuestionViewHolder(questions, mEntrance, "我的问答-关注问题"); - holder.itemView.setOnClickListener(v -> { - if (mContext instanceof Activity) { - Intent intent = QuestionsDetailActivity.getIntent(mContext, questions.getId(), mEntrance, "我的问答-关注问题", true); - ((Activity) mContext).startActivityForResult(intent, ConcernQuestionsFragment.KEY_CHECK_QUESTION_CONCERN); - } - }); + ((AskQuestionsNewViewHolder) holder).initMyQuestionsViewHolder(mEntityList.get(position)); + break; case ItemViewType.ITEM_FOOTER: FooterViewHolder footerViewHolder = (FooterViewHolder) holder; diff --git a/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsFragment.java b/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsFragment.java index 6a931c35c3..abc55b3fad 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsFragment.java +++ b/app/src/main/java/com/gh/gamecenter/qa/myqa/ConcernQuestionsFragment.java @@ -13,6 +13,7 @@ import com.gh.gamecenter.baselist.LoadType; import com.gh.gamecenter.baselist.NormalListViewModel; import com.gh.gamecenter.manager.UserManager; import com.gh.gamecenter.qa.entity.Questions; +import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity; import com.gh.gamecenter.retrofit.RetrofitManager; import java.util.List; @@ -46,7 +47,7 @@ public class ConcernQuestionsFragment extends ListFragment { private OnListClickListener mListClickListener; - private String mEntrance = ""; - public MyQuestionsAdapter(Context context, String entrance, OnListClickListener listClickListener) { + + public MyQuestionsAdapter(Context context, OnListClickListener listClickListener) { super(context); - mEntrance = entrance; mListClickListener = listClickListener; } @@ -46,8 +41,8 @@ public class MyQuestionsAdapter extends ListAdapter { view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false); return new FooterViewHolder(view, mListClickListener); case ItemViewType.ITEM_BODY: - view = mLayoutInflater.inflate(R.layout.community_question_item, parent, false); - return new CommunityQuestionViewHolder(CommunityQuestionItemBinding.bind(view)); + view = mLayoutInflater.inflate(R.layout.ask_questions_new_item, parent, false); + return new AskQuestionsNewViewHolder(view, mListClickListener); default: return null; } @@ -57,9 +52,8 @@ public class MyQuestionsAdapter extends ListAdapter { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (getItemViewType(position)) { case ItemViewType.ITEM_BODY: - Questions questions = mEntityList.get(position); - ((CommunityQuestionViewHolder) holder).bindMyQuestionViewHolder(questions,mEntrance,"我的光环-我的问答-我的问题"); - holder.itemView.setOnClickListener(v -> mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, questions.getId(), mEntrance, "我的光环-我的问答-我的问题"))); + ((AskQuestionsNewViewHolder) holder).initMyQuestionsViewHolder(mEntityList.get(position)); + break; case ItemViewType.ITEM_FOOTER: FooterViewHolder footerViewHolder = (FooterViewHolder) holder; diff --git a/app/src/main/java/com/gh/gamecenter/qa/myqa/MyQuestionsFragment.java b/app/src/main/java/com/gh/gamecenter/qa/myqa/MyQuestionsFragment.java index 5689ab6c99..ad3e8e6afd 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/myqa/MyQuestionsFragment.java +++ b/app/src/main/java/com/gh/gamecenter/qa/myqa/MyQuestionsFragment.java @@ -11,6 +11,7 @@ import com.gh.gamecenter.baselist.LoadType; import com.gh.gamecenter.baselist.NormalListViewModel; import com.gh.gamecenter.manager.UserManager; import com.gh.gamecenter.qa.entity.Questions; +import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity; import com.gh.gamecenter.retrofit.RetrofitManager; import com.halo.assistant.HaloApp; import com.lightgame.utils.Utils; @@ -37,7 +38,7 @@ public class MyQuestionsFragment extends ListFragment { + + @BindView(R.id.ask_questions_item_title) + TextView mTitle; + @BindView(R.id.ask_questions_item_answer_count) + TextView mAnswerCount; + @BindView(R.id.ask_questions_item_community_name) + TextView mCommunityName; + + public AskQuestionsNewViewHolder(View itemView) { + super(itemView); + itemView.setOnClickListener(this); + } + + public AskQuestionsNewViewHolder(View itemView, OnListClickListener listClickListener) { + super(itemView, listClickListener); + itemView.setOnClickListener(this); + } + + public void initAskQuestionsNewViewHolder(Questions questions) { + setClickData(questions); + mAnswerCount.setText(NumberUtils.transSimpleCount(questions.getAnswerCount())); + mTitle.setText(questions.getTitle()); + mCommunityName.setVisibility(View.VISIBLE); + mCommunityName.setText(NewsUtils.getFormattedTime(questions.getTime())); + } + + public void initMyQuestionsViewHolder(Questions questions) { + setClickData(questions); + mAnswerCount.setText(NumberUtils.transSimpleCount(questions.getAnswerCount())); + mTitle.setText(questions.getTitle()); + mCommunityName.setVisibility(View.VISIBLE); + mCommunityName.setText(questions.getCommunityName()); + } +} diff --git a/app/src/main/res/layout/ask_questions_new_item.xml b/app/src/main/res/layout/ask_questions_new_item.xml new file mode 100644 index 0000000000..a97a8f78b7 --- /dev/null +++ b/app/src/main/res/layout/ask_questions_new_item.xml @@ -0,0 +1,53 @@ + + + + + + + + + + \ No newline at end of file