From da4aaa5aa155ed319a29ae633244a5050205e988 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Thu, 6 Feb 2014 20:10:21 +0100 Subject: [PATCH] Recovered sendStickyBroadcast instead of LocalBroadcastManager#sendbroadcast; events were lost on screen rotations --- owncloud-android-library | 2 +- .../operations/SynchronizeFolderOperation.java | 6 +++--- .../owncloud/android/services/OperationsService.java | 12 +++++++----- .../android/syncadapter/FileSyncAdapter.java | 6 +++--- .../android/ui/activity/FileDisplayActivity.java | 12 ++++++------ 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/owncloud-android-library b/owncloud-android-library index 858d5f1064..546c19829c 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 858d5f106468ab2b78ee8f3ec6eeb8b00e8ff9a5 +Subproject commit 546c19829c4139a95996faef619424b96347b15a diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index a597c8ea4e..bf2a4e08a0 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -33,7 +33,7 @@ import org.apache.http.HttpStatus; import android.accounts.Account; import android.content.Context; 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.OCFile; @@ -512,8 +512,8 @@ public class SynchronizeFolderOperation extends RemoteOperation { intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath); } intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); - //mContext.sendStickyBroadcast(intent); - LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); + mContext.sendStickyBroadcast(intent); + //LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); } diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 80149f6311..919bedb3aa 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -42,7 +42,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Process; -import android.support.v4.content.LocalBroadcastManager; +//import android.support.v4.content.LocalBroadcastManager; import android.util.Pair; public class OperationsService extends Service { @@ -262,8 +262,9 @@ public class OperationsService extends Service { } else { intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl); } - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); - lbm.sendBroadcast(intent); + //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); + //lbm.sendBroadcast(intent); + sendStickyBroadcast(intent); } @@ -286,8 +287,9 @@ public class OperationsService extends Service { } else { intent.putExtra(EXTRA_SERVER_URL, target.mServerUrl); } - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); - lbm.sendBroadcast(intent); + //LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); + //lbm.sendBroadcast(intent); + sendStickyBroadcast(intent); } diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java index 83ed2bed37..c550eaa813 100644 --- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -51,7 +51,7 @@ import android.content.Context; import android.content.Intent; import android.content.SyncResult; import android.os.Bundle; -import android.support.v4.content.LocalBroadcastManager; +//import android.support.v4.content.LocalBroadcastManager; /** * Implementation of {@link AbstractThreadedSyncAdapter} responsible for synchronizing @@ -368,8 +368,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { if (result != null) { intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result); } - //getContext().sendStickyBroadcast(i); - LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); + getContext().sendStickyBroadcast(intent); + //LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 9d10a55699..4fc1aed657 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -43,7 +43,7 @@ import android.preference.PreferenceManager; import android.provider.MediaStore; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; -import android.support.v4.content.LocalBroadcastManager; +//import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import android.view.View; 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_SHARES_SYNCED); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); - //registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); - LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); // Listen for upload messages IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage()); @@ -708,8 +708,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa super.onPause(); Log_OC.e(TAG, "onPause() start"); if (mSyncBroadcastReceiver != null) { - //unregisterReceiver(mSyncBroadcastReceiver); - LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); + unregisterReceiver(mSyncBroadcastReceiver); + //LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver); mSyncBroadcastReceiver = null; } if (mUploadFinishReceiver != null) { @@ -947,7 +947,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa */ } - //removeStickyBroadcast(intent); + removeStickyBroadcast(intent); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); }