This commit is contained in:
veliymolfar 2020-03-02 17:22:00 +02:00
parent 3a869940b2
commit ec6386628c
2 changed files with 21 additions and 9 deletions

View file

@ -1971,7 +1971,7 @@ public class SettingsHelper {
return checkDuplicatesTask != null ? checkDuplicatesTask.getDuplicates() : null;
}
public void setImportedItems(List<SettingsItem> importedItems) {
public void setImportedItems(@Nullable List<SettingsItem> importedItems) {
this.importedItems = importedItems;
}

View file

@ -38,16 +38,21 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.data.LatLon;
import net.osmand.plus.views.DirectionDrawable;
import net.osmand.plus.widgets.TextViewEx;
import org.apache.commons.logging.Log;
import java.util.Locale;
import gnu.trove.map.hash.TLongObjectHashMap;
public class UiUtilities {
private static final Log LOG = PlatformUtil.getLog(UiUtilities.class);
private TLongObjectHashMap<Drawable> drawableCache = new TLongObjectHashMap<>();
private OsmandApplication app;
private static final int ORIENTATION_0 = 0;
@ -564,14 +569,21 @@ public class UiUtilities {
}
}
public static SpannableString createSpannableString(String text, String textToStyle, StyleSpan styleSpan) {
int startIndex = text.indexOf(textToStyle);
public static SpannableString createSpannableString(@NonNull String text,
@NonNull String textToStyle,
@NonNull StyleSpan styleSpan) {
SpannableString spannable = new SpannableString(text);
spannable.setSpan(
styleSpan,
startIndex,
startIndex + textToStyle.length(),
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
try {
int startIndex = text.indexOf(textToStyle);
spannable.setSpan(
styleSpan,
startIndex,
startIndex + textToStyle.length(),
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
} catch (RuntimeException e) {
LOG.error("Error trying to find index of " + textToStyle + " " + e);
return spannable;
}
}
}