问题精选更改Entity 和点击跳转
This commit is contained in:
@ -10,7 +10,7 @@ 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.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
|
||||
@ -24,7 +24,7 @@ public class AskQuestionsHotAdapter extends ListAdapter {
|
||||
|
||||
private OnListClickListener mListClickListener;
|
||||
|
||||
private List<QuestionsEntity> mEntityList;
|
||||
private List<AnswerEntity> mEntityList;
|
||||
|
||||
public AskQuestionsHotAdapter(Context context, OnListClickListener listClickListener) {
|
||||
super(context);
|
||||
@ -34,7 +34,7 @@ public class AskQuestionsHotAdapter extends ListAdapter {
|
||||
@NonNull
|
||||
@Override
|
||||
protected <T> void provideListData(List<T> listData) {
|
||||
mEntityList = (List<QuestionsEntity>) listData;
|
||||
mEntityList = (List<AnswerEntity>) listData;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class AskQuestionsHotAdapter extends ListAdapter {
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case ItemViewType.ITEM_BODY:
|
||||
((AskQuestionsHotViewHolder) holder).initQuestionsHotViewHolder(mContext, mEntityList.get(position));
|
||||
((AskQuestionsHotViewHolder) holder).initQuestionsHotViewHolder(mEntityList.get(position));
|
||||
break;
|
||||
case ItemViewType.ITEM_FOOTER:
|
||||
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.gamecenter.ask;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.gamecenter.AskQuestionsDetailActivity;
|
||||
import com.gh.gamecenter.NormalActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.baselist.ListAdapter;
|
||||
import com.gh.gamecenter.baselist.ListFragment;
|
||||
import com.gh.gamecenter.baselist.LoadStatus;
|
||||
@ -26,7 +28,7 @@ public class AskQuestionsHotFragment extends ListFragment {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Observable<List<QuestionsEntity>> provideDataObservable() {
|
||||
public Observable<List<AnswerEntity>> provideDataObservable() {
|
||||
return RetrofitManager.getInstance(getContext()).getApi().getAskHot(UserManager.getInstance().getCommunityId(getContext()), getListOffset());
|
||||
}
|
||||
|
||||
@ -37,7 +39,7 @@ public class AskQuestionsHotFragment extends ListFragment {
|
||||
|
||||
@Override
|
||||
public void onListClick(View view, int position, Object data) {
|
||||
List<QuestionsEntity> questionsList;
|
||||
List<AnswerEntity> questionsList;
|
||||
switch (view.getId()) {
|
||||
case R.id.footerview_item:
|
||||
if (mAdapter.isNetworkError()) {
|
||||
@ -48,16 +50,15 @@ public class AskQuestionsHotFragment extends ListFragment {
|
||||
case R.id.ask_item_constraintlayout:
|
||||
break;
|
||||
case R.id.ask_item_title:
|
||||
questionsList = (List<QuestionsEntity>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getQuestion().getId()));
|
||||
questionsList = (List<AnswerEntity>) data;
|
||||
startActivity(AskQuestionsDetailActivity.getIntent(getContext(), questionsList.get(position).getQuestions().getId()));
|
||||
break;
|
||||
case R.id.ask_item_img:
|
||||
case R.id.ask_item_content:
|
||||
questionsList = (List<QuestionsEntity>) data;
|
||||
|
||||
|
||||
// Bundle bundle = new Bundle();
|
||||
// bundle.putParcelable(AnswerEntity.TAG, entityList.get(position));
|
||||
// NormalActivity.startFragment(getContext(), AskAnswerDetailFragment.class, bundle);
|
||||
questionsList = (List<AnswerEntity>) data;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(AnswerEntity.TAG, questionsList.get(position));
|
||||
NormalActivity.startFragment(getContext(), AskAnswerDetailFragment.class, bundle);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter.ask;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -9,8 +8,7 @@ import com.gh.base.BaseRecyclerViewHolder;
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
import com.gh.gamecenter.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -40,24 +38,24 @@ public class AskQuestionsHotViewHolder extends BaseRecyclerViewHolder {
|
||||
public AskQuestionsHotViewHolder(View itemView, Object data, OnListClickListener listClickListener) {
|
||||
super(itemView, data, listClickListener);
|
||||
itemView.setOnClickListener(this);
|
||||
mAskImg.setOnClickListener(this);
|
||||
mAskTitle.setOnClickListener(this);
|
||||
mAskContent.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void initQuestionsHotViewHolder(Context context, QuestionsEntity entity) {
|
||||
public void initQuestionsHotViewHolder(AnswerEntity entity) {
|
||||
mAskVotecount.setText(itemView.getContext().getString(R.string.ask_vote_count, entity.getVote()));
|
||||
|
||||
mAskContent.setText(entity.getBrief());
|
||||
mAskVotecount.setText(context.getString(R.string.ask_vote_count, entity.getVote()));
|
||||
|
||||
UserEntity user = entity.getUser();
|
||||
if (user != null) {
|
||||
mAskUsername.setText(user.getName());
|
||||
ImageUtils.Companion.display(mAskUsericon, user.getIcon());
|
||||
}
|
||||
Questions question = entity.getQuestion();
|
||||
if (question != null) {
|
||||
mAskTitle.setText(question.getTitle());
|
||||
}
|
||||
mAskUsername.setText(user.getName());
|
||||
ImageUtils.Companion.display(mAskUsericon, user.getIcon());
|
||||
|
||||
mAskTitle.setText(entity.getQuestions().getTitle());
|
||||
|
||||
List<String> images = entity.getImages();
|
||||
if (images != null && images.size() > 0) {
|
||||
if (images.size() > 0) {
|
||||
mAskImg.setVisibility(View.VISIBLE);
|
||||
ImageUtils.Companion.display(mAskImg, images.get(0));
|
||||
} else {
|
||||
|
||||
@ -15,11 +15,11 @@ class AnswerEntity() : Parcelable {
|
||||
|
||||
var brief: String? = null
|
||||
|
||||
var images: List<String>? = null
|
||||
var images: List<String> = ArrayList()
|
||||
|
||||
var vote: Int = 0
|
||||
|
||||
var user: UserEntity? = null
|
||||
var user: UserEntity = UserEntity()
|
||||
|
||||
@SerializedName("question")
|
||||
var questions: Questions = Questions()
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
package com.gh.gamecenter.ask.entity
|
||||
|
||||
import com.gh.gamecenter.entity.UserEntity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Created by khy on 11/12/17.
|
||||
*/
|
||||
class QuestionsEntity {
|
||||
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
|
||||
var brief: String? = null
|
||||
|
||||
var images: List<String>? = null
|
||||
|
||||
var vote: Int = 0
|
||||
|
||||
var answers: Int = 0
|
||||
|
||||
var user: UserEntity? = null
|
||||
|
||||
var question: Questions? = null
|
||||
}
|
||||
@ -8,7 +8,6 @@ import com.gh.gamecenter.ask.entity.AskTagGroupsEntity;
|
||||
import com.gh.gamecenter.ask.entity.InviteEntity;
|
||||
import com.gh.gamecenter.ask.entity.Questions;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
|
||||
import com.gh.gamecenter.ask.entity.QuestionsEntity;
|
||||
import com.gh.gamecenter.entity.AppEntity;
|
||||
import com.gh.gamecenter.entity.CommentEntity;
|
||||
import com.gh.gamecenter.entity.CommentnumEntity;
|
||||
@ -701,7 +700,7 @@ public interface ApiService {
|
||||
* 获取社区首页精选
|
||||
*/
|
||||
@GET("communities/{community_id}/choiceness")
|
||||
Observable<List<QuestionsEntity>> getAskHot(@Path("community_id") String communityId, @Query("offset") int offset);
|
||||
Observable<List<AnswerEntity>> getAskHot(@Path("community_id") String communityId, @Query("offset") int offset);
|
||||
|
||||
/**
|
||||
* 获取社区首页-问题列表
|
||||
|
||||
Reference in New Issue
Block a user