Created CryptoAsset

master
henry 2017-09-13 23:13:37 -04:00
parent c9a23341a0
commit d41518de0f
4 changed files with 109 additions and 40 deletions

View File

@ -5,6 +5,7 @@ import android.arch.persistence.room.TypeConverter;
import java.util.Date;
import cy.agorise.crystalwallet.enums.CryptoCoin;
import cy.agorise.crystalwallet.enums.CryptoNet;
import cy.agorise.crystalwallet.models.CryptoNetAccount;
import static cy.agorise.crystalwallet.R.string.account;
@ -65,4 +66,22 @@ public class Converters {
return CryptoCoin.valueOf(value);
}
}
@TypeConverter
public String cryptoNetToName(CryptoNet net){
if (net == null) {
return "";
} else {
return net.getLabel();
}
}
@TypeConverter
public CryptoNet nameToCryptoNet(String value) {
if (value.equals("")){
return null;
} else {
return CryptoNet.valueOf(value);
}
}
}

View File

@ -8,7 +8,6 @@ import java.io.Serializable;
*
* Created by Henry Varona on 12/9/2017.
*/
public enum CryptoNet implements Serializable {
BITCOIN("BITCOIN",6), BITCOIN_TEST("BITCOIN(TEST)",6), LITECOIN("LITECOIN",6), DASH("DASH",6), DOGECOIN("DOGECOIN",6), BITSHARES("BITSHARES",1), STEEM("STEEN",1);

View File

@ -1,5 +1,12 @@
package cy.agorise.crystalwallet.models;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.PrimaryKey;
import android.arch.persistence.room.TypeConverters;
import cy.agorise.crystalwallet.dao.converters.Converters;
import cy.agorise.crystalwallet.enums.CryptoNet;
/**
* Represents each asset in transaction and balances
*
@ -7,4 +14,61 @@ package cy.agorise.crystalwallet.models;
*/
public class CryptoAsset {
/**
* The id on the database
*/
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
private int mId;
/**
* The name or tag of this seed
*/
@ColumnInfo(name = "name")
private String mName;
/**
* CryptoCoin network where this assets belongs to
*/
private CryptoNet mCryptoNet;
/**
* The decimal point
*/
@ColumnInfo(name = "precision")
private int mPrecision;
public int getId() {
return mId;
}
public void setId(int mId) {
this.mId = mId;
}
public String getName() {
return mName;
}
public void setName(String mName) {
this.mName = mName;
}
public CryptoNet getCryptoNet() {
return mCryptoNet;
}
public void setCryptoNet(CryptoNet cryptoNet) {
this.mCryptoNet = cryptoNet;
}
public int getPrecision() {
return mPrecision;
}
public void setPrecision(int precision) {
this.mPrecision = precision;
}
}

View File

@ -48,61 +48,36 @@ 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
* The id of the Crypto Asset to use in the database
*/
@ColumnInfo(name="crypto_coin")
protected CryptoCoin coin;
@ColumnInfo(name="id_asset")
private int idAsset;
/**
* If this transaction is confirmed
*/
@ColumnInfo(name="is_confirmed")
protected boolean isConfirmed;
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
/**
* The address or account the amount of assets comes from
*/
@ColumnInfo(name="from")
protected String from;
/**
* The address or account the amount of assets goes to
*/
@ColumnInfo(name="to")
protected String to;
public String getFrom() {
return from;
}
public String getFrom() { return from; }
public void setFrom(String from) {
this.from = from;
}
public void setFrom(String from) { this.from = from; }
public String getTo() {
return to;
}
public String getTo() { return to; }
public void setTo(String to) {
this.to = to;
}
public void setTo(String to) { this.to = to; }
public int getAccountId() {
return accountId;
@ -143,4 +118,16 @@ public class CryptoCoinTransaction {
public void setInput(boolean input) {
this.isInput = input;
}
public boolean isConfirmed() { return isConfirmed; }
public void setConfirmed(boolean confirmed) { isConfirmed = confirmed; }
public int getAmount() { return amount; }
public void setAmount(int amount) { this.amount = amount; }
public int getIdAsset() { return idAsset; }
public void setIdAsset(int idAsset) { this.idAsset = idAsset; }
}