Fix remarks
This commit is contained in:
parent
0a6d6923c5
commit
e2e0619454
1 changed files with 25 additions and 21 deletions
|
@ -71,6 +71,8 @@ public class AddPOIAction extends QuickAction {
|
||||||
|
|
||||||
private transient EditText title;
|
private transient EditText title;
|
||||||
private transient String prevType = "";
|
private transient String prevType = "";
|
||||||
|
private transient MapPoiTypes poiTypes;
|
||||||
|
private transient Map<String, PoiType> allTranslatedNames;
|
||||||
|
|
||||||
public AddPOIAction() {
|
public AddPOIAction() {
|
||||||
super(TYPE);
|
super(TYPE);
|
||||||
|
@ -80,24 +82,29 @@ public class AddPOIAction extends QuickAction {
|
||||||
super(quickAction);
|
super(quickAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MapPoiTypes getPoiTypes(Context context) {
|
||||||
|
if (poiTypes == null) {
|
||||||
|
final OsmandApplication application = (OsmandApplication) (context).getApplicationContext();
|
||||||
|
poiTypes = application.getPoiTypes();
|
||||||
|
}
|
||||||
|
return poiTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, PoiType> getAllTranslatedNames(Context context) {
|
||||||
|
if (allTranslatedNames == null) {
|
||||||
|
allTranslatedNames = getPoiTypes(context).getAllTranslatedNames(true);
|
||||||
|
}
|
||||||
|
return allTranslatedNames;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconRes(Context context) {
|
public int getIconRes(Context context) {
|
||||||
if (context instanceof MapActivity) {
|
PoiCategory category = getCategory(getAllTranslatedNames(context));
|
||||||
final OsmandApplication application = (OsmandApplication) (context).getApplicationContext();
|
|
||||||
final MapPoiTypes poiTypes = application.getPoiTypes();
|
|
||||||
final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(true);
|
|
||||||
PoiCategory category = getCategory(allTranslatedNames);
|
|
||||||
|
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
|
|
||||||
category.getIconKeyName();
|
category.getIconKeyName();
|
||||||
|
|
||||||
String res = category.getIconKeyName();
|
String res = category.getIconKeyName();
|
||||||
if (res instanceof String && RenderingIcons.containsBigIcon(res)) {
|
if (res != null && RenderingIcons.containsBigIcon(res)) {
|
||||||
return RenderingIcons.getBigIconResourceId(res);
|
return RenderingIcons.getBigIconResourceId(res);
|
||||||
} else {
|
|
||||||
return super.getIconRes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.getIconRes();
|
return super.getIconRes();
|
||||||
|
@ -206,17 +213,14 @@ public class AddPOIAction extends QuickAction {
|
||||||
final LinearLayout editTagsLineaLayout =
|
final LinearLayout editTagsLineaLayout =
|
||||||
(LinearLayout) view.findViewById(R.id.editTagsList);
|
(LinearLayout) view.findViewById(R.id.editTagsList);
|
||||||
|
|
||||||
final MapPoiTypes poiTypes = application.getPoiTypes();
|
|
||||||
final Map<String, PoiType> allTranslatedNames = poiTypes.getAllTranslatedNames(true);
|
|
||||||
final TagAdapterLinearLayoutHack mAdapter = new TagAdapterLinearLayoutHack(editTagsLineaLayout, getTagsFromParams(), deleteDrawable);
|
final TagAdapterLinearLayoutHack mAdapter = new TagAdapterLinearLayoutHack(editTagsLineaLayout, getTagsFromParams(), deleteDrawable);
|
||||||
// It is possible to not restart initialization every time, and probably move initialization to appInit
|
// It is possible to not restart initialization every time, and probably move initialization to appInit
|
||||||
Map<String, PoiType> translatedTypes = poiTypes.getAllTranslatedNames(true);
|
|
||||||
HashSet<String> tagKeys = new HashSet<>();
|
HashSet<String> tagKeys = new HashSet<>();
|
||||||
HashSet<String> valueKeys = new HashSet<>();
|
HashSet<String> valueKeys = new HashSet<>();
|
||||||
for (AbstractPoiType abstractPoiType : translatedTypes.values()) {
|
for (AbstractPoiType abstractPoiType : getAllTranslatedNames(application).values()) {
|
||||||
addPoiToStringSet(abstractPoiType, tagKeys, valueKeys);
|
addPoiToStringSet(abstractPoiType, tagKeys, valueKeys);
|
||||||
}
|
}
|
||||||
addPoiToStringSet(poiTypes.getOtherMapCategory(), tagKeys, valueKeys);
|
addPoiToStringSet(getPoiTypes(activity).getOtherMapCategory(), tagKeys, valueKeys);
|
||||||
tagKeys.addAll(EditPoiDialogFragment.BASIC_TAGS);
|
tagKeys.addAll(EditPoiDialogFragment.BASIC_TAGS);
|
||||||
mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()]));
|
mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()]));
|
||||||
mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()]));
|
mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()]));
|
||||||
|
@ -261,7 +265,7 @@ public class AddPOIAction extends QuickAction {
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
String tp = s.toString();
|
String tp = s.toString();
|
||||||
putTagIntoParams(POI_TYPE_TAG, tp);
|
putTagIntoParams(POI_TYPE_TAG, tp);
|
||||||
PoiCategory category = getCategory(allTranslatedNames);
|
PoiCategory category = getCategory(getAllTranslatedNames(application));
|
||||||
|
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
poiTypeTextInputLayout.setHint(category.getTranslation());
|
poiTypeTextInputLayout.setHint(category.getTranslation());
|
||||||
|
@ -294,8 +298,8 @@ public class AddPOIAction extends QuickAction {
|
||||||
if (event.getX() >= (editText.getRight()
|
if (event.getX() >= (editText.getRight()
|
||||||
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
|
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
|
||||||
- editText.getPaddingRight())) {
|
- editText.getPaddingRight())) {
|
||||||
PoiCategory category = getCategory(allTranslatedNames);
|
PoiCategory category = getCategory(getAllTranslatedNames(activity));
|
||||||
PoiCategory tempPoiCategory = (category != null) ? category : poiTypes.getOtherPoiCategory();
|
PoiCategory tempPoiCategory = (category != null) ? category : getPoiTypes(activity).getOtherPoiCategory();
|
||||||
PoiSubTypeDialogFragment f =
|
PoiSubTypeDialogFragment f =
|
||||||
PoiSubTypeDialogFragment.createInstance(tempPoiCategory);
|
PoiSubTypeDialogFragment.createInstance(tempPoiCategory);
|
||||||
f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
|
f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
|
||||||
|
@ -315,7 +319,7 @@ public class AddPOIAction extends QuickAction {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setUpAdapterForPoiTypeEditText(activity, allTranslatedNames, poiTypeEditText);
|
setUpAdapterForPoiTypeEditText(activity, getAllTranslatedNames(activity), poiTypeEditText);
|
||||||
|
|
||||||
ImageButton onlineDocumentationButton =
|
ImageButton onlineDocumentationButton =
|
||||||
(ImageButton) view.findViewById(R.id.onlineDocumentationButton);
|
(ImageButton) view.findViewById(R.id.onlineDocumentationButton);
|
||||||
|
|
Loading…
Reference in a new issue