- Now Room creates the database using the constructed entities and not with Migration queries
- Added some random data generators for improving testing
This commit is contained in:
parent
d5dbe02a50
commit
8db09a67c4
15 changed files with 164 additions and 35 deletions
|
@ -15,7 +15,11 @@ import android.widget.Button;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomCryptoNetAccountGenerator;
|
||||||
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomSeedGenerator;
|
||||||
import cy.agorise.crystalwallet.randomdatagenerators.RandomTransactionsGenerator;
|
import cy.agorise.crystalwallet.randomdatagenerators.RandomTransactionsGenerator;
|
||||||
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
import cy.agorise.crystalwallet.viewmodels.TransactionListViewModel;
|
||||||
import cy.agorise.crystalwallet.views.TransactionListView;
|
import cy.agorise.crystalwallet.views.TransactionListView;
|
||||||
|
@ -33,10 +37,20 @@ public class IntroActivity extends LifecycleActivity {
|
||||||
setContentView(R.layout.activity_intro);
|
setContentView(R.layout.activity_intro);
|
||||||
|
|
||||||
/*CrystalDatabase db = CrystalDatabase.getAppDatabase(getApplicationContext());
|
/*CrystalDatabase db = CrystalDatabase.getAppDatabase(getApplicationContext());
|
||||||
List<CryptoCoinTransaction> transactions = RandomTransactionsGenerator.generateTransactions(100,1262304001,1496275201,1,999999999);
|
List<AccountSeed> seeds = RandomSeedGenerator.generateSeeds(2);
|
||||||
|
for(int i=0;i<seeds.size();i++) {
|
||||||
|
long newId = db.accountSeedDao().insertAccountSeed(seeds.get(i))[0];
|
||||||
|
seeds.get(i).setId(newId);
|
||||||
|
}
|
||||||
|
List<CryptoNetAccount> accounts = RandomCryptoNetAccountGenerator.generateAccounts(5,seeds);
|
||||||
|
for(int i=0;i<accounts.size();i++) {
|
||||||
|
long newId = db.cryptoNetAccountDao().insertCryptoNetAccount(accounts.get(i))[0];
|
||||||
|
accounts.get(i).setId(newId);
|
||||||
|
}
|
||||||
|
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++) {
|
||||||
db.transactionDao().insertTransaction(transactions.get(i));
|
long newId = db.transactionDao().insertTransaction(transactions.get(i))[0];
|
||||||
|
transactions.get(i).setId(newId);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
transactionListView = this.findViewById(R.id.transaction_list);
|
transactionListView = this.findViewById(R.id.transaction_list);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package cy.agorise.crystalwallet.dao;
|
package cy.agorise.crystalwallet.dao;
|
||||||
|
|
||||||
import android.arch.persistence.room.Dao;
|
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 android.arch.persistence.room.Query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -16,4 +18,8 @@ public interface AccountSeedDao {
|
||||||
|
|
||||||
@Query("SELECT * FROM account_seed")
|
@Query("SELECT * FROM account_seed")
|
||||||
List<AccountSeed> getAll();
|
List<AccountSeed> getAll();
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
public long[] insertAccountSeed(AccountSeed... seeds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package cy.agorise.crystalwallet.dao;
|
package cy.agorise.crystalwallet.dao;
|
||||||
|
|
||||||
import android.arch.persistence.room.Dao;
|
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 android.arch.persistence.room.Query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,4 +19,8 @@ public interface CryptoNetAccountDao {
|
||||||
|
|
||||||
@Query("SELECT * FROM crypto_net_account")
|
@Query("SELECT * FROM crypto_net_account")
|
||||||
List<CryptoNetAccount> getAll();
|
List<CryptoNetAccount> getAll();
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
public long[] insertCryptoNetAccount(CryptoNetAccount... accounts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
Room.databaseBuilder(context,
|
Room.databaseBuilder(context,
|
||||||
CrystalDatabase.class, "CrystalWallet.db")
|
CrystalDatabase.class, "CrystalWallet.db")
|
||||||
.allowMainThreadQueries()
|
.allowMainThreadQueries()
|
||||||
.addMigrations(MIGRATION_1_2)
|
//.addMigrations(MIGRATION_1_2)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
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("CREATE TABLE 'account_seed' ('id' INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||||
|
@ -55,5 +55,5 @@ public abstract class CrystalDatabase extends RoomDatabase {
|
||||||
+ "'date' INT, 'is_input' INT, amount INT, crypto_coin TEXT, is_confirmed INT, "
|
+ "'date' INT, 'is_input' INT, amount INT, crypto_coin TEXT, is_confirmed INT, "
|
||||||
+ "FOREIGN_KEY(account_id) REFERENCES crypto_net_account(id))");
|
+ "FOREIGN_KEY(account_id) REFERENCES crypto_net_account(id))");
|
||||||
}
|
}
|
||||||
};
|
};*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public interface TransactionDao {
|
||||||
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByDate();
|
LivePagedListProvider<Integer, CryptoCoinTransaction> transactionsByDate();
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
public void insertTransaction(CryptoCoinTransaction... transactions);
|
public long[] insertTransaction(CryptoCoinTransaction... transactions);
|
||||||
|
|
||||||
@Query("DELETE FROM crypto_coin_transaction")
|
@Query("DELETE FROM crypto_coin_transaction")
|
||||||
public void deleteAllTransactions();
|
public void deleteAllTransactions();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class Converters {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
public int cryptoNetAccountToId(CryptoNetAccount account) {
|
public long cryptoNetAccountToId(CryptoNetAccount account) {
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +39,7 @@ public class Converters {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
public CryptoNetAccount fromCryptoNetAccountId(int value) {
|
public CryptoNetAccount fromCryptoNetAccountId(long value) {
|
||||||
if (value == -1){
|
if (value == -1){
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class AccountSeed {
|
||||||
*/
|
*/
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
@ColumnInfo(name = "id")
|
@ColumnInfo(name = "id")
|
||||||
private int mId;
|
private long mId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name or tag of this seed
|
* The name or tag of this seed
|
||||||
|
@ -32,11 +32,11 @@ public class AccountSeed {
|
||||||
@ColumnInfo(name = "master_seed")
|
@ColumnInfo(name = "master_seed")
|
||||||
private String mMasterSeed;
|
private String mMasterSeed;
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id){
|
public void setId(long id){
|
||||||
this.mId = id;
|
this.mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class CryptoCoinTransaction {
|
||||||
*/
|
*/
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
@ColumnInfo(name="id")
|
@ColumnInfo(name="id")
|
||||||
protected int id;
|
protected long id;
|
||||||
/**
|
/**
|
||||||
* The full date of this transaction
|
* The full date of this transaction
|
||||||
*/
|
*/
|
||||||
|
@ -54,7 +54,7 @@ public class CryptoCoinTransaction {
|
||||||
* The id of the account assoiciated, this is used for the foreign key definition
|
* The id of the account assoiciated, this is used for the foreign key definition
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name="account_id")
|
@ColumnInfo(name="account_id")
|
||||||
protected int accountId;
|
protected long accountId;
|
||||||
/**
|
/**
|
||||||
* The amount of asset is moved in this transaction
|
* The amount of asset is moved in this transaction
|
||||||
*/
|
*/
|
||||||
|
@ -92,11 +92,11 @@ public class CryptoCoinTransaction {
|
||||||
|
|
||||||
public void setTo(String to) { this.to = to; }
|
public void setTo(String to) { this.to = to; }
|
||||||
|
|
||||||
public int getAccountId() {
|
public long getAccountId() {
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountId(int accountId) {
|
public void setAccountId(long accountId) {
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,11 +108,11 @@ public class CryptoCoinTransaction {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ public class CryptoNetAccount {
|
||||||
*/
|
*/
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
@ColumnInfo(name = "id")
|
@ColumnInfo(name = "id")
|
||||||
private int mId;
|
private long mId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the seed used by this account
|
* The id of the seed used by this account
|
||||||
*/
|
*/
|
||||||
@ColumnInfo(name = "seed_id")
|
@ColumnInfo(name = "seed_id")
|
||||||
private int mSeedId;
|
private long mSeedId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The account number on the bip44 or slip44
|
* The account number on the bip44 or slip44
|
||||||
|
@ -45,19 +45,19 @@ public class CryptoNetAccount {
|
||||||
@ColumnInfo(name = "account_index")
|
@ColumnInfo(name = "account_index")
|
||||||
private int mAccountIndex;
|
private int mAccountIndex;
|
||||||
|
|
||||||
public int getId() {
|
public long getId() {
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id){
|
public void setId(long id){
|
||||||
this.mId = id;
|
this.mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSeedId() {
|
public long getSeedId() {
|
||||||
return mSeedId;
|
return mSeedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeedId(int mSeedId) {
|
public void setSeedId(long mSeedId) {
|
||||||
this.mSeedId = mSeedId;
|
this.mSeedId = mSeedId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package cy.agorise.crystalwallet.randomdatagenerators;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 20/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RandomCryptoNetAccountGenerator {
|
||||||
|
|
||||||
|
static public List<CryptoNetAccount> generateAccounts(int numberOfAccounts,List<AccountSeed> seeds){
|
||||||
|
ArrayList<CryptoNetAccount> result = new ArrayList<CryptoNetAccount>();
|
||||||
|
Random randomGenerator = new Random();
|
||||||
|
CryptoNetAccount randomAccount;
|
||||||
|
|
||||||
|
for (int i=0;i<numberOfAccounts;i++){
|
||||||
|
int randomSeedIndex = randomGenerator.nextInt(seeds.size());
|
||||||
|
AccountSeed randomSelectedSeed = seeds.get(randomSeedIndex);
|
||||||
|
int randomAccountIndex = randomGenerator.nextInt(1000);
|
||||||
|
int randomAccountNumber = randomGenerator.nextInt(1000);
|
||||||
|
|
||||||
|
randomAccount = new CryptoNetAccount();
|
||||||
|
randomAccount.setSeedId(randomSelectedSeed.getId());
|
||||||
|
randomAccount.setAccountIndex(randomAccountIndex);
|
||||||
|
randomAccount.setAccountNumber(randomAccountNumber);
|
||||||
|
result.add(randomAccount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cy.agorise.crystalwallet.randomdatagenerators;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Henry Varona on 20/9/2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class RandomSeedGenerator {
|
||||||
|
|
||||||
|
static public List<AccountSeed> generateSeeds(int numberOfSeeds){
|
||||||
|
ArrayList<AccountSeed> result = new ArrayList<AccountSeed>();
|
||||||
|
Random randomGenerator = new Random();
|
||||||
|
AccountSeed randomSeed;
|
||||||
|
|
||||||
|
for (int i=0;i<numberOfSeeds;i++){
|
||||||
|
int randomInt = randomGenerator.nextInt(999999999);
|
||||||
|
|
||||||
|
randomSeed = new AccountSeed();
|
||||||
|
randomSeed.setMasterSeed(""+randomInt);
|
||||||
|
randomSeed.setName("seed"+randomInt);
|
||||||
|
result.add(randomSeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Henry Varona on 20/9/2017.
|
* Created by Henry Varona on 20/9/2017.
|
||||||
|
@ -13,7 +14,7 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
|
||||||
|
|
||||||
public class RandomTransactionsGenerator {
|
public class RandomTransactionsGenerator {
|
||||||
|
|
||||||
static public List<CryptoCoinTransaction> generateTransactions(int numberOfTransactions, int minTimestamp, int maxTimestamp, int minAmount, int maxAmount){
|
static public List<CryptoCoinTransaction> generateTransactions(List<CryptoNetAccount> accounts, int numberOfTransactions, int minTimestamp, int maxTimestamp, int minAmount, int maxAmount){
|
||||||
ArrayList<CryptoCoinTransaction> result = new ArrayList<CryptoCoinTransaction>();
|
ArrayList<CryptoCoinTransaction> result = new ArrayList<CryptoCoinTransaction>();
|
||||||
Random randomGenerator = new Random();
|
Random randomGenerator = new Random();
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
|
@ -22,11 +23,14 @@ public class RandomTransactionsGenerator {
|
||||||
CryptoCoinTransaction randomTransaction;
|
CryptoCoinTransaction randomTransaction;
|
||||||
|
|
||||||
for (int i=0;i<numberOfTransactions;i++){
|
for (int i=0;i<numberOfTransactions;i++){
|
||||||
|
int randomAccountIndex = randomGenerator.nextInt(accounts.size());
|
||||||
|
CryptoNetAccount randomSelectedAccount = accounts.get(randomAccountIndex);
|
||||||
randomAmount = randomGenerator.nextInt((maxAmount - minAmount) + 1) + minAmount;
|
randomAmount = randomGenerator.nextInt((maxAmount - minAmount) + 1) + minAmount;
|
||||||
randomTimeStamp = randomGenerator.nextInt((maxTimestamp - minTimestamp) + 1) + minTimestamp;
|
randomTimeStamp = randomGenerator.nextInt((maxTimestamp - minTimestamp) + 1) + minTimestamp;
|
||||||
cal.setTimeInMillis(randomTimeStamp*1000);
|
cal.setTimeInMillis(randomTimeStamp*1000);
|
||||||
|
|
||||||
randomTransaction = new CryptoCoinTransaction();
|
randomTransaction = new CryptoCoinTransaction();
|
||||||
|
randomTransaction.setAccountId(randomSelectedAccount.getId());
|
||||||
randomTransaction.setAmount(randomAmount);
|
randomTransaction.setAmount(randomAmount);
|
||||||
randomTransaction.setFrom("friend"+i);
|
randomTransaction.setFrom("friend"+i);
|
||||||
randomTransaction.setTo("me"+i);
|
randomTransaction.setTo("me"+i);
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class TransactionListViewModel extends AndroidViewModel {
|
||||||
this.db = CrystalDatabase.getAppDatabase(application.getApplicationContext());
|
this.db = CrystalDatabase.getAppDatabase(application.getApplicationContext());
|
||||||
transactionList = this.db.transactionDao().transactionsByDate().create(0,
|
transactionList = this.db.transactionDao().transactionsByDate().create(0,
|
||||||
new PagedList.Config.Builder()
|
new PagedList.Config.Builder()
|
||||||
|
.setEnablePlaceholders(true)
|
||||||
.setPageSize(10)
|
.setPageSize(10)
|
||||||
.setPrefetchDistance(10)
|
.setPrefetchDistance(10)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -31,6 +31,9 @@ public class TransactionListView extends RelativeLayout {
|
||||||
|
|
||||||
TransactionListViewModel transactionListViewModel;
|
TransactionListViewModel transactionListViewModel;
|
||||||
|
|
||||||
|
private int visibleThreshold = 5;
|
||||||
|
private boolean loading = true;
|
||||||
|
|
||||||
public TransactionListView(Context context){
|
public TransactionListView(Context context){
|
||||||
super(context);
|
super(context);
|
||||||
this.mInflater = LayoutInflater.from(context);
|
this.mInflater = LayoutInflater.from(context);
|
||||||
|
@ -52,9 +55,28 @@ public class TransactionListView extends RelativeLayout {
|
||||||
public void init(){
|
public void init(){
|
||||||
rootView = mInflater.inflate(R.layout.transaction_list, this, true);
|
rootView = mInflater.inflate(R.layout.transaction_list, this, true);
|
||||||
this.listView = rootView.findViewById(R.id.transactionListView);
|
this.listView = rootView.findViewById(R.id.transactionListView);
|
||||||
this.listView.setLayoutManager(new LinearLayoutManager(this.getContext()));
|
|
||||||
|
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.getContext());
|
||||||
|
this.listView.setLayoutManager(linearLayoutManager);
|
||||||
this.listView.setNestedScrollingEnabled(false);
|
this.listView.setNestedScrollingEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
|
/*this.listView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||||
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
|
if(!loading && linearLayoutManager.getItemCount() <= (linearLayoutManager.findLastVisibleItemPosition() + visibleThreshold)){
|
||||||
|
onLoadMore();
|
||||||
|
loading = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//public void onLoadMore(){
|
||||||
|
// listAdapter.add();
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
public void setData(PagedList<CryptoCoinTransaction> data){
|
public void setData(PagedList<CryptoCoinTransaction> data){
|
||||||
if (this.listAdapter == null) {
|
if (this.listAdapter == null) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
transactionFrom = (TextView) itemView.findViewById(R.id.fromText);
|
transactionFrom = (TextView) itemView.findViewById(R.id.fromText);
|
||||||
transactionTo = (TextView) itemView.findViewById(R.id.toText);
|
transactionTo = (TextView) itemView.findViewById(R.id.toText);
|
||||||
transactionAmount = (TextView) itemView.findViewById(R.id.amountText);
|
transactionAmount = (TextView) itemView.findViewById(R.id.amountText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear(){
|
public void clear(){
|
||||||
|
@ -31,9 +32,14 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindTo(final CryptoCoinTransaction transaction/*, final OnTransactionClickListener listener*/) {
|
public void bindTo(final CryptoCoinTransaction transaction/*, final OnTransactionClickListener listener*/) {
|
||||||
|
if (transaction == null){
|
||||||
|
transactionFrom.setText("loading...");
|
||||||
|
transactionTo.setText("");
|
||||||
|
transactionAmount.setText("");
|
||||||
|
} else {
|
||||||
transactionFrom.setText(transaction.getFrom());
|
transactionFrom.setText(transaction.getFrom());
|
||||||
transactionTo.setText(transaction.getTo());
|
transactionTo.setText(transaction.getTo());
|
||||||
transactionAmount.setText(""+transaction.getAmount());
|
transactionAmount.setText("" + transaction.getAmount());
|
||||||
/*itemView.setOnClickListener(new View.OnClickListener() {
|
/*itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -41,4 +47,5 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
});*/
|
});*/
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue