Commit 8b300f0d authored by Gabriele M's avatar Gabriele M

Prevent null pointer exceptions

The main activity connects to the service after setting up the local
broadcast. This allows the service to send notification before the
activity is ready, causing null pointer exceptions. This happens for
example rotating the screen while an update is being installed.

Also, replace the existing check on mUpdaterController with a check
on mDownloadsId since the latter depends on the former and both are
required.

Change-Id: I620fd7aa1e90468ab40dfedaa06c23f96f3e6807
parent 4f7db45f
......@@ -204,7 +204,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
@Override
public void onBindViewHolder(final ViewHolder viewHolder, int i) {
if (mUpdaterController == null) {
if (mDownloadIds == null) {
viewHolder.mAction.setEnabled(false);
return;
}
......@@ -260,10 +260,16 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
}
public void notifyItemChanged(String downloadId) {
if (mDownloadIds == null) {
return;
}
notifyItemChanged(mDownloadIds.indexOf(downloadId));
}
public void removeItem(String downloadId) {
if (mDownloadIds == null) {
return;
}
int position = mDownloadIds.indexOf(downloadId);
mDownloadIds.remove(downloadId);
notifyItemRemoved(position);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment