Improved background and foreground connections

This commit is contained in:
Pierre HUBERT 2018-08-28 10:19:05 +02:00
parent e92201b51d
commit ee86c0c6e7

View File

@ -1,7 +1,6 @@
package org.communiquons.android.comunic.client.ui.fragments;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
@ -396,8 +395,7 @@ public class ConversationFragment extends Fragment
public void onDestroy() {
super.onDestroy();
if(mDeleteMessageAsyncTask != null)
mDeleteMessageAsyncTask.setOnPostExecuteListener(null);
unsetPendingDeleteTasksCallback();
}
@Override
@ -433,6 +431,10 @@ public class ConversationFragment extends Fragment
@Override
public void onLoadError() {
if(getActivity() == null)
return;
//Display a toast
Toast.makeText(getActivity(), R.string.fragment_conversation_err_load_message,
Toast.LENGTH_SHORT).show();
@ -814,6 +816,8 @@ public class ConversationFragment extends Fragment
* @param pos The position of the message to delete
*/
private void deleteConversationMessage(final int pos){
unsetPendingDeleteTasksCallback();
mDeleteMessageAsyncTask = new DeleteConversationMessageTask(getActivity());
mDeleteMessageAsyncTask.setOnPostExecuteListener(new SafeAsyncTask.OnPostExecuteListener<Boolean>() {
@Override
@ -827,6 +831,14 @@ public class ConversationFragment extends Fragment
messagesList.get(pos).getId());
}
/**
* Unset any conversation message delete pending tasks
*/
private void unsetPendingDeleteTasksCallback(){
if(mDeleteMessageAsyncTask != null)
mDeleteMessageAsyncTask.setOnPostExecuteListener(null);
}
/**
* Delete conversation message callback
*