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 601c705..300fbe7 100644 --- a/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java +++ b/app/src/main/java/com/example/nemophila/viewmodels/AccountViewModel.java @@ -6,6 +6,7 @@ import com.example.nemophila.R; import com.example.nemophila.entities.Account; import com.example.nemophila.entities.AccountJson; +import com.example.nemophila.entities.AccountNameJson; import com.example.nemophila.entities.Post; import com.example.nemophila.entities.PostJson; import com.example.nemophila.resources.AccountsRest; @@ -218,6 +219,7 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { + deleteAccountPostLiveData(pid); System.out.println("successful"); } else { System.out.println("response error"); @@ -229,4 +231,15 @@ } }); } + + private void deleteAccountPostLiveData(String id) { + ArrayList preData = new ArrayList<>(); + for (Post post: accountPostsLiveData.getValue()) { + if (post.getPid().equals(id)) { + continue; + } + preData.add(post); + } + accountPostsLiveData.setValue(preData); + } }