- Adding Transaction Entities, View and ViewModels (Still in progress..)

This commit is contained in:
Javier Varona 2017-09-11 22:07:43 -04:00
parent 8b9eee7fb2
commit 65c362da8d
7 changed files with 182 additions and 2 deletions

View file

@ -16,6 +16,5 @@ public class CrystalApplication extends Application {
//initialize the database
CrystalDatabase db = CrystalDatabase.getAppDatabase(this.getApplicationContext());
db.accountSeedDao().getAll();
}
}

View file

@ -38,9 +38,13 @@ public abstract class CrystalDatabase extends RoomDatabase {
database.execSQL("CREATE TABLE 'account_seed' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "'name' TEXT, 'master_seed' NUMERIC)");
database.execSQL("CREATE TABLE 'crypto_net_account' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "'seed_id', "
+ "'seed_id' INTEGER, "
+ "'account_number' INT, 'account_index' INT,"
+ "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))");
}
};
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View 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>

View 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>