Account seed find by id with livedata
This commit is contained in:
parent
528013ba12
commit
9212af8141
3 changed files with 8 additions and 5 deletions
|
@ -23,7 +23,10 @@ public interface AccountSeedDao {
|
||||||
LiveData<List<AccountSeed>> getAll();
|
LiveData<List<AccountSeed>> getAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM account_seed WHERE id = :id")
|
@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")
|
@Query("SELECT COUNT(*) from account_seed")
|
||||||
int countAccountSeeds();
|
int countAccountSeeds();
|
||||||
|
|
|
@ -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
|
* 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){
|
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){
|
if(seed == null){
|
||||||
System.out.println("Error: Seed null " + this.getSeedId());
|
System.out.println("Error: Seed null " + this.getSeedId());
|
||||||
return null;
|
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
|
* 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){
|
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)
|
if(seed == null)
|
||||||
return null;
|
return null;
|
||||||
if(seed.getType().equals(SeedType.BRAINKEY)){
|
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
|
* 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){
|
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)
|
if(seed == null)
|
||||||
return null;
|
return null;
|
||||||
if(seed.getType().equals(SeedType.BRAINKEY)){
|
if(seed.getType().equals(SeedType.BRAINKEY)){
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class AccountSeedViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSeed(int seedId){
|
public void loadSeed(int seedId){
|
||||||
this.accountSeed = this.db.accountSeedDao().findById(seedId);
|
this.accountSeed = this.db.accountSeedDao().findByIdLiveData(seedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSeed(AccountSeed seed){
|
public void addSeed(AccountSeed seed){
|
||||||
|
|
Loading…
Reference in a new issue