- Adding Transaction Entities, View and ViewModels (Still in progress..)
This commit is contained in:
parent
8b9eee7fb2
commit
65c362da8d
7 changed files with 182 additions and 2 deletions
|
@ -16,6 +16,5 @@ public class CrystalApplication extends Application {
|
||||||
|
|
||||||
//initialize the database
|
//initialize the database
|
||||||
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.getApplicationContext());
|
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.getApplicationContext());
|
||||||
db.accountSeedDao().getAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,13 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
database.execSQL("CREATE TABLE 'account_seed' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
database.execSQL("CREATE TABLE 'account_seed' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
+ "'name' TEXT, 'master_seed' NUMERIC)");
|
+ "'name' TEXT, 'master_seed' NUMERIC)");
|
||||||
database.execSQL("CREATE TABLE 'crypto_net_account' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
database.execSQL("CREATE TABLE 'crypto_net_account' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
+ "'seed_id', "
|
+ "'seed_id' INTEGER, "
|
||||||
+ "'account_number' INT, 'account_index' INT,"
|
+ "'account_number' INT, 'account_index' INT,"
|
||||||
+ "FOREIGN_KEY(seed_id) REFERENCES seed(id))");
|
+ "FOREIGN_KEY(seed_id) REFERENCES seed(id))");
|
||||||
|
database.execSQL("CREATE TABLE 'crypto_coin_transaction' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
|
+ "'account_id' INTEGER, "
|
||||||
|
+ "'date' INT, 'is_input' INT,"
|
||||||
|
+ "FOREIGN_KEY(account_id) REFERENCES crypto_net_account(id))");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
|
import android.arch.persistence.room.Entity;
|
||||||
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 11/9/2017.
|
||||||
|
*/
|
||||||
|
@Entity(tableName="crypto_coin_transaction")
|
||||||
|
public class CryptoCoinTransaction {
|
||||||
|
|
||||||
|
protected CryptoNetAccount account;
|
||||||
|
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
@ColumnInfo(name="id")
|
||||||
|
protected int id;
|
||||||
|
@ColumnInfo(name="date")
|
||||||
|
protected Date date;
|
||||||
|
@ColumnInfo(name="is_input")
|
||||||
|
protected boolean isInput;
|
||||||
|
@ColumnInfo(name="account_id")
|
||||||
|
protected int accountId;
|
||||||
|
|
||||||
|
public int getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(int accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CryptoNetAccount getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(CryptoNetAccount account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getInput() {
|
||||||
|
return isInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(boolean input) {
|
||||||
|
this.isInput = input;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package cy.agorise.crystalwallet.views;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 11/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TransactionListAdapter extends ArrayAdapter<CryptoCoinTransaction> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public TransactionListAdapter(Context context, int resource, List<CryptoCoinTransaction> items) {
|
||||||
|
super(context, resource, items);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package cy.agorise.crystalwallet.views;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ListAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 10/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TransactionListView extends RelativeLayout {
|
||||||
|
|
||||||
|
View rootView;
|
||||||
|
ListView list;
|
||||||
|
ListAdapter listAdapter;
|
||||||
|
|
||||||
|
public TransactionListView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
rootView = inflate(context, R.layout.transaction_list, this);
|
||||||
|
list = rootView.findViewById(R.id.transactionListView);
|
||||||
|
listAdapter = new TransactionListAdapter();
|
||||||
|
list.setAdapter(listAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
10
app/src/main/res/layout/transaction_list.xml
Normal file
10
app/src/main/res/layout/transaction_list.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/transactionListView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</LinearLayout>
|
47
app/src/main/res/layout/transaction_list_item.xml
Normal file
47
app/src/main/res/layout/transaction_list_item.xml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:paddingTop="10dp">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/fromText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="text"
|
||||||
|
android:text="from" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/toText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="false"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="text"
|
||||||
|
android:text="to"
|
||||||
|
android:textAlignment="textEnd" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/amountText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignWithParentIfMissing="false"
|
||||||
|
android:layout_below="@+id/fromText"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="center"
|
||||||
|
android:inputType="number"
|
||||||
|
android:text="amount" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</LinearLayout>
|
Loading…
Reference in a new issue