Display error in case of failure while deleting conversation

This commit is contained in:
Pierre 2017-12-31 14:13:39 +01:00
parent 2c29b49c24
commit c180bf3a3f

View File

@ -375,17 +375,22 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
* @param convID The ID of the conversation to delete * @param convID The ID of the conversation to delete
*/ */
private void delete_conversation(final int convID){ private void delete_conversation(final int convID){
new AsyncTask<Void, Void, Void>(){ new AsyncTask<Void, Void, Boolean>(){
@Override @Override
protected Void doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
conversationsListHelper.delete(convID); return conversationsListHelper.delete(convID);
return null;
} }
@Override @Override
protected void onPostExecute(Void aVoid) { protected void onPostExecute(Boolean result) {
refresh_conversations_list(); 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); }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }