Correctly unregister receiver in "connecting" swap view (Fixes #409)
Previously the receiver was added but never removed. The result is that once a swap session is cancelled, the receiver still gets broadcasts. This is what was causing the bug in #409. It was trying to access the `Activity` once it had been closed, and another swap session started with a new activity.
This commit is contained in:
parent
b19861226a
commit
c29aff2167
@ -61,13 +61,24 @@ public class SwapConnecting extends LinearLayout implements SwapWorkflowActivity
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Unregister correctly, not just when being notified of completion or errors.
|
||||
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
|
||||
repoUpdateReceiver, new IntentFilter(UpdateService.LOCAL_ACTION_STATUS));
|
||||
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
|
||||
prepareSwapReceiver, new IntentFilter(SwapWorkflowActivity.PrepareSwapRepo.ACTION));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove relevant listeners/receivers/etc so that they do not receive and process events
|
||||
* when this view is not in use.
|
||||
*/
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(repoUpdateReceiver);
|
||||
LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(prepareSwapReceiver);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver repoUpdateReceiver = new ConnectSwapReceiver();
|
||||
private final BroadcastReceiver prepareSwapReceiver = new PrepareSwapReceiver();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user