forked from organicmaps/organicmaps
[types_strings] review fixes
This commit is contained in:
parent
a7681b5eb9
commit
c85aa17a61
8 changed files with 27 additions and 21 deletions
|
@ -369,9 +369,7 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
|
|||
private MapObject createMapObject(@NonNull Items.SearchItem item)
|
||||
{
|
||||
String featureType = item.getFeatureType();
|
||||
String subtitle = TextUtils.isEmpty(featureType)
|
||||
? ""
|
||||
: Utils.getLocalizedFeatureType(getContext(), featureType);
|
||||
String subtitle = Utils.getLocalizedFeatureType(getContext(), featureType);
|
||||
|
||||
String title = TextUtils.isEmpty(item.getTitle()) ? subtitle : item.getTitle();
|
||||
|
||||
|
|
|
@ -140,9 +140,10 @@ public final class Editor
|
|||
public static native boolean nativeSaveEditedFeature();
|
||||
|
||||
@NonNull
|
||||
public static native String[] nativeGetAllCreatableFeatureTypes(String lang);
|
||||
public static native String[] nativeGetAllCreatableFeatureTypes(@NonNull String lang);
|
||||
@NonNull
|
||||
public static native String[] nativeSearchCreatableFeatureTypes(String query, String lang);
|
||||
public static native String[] nativeSearchCreatableFeatureTypes(@NonNull String query,
|
||||
@NonNull String lang);
|
||||
|
||||
/**
|
||||
* Creates new object on the map. Places it in the center of current viewport.
|
||||
|
@ -153,7 +154,7 @@ public final class Editor
|
|||
{
|
||||
nativeCreateMapObject(category.getType());
|
||||
}
|
||||
public static native void nativeCreateMapObject(String type);
|
||||
public static native void nativeCreateMapObject(@NonNull String type);
|
||||
public static native void nativeCreateNote(String text);
|
||||
public static native void nativePlaceDoesNotExist(@NonNull String comment);
|
||||
public static native void nativeRollbackMapObject();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FeatureCategoryFragment extends BaseMwmRecyclerFragment<FeatureCate
|
|||
? Editor.nativeGetAllCreatableFeatureTypes(locale)
|
||||
: Editor.nativeSearchCreatableFeatureTypes(query, locale);
|
||||
|
||||
FeatureCategory[] categories = MakeFeatureCategoriesFromTypes(creatableTypes);
|
||||
FeatureCategory[] categories = makeFeatureCategoriesFromTypes(creatableTypes);
|
||||
|
||||
getAdapter().setCategories(categories);
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ public class FeatureCategoryFragment extends BaseMwmRecyclerFragment<FeatureCate
|
|||
String locale = Language.getDefaultLocale();
|
||||
String[] creatableTypes = Editor.nativeGetAllCreatableFeatureTypes(locale);
|
||||
|
||||
FeatureCategory[] categories = MakeFeatureCategoriesFromTypes(creatableTypes);
|
||||
FeatureCategory[] categories = makeFeatureCategoriesFromTypes(creatableTypes);
|
||||
|
||||
return new FeatureCategoryAdapter(this, categories, mSelectedCategory);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private FeatureCategory[] MakeFeatureCategoriesFromTypes(@NonNull String[] creatableTypes)
|
||||
private FeatureCategory[] makeFeatureCategoriesFromTypes(@NonNull String[] creatableTypes)
|
||||
{
|
||||
FeatureCategory[] categories = new FeatureCategory[creatableTypes.length];
|
||||
|
||||
|
|
|
@ -249,9 +249,7 @@ public class Holders
|
|||
super.bind(item);
|
||||
|
||||
String featureType = item.getFeatureType();
|
||||
String localizedType = TextUtils.isEmpty(featureType)
|
||||
? ""
|
||||
: Utils.getLocalizedFeatureType(mSubtitle.getContext(), featureType);
|
||||
String localizedType = Utils.getLocalizedFeatureType(mSubtitle.getContext(), featureType);
|
||||
String title = TextUtils.isEmpty(item.getTitle()) ? localizedType : item.getTitle();
|
||||
|
||||
UiUtils.setTextAndHideIfEmpty(mTitle, title);
|
||||
|
@ -290,9 +288,7 @@ public class Holders
|
|||
public void bind(@NonNull Items.SearchItem item)
|
||||
{
|
||||
String featureType = item.getFeatureType();
|
||||
String localizedType = TextUtils.isEmpty(featureType)
|
||||
? ""
|
||||
: Utils.getLocalizedFeatureType(mSubtitle.getContext(), featureType);
|
||||
String localizedType = Utils.getLocalizedFeatureType(mSubtitle.getContext(), featureType);
|
||||
String title = TextUtils.isEmpty(item.getTitle()) ? localizedType : item.getTitle();
|
||||
|
||||
UiUtils.setTextAndHideIfEmpty(mTitle, title);
|
||||
|
|
|
@ -212,7 +212,6 @@ class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.SearchDataViewHol
|
|||
// FIXME: Better format based on result type
|
||||
private CharSequence formatDescription(SearchResult result, boolean isHotelAvailable)
|
||||
{
|
||||
|
||||
String localizedType = Utils.getLocalizedFeatureType(mFrame.getContext(),
|
||||
result.description.featureType);
|
||||
final SpannableStringBuilder res = new SpannableStringBuilder(localizedType);
|
||||
|
|
|
@ -712,8 +712,12 @@ public class Utils
|
|||
void invoke(@NonNull T param);
|
||||
}
|
||||
|
||||
public static String getLocalizedFeatureType(@NonNull Context context, @NonNull String type)
|
||||
@NonNull
|
||||
public static String getLocalizedFeatureType(@NonNull Context context, @Nullable String type)
|
||||
{
|
||||
if (TextUtils.isEmpty(type))
|
||||
return "";
|
||||
|
||||
String key = "type." + type.replace('-', '.');
|
||||
|
||||
@StringRes
|
||||
|
@ -725,12 +729,15 @@ public class Utils
|
|||
}
|
||||
catch (Resources.NotFoundException e)
|
||||
{
|
||||
LOGGER.e(TAG, "Failed to get localized string for type'" + type + "'", e);
|
||||
LOGGER.e(TAG, "Failed to get localized string for type '" + type + "'", e);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
// Called from JNI.
|
||||
@NonNull
|
||||
@SuppressWarnings("unused")
|
||||
public static String getLocalizedFeatureType(String type)
|
||||
{
|
||||
return getLocalizedFeatureType(MwmApplication.get(), type);
|
||||
|
|
|
@ -46,7 +46,7 @@ void NewFeatureCategories::AddLanguage(string lang)
|
|||
lang = "en";
|
||||
langCode = CategoriesHolder::kEnglishCode;
|
||||
}
|
||||
if (m_addedLangs.find(lang) != m_addedLangs.end())
|
||||
if (m_addedLangs.Contains(langCode))
|
||||
return;
|
||||
|
||||
auto const & c = classif();
|
||||
|
@ -55,7 +55,7 @@ void NewFeatureCategories::AddLanguage(string lang)
|
|||
m_index.AddCategoryByTypeAndLang(c.GetTypeByReadableObjectName(type), langCode);
|
||||
}
|
||||
|
||||
m_addedLangs.insert(lang);
|
||||
m_addedLangs.Insert(langCode);
|
||||
}
|
||||
|
||||
NewFeatureCategories::TypeNames NewFeatureCategories::Search(string const & query) const
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
#include "editor/editor_config.hpp"
|
||||
|
||||
#include "indexer/categories_holder.hpp"
|
||||
#include "indexer/categories_index.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
#include "base/small_set.hpp"
|
||||
|
||||
#include "std/cstdint.hpp"
|
||||
#include "std/string.hpp"
|
||||
|
@ -48,8 +50,11 @@ public:
|
|||
TypeNames const & GetAllCreatableTypeNames() const;
|
||||
|
||||
private:
|
||||
using Langs =
|
||||
base::SmallSet<static_cast<uint64_t>(CategoriesHolder::kMaxSupportedLocaleIndex) + 1>;
|
||||
|
||||
indexer::CategoriesIndex m_index;
|
||||
unordered_set<string> m_addedLangs;
|
||||
Langs m_addedLangs;
|
||||
TypeNames m_types;
|
||||
|
||||
DISALLOW_COPY(NewFeatureCategories);
|
||||
|
|
Loading…
Add table
Reference in a new issue