- First version of Transaction History views
This commit is contained in:
parent
81da660a2e
commit
93a60e6084
6 changed files with 79 additions and 11 deletions
|
@ -4,11 +4,22 @@ import android.arch.lifecycle.LifecycleActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
||||||
|
import cy.agorise.crystalwallet.views.TransactionListView;
|
||||||
|
|
||||||
public class IntroActivity extends LifecycleActivity {
|
public class IntroActivity extends LifecycleActivity {
|
||||||
|
|
||||||
|
TransactionListViewModel transactionListViewModel;
|
||||||
|
TransactionListView transactionListView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_intro);
|
setContentView(R.layout.activity_intro);
|
||||||
|
|
||||||
|
transactionListViewModel = new TransactionListViewModel(getApplicationContext());
|
||||||
|
transactionListView = this.findViewById(R.id.transaction_list);
|
||||||
|
|
||||||
|
transactionListView.init(transactionListViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,35 @@ public class CryptoCoinTransaction {
|
||||||
@ColumnInfo(name="is_confirmed")
|
@ColumnInfo(name="is_confirmed")
|
||||||
protected boolean isConfirmed;
|
protected boolean isConfirmed;
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColumnInfo(name="from")
|
||||||
|
protected String from;
|
||||||
|
@ColumnInfo(name="to")
|
||||||
|
protected String to;
|
||||||
|
|
||||||
|
public String getFrom() {
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrom(String from) {
|
||||||
|
this.from = from;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTo() {
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTo(String to) {
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
|
||||||
public int getAccountId() {
|
public int getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
package cy.agorise.crystalwallet.views;
|
package cy.agorise.crystalwallet.views;
|
||||||
|
|
||||||
|
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,9 +23,29 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
|
||||||
public class TransactionListAdapter extends ArrayAdapter<CryptoCoinTransaction> {
|
public class TransactionListAdapter extends ArrayAdapter<CryptoCoinTransaction> {
|
||||||
|
|
||||||
|
//List<CryptoCoinTransaction> items;
|
||||||
|
|
||||||
|
public TransactionListAdapter(Context context, LiveData<List<CryptoCoinTransaction>> items) {
|
||||||
|
super(context, 0, items.getValue());
|
||||||
|
|
||||||
public TransactionListAdapter(Context context, int resource, List<CryptoCoinTransaction> items) {
|
}
|
||||||
super(context, resource, items);
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
CryptoCoinTransaction transaction = getItem(position);
|
||||||
|
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = LayoutInflater.from(getContext()).inflate(R.layout.transaction_list_item, parent, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView tvFrom = (TextView) convertView.findViewById(R.id.fromText);
|
||||||
|
TextView tvTo = (TextView) convertView.findViewById(R.id.toText);
|
||||||
|
TextView tvAmount = (TextView) convertView.findViewById(R.id.amountText);
|
||||||
|
|
||||||
|
tvFrom.setText(transaction.getFrom());
|
||||||
|
tvTo.setText(transaction.getTo());
|
||||||
|
tvAmount.setText(transaction.getAmount());
|
||||||
|
|
||||||
|
return convertView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,17 @@ public class TransactionListView extends RelativeLayout {
|
||||||
ListView listView;
|
ListView listView;
|
||||||
ListAdapter listAdapter;
|
ListAdapter listAdapter;
|
||||||
|
|
||||||
|
|
||||||
TransactionListViewModel transactionListViewModel;
|
TransactionListViewModel transactionListViewModel;
|
||||||
|
|
||||||
public TransactionListView(Context context, AttributeSet attrs) {
|
public TransactionListView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
rootView = inflate(context, R.layout.transaction_list, this);
|
rootView = inflate(context, R.layout.transaction_list, this);
|
||||||
listView = rootView.findViewById(R.id.transactionListView);
|
listView = rootView.findViewById(R.id.transactionListView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(TransactionListViewModel transactionListViewModel){
|
||||||
|
this.transactionListViewModel = transactionListViewModel;
|
||||||
transactionListViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);
|
listAdapter = new TransactionListAdapter(this.getContext(), transactionListViewModel.getTransactionList());
|
||||||
|
|
||||||
listAdapter = new TransactionListAdapter(context, getResources(), transactionDao.getAll());
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Hello World!" />
|
android:text="Hello World!" />
|
||||||
|
|
||||||
<cy.agorise.crystalwallet.views.TransactionListView
|
<cy.agorise.crystalwallet.views.TransactionListView
|
||||||
|
android:id="@+id/transaction_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_alignParentTop="true">
|
android:layout_alignParentTop="true">
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/fromText"
|
android:id="@+id/fromText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:text="from" />
|
android:text="from" />
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/toText"
|
android:id="@+id/toText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
android:text="to"
|
android:text="to"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/amountText"
|
android:id="@+id/amountText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
Loading…
Reference in a new issue