Skip to content

Commit

Permalink
Fix the problem that the asset list display is garbled.
Browse files Browse the repository at this point in the history
  • Loading branch information
healergyl committed Jun 16, 2023
1 parent a7d39aa commit 9b63a14
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* author: guoyalei
* date: 2022/11/2
*/
public class ListAssetItemEntity extends BaseListEntity {
public class ListAssetItemEntity extends BaseListEntity implements Comparable<ListAssetItemEntity> {
private long amount;
private long propertyid;
private int type;
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import lnrpc.LightningOuterClass;
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 9b63a14

Please sign in to comment.