- Fixing the views (in progress...)

This commit is contained in:
Javier Varona 2017-09-13 22:09:58 -04:00
parent 41b054c9bf
commit c9a23341a0
4 changed files with 91 additions and 1 deletions

View file

@ -1,6 +1,8 @@
package cy.agorise.crystalwallet;
import android.arch.lifecycle.LifecycleActivity;
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
@ -17,7 +19,7 @@ public class IntroActivity extends LifecycleActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intro);
transactionListViewModel = new TransactionListViewModel(getApplicationContext());
transactionListViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);
transactionListView = this.findViewById(R.id.transaction_list);
transactionListView.init(transactionListViewModel);

View file

@ -4,9 +4,11 @@ import android.arch.persistence.db.SupportSQLiteDatabase;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.arch.persistence.room.TypeConverters;
import android.arch.persistence.room.migration.Migration;
import android.content.Context;
import cy.agorise.crystalwallet.dao.converters.Converters;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
@ -17,6 +19,7 @@ import cy.agorise.crystalwallet.models.CryptoNetAccount;
*/
@Database(entities = {AccountSeed.class, CryptoNetAccount.class, CryptoCoinTransaction.class}, version = 2)
@TypeConverters({Converters.class})
public abstract class CrystalDatabase extends RoomDatabase {
private static CrystalDatabase instance;

View file

@ -0,0 +1,68 @@
package cy.agorise.crystalwallet.dao.converters;
import android.arch.persistence.room.TypeConverter;
import java.util.Date;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import static cy.agorise.crystalwallet.R.string.account;
/**
* Created by Henry Varona on 13/9/2017.
*/
public class Converters {
@TypeConverter
public Date fromTimestamp(Long value) {
return value == null ? null : new Date(value);
}
@TypeConverter
public Long dateToTimestamp(Date date) {
if (date == null) {
return null;
} else {
return date.getTime();
}
}
@TypeConverter
public int cryptoNetAccountToId(CryptoNetAccount account) {
if (account == null) {
return -1;
} else {
return account.getId();
}
}
@TypeConverter
public CryptoNetAccount fromCryptoNetAccountId(int value) {
if (value == -1){
return null;
} else {
CryptoNetAccount account = new CryptoNetAccount();
account.setId(value);
return account;
}
}
@TypeConverter
public String cryptoCoinToName(CryptoCoin coin) {
if (coin == null) {
return "";
} else {
return coin.name();
}
}
@TypeConverter
public CryptoCoin nameToCryptoCoin(String value) {
if (value.equals("")){
return null;
} else {
return CryptoCoin.valueOf(value);
}
}
}

View file

@ -47,6 +47,23 @@ public class CryptoCoinTransaction {
*/
@ColumnInfo(name="amount")
protected int amount;
public CryptoCoin getCoin() {
return coin;
}
public void setCoin(CryptoCoin coin) {
this.coin = coin;
}
public boolean isConfirmed() {
return isConfirmed;
}
public void setConfirmed(boolean confirmed) {
isConfirmed = confirmed;
}
/**
* The crypto Coin associated with this transaction
*/