|
|
@@ -10,6 +10,7 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
|
|
|
+import com.sheep.gamegroup.absBase.BaseRefreshLoadMoreFragment;
|
|
|
import com.sheep.gamegroup.helper.ImageListHelper;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.Entry;
|
|
|
@@ -17,12 +18,14 @@ import com.sheep.gamegroup.model.entity.GameApp;
|
|
|
import com.sheep.gamegroup.model.entity.GameEntity;
|
|
|
import com.sheep.gamegroup.model.entity.GameInfoList;
|
|
|
import com.sheep.gamegroup.model.entity.ShowAll;
|
|
|
+import com.sheep.gamegroup.model.entity.UserComment;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.GlideImageLoader;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.TextViewUtil;
|
|
|
import com.sheep.gamegroup.util.TimeUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.gamegroup.view.adapter.AdpGcGameAppComment;
|
|
|
import com.sheep.gamegroup.view.adapter.AdpGcGameAppInfoList;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
@@ -30,19 +33,21 @@ import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
import rx.Observable;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.functions.Action1;
|
|
|
+import rx.schedulers.Schedulers;
|
|
|
|
|
|
/**
|
|
|
* Created by realicing on 2018/11/1.
|
|
|
* realicing@sina.com
|
|
|
* 玩转游戏 详情
|
|
|
*/
|
|
|
-public class FgtGcGameAppDetail extends BaseFragment {
|
|
|
+public class FgtGcGameAppDetail extends BaseRefreshLoadMoreFragment implements Action1<List<UserComment>>{
|
|
|
@BindView(R.id.gc_game_app_detail_pic_list)
|
|
|
RecyclerView gc_game_app_detail_pic_list;
|
|
|
@BindView(R.id.gc_game_app_detail_info_list)
|
|
|
@@ -98,7 +103,7 @@ public class FgtGcGameAppDetail extends BaseFragment {
|
|
|
public void convert(ViewHolder viewHolder, ShowAll showAll, int position) {
|
|
|
TextViewUtil.initIntroView(viewHolder.itemView, showAll);
|
|
|
}
|
|
|
- }));
|
|
|
+ }).setSort(SORT_GAME_INTRO));
|
|
|
}
|
|
|
final List<Entry<String, String>> entryList = ListUtil.emptyList();
|
|
|
entryList.add(new Entry<>("当前版本", gameApp.getVersions()));
|
|
|
@@ -118,41 +123,15 @@ public class FgtGcGameAppDetail extends BaseFragment {
|
|
|
ViewUtil.setText(item_gc_game_info_key, item.getK());
|
|
|
ViewUtil.setText(item_gc_game_info_value, item.getV());
|
|
|
}
|
|
|
- }));
|
|
|
- gameInfoListArrayList.add(new GameInfoList("用户评价", new RecyclerViewAdapter<Entry<String, String>>(SheepApp.getInstance(), R.layout.item_gc_game_info, entryList) {
|
|
|
- @Override
|
|
|
- public void convert(ViewHolder viewHolder, Entry<String, String> item, int position) {
|
|
|
- View item_gc_game_info_top = viewHolder.itemView.findViewById(R.id.item_gc_game_info_top);
|
|
|
- TextView item_gc_game_info_key = viewHolder.itemView.findViewById(R.id.item_gc_game_info_key);
|
|
|
- TextView item_gc_game_info_value = viewHolder.itemView.findViewById(R.id.item_gc_game_info_value);
|
|
|
- View item_gc_game_info_bottom = viewHolder.itemView.findViewById(R.id.item_gc_game_info_bottom);
|
|
|
- ViewUtil.setVisibility(item_gc_game_info_top, position == 0);
|
|
|
- ViewUtil.setVisibility(item_gc_game_info_bottom, position + 1 == entryList.size());
|
|
|
- ViewUtil.setText(item_gc_game_info_key, item.getK());
|
|
|
- ViewUtil.setText(item_gc_game_info_value, item.getV());
|
|
|
- }
|
|
|
- }));
|
|
|
-
|
|
|
+ }).setSort(SORT_GAME_INFO));
|
|
|
+ Collections.sort(gameInfoListArrayList);
|
|
|
gc_game_app_detail_info_list.getAdapter().notifyDataSetChanged();
|
|
|
- if (appId > 0) {
|
|
|
- initData("相关游戏", SheepApp.getInstance().getNetComponent().getApiService().getDetailRelevantGames(appId), new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- G.showToast(R.string.coming_soon);
|
|
|
- }
|
|
|
- });
|
|
|
- initData("热门试玩", SheepApp.getInstance().getNetComponent().getApiService().getDetailHotGames(appId), new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- G.showToast(R.string.coming_soon);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//加载相关游戏与热门试玩数据列表
|
|
|
- private void initData(final String name, Observable<BaseMessage> observable, final View.OnClickListener onClickListener) {
|
|
|
- observable.observeOn(AndroidSchedulers.mainThread())
|
|
|
+ private void initData(final int sort, final String name, Observable<BaseMessage> observable, final View.OnClickListener onClickListener) {
|
|
|
+ observable.subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
.subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
@@ -171,12 +150,16 @@ public class FgtGcGameAppDetail extends BaseFragment {
|
|
|
GlideImageLoader.setGameImage(item_gc_game_app_iv, item.getIcon());
|
|
|
}
|
|
|
}
|
|
|
- }, onClickListener).setHorizontal());
|
|
|
+ }, onClickListener).setHorizontal().setSort(sort));
|
|
|
+ Collections.sort(gameInfoListArrayList);
|
|
|
+ gc_game_app_detail_info_list.getAdapter().notifyDataSetChanged();
|
|
|
}
|
|
|
+ refreshOrLoadMoreComplete();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
+ refreshOrLoadMoreComplete();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -184,4 +167,71 @@ public class FgtGcGameAppDetail extends BaseFragment {
|
|
|
private int appId;
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void loadMoreData() {
|
|
|
+ setNoMore(true);
|
|
|
+ refreshOrLoadMoreComplete();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void refreshData() {
|
|
|
+ ListUtil.removeItem(gameInfoListArrayList, new ListUtil.CallBack<GameInfoList, Boolean>() {
|
|
|
+ @Override
|
|
|
+ public Boolean call(GameInfoList gameInfoList) {
|
|
|
+ return gameInfoList.getSort() == SORT_GAME_RELEVANT || gameInfoList.getSort() == SORT_GAME_HOT;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ initData(SORT_GAME_RELEVANT, "相关游戏", SheepApp.getInstance().getNetComponent().getApiService().getDetailRelevantGames(appId), new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ G.showToast(R.string.coming_soon);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ initData(SORT_GAME_HOT, "热门试玩", SheepApp.getInstance().getNetComponent().getApiService().getDetailHotGames(appId), new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ G.showToast(R.string.coming_soon);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //评论列表数据
|
|
|
+ private List<UserComment> userCommentList = ListUtil.emptyList();
|
|
|
+ public static final int MAX_USER_COMMENT_NUM = 2;//最多显示评论的个数
|
|
|
+ @Override
|
|
|
+ public void call(List<UserComment> userComments) {
|
|
|
+ userCommentList.clear();
|
|
|
+ if(userComments != null) {
|
|
|
+ for (int i = 0; i < userComments.size(); i++) {
|
|
|
+ if(i < MAX_USER_COMMENT_NUM)
|
|
|
+ userCommentList.add(userComments.get(i));
|
|
|
+ else
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ GameInfoList item = ListUtil.getItem(gameInfoListArrayList, new ListUtil.CallBack<GameInfoList, Boolean>(){
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean call(GameInfoList gameInfoList) {
|
|
|
+ return gameInfoList.getSort() == SORT_USER_COMMENT;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(item == null) {
|
|
|
+ gameInfoListArrayList.add(new GameInfoList("用户评价", new AdpGcGameAppComment(userCommentList)).setSort(SORT_USER_COMMENT));
|
|
|
+ Collections.sort(gameInfoListArrayList);
|
|
|
+ }
|
|
|
+ gc_game_app_detail_info_list.getAdapter().notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ //游戏介绍
|
|
|
+ public static final int SORT_GAME_INTRO = 1;
|
|
|
+ //详细信息
|
|
|
+ public static final int SORT_GAME_INFO = 2;
|
|
|
+ //用户评价
|
|
|
+ public static final int SORT_USER_COMMENT = 3;
|
|
|
+ //相关游戏
|
|
|
+ public static final int SORT_GAME_RELEVANT = 4;
|
|
|
+ //热门试玩
|
|
|
+ public static final int SORT_GAME_HOT = 5;
|
|
|
}
|