From 9b63a14ecfc92da341ded4de9490e2c33cf09e16 Mon Sep 17 00:00:00 2001 From: healergyl <175641710@qq.com> Date: Fri, 16 Jun 2023 22:37:33 +0800 Subject: [PATCH] Fix the problem that the asset list display is garbled. --- .../entity/ListAssetItemEntity.java | 7 ++++- .../ui/activity/AccountLightningActivity.java | 31 ++++++++++++++----- .../popupwindow/SelectAssetPopupWindow.java | 18 +++++++---- .../SelectAssetTypePopupWindow.java | 18 +++++++---- .../SelectAssetUnitPopupWindow.java | 18 +++++++---- .../SelectChannelBalancePopupWindow.java | 20 ++++++++---- config.gradle | 4 +-- 7 files changed, 81 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/omni/wallet_mainnet/entity/ListAssetItemEntity.java b/app/src/main/java/com/omni/wallet_mainnet/entity/ListAssetItemEntity.java index 08bf0123..d825930d 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/entity/ListAssetItemEntity.java +++ b/app/src/main/java/com/omni/wallet_mainnet/entity/ListAssetItemEntity.java @@ -8,7 +8,7 @@ * author: guoyalei * date: 2022/11/2 */ -public class ListAssetItemEntity extends BaseListEntity { +public class ListAssetItemEntity extends BaseListEntity implements Comparable { private long amount; private long propertyid; private int type; @@ -36,4 +36,9 @@ public int getType() { public void setType(int type) { this.type = type; } + + @Override + public int compareTo(ListAssetItemEntity o) { + return (int) (o.getPropertyid() - this.getPropertyid()); + } } diff --git a/app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java b/app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java index 38392237..d1364cdc 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java +++ b/app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java @@ -519,20 +519,26 @@ public void onResponse(byte[] bytes) { LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes); LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString()); if (ConstantInOB.networkType == NetworkType.TEST) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147485160"))) { setDefaultData(); } } } else if (ConstantInOB.networkType == NetworkType.REG) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147483651"))) { setDefaultData(); } } } else { //mainnet - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("31"))) { setDefaultData(); } } @@ -546,7 +552,7 @@ public void onResponse(byte[] bytes) { blockData.add(entity); getChannelBalance(resp.getListList().get(i).getPropertyid()); } - allData.addAll(blockData); +// allData.addAll(blockData); runOnUiThread(() -> mAdapter.notifyDataSetChanged()); } catch (InvalidProtocolBufferException e) { e.printStackTrace(); @@ -627,7 +633,16 @@ public void run() { entity.setPropertyid(propertyid); entity.setType(2); lightningData.add(entity); - allData.addAll(lightningData); + for (int i = 0; i < blockData.size(); i++) { + for (int j = 0; j < lightningData.size(); j++) { + if (blockData.get(i).getPropertyid() == lightningData.get(j).getPropertyid()) { + allData.add(blockData.get(i)); + allData.add(lightningData.get(j)); + } + } + } + Collections.sort(allData.subList(2, allData.size())); +// allData.addAll(lightningData); runOnUiThread(() -> mAdapter.notifyDataSetChanged()); if (mRefreshLayout != null) { mRefreshLayout.stopRefresh(); diff --git a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetPopupWindow.java b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetPopupWindow.java index 8be77672..0dc41661 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetPopupWindow.java +++ b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetPopupWindow.java @@ -147,20 +147,26 @@ public void onResponse(byte[] bytes) { LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes); LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString()); if (ConstantInOB.networkType == NetworkType.TEST) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147485160"))) { setDefaultData(); } } } else if (ConstantInOB.networkType == NetworkType.REG) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147483651"))) { setDefaultData(); } } } else { //mainnet - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("31"))) { setDefaultData(); } } diff --git a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetTypePopupWindow.java b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetTypePopupWindow.java index a1323774..23855bec 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetTypePopupWindow.java +++ b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetTypePopupWindow.java @@ -146,20 +146,26 @@ public void onResponse(byte[] bytes) { LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes); LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString()); if (ConstantInOB.networkType == NetworkType.TEST) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147485160"))) { setDefaultData(); } } } else if (ConstantInOB.networkType == NetworkType.REG) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147483651"))) { setDefaultData(); } } } else { //mainnet - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("31"))) { setDefaultData(); } } diff --git a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetUnitPopupWindow.java b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetUnitPopupWindow.java index 4bdbb917..c001faed 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetUnitPopupWindow.java +++ b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetUnitPopupWindow.java @@ -145,20 +145,26 @@ public void onResponse(byte[] bytes) { LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes); LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString()); if (ConstantInOB.networkType == NetworkType.TEST) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147485160"))) { setDefaultData(); } } } else if (ConstantInOB.networkType == NetworkType.REG) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147483651"))) { setDefaultData(); } } } else { //mainnet - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("31"))) { setDefaultData(); } } diff --git a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectChannelBalancePopupWindow.java b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectChannelBalancePopupWindow.java index 52279a31..6c9dcb52 100644 --- a/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectChannelBalancePopupWindow.java +++ b/app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectChannelBalancePopupWindow.java @@ -26,6 +26,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import lnrpc.LightningOuterClass; @@ -155,20 +156,26 @@ public void onResponse(byte[] bytes) { LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes); LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString()); if (ConstantInOB.networkType == NetworkType.TEST) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147485160"))) { setDefaultData(); } } } else if (ConstantInOB.networkType == NetworkType.REG) { - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("2147483651"))) { setDefaultData(); } } } else { //mainnet - for (int i = 0; i < resp.getListList().size(); i++) { - if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) { + List list = new ArrayList(); + for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) { + list.add(response.getPropertyid()); + if (!list.contains(Long.parseLong("31"))) { setDefaultData(); } } @@ -222,6 +229,7 @@ public void run() { entity.setType(2); lightningData.add(entity); allData.addAll(lightningData); + Collections.sort(allData.subList(1, allData.size())); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { diff --git a/config.gradle b/config.gradle index bde152e2..bc2b0f64 100644 --- a/config.gradle +++ b/config.gradle @@ -6,8 +6,8 @@ ext { targetSdkVersion: 28, compileVersion : 28, buildToolVersion: "28.0.3", - versionCode : 2, - versionName : "0.1.1" + versionCode : 3, + versionName : "0.1.2" ] // 依赖相关版本控制 depVersion = [