Fix possible npe

This commit is contained in:
Vitaliy 2020-09-15 18:09:50 +03:00
parent bf59a702e5
commit f543d40b1a
2 changed files with 12 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import android.graphics.BitmapFactory;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import net.osmand.GPXUtilities.WptPt; import net.osmand.GPXUtilities.WptPt;
@ -89,6 +90,7 @@ public class FavouritePoint implements Serializable, LocationPoint {
return color; return color;
} }
@Nullable
public String getAddress() { public String getAddress() {
return address; return address;
} }

View file

@ -28,6 +28,7 @@ import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragmentNew;
import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
import net.osmand.view.GravityDrawable; import net.osmand.view.GravityDrawable;
@ -160,11 +161,16 @@ public class FavouritePointMenuController extends MenuController {
@NonNull @NonNull
@Override @Override
public CharSequence getSubtypeStr() { public CharSequence getSubtypeStr() {
Typeface typeface = FontCache.getRobotoRegular(getMapActivity()); MapActivity mapActivity = getMapActivity();
SpannableString addressSpannable = new SpannableString(fav.getAddress()); if (mapActivity != null && !Algorithms.isEmpty(fav.getAddress())) {
addressSpannable.setSpan(new CustomTypefaceSpan(typeface), 0, addressSpannable.length(), 0); Typeface typeface = FontCache.getRobotoRegular(mapActivity);
SpannableString addressSpannable = new SpannableString(fav.getAddress());
addressSpannable.setSpan(new CustomTypefaceSpan(typeface), 0, addressSpannable.length(), 0);
return addressSpannable; return addressSpannable;
} else {
return "";
}
} }
@Override @Override