mirror of https://github.com/m2049r/xmrwallet.git
minor fixes for confirmations indicator (#782)
This commit is contained in:
parent
e82b471c14
commit
148faa00e4
|
@ -49,8 +49,6 @@ import java.util.TimeZone;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfoAdapter.ViewHolder> {
|
public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfoAdapter.ViewHolder> {
|
||||||
private final static int MAX_CONFIRMATIONS = 10;
|
|
||||||
|
|
||||||
private final static SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
private final static SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
|
||||||
private final int outboundColour;
|
private final int outboundColour;
|
||||||
|
@ -81,7 +79,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsTransactionUpdateOnNewBlock() {
|
public boolean needsTransactionUpdateOnNewBlock() {
|
||||||
return (infoItems.size() > 0) && (infoItems.get(0).confirmations < MAX_CONFIRMATIONS);
|
return (infoItems.size() > 0) && !infoItems.get(0).isConfirmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TransactionInfoDiff extends DiffCallback<TransactionInfo> {
|
private static class TransactionInfoDiff extends DiffCallback<TransactionInfo> {
|
||||||
|
@ -169,7 +167,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
tvPaymentId = itemView.findViewById(R.id.tx_paymentid);
|
tvPaymentId = itemView.findViewById(R.id.tx_paymentid);
|
||||||
tvDateTime = itemView.findViewById(R.id.tx_datetime);
|
tvDateTime = itemView.findViewById(R.id.tx_datetime);
|
||||||
pbConfirmations = itemView.findViewById(R.id.pbConfirmations);
|
pbConfirmations = itemView.findViewById(R.id.pbConfirmations);
|
||||||
pbConfirmations.setMax(MAX_CONFIRMATIONS);
|
pbConfirmations.setMax(TransactionInfo.CONFIRMATION);
|
||||||
tvConfirmations = itemView.findViewById(R.id.tvConfirmations);
|
tvConfirmations = itemView.findViewById(R.id.tvConfirmations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,9 +226,9 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
tvConfirmations.setVisibility(View.GONE);
|
tvConfirmations.setVisibility(View.GONE);
|
||||||
} else if (infoItem.direction == TransactionInfo.Direction.Direction_In) {
|
} else if (infoItem.direction == TransactionInfo.Direction.Direction_In) {
|
||||||
setTxColour(inboundColour);
|
setTxColour(inboundColour);
|
||||||
final int confirmations = (int) infoItem.confirmations;
|
if (!infoItem.isConfirmed()) {
|
||||||
if (confirmations <= MAX_CONFIRMATIONS) {
|
|
||||||
pbConfirmations.setVisibility(View.VISIBLE);
|
pbConfirmations.setVisibility(View.VISIBLE);
|
||||||
|
final int confirmations = (int) infoItem.confirmations;
|
||||||
pbConfirmations.setProgressCompat(confirmations, true);
|
pbConfirmations.setProgressCompat(confirmations, true);
|
||||||
final String confCount = Integer.toString(confirmations);
|
final String confCount = Integer.toString(confirmations);
|
||||||
tvConfirmations.setText(confCount);
|
tvConfirmations.setText(confCount);
|
||||||
|
|
|
@ -29,6 +29,8 @@ import lombok.RequiredArgsConstructor;
|
||||||
// this is not the TransactionInfo from the API as that is owned by the TransactionHistory
|
// this is not the TransactionInfo from the API as that is owned by the TransactionHistory
|
||||||
// this is a POJO for the TransactionInfoAdapter
|
// this is a POJO for the TransactionInfoAdapter
|
||||||
public class TransactionInfo implements Parcelable, Comparable<TransactionInfo> {
|
public class TransactionInfo implements Parcelable, Comparable<TransactionInfo> {
|
||||||
|
public static final int CONFIRMATION = 10; // blocks
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
Direction_In(0),
|
Direction_In(0),
|
||||||
|
@ -98,6 +100,10 @@ public class TransactionInfo implements Parcelable, Comparable<TransactionInfo>
|
||||||
this.transfers = transfers;
|
this.transfers = transfers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConfirmed() {
|
||||||
|
return confirmations >= CONFIRMATION;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayLabel() {
|
public String getDisplayLabel() {
|
||||||
if (subaddressLabel.isEmpty() || (Subaddress.DEFAULT_LABEL_FORMATTER.matcher(subaddressLabel).matches()))
|
if (subaddressLabel.isEmpty() || (Subaddress.DEFAULT_LABEL_FORMATTER.matcher(subaddressLabel).matches()))
|
||||||
return ("#" + addressIndex);
|
return ("#" + addressIndex);
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvConfirmations"
|
android:id="@+id/tvConfirmations"
|
||||||
style="@style/MoneroText"
|
style="@style/MoneroText.Small"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|
Loading…
Reference in New Issue