mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
Fixed crash due to lifecycle of registered SyncBroadcastReceiver
This commit is contained in:
parent
3ce879be24
commit
5707fce666
1 changed files with 15 additions and 8 deletions
|
@ -179,6 +179,13 @@ public class Uploader extends FileActivity
|
|||
if (mAccountSelected) {
|
||||
setAccount((Account) savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
|
||||
}
|
||||
|
||||
// Listen for sync messages
|
||||
IntentFilter syncIntentFilter = new IntentFilter(RefreshFolderOperation.
|
||||
EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
|
||||
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
|
||||
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
|
||||
registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,13 +210,6 @@ public class Uploader extends FileActivity
|
|||
showDialog(DIALOG_NO_STREAM);
|
||||
}
|
||||
|
||||
// Listen for sync messages
|
||||
IntentFilter syncIntentFilter = new IntentFilter(RefreshFolderOperation.
|
||||
EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
|
||||
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
|
||||
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
|
||||
registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
|
||||
|
||||
super.setAccount(account, savedAccount);
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,14 @@ public class Uploader extends FileActivity
|
|||
Log_OC.d(TAG, "onSaveInstanceState() end");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy(){
|
||||
if (mSyncBroadcastReceiver != null) {
|
||||
unregisterReceiver(mSyncBroadcastReceiver);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(final int id) {
|
||||
final AlertDialog.Builder builder = new Builder(this);
|
||||
|
@ -357,7 +365,6 @@ public class Uploader extends FileActivity
|
|||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mParents.size() <= 1) {
|
||||
unregisterReceiver(mSyncBroadcastReceiver);
|
||||
super.onBackPressed();
|
||||
return;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue