diff --git a/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java b/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java index d58ef10..ed904e0 100644 --- a/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java +++ b/app/src/main/java/com/example/citrusclient/viewmodels/SettingsViewModel.java @@ -17,6 +17,13 @@ private final Retrofit retrofit; private final AccountsRest accountsRest; private final MutableLiveData accountColorLiveData; + //通信レスポンスの画面表示用のライブデーター + //PW変更時の通信レスポンス結果格納用 + private final MutableLiveData response_changePw_LiveData; + //アカウント削除時の通信レスポンス結果格納用 + private final MutableLiveData response_deleteAccount_LiveData; + //アカウントID変更はやるのか不明なので一旦保留 + public SettingsViewModel(){ @@ -26,8 +33,12 @@ .build(); this.accountsRest = retrofit.create(AccountsRest.class); this.accountColorLiveData = new MutableLiveData<>(); + this.response_changePw_LiveData = new MutableLiveData<>(); + this.response_deleteAccount_LiveData = new MutableLiveData<>(); } public MutableLiveData getAccountColorLiveData(){return accountColorLiveData;} + public MutableLiveData getResponse_changePw(){return response_changePw_LiveData;} + public MutableLiveDatagetResponse_deleteAccount(){return response_deleteAccount_LiveData;} public void loadAccountColor(String accountId){ Call call= accountsRest.getAccountColor(accountId); @@ -60,15 +71,19 @@ public void onResponse(Call call, Response response) { if (response.isSuccessful()) { System.out.println("success"); + response_changePw_LiveData.setValue(204); + //成功処理 } else { System.out.println("fail"); + response_changePw_LiveData.setValue(404); } } @Override public void onFailure(Call call, Throwable t) { System.out.println("NetWorkError"+t); + response_changePw_LiveData.setValue(404); } }); } @@ -82,9 +97,11 @@ if(response.isSuccessful()){ System.out.println("success"); //成功処理 + response_deleteAccount_LiveData.setValue(204); }else{ System.out.println("fail"); //もしコンソール表記をするならこの下に処理を記載 + response_deleteAccount_LiveData.setValue(404); } } @@ -92,6 +109,7 @@ public void onFailure(Call call, Throwable t) { System.out.println("NetWorkError"+t); //もしコンソール表記をするならこの下に処理を記載 + response_deleteAccount_LiveData.setValue(404); } }); } @@ -139,4 +157,5 @@ }); } + }