Recovered sendStickyBroadcast instead of LocalBroadcastManager#sendbroadcast; events were lost on screen rotations

This commit is contained in:
David A. Velasco 2014-02-06 20:10:21 +01:00
parent 533924f538
commit da4aaa5aa1
5 changed files with 20 additions and 18 deletions

@ -1 +1 @@
Subproject commit 858d5f106468ab2b78ee8f3ec6eeb8b00e8ff9a5 Subproject commit 546c19829c4139a95996faef619424b96347b15a

View file

@ -33,7 +33,7 @@ import org.apache.http.HttpStatus;
import android.accounts.Account; import android.accounts.Account;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager; //import android.support.v4.content.LocalBroadcastManager;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
@ -512,8 +512,8 @@ public class SynchronizeFolderOperation extends RemoteOperation {
intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath); intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath);
} }
intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result);
//mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); //LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} }

View file

@ -42,7 +42,7 @@ import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.Process; import android.os.Process;
import android.support.v4.content.LocalBroadcastManager; //import android.support.v4.content.LocalBroadcastManager;
import android.util.Pair; import android.util.Pair;
public class OperationsService extends Service { public class OperationsService extends Service {
@ -262,8 +262,9 @@ public class OperationsService extends Service {
} else { } else {
intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl); intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl);
} }
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.sendBroadcast(intent); //lbm.sendBroadcast(intent);
sendStickyBroadcast(intent);
} }
@ -286,8 +287,9 @@ public class OperationsService extends Service {
} else { } else {
intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl); intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl);
} }
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
lbm.sendBroadcast(intent); //lbm.sendBroadcast(intent);
sendStickyBroadcast(intent);
} }

View file

@ -51,7 +51,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SyncResult; import android.content.SyncResult;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager; //import android.support.v4.content.LocalBroadcastManager;
/** /**
* Implementation of {@link AbstractThreadedSyncAdapter} responsible for synchronizing * Implementation of {@link AbstractThreadedSyncAdapter} responsible for synchronizing
@ -368,8 +368,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
if (result != null) { if (result != null) {
intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result);
} }
//getContext().sendStickyBroadcast(i); getContext().sendStickyBroadcast(intent);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); //LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
} }

View file

@ -43,7 +43,7 @@ import android.preference.PreferenceManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager; //import android.support.v4.content.LocalBroadcastManager;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -677,8 +677,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED); syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED); syncIntentFilter.addAction(SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
mSyncBroadcastReceiver = new SyncBroadcastReceiver(); mSyncBroadcastReceiver = new SyncBroadcastReceiver();
//registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
// Listen for upload messages // Listen for upload messages
IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage()); IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
@ -708,8 +708,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
super.onPause(); super.onPause();
Log_OC.e(TAG, "onPause() start"); Log_OC.e(TAG, "onPause() start");
if (mSyncBroadcastReceiver != null) { if (mSyncBroadcastReceiver != null) {
//unregisterReceiver(mSyncBroadcastReceiver); unregisterReceiver(mSyncBroadcastReceiver);
LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); //LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver);
mSyncBroadcastReceiver = null; mSyncBroadcastReceiver = null;
} }
if (mUploadFinishReceiver != null) { if (mUploadFinishReceiver != null) {
@ -947,7 +947,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
*/ */
} }
//removeStickyBroadcast(intent); removeStickyBroadcast(intent);
setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
} }