/**
* This file is part of MountainNavigation.
*
* MountainNavigation is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MountainNavigation is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MountainNavigation. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright (c) 2016 Vinzenz Rosenkanz <vinzenz.rosenkranz@gmail.com>
*
* @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
*/
package de.apps4ics.mountainnavigation.pois;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.EditText;
import de.apps4ics.mountainnavigation.MainActivity;
import de.apps4ics.mountainnavigation.R;
import de.apps4ics.mountainnavigation.handlers.PoiHandler;
public class AddPeakDialog extends DialogFragment {
private PoiHandler poiHandler;
public AddPeakDialog() {
this.poiHandler = MainActivity.getPoiHandler();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final EditText input = new EditText(poiHandler.getContext());
builder.setTitle(R.string.peak_dialog_title)
.setMessage(R.string.peak_dialog_msg)
.setView(input)
.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = input.getText().toString().trim();
if (!name.equals("")) {
poiHandler.addPoi(new Peak(0, name));
}
}
})
.setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
return builder.create();
}
}