Change on the managment of the id when saving on database

This commit is contained in:
henry 2018-04-08 22:44:37 -04:00
parent 3a6f4635b0
commit eb351bfbfa
3 changed files with 5 additions and 3 deletions

View file

@ -112,7 +112,6 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
@Override @Override
public void importAccountFromSeed(CryptoNetAccount account, final Context context) { public void importAccountFromSeed(CryptoNetAccount account, final Context context) {
if(account instanceof GrapheneAccount) { if(account instanceof GrapheneAccount) {
final GrapheneAccount grapheneAccount = (GrapheneAccount) account; final GrapheneAccount grapheneAccount = (GrapheneAccount) account;
@ -123,7 +122,8 @@ public class BitsharesAccountManager implements CryptoAccountManager, CryptoNetI
GrapheneAccount fetch = (GrapheneAccount) answer; GrapheneAccount fetch = (GrapheneAccount) answer;
grapheneAccount.setAccountId(fetch.getAccountId()); grapheneAccount.setAccountId(fetch.getAccountId());
CrystalDatabase db = CrystalDatabase.getAppDatabase(context); CrystalDatabase db = CrystalDatabase.getAppDatabase(context);
db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount); long[] idAccount = db.cryptoNetAccountDao().insertCryptoNetAccount(grapheneAccount);
grapheneAccount.setId(idAccount[0]);
db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount)); db.grapheneAccountInfoDao().insertGrapheneAccountInfo(new GrapheneAccountInfo(grapheneAccount));
subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context); subscribeBitsharesAccount(grapheneAccount.getId(),grapheneAccount.getAccountId(),context);
} }

View file

@ -252,6 +252,8 @@ public class FileBackupManager implements FileServiceRequestsListener {
account.setName(validatorRequest.getAccountName()); account.setName(validatorRequest.getAccountName());
BitsharesAccountManager bManger = new BitsharesAccountManager(); BitsharesAccountManager bManger = new BitsharesAccountManager();
bManger.importAccountFromSeed(account,request.getContext()); bManger.importAccountFromSeed(account,request.getContext());
request.setStatus(ImportBackupRequest.StatusCode.SUCCEEDED); request.setStatus(ImportBackupRequest.StatusCode.SUCCEEDED);
}else{ }else{
request.setStatus(ImportBackupRequest.StatusCode.FAILED); //TODO reason couldn't insert seed request.setStatus(ImportBackupRequest.StatusCode.FAILED); //TODO reason couldn't insert seed

View file

@ -187,7 +187,7 @@ public class CryptoNetBalanceViewHolder extends RecyclerView.ViewHolder {
* Binds this view with the data of an element of the list * Binds this view with the data of an element of the list
*/ */
public void bindTo(final CryptoNetBalance balance) { public void bindTo(final CryptoNetBalance balance) {
if (balance == null){ if (balance == null ){
cryptoNetName.setText("loading..."); cryptoNetName.setText("loading...");
} else { } else {
final CryptoNetBalanceViewHolder thisViewHolder = this; final CryptoNetBalanceViewHolder thisViewHolder = this;