|
|
@@ -19,6 +19,7 @@ import com.sheep.gamegroup.model.entity.GameListType;
|
|
|
import com.sheep.gamegroup.model.entity.ListTypeList;
|
|
|
import com.sheep.gamegroup.model.entity.SlideshowEty;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
+import com.sheep.gamegroup.module.game.adapter.AdpGameCenter4_3List;
|
|
|
import com.sheep.gamegroup.module.game.adapter.AdpGameCenterType;
|
|
|
import com.sheep.gamegroup.module.game.model.GameCenterType;
|
|
|
import com.sheep.gamegroup.module.game.model.PackageTypes;
|
|
|
@@ -29,7 +30,6 @@ import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.ObservableUtil;
|
|
|
import com.sheep.gamegroup.util.RefreshUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
-import com.sheep.gamegroup.view.adapter.AdpGameCenter3_3List;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
@@ -42,6 +42,8 @@ import com.youth.banner.loader.ImageLoader;
|
|
|
import org.afinal.simplecache.ApiKey;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
@@ -67,7 +69,7 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
|
|
|
//绵羊新游、免费道具、绵羊推荐、排行榜
|
|
|
private List<GameCenterType> gameCenterList = new ArrayList<>();
|
|
|
- public static final String[] GAME_CENTER_TYPE_NAME = {"绵羊新游", "免费道具", "绵羊推荐", "排行榜"};
|
|
|
+ public static final String[] GAME_CENTER_TYPE_NAME = {"绵羊新游", "会员推荐", "绵羊推荐", "排行榜"};
|
|
|
public static final String[] GAME_CENTER_TYPE_ICON_NAME = {"myxy", "免费道具", "绵羊推荐", "排行榜"};
|
|
|
public static final int[] GAME_CENTER_TYPE_ID = {1, 2, 3, -1};//1:绵羊新游 2:绵羊推荐 3:免费道具
|
|
|
//预下载和tag列表的数据
|
|
|
@@ -108,7 +110,7 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
play_game_list_x_rv.setHasFixedSize(true);
|
|
|
play_game_list_x_rv.setNestedScrollingEnabled(false);
|
|
|
play_game_list_x_rv.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
- play_game_list_x_rv.setAdapter(new AdpGameCenter3_3List(getActivity(), gameEntityListx).setShowFirstTop(false));
|
|
|
+ play_game_list_x_rv.setAdapter(new AdpGameCenter4_3List(getActivity(), gameEntityListx).setShowFirstTop(false));
|
|
|
|
|
|
refresh.setOnRefreshListener(refreshLayout -> refreshData());
|
|
|
RefreshUtil.newInstance().publicParameter(refresh, getActivity());
|
|
|
@@ -123,23 +125,20 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //预下载下面的tagList
|
|
|
+ //获取出包类型列表 的tagList
|
|
|
private void initGameTagList() {
|
|
|
gameEntityListx.clear();
|
|
|
ViewUtil.notifyDataSetChanged(play_game_list_x_rv);
|
|
|
//其它tag
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().getFindPackageTypeList()
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
- .flatMap((Function<BaseMessage, Observable<PackageTypes>>) baseMessage -> {
|
|
|
- ArrayList<PackageTypes> gameListTagList = baseMessage.getDataList(PackageTypes.class);
|
|
|
- return Observable.fromIterable(gameListTagList);
|
|
|
- })
|
|
|
+ .flatMap((Function<BaseMessage, Observable<PackageTypes>>) baseMessage -> Observable.fromIterable(baseMessage.getDataList(PackageTypes.class)))
|
|
|
.filter(gameListTag -> gameListTag != null)
|
|
|
.subscribe(new AbsObserver<PackageTypes>() {
|
|
|
|
|
|
@Override
|
|
|
public void onNext(PackageTypes gameListTag) {
|
|
|
- initGameList(play_game_list_x_rv, gameEntityListx, gameListTag.toGameListType());
|
|
|
+ initGameList(play_game_list_x_rv, gameEntityListx, gameListTag);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -235,8 +234,9 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
//结束轮播
|
|
|
banner.stopAutoPlay();
|
|
|
}
|
|
|
-
|
|
|
- private void initGameList(final RecyclerView playGameListRv, final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, final GameListType gameListType) {
|
|
|
+ private Comparator<ListTypeList<GameEntity, GameListType>> comparator = (item1, item2) -> item2.getSort() - item1.getSort();
|
|
|
+ private void initGameList(final RecyclerView playGameListRv, final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, PackageTypes packageTypes) {
|
|
|
+ GameListType gameListType = packageTypes.toGameListType();
|
|
|
if (gameListType == null) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -248,7 +248,8 @@ public class FgtPlayGame extends BaseFragment {
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
|
if (!ListUtil.isEmpty(newList)) {
|
|
|
- gameEntityListList.add(new ListTypeList<>(gameListType, newList));
|
|
|
+ gameEntityListList.add(new ListTypeList<>(gameListType, newList).setSort(packageTypes.getSort()));
|
|
|
+ Collections.sort(gameEntityListList, comparator);//排序
|
|
|
ViewUtil.notifyDataSetChanged(playGameListRv);
|
|
|
}
|
|
|
notifyDataSetChanged();
|