From c180bf3a3f19d2b72c6088b5924b0701c42a4ace Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 31 Dec 2017 14:13:39 +0100 Subject: [PATCH] Display error in case of failure while deleting conversation --- .../fragments/ConversationsListFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java index 618075a..1d99f51 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java @@ -375,17 +375,22 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O * @param convID The ID of the conversation to delete */ private void delete_conversation(final int convID){ - new AsyncTask(){ + new AsyncTask(){ @Override - protected Void doInBackground(Void... params) { - conversationsListHelper.delete(convID); - return null; + protected Boolean doInBackground(Void... params) { + return conversationsListHelper.delete(convID); } @Override - protected void onPostExecute(Void aVoid) { + protected void onPostExecute(Boolean result) { refresh_conversations_list(); + + //Display a toast if an error occurred + if(!result) + Toast.makeText(getActivity(), + R.string.fragment_conversationslist_err_del_conversation, + Toast.LENGTH_SHORT).show(); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }