From 39818064f6874058d5423e80a63ad556294399ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E7=9A=AE?= <14840170+lao-pi123@user.noreply.gitee.com> Date: Mon, 28 Oct 2024 15:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=80=9A=E8=A1=8C=E8=AF=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B0=E7=9A=84=E7=AD=89=E7=BA=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=9B=A0=E4=B8=BA=E4=B8=8D=E7=9F=A5=E5=90=8D=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E9=A1=BA=E5=BA=8F=E9=94=99=E4=B9=B1=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8E=92=E5=BA=8F=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/fragment/BattlePassRewardFragment.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java index 11ee058cc..3ca10a16e 100644 --- a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java @@ -4,12 +4,15 @@ import static com.yunbao.common.utils.RouteUtil.PATH_COIN; import android.app.Activity; import android.app.Dialog; +import android.os.Build; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import androidx.annotation.RequiresApi; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -37,8 +40,12 @@ import com.yunbao.main.interfaces.BattlePassUserInfoListener; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.TreeMap; +import java.util.stream.Collectors; public class BattlePassRewardFragment extends BaseFragment { ImageView tab1; @@ -175,6 +182,7 @@ public class BattlePassRewardFragment extends BaseFragment { LiveNetManager.get(getContext()) .getLiveBattlePassRewards(new HttpCallback() { + @RequiresApi(api = Build.VERSION_CODES.N) @Override public void onSuccess(LiveBattlePassRewardsBean data) { @@ -195,8 +203,14 @@ public class BattlePassRewardFragment extends BaseFragment { }else{ Bus.get().post(new BattlePassTypeEvent(2).setBean(data)); } - Collection> values = data.getLive_battle_pass_rewards().values(); + + // data.getLive_battle_pass_rewards()返回的Map排序,不能转为集合 + Map> liveBattlePassRewards = data.getLive_battle_pass_rewards(); + // 使用TreeMap来自动按键排序 + Map> sortedMap = new TreeMap<>(liveBattlePassRewards); + Collection> values = sortedMap.values(); List> list = new ArrayList<>(values); + /* list.get(1).get(1).setReceived(2); list.get(0).get(2).setLock(2); list.get(1).get(2).setLock(2);