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