|
@@ -3,7 +3,6 @@ package com.sheep.gamegroup.module.game.fragment;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
-import android.util.SparseIntArray;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -71,6 +70,9 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshData() {
|
|
private void refreshData() {
|
|
|
|
|
+ if(count != 0){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
initGameTagList();
|
|
initGameTagList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -84,11 +86,7 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
.subscribeOn(Schedulers.io())
|
|
.subscribeOn(Schedulers.io())
|
|
|
.flatMap((Function<BaseMessage, Observable<GameListTag>>) baseMessage -> {
|
|
.flatMap((Function<BaseMessage, Observable<GameListTag>>) baseMessage -> {
|
|
|
ArrayList<GameListTag> gameListTagList = baseMessage.getDataList(GameListTag.class);
|
|
ArrayList<GameListTag> gameListTagList = baseMessage.getDataList(GameListTag.class);
|
|
|
- int i = 0;
|
|
|
|
|
- for (GameListTag item : gameListTagList) {
|
|
|
|
|
- sortSparseIntArray.put(i, item.getId());
|
|
|
|
|
- i ++;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ gameTagListCount = ListUtil.size(gameListTagList);
|
|
|
return Observable.fromIterable(gameListTagList);
|
|
return Observable.fromIterable(gameListTagList);
|
|
|
})
|
|
})
|
|
|
.filter(gameListTag -> gameListTag != null)
|
|
.filter(gameListTag -> gameListTag != null)
|
|
@@ -96,7 +94,7 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onNext(GameListTag gameListTag) {
|
|
public void onNext(GameListTag gameListTag) {
|
|
|
- initGameList(play_game_list_x_rv, gameEntityListx, gameListTag.toGameListType());
|
|
|
|
|
|
|
+ initGameList(gameEntityListx, gameListTag.toGameListType());
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -121,9 +119,10 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
return rootView;
|
|
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) {
|
|
|
|
|
|
|
+ private int gameTagListCount;
|
|
|
|
|
+ private int count;
|
|
|
|
|
+ private Comparator<ListTypeList<GameEntity, GameListType>> comparator = (item1, item2) -> item1.getType().getTag_id() - item2.getType().getTag_id();
|
|
|
|
|
+ private void initGameList(final List<ListTypeList<GameEntity, GameListType>> gameEntityListList, final GameListType gameListType) {
|
|
|
if (gameListType == null) {
|
|
if (gameListType == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -136,8 +135,6 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
List<GameEntity> newList = baseMessage.getDatas(GameEntity.class);
|
|
|
if (!ListUtil.isEmpty(newList)) {
|
|
if (!ListUtil.isEmpty(newList)) {
|
|
|
gameEntityListList.add(new ListTypeList<>(gameListType, newList));
|
|
gameEntityListList.add(new ListTypeList<>(gameListType, newList));
|
|
|
- Collections.sort(gameEntityListList, comparator);//排序
|
|
|
|
|
- ViewUtil.notifyDataSetChanged(playGameListRv);
|
|
|
|
|
}
|
|
}
|
|
|
notifyDataSetChanged();
|
|
notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
@@ -150,8 +147,13 @@ public class FgtGameGroupMore extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void notifyDataSetChanged() {
|
|
private void notifyDataSetChanged() {
|
|
|
- if (refresh != null) {
|
|
|
|
|
- refresh.finishRefresh();
|
|
|
|
|
|
|
+ if(gameTagListCount == ++count) {
|
|
|
|
|
+ Collections.sort(gameEntityListx, comparator);//排序
|
|
|
|
|
+ ViewUtil.notifyDataSetChanged(play_game_list_x_rv);
|
|
|
|
|
+ if (refresh != null) {
|
|
|
|
|
+ refresh.finishRefresh();
|
|
|
|
|
+ }
|
|
|
|
|
+ count = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|