|
|
@@ -1,16 +1,14 @@
|
|
|
package com.sheep.gamegroup.module.game.fragment;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
+import android.util.SparseIntArray;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
-import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
-import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
|
|
import com.sheep.gamegroup.absBase.AbsObserver;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.GameEntity;
|
|
|
@@ -28,6 +26,8 @@ import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseFragment;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
@@ -82,7 +82,15 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
//其它tag
|
|
|
SheepApp.getInstance().getNetComponent().getApiService().getGameTagList()
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
- .flatMap((Function<BaseMessage, Observable<GameListTag>>) baseMessage -> Observable.fromIterable(baseMessage.getDataList(GameListTag.class)))
|
|
|
+ .flatMap((Function<BaseMessage, Observable<GameListTag>>) baseMessage -> {
|
|
|
+ ArrayList<GameListTag> gameListTagList = baseMessage.getDataList(GameListTag.class);
|
|
|
+ int i = 0;
|
|
|
+ for (GameListTag item : gameListTagList) {
|
|
|
+ sortSparseIntArray.put(i, item.getId());
|
|
|
+ i ++;
|
|
|
+ }
|
|
|
+ return Observable.fromIterable(gameListTagList);
|
|
|
+ })
|
|
|
.filter(gameListTag -> gameListTag != null)
|
|
|
.subscribe(new AbsObserver<GameListTag>() {
|
|
|
|
|
|
@@ -113,6 +121,8 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
return rootView;
|
|
|
}
|
|
|
|
|
|
+ private SparseIntArray sortSparseIntArray = new SparseIntArray();
|
|
|
+ private Comparator<ListTypeList<GameEntity, GameListType>> comparator = (item1, item2) -> sortSparseIntArray.get(item1.getType().getPort_type()) - sortSparseIntArray.get(item2.getType().getPort_type());
|
|
|
private void initGameList(final RecyclerView playGameListRv, final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, final GameListType gameListType) {
|
|
|
if (gameListType == null) {
|
|
|
return;
|
|
|
@@ -126,6 +136,7 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
|
if (!ListUtil.isEmpty(newList)) {
|
|
|
gameEntityListList.add(new ListTypeList<>(gameListType, newList));
|
|
|
+ Collections.sort(gameEntityListList, comparator);//排序
|
|
|
ViewUtil.notifyDataSetChanged(playGameListRv);
|
|
|
}
|
|
|
notifyDataSetChanged();
|