Made impossible to start second EditPoiDialogFragment fix #1957.
This commit is contained in:
parent
5e49b10b92
commit
ddc8ba2edd
2 changed files with 53 additions and 40 deletions
|
@ -17,6 +17,7 @@ import android.support.v4.app.DialogFragment;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -310,6 +311,43 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
return true;
|
||||
} else {
|
||||
dismissCheckForChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putSerializable(TAGS_LIST, (Serializable) editPoiData.getTagValues());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(FragmentManager manager, String tag) {
|
||||
if (manager.findFragmentByTag(TAG) == null) {
|
||||
super.show(manager, TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int show(FragmentTransaction transaction, String tag) {
|
||||
throw new UnsupportedOperationException("Please use show(FragmentManager manager, String tag)");
|
||||
}
|
||||
|
||||
private void trySave() {
|
||||
if (TextUtils.isEmpty(poiTypeEditText.getText())) {
|
||||
HashSet<String> tagsCopy = new HashSet<>();
|
||||
|
@ -388,25 +426,6 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
}, getActivity(), mOpenstreetmapUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getDialog().setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||
if (keyCode == android.view.KeyEvent.KEYCODE_BACK) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
return true;
|
||||
} else {
|
||||
dismissCheckForChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void dismissCheckForChanges() {
|
||||
if (editPoiData.hasChangesBeenMade()) {
|
||||
new AreYouSureDialogFragment().show(getChildFragmentManager(),
|
||||
|
@ -416,12 +435,6 @@ public class EditPoiDialogFragment extends DialogFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putSerializable(TAGS_LIST, (Serializable) editPoiData.getTagValues());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
public EditPoiData getEditPoiData() {
|
||||
return editPoiData;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import java.util.List;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
|
@ -27,19 +39,7 @@ import net.osmand.util.Algorithms;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class OsmEditingPlugin extends OsmandPlugin {
|
||||
|
@ -204,7 +204,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
} else if (resId == R.string.poi_context_menu_modify_osm_change) {
|
||||
final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity();
|
||||
EditPoiDialogFragment.createInstance(entity, false)
|
||||
.show(mapActivity.getSupportFragmentManager(), "edit_poi");
|
||||
.show(mapActivity.getSupportFragmentManager(), EditPoiDialogFragment.TAG);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue