Correctly re-initialize loaders in updates screen.

There used to be a single loader which would get all apps which have
updates available. This was restarted when we were notified about new
apps requiring updates.

Then, in 7424220 I introduced a second loader responsible for getting
apps with known vulnerabilities. This change caused the bug in #1203,
because it changed the loaders from a single loader with ID = 0, to two
different loaders with arbitrary IDs. However, there was still a line of
code responding to when repo updates completed and we learn about new
updateable apps, and this was asking for a loader with an ID of 0 like
before. This crashed when the loader was completed and we tried to pase
the results.

This is fixed ensuring that both loaders are restarted upon learning of
new updateable apps. To prevent this disconnect in the future, they are
also extracted into the same method.
This commit is contained in:
Peter Serwylo 2017-11-30 08:09:55 +11:00
parent 810533cb1f
commit 50b4aac263

View File

@ -89,8 +89,7 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
.addDelegate(new UpdateableAppsHeader.Delegate(activity)) .addDelegate(new UpdateableAppsHeader.Delegate(activity))
.addDelegate(new KnownVulnApp.Delegate(activity)); .addDelegate(new KnownVulnApp.Delegate(activity));
activity.getSupportLoaderManager().initLoader(LOADER_CAN_UPDATE, null, this); initLoaders();
activity.getSupportLoaderManager().initLoader(LOADER_KNOWN_VULN, null, this);
} }
/** /**
@ -298,7 +297,12 @@ public class UpdatesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
* We need to rerun our database query to get a list of apps to update. * We need to rerun our database query to get a list of apps to update.
*/ */
private void onUpdateableAppsChanged() { private void onUpdateableAppsChanged() {
activity.getSupportLoaderManager().initLoader(0, null, this); initLoaders();
}
private void initLoaders() {
activity.getSupportLoaderManager().initLoader(LOADER_CAN_UPDATE, null, this);
activity.getSupportLoaderManager().initLoader(LOADER_KNOWN_VULN, null, this);
} }
/** /**