diff --git a/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java b/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java index 300fbe7..207f837 100644 --- a/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java +++ b/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java @@ -7,6 +7,7 @@ import com.example.nemophila.entities.Account; import com.example.nemophila.entities.AccountJson; import com.example.nemophila.entities.AccountNameJson; +import com.example.nemophila.entities.ErrorType; import com.example.nemophila.entities.Post; import com.example.nemophila.entities.PostJson; import com.example.nemophila.resources.AccountsRest; @@ -35,6 +36,7 @@ private final MutableLiveData> accountPostsLiveData; private final MutableLiveData pwErrorLiveData; private final MutableLiveData accountLiveData; + private final MutableLiveData errorLiveData; // コンストラクタ public AccountViewModel() { @@ -48,6 +50,7 @@ this.accountPostsLiveData = new MutableLiveData<>(); this.pwErrorLiveData = new MutableLiveData<>(); this.accountLiveData = new MutableLiveData<>(); + this.errorLiveData = new MutableLiveData<>(); } // ライブデータの取得(ゲッター) @@ -64,6 +67,9 @@ public MutableLiveData getAccountLiveData() { return accountLiveData; } + public MutableLiveData getErrorLiveData() { + return errorLiveData; + } // 対象のアカウント情報の削除 public void deleteAccount(String uid, String token) { @@ -242,4 +248,17 @@ } accountPostsLiveData.setValue(preData); } + + private String parseStatusCode(Integer stats) { + switch (stats) { + case 404: + return ErrorType.ResponseNoyFound.getText(); + case 401: + return ErrorType.InvalidToken.getText(); + case 400: + return ErrorType.ResponseError.getText(); + default: + return ErrorType.UnknownError.getText(); + } + } }