Handle icon 404s without crashing. Resume settings without crashing on API > 17.

The image loading code for the app cards was presuming that the icon
returned did indeed exist. In this case, it crashed due to trying to
decode a `null` image.

I noticed that when returning to the settings fragment (e.g. by closing
then reopening F-Droid while viewing), it will attempt to re-remove the
priviledged preference. This causes a crash, so we check to see that we
still have the preference before deciding to remove it.
This commit is contained in:
Peter Serwylo 2017-03-08 13:04:51 +11:00
parent 517321356d
commit 5aa44a4d74
2 changed files with 4 additions and 2 deletions

View File

@ -150,7 +150,7 @@ public class AppCardController extends RecyclerView.ViewHolder implements ImageL
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (featuredImage != null) {
if (featuredImage != null && loadedImage != null) {
new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {

View File

@ -227,7 +227,9 @@ public class PreferencesFragment extends PreferenceFragment
// way to easily install from here.
if (Build.VERSION.SDK_INT > 19 && !installed) {
PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
other.removePreference(pref);
if (pref != null) {
other.removePreference(pref);
}
} else {
pref.setEnabled(installed);
pref.setDefaultValue(installed);