Skip to content

Commit 9b63a14

Browse files
committed
Fix the problem that the asset list display is garbled.
1 parent a7d39aa commit 9b63a14

File tree

7 files changed

+81
-35
lines changed

7 files changed

+81
-35
lines changed

app/src/main/java/com/omni/wallet_mainnet/entity/ListAssetItemEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* author: guoyalei
99
* date: 2022/11/2
1010
*/
11-
public class ListAssetItemEntity extends BaseListEntity {
11+
public class ListAssetItemEntity extends BaseListEntity implements Comparable<ListAssetItemEntity> {
1212
private long amount;
1313
private long propertyid;
1414
private int type;
@@ -36,4 +36,9 @@ public int getType() {
3636
public void setType(int type) {
3737
this.type = type;
3838
}
39+
40+
@Override
41+
public int compareTo(ListAssetItemEntity o) {
42+
return (int) (o.getPropertyid() - this.getPropertyid());
43+
}
3944
}

app/src/main/java/com/omni/wallet_mainnet/ui/activity/AccountLightningActivity.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,20 +519,26 @@ public void onResponse(byte[] bytes) {
519519
LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes);
520520
LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString());
521521
if (ConstantInOB.networkType == NetworkType.TEST) {
522-
for (int i = 0; i < resp.getListList().size(); i++) {
523-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) {
522+
List list = new ArrayList();
523+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
524+
list.add(response.getPropertyid());
525+
if (!list.contains(Long.parseLong("2147485160"))) {
524526
setDefaultData();
525527
}
526528
}
527529
} else if (ConstantInOB.networkType == NetworkType.REG) {
528-
for (int i = 0; i < resp.getListList().size(); i++) {
529-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) {
530+
List list = new ArrayList();
531+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
532+
list.add(response.getPropertyid());
533+
if (!list.contains(Long.parseLong("2147483651"))) {
530534
setDefaultData();
531535
}
532536
}
533537
} else { //mainnet
534-
for (int i = 0; i < resp.getListList().size(); i++) {
535-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) {
538+
List list = new ArrayList();
539+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
540+
list.add(response.getPropertyid());
541+
if (!list.contains(Long.parseLong("31"))) {
536542
setDefaultData();
537543
}
538544
}
@@ -546,7 +552,7 @@ public void onResponse(byte[] bytes) {
546552
blockData.add(entity);
547553
getChannelBalance(resp.getListList().get(i).getPropertyid());
548554
}
549-
allData.addAll(blockData);
555+
// allData.addAll(blockData);
550556
runOnUiThread(() -> mAdapter.notifyDataSetChanged());
551557
} catch (InvalidProtocolBufferException e) {
552558
e.printStackTrace();
@@ -627,7 +633,16 @@ public void run() {
627633
entity.setPropertyid(propertyid);
628634
entity.setType(2);
629635
lightningData.add(entity);
630-
allData.addAll(lightningData);
636+
for (int i = 0; i < blockData.size(); i++) {
637+
for (int j = 0; j < lightningData.size(); j++) {
638+
if (blockData.get(i).getPropertyid() == lightningData.get(j).getPropertyid()) {
639+
allData.add(blockData.get(i));
640+
allData.add(lightningData.get(j));
641+
}
642+
}
643+
}
644+
Collections.sort(allData.subList(2, allData.size()));
645+
// allData.addAll(lightningData);
631646
runOnUiThread(() -> mAdapter.notifyDataSetChanged());
632647
if (mRefreshLayout != null) {
633648
mRefreshLayout.stopRefresh();

app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetPopupWindow.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,26 @@ public void onResponse(byte[] bytes) {
147147
LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes);
148148
LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString());
149149
if (ConstantInOB.networkType == NetworkType.TEST) {
150-
for (int i = 0; i < resp.getListList().size(); i++) {
151-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) {
150+
List list = new ArrayList();
151+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
152+
list.add(response.getPropertyid());
153+
if (!list.contains(Long.parseLong("2147485160"))) {
152154
setDefaultData();
153155
}
154156
}
155157
} else if (ConstantInOB.networkType == NetworkType.REG) {
156-
for (int i = 0; i < resp.getListList().size(); i++) {
157-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) {
158+
List list = new ArrayList();
159+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
160+
list.add(response.getPropertyid());
161+
if (!list.contains(Long.parseLong("2147483651"))) {
158162
setDefaultData();
159163
}
160164
}
161165
} else { //mainnet
162-
for (int i = 0; i < resp.getListList().size(); i++) {
163-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) {
166+
List list = new ArrayList();
167+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
168+
list.add(response.getPropertyid());
169+
if (!list.contains(Long.parseLong("31"))) {
164170
setDefaultData();
165171
}
166172
}

app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetTypePopupWindow.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,26 @@ public void onResponse(byte[] bytes) {
146146
LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes);
147147
LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString());
148148
if (ConstantInOB.networkType == NetworkType.TEST) {
149-
for (int i = 0; i < resp.getListList().size(); i++) {
150-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) {
149+
List list = new ArrayList();
150+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
151+
list.add(response.getPropertyid());
152+
if (!list.contains(Long.parseLong("2147485160"))) {
151153
setDefaultData();
152154
}
153155
}
154156
} else if (ConstantInOB.networkType == NetworkType.REG) {
155-
for (int i = 0; i < resp.getListList().size(); i++) {
156-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) {
157+
List list = new ArrayList();
158+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
159+
list.add(response.getPropertyid());
160+
if (!list.contains(Long.parseLong("2147483651"))) {
157161
setDefaultData();
158162
}
159163
}
160164
} else { //mainnet
161-
for (int i = 0; i < resp.getListList().size(); i++) {
162-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) {
165+
List list = new ArrayList();
166+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
167+
list.add(response.getPropertyid());
168+
if (!list.contains(Long.parseLong("31"))) {
163169
setDefaultData();
164170
}
165171
}

app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectAssetUnitPopupWindow.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,26 @@ public void onResponse(byte[] bytes) {
145145
LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes);
146146
LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString());
147147
if (ConstantInOB.networkType == NetworkType.TEST) {
148-
for (int i = 0; i < resp.getListList().size(); i++) {
149-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) {
148+
List list = new ArrayList();
149+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
150+
list.add(response.getPropertyid());
151+
if (!list.contains(Long.parseLong("2147485160"))) {
150152
setDefaultData();
151153
}
152154
}
153155
} else if (ConstantInOB.networkType == NetworkType.REG) {
154-
for (int i = 0; i < resp.getListList().size(); i++) {
155-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) {
156+
List list = new ArrayList();
157+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
158+
list.add(response.getPropertyid());
159+
if (!list.contains(Long.parseLong("2147483651"))) {
156160
setDefaultData();
157161
}
158162
}
159163
} else { //mainnet
160-
for (int i = 0; i < resp.getListList().size(); i++) {
161-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) {
164+
List list = new ArrayList();
165+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
166+
list.add(response.getPropertyid());
167+
if (!list.contains(Long.parseLong("31"))) {
162168
setDefaultData();
163169
}
164170
}

app/src/main/java/com/omni/wallet_mainnet/view/popupwindow/SelectChannelBalancePopupWindow.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import java.text.DecimalFormat;
2828
import java.util.ArrayList;
29+
import java.util.Collections;
2930
import java.util.List;
3031

3132
import lnrpc.LightningOuterClass;
@@ -155,20 +156,26 @@ public void onResponse(byte[] bytes) {
155156
LightningOuterClass.AssetsBalanceByAddressResponse resp = LightningOuterClass.AssetsBalanceByAddressResponse.parseFrom(bytes);
156157
LogUtils.e(TAG, "------------------assetsBalanceOnResponse------------------" + resp.getListList().toString());
157158
if (ConstantInOB.networkType == NetworkType.TEST) {
158-
for (int i = 0; i < resp.getListList().size(); i++) {
159-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147485160")) {
159+
List list = new ArrayList();
160+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
161+
list.add(response.getPropertyid());
162+
if (!list.contains(Long.parseLong("2147485160"))) {
160163
setDefaultData();
161164
}
162165
}
163166
} else if (ConstantInOB.networkType == NetworkType.REG) {
164-
for (int i = 0; i < resp.getListList().size(); i++) {
165-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("2147483651")) {
167+
List list = new ArrayList();
168+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
169+
list.add(response.getPropertyid());
170+
if (!list.contains(Long.parseLong("2147483651"))) {
166171
setDefaultData();
167172
}
168173
}
169174
} else { //mainnet
170-
for (int i = 0; i < resp.getListList().size(); i++) {
171-
if (resp.getListList().get(i).getPropertyid() != Long.parseLong("31")) {
175+
List list = new ArrayList();
176+
for (lnrpc.LightningOuterClass.AssetBalanceByAddressResponse response : resp.getListList()) {
177+
list.add(response.getPropertyid());
178+
if (!list.contains(Long.parseLong("31"))) {
172179
setDefaultData();
173180
}
174181
}
@@ -222,6 +229,7 @@ public void run() {
222229
entity.setType(2);
223230
lightningData.add(entity);
224231
allData.addAll(lightningData);
232+
Collections.sort(allData.subList(1, allData.size()));
225233
new Handler(Looper.getMainLooper()).post(new Runnable() {
226234
@Override
227235
public void run() {

config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ext {
66
targetSdkVersion: 28,
77
compileVersion : 28,
88
buildToolVersion: "28.0.3",
9-
versionCode : 2,
10-
versionName : "0.1.1"
9+
versionCode : 3,
10+
versionName : "0.1.2"
1111
]
1212
// 依赖相关版本控制
1313
depVersion = [

0 commit comments

Comments
 (0)