Fix deleting basic tags in offline mode

This commit is contained in:
Chumva 2018-09-07 17:48:04 +03:00
parent aecf98195c
commit 1ae6e344b1

View file

@ -47,6 +47,8 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
private EditText descriptionEditText; private EditText descriptionEditText;
OpeningHoursAdapter mOpeningHoursAdapter; OpeningHoursAdapter mOpeningHoursAdapter;
private boolean basicTagsInitialized = false;
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -130,7 +132,7 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
if (data != null && !data.isInEdit()) { if (data != null && !data.isInEdit()) {
if (!TextUtils.isEmpty(s)) { if (!TextUtils.isEmpty(s)) {
data.putTag(tag, s.toString()); data.putTag(tag, s.toString());
} else { } else if (basicTagsInitialized && isResumed()) {
data.removeTag(tag); data.removeTag(tag);
} }
} }
@ -178,6 +180,7 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
} }
mOpeningHoursAdapter.replaceOpeningHours(openingHours); mOpeningHoursAdapter.replaceOpeningHours(openingHours);
mOpeningHoursAdapter.updateViews(); mOpeningHoursAdapter.updateViews();
basicTagsInitialized = true;
} }
private class OpeningHoursAdapter { private class OpeningHoursAdapter {
@ -223,7 +226,7 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
data.putTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(), data.putTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue(),
openingHoursString); openingHoursString);
} }
} else { } else if (basicTagsInitialized && isResumed()) {
data.removeTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()); data.removeTag(OSMSettings.OSMTagKey.OPENING_HOURS.getValue());
} }
} }