This commit is contained in:
Chumva 2019-07-09 16:35:17 +03:00
parent 3c15a7a2ff
commit 900196975b
2 changed files with 24 additions and 5 deletions

View file

@ -1,7 +1,5 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
@ -10,8 +8,6 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.Editable; import android.text.Editable;
import android.text.InputFilter; import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.TypedValue; import android.util.TypedValue;
@ -41,6 +37,8 @@ import java.util.Map;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
import static net.osmand.plus.osmedit.EditPoiDialogFragment.AMENITY_TEXT_LENGTH;
public class BasicEditPoiFragment extends BaseOsmAndFragment public class BasicEditPoiFragment extends BaseOsmAndFragment
implements EditPoiDialogFragment.OnFragmentActivatedListener { implements EditPoiDialogFragment.OnFragmentActivatedListener {
private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class); private static final Log LOG = PlatformUtil.getLog(BasicEditPoiFragment.class);
@ -167,6 +165,19 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
mOpeningHoursAdapter.setOpeningHoursRule(item, position); mOpeningHoursAdapter.setOpeningHoursRule(item, position);
} }
public void removeUnsavedOpeningHours() {
EditPoiData data = getData();
if (data != null) {
OpeningHoursParser.OpeningHours openingHours = OpeningHoursParser.parseOpenedHoursHandleErrors(data.getTagValues()
.get(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()));
if (openingHours == null) {
openingHours = new OpeningHoursParser.OpeningHours();
}
mOpeningHoursAdapter.replaceOpeningHours(openingHours);
mOpeningHoursAdapter.updateViews();
}
}
private EditPoiData getData() { private EditPoiData getData() {
Fragment parent = getParentFragment(); Fragment parent = getParentFragment();
if (parent != null && parent instanceof EditPoiDialogFragment) { if (parent != null && parent instanceof EditPoiDialogFragment) {

View file

@ -83,7 +83,15 @@ public class OpeningHoursHoursDialogFragment extends DialogFragment {
} }
} }
}) })
.setNegativeButton(R.string.shared_string_cancel, null); .setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
BasicEditPoiFragment editPoiFragment = ((BasicEditPoiFragment) getParentFragment());
if (editPoiFragment != null) {
editPoiFragment.removeUnsavedOpeningHours();
}
}
});
int paddingInDp = 18; int paddingInDp = 18;
float density = getActivity().getResources().getDisplayMetrics().density; float density = getActivity().getResources().getDisplayMetrics().density;