Fix crash on invalid icon name

pull/2984/head
Alex Baker 2 months ago
parent 40ec1d86f7
commit 25557579f9

@ -16,6 +16,7 @@ import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.IIcon;
import org.tasks.R; import org.tasks.R;
import org.tasks.billing.Inventory; import org.tasks.billing.Inventory;
@ -26,6 +27,7 @@ import org.tasks.filters.PlaceFilter;
import org.tasks.icons.OutlinedGoogleMaterial; import org.tasks.icons.OutlinedGoogleMaterial;
import org.tasks.location.LocationPickerAdapter.PlaceViewHolder; import org.tasks.location.LocationPickerAdapter.PlaceViewHolder;
import org.tasks.themes.ColorProvider; import org.tasks.themes.ColorProvider;
import org.tasks.themes.TasksIcons;
import org.tasks.themes.ThemeColor; import org.tasks.themes.ThemeColor;
public class LocationPickerAdapter extends ListAdapter<PlaceUsage, PlaceViewHolder> { public class LocationPickerAdapter extends ListAdapter<PlaceUsage, PlaceViewHolder> {
@ -109,10 +111,13 @@ public class LocationPickerAdapter extends ListAdapter<PlaceUsage, PlaceViewHold
place = placeUsage.place; place = placeUsage.place;
String name = place.getDisplayName(); String name = place.getDisplayName();
String address = place.getDisplayAddress(); String address = place.getDisplayAddress();
Drawable drawable = new IconicsDrawable( IIcon iconicsIcon;
context, try {
OutlinedGoogleMaterial.INSTANCE.getIcon("gmo_" + icon) iconicsIcon = OutlinedGoogleMaterial.INSTANCE.getIcon("gmo_" + icon);
).mutate(); } catch (Exception e) {
iconicsIcon = OutlinedGoogleMaterial.INSTANCE.getIcon("gmo_" + TasksIcons.PLACE);
}
Drawable drawable = new IconicsDrawable(context, iconicsIcon).mutate();
this.icon.setImageDrawable(drawable); this.icon.setImageDrawable(drawable);
this.icon.getDrawable().setTint(color); this.icon.getDrawable().setTint(color);
this.name.setText(name); this.name.setText(name);

Loading…
Cancel
Save