回退关注问题/我的问题UI代码

This commit is contained in:
kehaoyuan@ghzhushou.com
2020-02-28 12:44:41 +08:00
parent 1b1bd3264a
commit 23267ec0ee
6 changed files with 146 additions and 43 deletions

View File

@ -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<Questions> {
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<Questions> {
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<Questions> {
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;

View File

@ -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<Questions, NormalList
@Override
protected ListAdapter provideListAdapter() {
return mAdapter == null ? mAdapter = new ConcernQuestionsAdapter(getContext(), mEntrance, this) : mAdapter;
return mAdapter == null ? mAdapter = new ConcernQuestionsAdapter(getContext(), this) : mAdapter;
}
@Override
@ -56,10 +57,17 @@ public class ConcernQuestionsFragment extends ListFragment<Questions, NormalList
@Override
public void onListClick(View view, int position, Object data) {
if (view.getId() == R.id.footerview_item) {
if (mAdapter.isNetworkError()) {
mListViewModel.load(LoadType.RETRY);
}
switch (view.getId()) {
case R.id.footerview_item:
if (mAdapter.isNetworkError()) {
mListViewModel.load(LoadType.RETRY);
}
break;
case R.id.ask_questions_new_item:
Questions questions = (Questions) data;
Intent intent = QuestionsDetailActivity.getIntent(getContext(), questions.getId(), mEntrance, "我的问答-关注问题", true);
startActivityForResult(intent, KEY_CHECK_QUESTION_CONCERN);
break;
}
}
}

View File

@ -1,9 +1,7 @@
package com.gh.gamecenter.qa.myqa;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
@ -11,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.
@ -24,11 +20,10 @@ import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity;
public class MyQuestionsAdapter extends ListAdapter<Questions> {
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<Questions> {
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<Questions> {
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;

View File

@ -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<Questions, NormalListViewM
@Override
protected ListAdapter provideListAdapter() {
return mAdapter == null ? mAdapter = new MyQuestionsAdapter(getContext(), mEntrance, this) : mAdapter;
return mAdapter == null ? mAdapter = new MyQuestionsAdapter(getContext(), this) : mAdapter;
}
@Override
@ -48,10 +49,17 @@ public class MyQuestionsFragment extends ListFragment<Questions, NormalListViewM
@Override
public void onListClick(View view, int position, Object data) {
if (view.getId() == R.id.footerview_item) {
if (mAdapter.isNetworkError()) {
mListViewModel.load(LoadType.RETRY);
}
switch (view.getId()) {
case R.id.footerview_item:
if (mAdapter.isNetworkError()) {
mListViewModel.load(LoadType.RETRY);
}
break;
case R.id.ask_questions_new_item:
Questions questions = (Questions) data;
startActivity(QuestionsDetailActivity.getIntent(getContext(), questions.getId(), mEntrance, "我的光环-我的问答-我的问题"));
break;
}
}
}

View File

@ -0,0 +1,53 @@
package com.gh.gamecenter.qa.newest;
import android.view.View;
import android.widget.TextView;
import com.gh.base.BaseRecyclerViewHolder;
import com.gh.base.OnListClickListener;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.NumberUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.qa.entity.Questions;
import butterknife.BindView;
/**
* Created by khy on 6/12/17.
*/
public class AskQuestionsNewViewHolder extends BaseRecyclerViewHolder<Questions> {
@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());
}
}