Skip to content

Commit 284d310

Browse files
authored
Merge pull request #27 from Anschutz1927/mul-1695-review-create-asset
MUL-1695 Review response of create asset
2 parents 472e52b + 25f8ed0 commit 284d310

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

app/src/main/java/io/multy/ui/fragments/asset/CreateAssetFragment.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.content.Intent;
1313
import android.graphics.Color;
1414
import android.os.Bundle;
15+
import android.support.annotation.NonNull;
1516
import android.support.annotation.Nullable;
1617
import android.text.Editable;
1718
import android.text.TextWatcher;
@@ -25,6 +26,8 @@
2526

2627
import com.samwolfand.oneprefs.Prefs;
2728

29+
import org.json.JSONObject;
30+
2831
import butterknife.BindView;
2932
import butterknife.ButterKnife;
3033
import butterknife.OnClick;
@@ -225,10 +228,18 @@ public void onClickCreate() {
225228
Wallet walletRealmObject = walletViewModel.createWallet(editTextWalletName.getText().toString(), chainId, chainNet);
226229
MultyApi.INSTANCE.addWallet(getActivity(), walletRealmObject).enqueue(new Callback<ResponseBody>() {
227230
@Override
228-
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
231+
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
229232
if (response.isSuccessful()) {
230-
//todo improve when Jack will change api with 'dateofcreation' param in response
231-
loadCreatedWallet(chainId, chainNet);
233+
try {
234+
String body = response.body().string();
235+
long dateOfCreation = new JSONObject(body).getLong("time");
236+
walletRealmObject.setDateOfCreation(dateOfCreation);
237+
RealmManager.getAssetsDao().saveWallet(walletRealmObject);
238+
showWalletInfoActivity(walletRealmObject);
239+
} catch (Throwable t) {
240+
t.printStackTrace();
241+
loadCreatedWallet(chainId, chainNet);
242+
}
232243
} else {
233244
walletViewModel.errorMessage.setValue(getString(R.string.something_went_wrong));
234245
walletViewModel.isLoading.setValue(false);

0 commit comments

Comments
 (0)