From b64f243ced06936633ef53d525bf77a911d839c5 Mon Sep 17 00:00:00 2001 From: healergyl <175641710@qq.com> Date: Tue, 18 Jul 2023 20:03:54 +0800 Subject: [PATCH] Add a new cloud node address under the testnet and optimize some functions. --- .../ui/activity/BalanceDetailActivity.java | 31 ++++++++++++++++--- .../wallet/view/TransactionsChainView.java | 4 +-- .../TransactionsDetailsChainPopupWindow.java | 4 +-- config.gradle | 4 +-- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/omni/wallet/ui/activity/BalanceDetailActivity.java b/app/src/main/java/com/omni/wallet/ui/activity/BalanceDetailActivity.java index 0a6ed24..490670a 100644 --- a/app/src/main/java/com/omni/wallet/ui/activity/BalanceDetailActivity.java +++ b/app/src/main/java/com/omni/wallet/ui/activity/BalanceDetailActivity.java @@ -108,6 +108,7 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -873,11 +874,21 @@ public void run() { LightningOuterClass.TransactionDetails resp = LightningOuterClass.TransactionDetails.parseFrom(bytes); LogUtils.e(TAG, "------------------getPendingTxsChainOnResponse-----------------" + resp); for (LightningOuterClass.Transaction transaction : resp.getTransactionsList()) { - if (StringUtils.isEmpty(String.valueOf(transaction.getNumConfirmations())) || transaction.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(transaction.getNumConfirmations())) || transaction.getNumConfirmations() < 1) { mPendingTxsChainData.add(transaction); } } - mToBePaidNumTv.setText(mPendingTxsChainData.size() + ""); + Collections.sort(mPendingTxsChainData, new Comparator() { + @Override + public int compare(LightningOuterClass.Transaction o1, LightningOuterClass.Transaction o2) { + return (int) (o2.getTimeStamp() - o1.getTimeStamp()); + } + }); + try { + mToBePaidNumTv.setText(mPendingTxsChainData.size() + ""); + } catch (Exception e) { + LogUtils.e(TAG, "Error: " + e.getMessage()); + } mPendingTxsChainAdapter.notifyDataSetChanged(); } catch (InvalidProtocolBufferException e) { e.printStackTrace(); @@ -965,7 +976,17 @@ public void run() { } mPendingTxsAssetData.add(resp); } - mToBePaidNumTv.setText(mPendingTxsAssetData.size() + ""); + Collections.sort(mPendingTxsAssetData, new Comparator() { + @Override + public int compare(LightningOuterClass.AssetTx o1, LightningOuterClass.AssetTx o2) { + return (int) (o2.getBlocktime() - o1.getBlocktime()); + } + }); + try { + mToBePaidNumTv.setText(mPendingTxsAssetData.size() + ""); + } catch (Exception e) { + LogUtils.e(TAG, "Error: " + e.getMessage()); + } mPendingTxsAssetAdapter.notifyDataSetChanged(); } catch (InvalidProtocolBufferException e) { e.printStackTrace(); @@ -1327,7 +1348,7 @@ public void convert(ViewHolder holder, final int position, final LightningOuterC DecimalFormat df = new DecimalFormat("0.00######"); if (item.getAmount() <= 0) { holder.setText(R.id.tv_amount, df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000).replace("-", "")); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { holder.setText(R.id.tv_receiver, "PENDING"); holder.setImageResource(R.id.iv_state, R.mipmap.icon_alarm_clock_blue); } else { @@ -1336,7 +1357,7 @@ public void convert(ViewHolder holder, final int position, final LightningOuterC } } else if (item.getAmount() > 0) { holder.setText(R.id.tv_amount, df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000)); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { holder.setText(R.id.tv_receiver, "PENDING"); holder.setImageResource(R.id.iv_state, R.mipmap.icon_alarm_clock_blue); } else { diff --git a/app/src/main/java/com/omni/wallet/view/TransactionsChainView.java b/app/src/main/java/com/omni/wallet/view/TransactionsChainView.java index d4e5287..f775e18 100644 --- a/app/src/main/java/com/omni/wallet/view/TransactionsChainView.java +++ b/app/src/main/java/com/omni/wallet/view/TransactionsChainView.java @@ -101,7 +101,7 @@ public void convert(ViewHolder holder, int position, LightningOuterClass.Transac DecimalFormat df = new DecimalFormat("0.00######"); if (item.getAmount() <= 0) { holder.setText(R.id.tv_amount, "- " + df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000).replace("-", "")); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { holder.setText(R.id.tv_state, "Unnamed"); holder.setImageResource(R.id.iv_state, R.mipmap.icon_alarm_clock_blue); } else { @@ -110,7 +110,7 @@ public void convert(ViewHolder holder, int position, LightningOuterClass.Transac } } else if (item.getAmount() > 0) { holder.setText(R.id.tv_amount, "+ " + df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000)); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { holder.setText(R.id.tv_state, "Unnamed"); holder.setImageResource(R.id.iv_state, R.mipmap.icon_alarm_clock_blue); } else { diff --git a/app/src/main/java/com/omni/wallet/view/popupwindow/TransactionsDetailsChainPopupWindow.java b/app/src/main/java/com/omni/wallet/view/popupwindow/TransactionsDetailsChainPopupWindow.java index 6e3f694..cb37044 100644 --- a/app/src/main/java/com/omni/wallet/view/popupwindow/TransactionsDetailsChainPopupWindow.java +++ b/app/src/main/java/com/omni/wallet/view/popupwindow/TransactionsDetailsChainPopupWindow.java @@ -70,7 +70,7 @@ public void show(final View view, LightningOuterClass.Transaction item, long ass amountTv.setText(df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000).replace("-", "")); String totalValue = (long) (Double.parseDouble(String.valueOf(item.getAmount()).replace("-", ""))) + item.getTotalFees() + ""; totalAmountTv.setText(df1.format(Double.parseDouble(totalValue) / 100000000 * Double.parseDouble(User.getInstance().getBtcPrice(mContext)))); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { typeTv.setText("PENDING"); typeIv.setImageResource(R.mipmap.icon_failed_red); statusTv.setText("Pending"); @@ -93,7 +93,7 @@ public void show(final View view, LightningOuterClass.Transaction item, long ass amountTv.setText(df.format(Double.parseDouble(String.valueOf(item.getAmount())) / 100000000)); String totalValue = (long) (Double.parseDouble(String.valueOf(item.getAmount()))) + item.getTotalFees() + ""; totalAmountTv.setText(df1.format(Double.parseDouble(totalValue) / 100000000 * Double.parseDouble(User.getInstance().getBtcPrice(mContext)))); - if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 3) { + if (StringUtils.isEmpty(String.valueOf(item.getNumConfirmations())) || item.getNumConfirmations() < 1) { typeTv.setText("PENDING"); typeIv.setImageResource(R.mipmap.icon_failed_red); statusTv.setText("Pending"); diff --git a/config.gradle b/config.gradle index 292cbfd..1abe02a 100644 --- a/config.gradle +++ b/config.gradle @@ -6,8 +6,8 @@ ext { targetSdkVersion: 28, compileVersion : 28, buildToolVersion: "28.0.3", - versionCode : 5, - versionName : "0.1.4" + versionCode : 6, + versionName : "0.1.5" ] // 依赖相关版本控制 depVersion = [