- Added GrapheneAccountInfo for graphene specific information of accounts
- Added type of account in crypto_net_account
This commit is contained in:
parent
a1ec57044c
commit
7123c01aff
14 changed files with 147 additions and 21 deletions
|
@ -18,8 +18,10 @@ import java.util.List;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.models.AccountSeed;
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoCoinBalanceGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomTransactionsGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomTransactionsGenerator;
|
||||||
|
@ -63,6 +65,11 @@ public class IntroActivity extends AppCompatActivity {
|
||||||
long newId = db.cryptoNetAccountDao().insertCryptoNetAccount(accounts.get(i))[0];
|
long newId = db.cryptoNetAccountDao().insertCryptoNetAccount(accounts.get(i))[0];
|
||||||
accounts.get(i).setId(newId);
|
accounts.get(i).setId(newId);
|
||||||
}
|
}
|
||||||
|
List<CryptoCoinBalance> balances = RandomCryptoCoinBalanceGenerator.generateCryptoCoinBalances(accounts,5,1,20);
|
||||||
|
for(int i=0;i<balances.size();i++) {
|
||||||
|
long newId = db.cryptoCoinBalanceDao().insertCryptoCoinBalance(balances.get(i))[0];
|
||||||
|
balances.get(i).setId(newId);
|
||||||
|
}
|
||||||
List<CryptoCoinTransaction> transactions = RandomTransactionsGenerator.generateTransactions(accounts,100,1262304001,1496275201,1,999999999);
|
List<CryptoCoinTransaction> transactions = RandomTransactionsGenerator.generateTransactions(accounts,100,1262304001,1496275201,1,999999999);
|
||||||
for(int i=0;i<transactions.size();i++) {
|
for(int i=0;i<transactions.size();i++) {
|
||||||
long newId = db.transactionDao().insertTransaction(transactions.get(i))[0];
|
long newId = db.transactionDao().insertTransaction(transactions.get(i))[0];
|
||||||
|
|
|
@ -19,7 +19,7 @@ public interface CryptoCurrencyDao {
|
||||||
@Query("SELECT * FROM crypto_currency")
|
@Query("SELECT * FROM crypto_currency")
|
||||||
List<CryptoCurrency> getAll();
|
List<CryptoCurrency> getAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_currency WHERE id := id")
|
@Query("SELECT * FROM crypto_currency WHERE id = :id")
|
||||||
CryptoCurrency getById(int id);
|
CryptoCurrency getById(int id);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
|
|
@ -23,6 +23,9 @@ public interface CryptoNetAccountDao {
|
||||||
@Query("SELECT * FROM crypto_net_account")
|
@Query("SELECT * FROM crypto_net_account")
|
||||||
List<CryptoNetAccount> getAll();
|
List<CryptoNetAccount> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM crypto_net_account WHERE type = 1")
|
||||||
|
LiveData<List<CryptoNetAccount>> getGrapheneAccounts();
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);
|
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package cy.agorise.crystalwallet.dao;
|
package cy.agorise.crystalwallet.dao;
|
||||||
|
|
||||||
import android.arch.persistence.db.SupportSQLiteDatabase;
|
|
||||||
import android.arch.persistence.room.Database;
|
import android.arch.persistence.room.Database;
|
||||||
import android.arch.persistence.room.Room;
|
import android.arch.persistence.room.Room;
|
||||||
import android.arch.persistence.room.RoomDatabase;
|
import android.arch.persistence.room.RoomDatabase;
|
||||||
import android.arch.persistence.room.TypeConverters;
|
import android.arch.persistence.room.TypeConverters;
|
||||||
import android.arch.persistence.room.migration.Migration;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.dao.converters.Converters;
|
import cy.agorise.crystalwallet.dao.converters.Converters;
|
||||||
|
@ -14,13 +12,14 @@ import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage the Database
|
* Manage the Database
|
||||||
* Created by Henry Varona on 4/9/2017.
|
* Created by Henry Varona on 4/9/2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {AccountSeed.class, CryptoNetAccount.class, CryptoCoinTransaction.class, CryptoCurrency.class, CryptoCoinBalance.class}, version = 2)
|
@Database(entities = {AccountSeed.class, CryptoNetAccount.class, CryptoCoinTransaction.class, CryptoCurrency.class, CryptoCoinBalance.class, GrapheneAccountInfo.class}, version = 2)
|
||||||
@TypeConverters({Converters.class})
|
@TypeConverters({Converters.class})
|
||||||
public abstract class CrystalDatabase extends RoomDatabase {
|
public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
|
|
||||||
|
@ -28,6 +27,7 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
|
|
||||||
public abstract AccountSeedDao accountSeedDao();
|
public abstract AccountSeedDao accountSeedDao();
|
||||||
public abstract CryptoNetAccountDao cryptoNetAccountDao();
|
public abstract CryptoNetAccountDao cryptoNetAccountDao();
|
||||||
|
public abstract GrapheneAccountInfoDao grapheneAccountInfoDao();
|
||||||
public abstract TransactionDao transactionDao();
|
public abstract TransactionDao transactionDao();
|
||||||
public abstract CryptoCoinBalanceDao cryptoCoinBalanceDao();
|
public abstract CryptoCoinBalanceDao cryptoCoinBalanceDao();
|
||||||
public abstract CryptoCurrencyDao cryptoCurrencyDao();
|
public abstract CryptoCurrencyDao cryptoCurrencyDao();
|
||||||
|
@ -49,16 +49,10 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
/*static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
/*static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
public void migrate(SupportSQLiteDatabase database) {
|
||||||
database.execSQL("CREATE TABLE 'account_seed' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
database.execSQL("UPDATE TABLE 'crypto_net_account' ADD "
|
||||||
+ "'name' TEXT, 'master_seed' NUMERIC)");
|
+ "'subclass' INT, "
|
||||||
database.execSQL("CREATE TABLE 'crypto_net_account' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
+ "'bitshares_account_name' STRING, "
|
||||||
+ "'seed_id' INTEGER, "
|
+ "'bitshares_account_id' STRING ");
|
||||||
+ "'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, amount INT, crypto_coin TEXT, is_confirmed INT, "
|
|
||||||
+ "FOREIGN_KEY(account_id) REFERENCES crypto_net_account(id))");
|
|
||||||
}
|
}
|
||||||
};*/
|
};*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cy.agorise.crystalwallet.dao;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
|
import android.arch.persistence.room.Dao;
|
||||||
|
import android.arch.persistence.room.Insert;
|
||||||
|
import android.arch.persistence.room.OnConflictStrategy;
|
||||||
|
import android.arch.persistence.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||||
|
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 10/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface GrapheneAccountInfoDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM graphene_account WHERE subclass = 1")
|
||||||
|
LiveData<List<GrapheneAccountInfo>> getAll();
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
public long[] insertGrapheneAccountInfo(GrapheneAccountInfo... accounts);
|
||||||
|
|
||||||
|
}
|
|
@ -23,8 +23,8 @@ public interface TransactionDao {
|
||||||
@Query("SELECT * FROM crypto_coin_transaction ORDER BY date ASC")
|
@Query("SELECT * FROM crypto_coin_transaction ORDER BY date ASC")
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByDate();
|
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByDate();
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_coin_transaction WHERE account_id := idAccount ORDER BY date ASC")
|
@Query("SELECT * FROM crypto_coin_transaction WHERE account_id = :idAccount ORDER BY date ASC")
|
||||||
LiveData<List<CryptoCoinTransaction>> getByIdAccount(long idAccount);
|
LiveData<List<CryptoCoinTransaction>> getByIdAccount(long idAccount);
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public long[] insertTransaction(CryptoCoinTransaction... transactions);
|
public long[] insertTransaction(CryptoCoinTransaction... transactions);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package cy.agorise.crystalwallet.enums;
|
package cy.agorise.crystalwallet.enums;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Henry Varona on 12/9/2017.
|
* Created by Henry Varona on 12/9/2017.
|
||||||
|
@ -34,5 +36,16 @@ public enum CryptoCoin implements Serializable {
|
||||||
public int getPrecision(){
|
public int getPrecision(){
|
||||||
return this.precision;
|
return this.precision;
|
||||||
}
|
}
|
||||||
|
public static List<CryptoCoin> getByCryptoNet(CryptoNet cryptoNet){
|
||||||
|
List<CryptoCoin> result = new ArrayList<CryptoCoin>();
|
||||||
|
|
||||||
|
for (CryptoCoin nextCryptoCoin : CryptoCoin.values()){
|
||||||
|
if (nextCryptoCoin.getCryptoNet().equals(cryptoNet)) {
|
||||||
|
result.add(nextCryptoCoin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,12 @@ public class CryptoNetAccount {
|
||||||
@ColumnInfo(name = "account_index")
|
@ColumnInfo(name = "account_index")
|
||||||
private int mAccountIndex;
|
private int mAccountIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the account
|
||||||
|
*/
|
||||||
|
@ColumnInfo(name = "type")
|
||||||
|
private int type;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
@ -77,4 +83,11 @@ public class CryptoNetAccount {
|
||||||
this.mAccountIndex = mAccountIndex;
|
this.mAccountIndex = mAccountIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
public class GrapheneAccount extends CryptoNetAccount {
|
public class GrapheneAccount extends CryptoNetAccount {
|
||||||
|
|
||||||
|
public static int subclass = 1;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String accountId;
|
protected String accountId;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package cy.agorise.crystalwallet.models;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
|
import android.arch.persistence.room.Entity;
|
||||||
|
import android.arch.persistence.room.ForeignKey;
|
||||||
|
import android.arch.persistence.room.Index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by henry on 24/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Entity(tableName = "graphene_account",
|
||||||
|
indices = {@Index("id"),@Index(value = "crypto_net_account_id",unique=true)},
|
||||||
|
foreignKeys = @ForeignKey(entity = CryptoNetAccount.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "crypto_net_account_id"))
|
||||||
|
public class GrapheneAccountInfo {
|
||||||
|
|
||||||
|
@ColumnInfo(name = "crypto_net_account_id")
|
||||||
|
protected String cryptoNetAccountId;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "account_name")
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "account_id")
|
||||||
|
protected String accountId;
|
||||||
|
|
||||||
|
public String getCryptoNetAccountId() {
|
||||||
|
return cryptoNetAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCryptoNetAccountId(String cryptoNetAccountId) {
|
||||||
|
this.cryptoNetAccountId = cryptoNetAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountId() {
|
||||||
|
return accountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountId(String accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,11 +51,11 @@ public class CryptoCoinBalanceListView extends RelativeLayout {
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
rootView = mInflater.inflate(R.layout.crypto_coin_balance_list, this, true);
|
rootView = mInflater.inflate(R.layout.crypto_coin_balance_list, this, true);
|
||||||
/*this.listView = rootView.findViewById(R.id.cryptoCoinBalanceListView);
|
this.listView = (RecyclerView) rootView.findViewById(R.id.cryptoCoinBalanceListView);
|
||||||
|
|
||||||
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
|
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
|
||||||
this.listView.setLayoutManager(linearLayoutManager);
|
this.listView.setLayoutManager(linearLayoutManager);
|
||||||
this.listView.setNestedScrollingEnabled(false);*/
|
this.listView.setNestedScrollingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<CryptoCoinBalance> data){
|
public void setData(List<CryptoCoinBalance> data){
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
cryptoCoinBalance.setText("");
|
cryptoCoinBalance.setText("");
|
||||||
} else {
|
} else {
|
||||||
cryptoCoinName.setText(balance.getCoin().getLabel());
|
cryptoCoinName.setText(balance.getCoin().getLabel());
|
||||||
cryptoCoinBalance.setText(balance.getBalance());
|
cryptoCoinBalance.setText(""+balance.getBalance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cy.agorise.crystalwallet.views;
|
package cy.agorise.crystalwallet.views;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
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.ImageView;
|
||||||
|
@ -23,7 +24,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cryptoNetIcon = (ImageView) itemView.findViewById(R.id.ivCryptoNetIcon);
|
cryptoNetIcon = (ImageView) itemView.findViewById(R.id.ivCryptoNetIcon);
|
||||||
cryptoNetName = (TextView) itemView.findViewById(R.id.tvCryptoNetName);
|
cryptoNetName = (TextView) itemView.findViewById(R.id.tvCryptoNetName);
|
||||||
cryptoCoinBalanceListView = (CryptoCoinBalanceListView) itemView.findViewById(R.id.cryptoCoinBalanceListView);
|
cryptoCoinBalanceListView = (CryptoCoinBalanceListView) itemView.findViewById(R.id.cryptoCoinBalancesListView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +37,21 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
|
||||||
cryptoNetName.setText("loading...");
|
cryptoNetName.setText("loading...");
|
||||||
} else {
|
} else {
|
||||||
cryptoNetName.setText(balance.getCryptoNet().getLabel());
|
cryptoNetName.setText(balance.getCryptoNet().getLabel());
|
||||||
|
|
||||||
|
/*transactionListView = this.findViewById(R.id.transaction_list);
|
||||||
|
|
||||||
|
transactionListViewModel = ViewModelProviders.of(getContext).get(TransactionListViewModel.class);
|
||||||
|
LiveData<PagedList<CryptoCoinTransaction>> transactionData = transactionListViewModel.getTransactionList();
|
||||||
|
transactionListView.setData(null);
|
||||||
|
|
||||||
|
transactionData.observe(this, new Observer<PagedList<CryptoCoinTransaction>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(PagedList<CryptoCoinTransaction> cryptoCoinTransactions) {
|
||||||
|
transactionListView.setData(cryptoCoinTransactions);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cryptoCoinBalanceListView.setData();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<cy.agorise.crystalwallet.views.CryptoCoinBalanceListView
|
<cy.agorise.crystalwallet.views.CryptoCoinBalanceListView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/cryptoCoinBalanceListView">
|
android:id="@+id/cryptoCoinBalancesListView">
|
||||||
|
|
||||||
</cy.agorise.crystalwallet.views.CryptoCoinBalanceListView>
|
</cy.agorise.crystalwallet.views.CryptoCoinBalanceListView>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue