Skip to content

Commit

Permalink
Workaround for 'IllegalArgumentException: Receiver not registered' in…
Browse files Browse the repository at this point in the history
… blocks list.
  • Loading branch information
schildbach committed Oct 13, 2014
1 parent 6baae4b commit 581182e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions wallet/src/de/schildbach/wallet/ui/BlockListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,36 @@ public void onCreate(final Bundle savedInstanceState)
setListAdapter(adapter);
}

private boolean resumed = false;

@Override
public void onResume()
{
super.onResume();

activity.registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));

loaderManager.initLoader(ID_TRANSACTION_LOADER, null, transactionLoaderCallbacks);

adapter.notifyDataSetChanged();

resumed = true;
}

@Override
public void onPause()
{
loaderManager.destroyLoader(ID_TRANSACTION_LOADER);
// workaround: under high load, it can happen that onPause() is called twice (recursively via destroyLoader)
if (resumed)
{
loaderManager.destroyLoader(ID_TRANSACTION_LOADER);
activity.unregisterReceiver(tickReceiver);

activity.unregisterReceiver(tickReceiver);
resumed = false;
}
else
{
log.warn("onPause() called without onResume(), appending stack trace", new RuntimeException());
}

super.onPause();
}
Expand Down

0 comments on commit 581182e

Please sign in to comment.