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 08bf012..d825930 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 3839223..d1364cd 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 8be7767..0dc4166 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 a132377..23855be 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 4bdbb91..c001fae 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 52279a3..6c9dcb5 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 bde152e..bc2b0f6 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 = [