|
12 | 12 | import android.content.Intent; |
13 | 13 | import android.graphics.Color; |
14 | 14 | import android.os.Bundle; |
| 15 | +import android.support.annotation.NonNull; |
15 | 16 | import android.support.annotation.Nullable; |
16 | 17 | import android.text.Editable; |
17 | 18 | import android.text.TextWatcher; |
|
25 | 26 |
|
26 | 27 | import com.samwolfand.oneprefs.Prefs; |
27 | 28 |
|
| 29 | +import org.json.JSONObject; |
| 30 | + |
28 | 31 | import butterknife.BindView; |
29 | 32 | import butterknife.ButterKnife; |
30 | 33 | import butterknife.OnClick; |
@@ -225,10 +228,18 @@ public void onClickCreate() { |
225 | 228 | Wallet walletRealmObject = walletViewModel.createWallet(editTextWalletName.getText().toString(), chainId, chainNet); |
226 | 229 | MultyApi.INSTANCE.addWallet(getActivity(), walletRealmObject).enqueue(new Callback<ResponseBody>() { |
227 | 230 | @Override |
228 | | - public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { |
| 231 | + public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { |
229 | 232 | 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 | + } |
232 | 243 | } else { |
233 | 244 | walletViewModel.errorMessage.setValue(getString(R.string.something_went_wrong)); |
234 | 245 | walletViewModel.isLoading.setValue(false); |
|
0 commit comments