Merge branch '714-asynchronous-context-leaks' into 'master'

Fixed asynchronous Activity leaks in Fragments

If a Fragment has been detached its `getActivity()` method will return null, providing numerous crash possibilities within the app.

My approach to fixing this is to make Fragments use their own `runOnUiThreadUnlessDestroyed` method, which also checks if the Fragment has been detached before running the Runnable

Closes #714

See merge request !387
This commit is contained in:
akwizgran
2016-11-08 11:49:45 +00:00
12 changed files with 54 additions and 39 deletions

View File

@@ -126,7 +126,7 @@ public class GroupListFragment extends BaseFragment implements
@Override
public void onGroupRemoveClick(GroupItem item) {
controller.removeGroup(item.getId(),
new UiResultExceptionHandler<Void, DbException>(listener) {
new UiResultExceptionHandler<Void, DbException>(this) {
@Override
public void onResultUi(Void result) {
// handled by GroupRemovedEvent and onGroupRemoved()
@@ -173,7 +173,7 @@ public class GroupListFragment extends BaseFragment implements
final int revision = adapter.getRevision();
controller.loadGroups(
new UiResultExceptionHandler<Collection<GroupItem>, DbException>(
listener) {
this) {
@Override
public void onResultUi(Collection<GroupItem> groups) {
if (revision == adapter.getRevision()) {