Select transaction arroy and left view color according to the direction of the payment (received or sent)
This commit is contained in:
parent
a0075117d1
commit
1456b58e7a
4 changed files with 66 additions and 69 deletions
|
@ -32,9 +32,9 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended;
|
||||||
|
|
||||||
public class TransactionListAdapter extends PagedListAdapter<CryptoCoinTransactionExtended, TransactionViewHolder> {
|
public class TransactionListAdapter extends PagedListAdapter<CryptoCoinTransactionExtended, TransactionViewHolder> {
|
||||||
|
|
||||||
Fragment fragment;
|
private Fragment fragment;
|
||||||
|
|
||||||
public TransactionListAdapter(Fragment fragment) {
|
TransactionListAdapter(Fragment fragment) {
|
||||||
super(CryptoCoinTransactionExtended.DIFF_CALLBACK);
|
super(CryptoCoinTransactionExtended.DIFF_CALLBACK);
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -30,34 +31,29 @@ import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/*
|
|
||||||
* The view holding the transaction "from"
|
private View vPaymentDirection;
|
||||||
*/
|
|
||||||
private TextView tvFrom;
|
private TextView tvFrom;
|
||||||
/*
|
private ImageView ivDirectionArrow;
|
||||||
* The view holding the transaction "to"
|
|
||||||
*/
|
|
||||||
private TextView tvTo;
|
private TextView tvTo;
|
||||||
/*
|
|
||||||
* The view holding the transaction amount
|
|
||||||
*/
|
|
||||||
private TextView tvCryptoAmount;
|
private TextView tvCryptoAmount;
|
||||||
private TextView tvFiatEquivalent;
|
private TextView tvFiatEquivalent;
|
||||||
private TextView tvDate;
|
private TextView tvDate;
|
||||||
private TextView tvTime;
|
private TextView tvTime;
|
||||||
private View rootView;
|
|
||||||
|
|
||||||
private Fragment fragment;
|
private Fragment fragment;
|
||||||
|
|
||||||
private long cryptoCoinTransactionId;
|
private long cryptoCoinTransactionId;
|
||||||
|
|
||||||
public TransactionViewHolder(View itemView, Fragment fragment) {
|
TransactionViewHolder(View itemView, Fragment fragment) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
//TODO: use ButterKnife to load this
|
//TODO: use ButterKnife to load this
|
||||||
this.cryptoCoinTransactionId = -1;
|
this.cryptoCoinTransactionId = -1;
|
||||||
|
|
||||||
rootView = itemView.findViewById(R.id.rootView);
|
View rootView = itemView.findViewById(R.id.rootView);
|
||||||
|
vPaymentDirection = itemView.findViewById(R.id.vPaymentDirection);
|
||||||
tvFrom = itemView.findViewById(R.id.tvFrom);
|
tvFrom = itemView.findViewById(R.id.tvFrom);
|
||||||
|
ivDirectionArrow = itemView.findViewById(R.id.ivDirectionArrow);
|
||||||
tvTo = itemView.findViewById(R.id.tvTo);
|
tvTo = itemView.findViewById(R.id.tvTo);
|
||||||
tvDate = itemView.findViewById(R.id.tvDate);
|
tvDate = itemView.findViewById(R.id.tvDate);
|
||||||
tvTime = itemView.findViewById(R.id.tvTime);
|
tvTime = itemView.findViewById(R.id.tvTime);
|
||||||
|
@ -68,7 +64,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
rootView.setOnClickListener(new View.OnClickListener() {
|
rootView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ereceiptOfThisTransaction();
|
eReceiptOfThisTransaction();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -76,7 +72,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/*
|
/*
|
||||||
* dispatch the user to the receipt activity using this transaction
|
* dispatch the user to the receipt activity using this transaction
|
||||||
*/
|
*/
|
||||||
public void ereceiptOfThisTransaction(){
|
private void eReceiptOfThisTransaction(){
|
||||||
//if the transaction was loaded
|
//if the transaction was loaded
|
||||||
if (this.cryptoCoinTransactionId >= 0) {
|
if (this.cryptoCoinTransactionId >= 0) {
|
||||||
Context context = fragment.getContext();
|
Context context = fragment.getContext();
|
||||||
|
@ -134,6 +130,14 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss");
|
DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss");
|
||||||
hourFormat.setTimeZone(userTimeZone);
|
hourFormat.setTimeZone(userTimeZone);
|
||||||
|
|
||||||
|
if(transaction.getInput()) {
|
||||||
|
vPaymentDirection.setBackgroundColor(fragment.getContext().getResources().getColor(R.color.receiveAmount));
|
||||||
|
ivDirectionArrow.setImageDrawable(fragment.getContext().getDrawable(R.drawable.ic_arrow_forward_receive));
|
||||||
|
} else {
|
||||||
|
vPaymentDirection.setBackgroundColor(fragment.getContext().getResources().getColor(R.color.sendAmount));
|
||||||
|
ivDirectionArrow.setImageDrawable(fragment.getContext().getDrawable(R.drawable.ic_arrow_forward_send));
|
||||||
|
}
|
||||||
|
|
||||||
tvDate.setText(dateFormat.format(transaction.getDate()));
|
tvDate.setText(dateFormat.format(transaction.getDate()));
|
||||||
tvTime.setText(hourFormat.format(transaction.getDate()));
|
tvTime.setText(hourFormat.format(transaction.getDate()));
|
||||||
|
|
||||||
|
@ -145,6 +149,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
//cryptoNetAccountLiveData.observe(this.fragment, new Observer<CryptoNetAccount>() {
|
//cryptoNetAccountLiveData.observe(this.fragment, new Observer<CryptoNetAccount>() {
|
||||||
// @Override
|
// @Override
|
||||||
// public void onChanged(@Nullable CryptoNetAccount cryptoNetAccount) {
|
// public void onChanged(@Nullable CryptoNetAccount cryptoNetAccount) {
|
||||||
|
// TODO is this useful??
|
||||||
if (transaction.getInput()){
|
if (transaction.getInput()){
|
||||||
tvTo.setText(transaction.getUserAccountName());
|
tvTo.setText(transaction.getUserAccountName());
|
||||||
|
|
||||||
|
@ -165,26 +170,9 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
// }
|
// }
|
||||||
//});
|
//});
|
||||||
|
|
||||||
String finalAmountText = "";
|
String finalAmountText = transaction.getInput() ? "+ " : "";
|
||||||
if (transaction.getInput()) {
|
finalAmountText += amountString + " " + cryptoCurrency.getName();
|
||||||
tvCryptoAmount.setTextColor(itemView.getContext().getResources().getColor(R.color.green));
|
|
||||||
finalAmountText = "+ "+amountString
|
|
||||||
+ " "
|
|
||||||
+ cryptoCurrency.getName();
|
|
||||||
} else {
|
|
||||||
tvCryptoAmount.setTextColor(itemView.getContext().getResources().getColor(R.color.red));
|
|
||||||
finalAmountText = amountString
|
|
||||||
+ " "
|
|
||||||
+ cryptoCurrency.getName();
|
|
||||||
}
|
|
||||||
tvCryptoAmount.setText(finalAmountText);
|
tvCryptoAmount.setText(finalAmountText);
|
||||||
//This will load the transaction receipt when the user clicks this view
|
|
||||||
/*itemView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
listener.onUserClick(user);
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
app/src/main/res/drawable/ic_arrow_forward_send.xml
Normal file
10
app/src/main/res/drawable/ic_arrow_forward_send.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/sendAmount"
|
||||||
|
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
|
||||||
|
</vector>
|
|
@ -1,47 +1,46 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/rlTransactionToolsHeader"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/rlTransactionToolsHeader"
|
<EditText
|
||||||
|
android:id="@+id/etTransactionSearch"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etTransactionSearch"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_toLeftOf="@+id/btnTransactionsFilterDisplay" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btnTransactionsFilterDisplay"
|
|
||||||
android:layout_width="40dip"
|
|
||||||
android:layout_height="40dip"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_toStartOf="@+id/spTransactionsOrder"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/spTransactionsOrder"
|
|
||||||
android:layout_width="40dip"
|
|
||||||
android:layout_height="40dip"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:background="@drawable/sort_transactions_icon"
|
|
||||||
android:text="order" />
|
|
||||||
</RelativeLayout>
|
|
||||||
<android.support.v7.widget.RecyclerView
|
|
||||||
android:id="@+id/transactionListView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/rlTransactionToolsHeader"
|
android:layout_alignParentStart="true"
|
||||||
/>
|
android:layout_toStartOf="@+id/btnTransactionsFilterDisplay" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnTransactionsFilterDisplay"
|
||||||
|
android:layout_width="40dip"
|
||||||
|
android:layout_height="40dip"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_toStartOf="@+id/spTransactionsOrder"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spTransactionsOrder"
|
||||||
|
android:layout_width="40dip"
|
||||||
|
android:layout_height="40dip"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:background="@drawable/sort_transactions_icon"
|
||||||
|
android:text="order" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/transactionListView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
tools:listitem="@layout/transaction_list_item"
|
||||||
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in a new issue