Account seed find by id with livedata

master
henry 2018-01-09 22:33:23 -04:00
parent 528013ba12
commit 9212af8141
3 changed files with 8 additions and 5 deletions

View File

@ -23,7 +23,10 @@ public interface AccountSeedDao {
LiveData<List<AccountSeed>> getAll();
@Query("SELECT * FROM account_seed WHERE id = :id")
LiveData<AccountSeed> findById(long id);
LiveData<AccountSeed> findByIdLiveData(long id);
@Query("SELECT * FROM account_seed WHERE id = :id")
AccountSeed findById(long id);
@Query("SELECT COUNT(*) from account_seed")
int countAccountSeeds();

View File

@ -54,7 +54,7 @@ public class GrapheneAccount extends CryptoNetAccount {
* Return the owner key, generates from the seed if it has not been generated. null if it can't be generated
*/
public ECKey getOwnerKey(Context context){
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId()).getValue();
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId());
if(seed == null){
System.out.println("Error: Seed null " + this.getSeedId());
return null;
@ -83,7 +83,7 @@ public class GrapheneAccount extends CryptoNetAccount {
* Return the active key, generates from the seed if it has not been generated. null if it can't be generated
*/
public ECKey getActiveKey(Context context){
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId()).getValue();
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId());
if(seed == null)
return null;
if(seed.getType().equals(SeedType.BRAINKEY)){
@ -107,7 +107,7 @@ public class GrapheneAccount extends CryptoNetAccount {
* Return the memo key, generates from the seed if it has not been generated. null if it can't be generated
*/
public ECKey getMemoKey(Context context){
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId()).getValue();
AccountSeed seed = CrystalDatabase.getAppDatabase(context).accountSeedDao().findById(this.getSeedId());
if(seed == null)
return null;
if(seed.getType().equals(SeedType.BRAINKEY)){

View File

@ -30,7 +30,7 @@ public class AccountSeedViewModel extends AndroidViewModel {
}
public void loadSeed(int seedId){
this.accountSeed = this.db.accountSeedDao().findById(seedId);
this.accountSeed = this.db.accountSeedDao().findByIdLiveData(seedId);
}
public void addSeed(AccountSeed seed){