Merge branch 'master' into import_export_data

This commit is contained in:
Vitaliy 2020-10-15 17:13:18 +03:00
commit ee1ab5e2eb
11 changed files with 119 additions and 94 deletions

View file

@ -53,7 +53,8 @@
android:icon="@mipmap/icon" android:label="@string/app_name" android:icon="@mipmap/icon" android:label="@string/app_name"
android:name="net.osmand.plus.OsmandApplication" android:configChanges="locale" android:name="net.osmand.plus.OsmandApplication" android:configChanges="locale"
android:theme="@style/OsmandDarkTheme" android:restoreAnyVersion="true" android:largeHeap="true" android:theme="@style/OsmandDarkTheme" android:restoreAnyVersion="true" android:largeHeap="true"
android:supportsRtl="true" android:usesCleartextTraffic="true"> android:supportsRtl="true" android:usesCleartextTraffic="true"
android:hasFragileUserData="true" android:requestLegacyExternalStorage="true">
<meta-data android:name="com.google.android.backup.api_key" android:value="AEdPqrEAAAAIqF3tNGT66etVBn_vgzpfAY1wmIzKV1Ss6Ku-2A" /> <meta-data android:name="com.google.android.backup.api_key" android:value="AEdPqrEAAAAIqF3tNGT66etVBn_vgzpfAY1wmIzKV1Ss6Ku-2A" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />

View file

@ -53,7 +53,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15 minSdkVersion System.getenv("MIN_SDK_VERSION") ? System.getenv("MIN_SDK_VERSION").toInteger() : 15
targetSdkVersion 28 targetSdkVersion 29
versionCode 390 versionCode 390
versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode versionCode System.getenv("APK_NUMBER_VERSION") ? System.getenv("APK_NUMBER_VERSION").toInteger() : versionCode
multiDexEnabled true multiDexEnabled true

View file

@ -3882,7 +3882,7 @@
<string name="disable_recording_once_app_killed_descrp">Остановка записи GPX при принудительном закрытии (через последние приложения). (Из панели уведомлений Android исчезнет значок фонового режима.)</string> <string name="disable_recording_once_app_killed_descrp">Остановка записи GPX при принудительном закрытии (через последние приложения). (Из панели уведомлений Android исчезнет значок фонового режима.)</string>
<string name="shared_string_is_saved">сохранен</string> <string name="shared_string_is_saved">сохранен</string>
<string name="one_point_error">Добавьте хотя бы две точки.</string> <string name="one_point_error">Добавьте хотя бы две точки.</string>
<string name="shared_string_redo">ПОВТОРИТЬ</string> <string name="shared_string_redo">Повторить</string>
<string name="release_3_8">• Обновлённая функция планирования маршрута позволяет применять к сегментам разные режимы навигации и настраивать привязку к дорогам <string name="release_3_8">• Обновлённая функция планирования маршрута позволяет применять к сегментам разные режимы навигации и настраивать привязку к дорогам
\n \n
\n • Новые настройки вида треков: выбор цвета и толщины линии, указатели направления, метки начала и конца маршрута \n • Новые настройки вида треков: выбор цвета и толщины линии, указатели направления, метки начала и конца маршрута
@ -3920,6 +3920,6 @@
<string name="perform_oauth_authorization">Войти через OAuth</string> <string name="perform_oauth_authorization">Войти через OAuth</string>
<string name="clear_osm_token">Очистить токен OAuth OpenStreetMap</string> <string name="clear_osm_token">Очистить токен OAuth OpenStreetMap</string>
<string name="osm_edit_logout_success">Выход выполнен</string> <string name="osm_edit_logout_success">Выход выполнен</string>
<string name="shared_string_graph">»в 997777777:66666776666</string> <string name="shared_string_graph">График</string>
<string name="file_already_imported">Файл уже импортирован</string> <string name="file_already_imported">Файл уже импортирован</string>
</resources> </resources>

View file

@ -46,7 +46,6 @@ import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.search.QuickSearchDialogFragment; import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.settings.backend.OsmandPreference;
import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment;
@ -499,6 +498,9 @@ public abstract class OsmandPlugin {
public void mapActivityResume(MapActivity activity) { public void mapActivityResume(MapActivity activity) {
} }
public void mapActivityResumeOnTop(MapActivity activity) {
}
public void mapActivityPause(MapActivity activity) { public void mapActivityPause(MapActivity activity) {
} }
@ -752,6 +754,12 @@ public abstract class OsmandPlugin {
} }
} }
public static void onMapActivityResumeOnTop(MapActivity activity) {
for (OsmandPlugin plugin : getEnabledPlugins()) {
plugin.mapActivityResumeOnTop(activity);
}
}
public static void onMapActivityPause(MapActivity activity) { public static void onMapActivityPause(MapActivity activity) {
for (OsmandPlugin plugin : getEnabledPlugins()) { for (OsmandPlugin plugin : getEnabledPlugins()) {
plugin.mapActivityPause(activity); plugin.mapActivityPause(activity);

View file

@ -74,10 +74,6 @@ import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.DayNightHelper;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
@ -88,6 +84,7 @@ import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.base.FailSafeFuntions; import net.osmand.plus.base.FailSafeFuntions;
import net.osmand.plus.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.chooseplan.OsmLiveCancelledDialog; import net.osmand.plus.chooseplan.OsmLiveCancelledDialog;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment; import net.osmand.plus.dialogs.CrashBottomSheetDialogFragment;
import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment;
@ -101,13 +98,14 @@ import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
import net.osmand.plus.firstusage.FirstUsageWelcomeFragment; import net.osmand.plus.firstusage.FirstUsageWelcomeFragment;
import net.osmand.plus.firstusage.FirstUsageWizardFragment; import net.osmand.plus.firstusage.FirstUsageWizardFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.DayNightHelper;
import net.osmand.plus.helpers.DiscountHelper; import net.osmand.plus.helpers.DiscountHelper;
import net.osmand.plus.importfiles.ImportHelper;
import net.osmand.plus.helpers.IntentHelper; import net.osmand.plus.helpers.IntentHelper;
import net.osmand.plus.helpers.LockHelper; import net.osmand.plus.helpers.LockHelper;
import net.osmand.plus.helpers.LockHelper.LockUIAdapter; import net.osmand.plus.helpers.LockHelper.LockUIAdapter;
import net.osmand.plus.helpers.ScrollHelper; import net.osmand.plus.helpers.ScrollHelper;
import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener; import net.osmand.plus.helpers.ScrollHelper.OnScrollEventListener;
import net.osmand.plus.importfiles.ImportHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
@ -133,7 +131,9 @@ import net.osmand.plus.search.QuickSearchDialogFragment;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchTab;
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType; import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.settings.fragments.ConfigureProfileFragment; import net.osmand.plus.settings.fragments.ConfigureProfileFragment;
@ -886,6 +886,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
settings.USE_SYSTEM_SCREEN_TIMEOUT.addListener(useSystemScreenTimeoutListener); settings.USE_SYSTEM_SCREEN_TIMEOUT.addListener(useSystemScreenTimeoutListener);
} }
@Override
public void onTopResumedActivityChanged(boolean isTopResumedActivity) {
if (isTopResumedActivity) {
OsmandPlugin.onMapActivityResumeOnTop(this);
}
}
public void applyScreenOrientation() { public void applyScreenOrientation() {
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());

View file

@ -893,7 +893,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
@Override @Override
public void mapActivityResume(MapActivity activity) { public void mapActivityResumeOnTop(MapActivity activity) {
this.mapActivity = activity; this.mapActivity = activity;
// ((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver( // ((AudioManager) activity.getSystemService(Context.AUDIO_SERVICE)).registerMediaButtonEventReceiver(
// new ComponentName(activity, MediaRemoteControlReceiver.class)); // new ComponentName(activity, MediaRemoteControlReceiver.class));

View file

@ -632,7 +632,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter);
iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
horizontalSelectionAdapter.notifyDataSetChanged(); horizontalSelectionAdapter.notifyDataSetChanged();
iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPosition(selectedIconCategory)); iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
for (String name : iconNameList) { for (String name : iconNameList) {
selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0)); selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0));
} }

View file

@ -110,13 +110,16 @@ public class HorizontalSelectionAdapter extends RecyclerView.Adapter<HorizontalS
return items.size(); return items.size();
} }
public int getItemPosition(String name) { public int getItemPositionByTitle(String title) {
return items.indexOf(name); return getItemPosition(getItemByTitle(title));
} }
public void setSelectedItemByTitle(String selectedItemTitle) { public int getItemPosition(HorizontalSelectionItem item) {
HorizontalSelectionItem selectedItem = getItemByTitle(selectedItemTitle); return items.indexOf(item);
setSelectedItem(selectedItem); }
public void setSelectedItemByTitle(String title) {
setSelectedItem(getItemByTitle(title));
} }
public void setSelectedItem(HorizontalSelectionItem selectedItem) { public void setSelectedItem(HorizontalSelectionItem selectedItem) {

View file

@ -314,71 +314,17 @@ public class MeasurementEditingContext {
} }
public List<RouteSegmentResult> getAllRouteSegments() { public List<RouteSegmentResult> getAllRouteSegments() {
// prepare data for sorting List<RouteSegmentResult> allSegments = new ArrayList<>();
List<TmpRouteSegmentData> fullList = new ArrayList<>(); for (Pair<WptPt, WptPt> key : getOrderedRoadSegmentDataKeys()) {
for (Map.Entry<Pair<WptPt, WptPt>, RoadSegmentData> entry : roadSegmentData.entrySet()) { RoadSegmentData data = roadSegmentData.get(key);
fullList.add(new TmpRouteSegmentData( if (data != null) {
entry.getKey().first, List<RouteSegmentResult> segments = data.getSegments();
entry.getKey().second, if (segments != null) {
entry.getValue().getSegments())); allSegments.addAll(segments);
}
// sorting data by connecting together
while (fullList.size() > 1) {
TmpRouteSegmentData firstInList = fullList.get(0);
for (int i = 1; i < fullList.size(); i++) {
TmpRouteSegmentData other = fullList.get(i);
boolean isMatched = false;
if (firstInList.isAfterOf(other)) {
isMatched = true;
firstInList.joinBefore(other);
} else if (firstInList.isBeforeOf(other)) {
isMatched = true;
firstInList.joinAfter(other);
}
if (isMatched) {
fullList.remove(other);
break;
} }
} }
} }
return fullList.size() > 0 ? fullList.get(0).getRouteSegments() : null; return allSegments.size() > 0 ? allSegments : null;
}
private static class TmpRouteSegmentData {
private WptPt start;
private WptPt end;
private List<RouteSegmentResult> routeSegments;
public TmpRouteSegmentData(WptPt start, WptPt end,
List<RouteSegmentResult> routeSegments) {
this.start = start;
this.end = end;
this.routeSegments = new ArrayList<>(routeSegments);
}
boolean isAfterOf(TmpRouteSegmentData other) {
return Algorithms.objectEquals(this.start, other.end);
}
boolean isBeforeOf(TmpRouteSegmentData other) {
return Algorithms.objectEquals(this.end, other.start);
}
void joinAfter(TmpRouteSegmentData other) {
end = other.end;
routeSegments.addAll(other.routeSegments);
}
void joinBefore(TmpRouteSegmentData other) {
start = other.start;
routeSegments.addAll(0, other.routeSegments);
}
public List<RouteSegmentResult> getRouteSegments() {
return routeSegments;
}
} }
void splitSegments(int position) { void splitSegments(int position) {
@ -501,6 +447,16 @@ public class MeasurementEditingContext {
return res; return res;
} }
private List<Pair<WptPt, WptPt>> getOrderedRoadSegmentDataKeys() {
List<Pair<WptPt, WptPt>> keys = new ArrayList<>();
for (List<WptPt> points : Arrays.asList(before.points, after.points)) {
for (int i = 0; i < points.size() - 1; i++) {
keys.add(new Pair<>(points.get(i), points.get(i + 1)));
}
}
return keys;
}
private void recreateCacheForSnap(TrkSegment cache, TrkSegment original, boolean calculateIfNeeded) { private void recreateCacheForSnap(TrkSegment cache, TrkSegment original, boolean calculateIfNeeded) {
boolean hasDefaultModeOnly = true; boolean hasDefaultModeOnly = true;
if (original.points.size() > 1) { if (original.points.size() > 1) {

View file

@ -18,6 +18,7 @@ import net.osmand.osm.edit.Entity.EntityType;
import net.osmand.osm.edit.EntityInfo; import net.osmand.osm.edit.EntityInfo;
import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way; import net.osmand.osm.edit.Way;
import net.osmand.osm.io.Base64;
import net.osmand.osm.io.NetworkUtils; import net.osmand.osm.io.NetworkUtils;
import net.osmand.osm.io.OsmBaseStorage; import net.osmand.osm.io.OsmBaseStorage;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -30,10 +31,8 @@ import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
import java.io.ByteArrayInputStream; import java.io.*;
import java.io.File; import java.net.HttpURLConnection;
import java.io.IOException;
import java.io.StringWriter;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
@ -108,13 +107,15 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
boolean doAuthenticate) { boolean doAuthenticate) {
log.info("Sending request " + url); //$NON-NLS-1$ log.info("Sending request " + url); //$NON-NLS-1$
try { try {
if (doAuthenticate){
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx); OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx);
if (doAuthenticate) {
if (client.isValidToken()) {
Response response = client.performRequest(url, requestMethod, requestBody); Response response = client.performRequest(url, requestMethod, requestBody);
return response.getBody(); return response.getBody();
} else {
return performBasicAuthRequest(url, requestMethod, requestBody, userOperation);
} }
else { } else {
OsmOAuthAuthorizationAdapter client = new OsmOAuthAuthorizationAdapter(ctx);
Response response = client.performRequestWithoutAuth(url, requestMethod, requestBody); Response response = client.performRequestWithoutAuth(url, requestMethod, requestBody);
return response.getBody(); return response.getBody();
} }
@ -135,7 +136,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$ log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$
showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template) showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template)
+ ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation)); + ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation));
} catch (ExecutionException e) { } catch (Exception e) {
log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$ log.error(userOperation + " " + ctx.getString(R.string.failed_op), e); //$NON-NLS-1$
showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template) showWarning(MessageFormat.format(ctx.getResources().getString(R.string.shared_string_action_template)
+ ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation)); + ": " + ctx.getResources().getString(R.string.shared_string_unexpected_error), userOperation));
@ -144,6 +145,55 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
return null; return null;
} }
private String performBasicAuthRequest(String url, String requestMethod, String requestBody, String userOperation) throws IOException {
HttpURLConnection connection = NetworkUtils.getHttpURLConnection(url);
connection.setConnectTimeout(15000);
connection.setRequestMethod(requestMethod);
connection.setRequestProperty("User-Agent", Version.getFullVersion(ctx)); //$NON-NLS-1$
StringBuilder responseBody = new StringBuilder();
String token = settings.USER_NAME.get() + ":" + settings.USER_PASSWORD.get(); //$NON-NLS-1$
connection.addRequestProperty("Authorization", "Basic " + Base64.encode(token.getBytes("UTF-8"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
connection.setDoInput(true);
if (requestMethod.equals("PUT") || requestMethod.equals("POST") || requestMethod.equals("DELETE")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
connection.setDoOutput(true);
connection.setRequestProperty("Content-type", "text/xml"); //$NON-NLS-1$ //$NON-NLS-2$
OutputStream out = connection.getOutputStream();
if (requestBody != null) {
BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8"), 1024); //$NON-NLS-1$
bwr.write(requestBody);
bwr.flush();
}
out.close();
}
connection.connect();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
String msg = userOperation
+ " " + ctx.getString(R.string.failed_op) + " : " + connection.getResponseMessage(); //$NON-NLS-1$//$NON-NLS-2$
log.error(msg);
showWarning(msg);
} else {
log.info("Response : " + connection.getResponseMessage()); //$NON-NLS-1$
// populate return fields.
responseBody.setLength(0);
InputStream i = connection.getInputStream();
if (i != null) {
BufferedReader in = new BufferedReader(new InputStreamReader(i, "UTF-8"), 256); //$NON-NLS-1$
String s;
boolean f = true;
while ((s = in.readLine()) != null) {
if (!f) {
responseBody.append("\n"); //$NON-NLS-1$
} else {
f = false;
}
responseBody.append(s);
}
}
return responseBody.toString();
}
return null;
}
public long openChangeSet(String comment) { public long openChangeSet(String comment) {
long id = -1; long id = -1;
StringWriter writer = new StringWriter(256); StringWriter writer = new StringWriter(256);

View file

@ -122,7 +122,7 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
} }
selectedItem = preference.getEntryFromValue(String.valueOf(currentValue)); selectedItem = preference.getEntryFromValue(String.valueOf(currentValue));
adapter.setSelectedItemByTitle(selectedItem); adapter.setSelectedItemByTitle(selectedItem);
int itemPosition = adapter.getItemPosition(selectedItem); int itemPosition = adapter.getItemPositionByTitle(selectedItem);
if (itemPosition >= 0) { if (itemPosition >= 0) {
recyclerView.smoothScrollToPosition(itemPosition); recyclerView.smoothScrollToPosition(itemPosition);
} }