use of com.ushahidi.android.app.views.AddMapView in project Ushahidi_Android by ushahidi.
the class ListMapFragment method createDialog.
/**
* Create an alert dialog
*/
public void createDialog(int d) {
switch(d) {
case DIALOG_SHOW_MESSAGE:
AlertDialog.Builder messageBuilder = new AlertDialog.Builder(getActivity());
messageBuilder.setMessage(errorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog showDialog = messageBuilder.create();
showDialog.show();
break;
case DIALOG_DISTANCE:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.select_distance);
builder.setSingleChoiceItems(items, Preferences.selectedDistance, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
distance = items[item];
setDeviceLocation();
Preferences.selectedDistance = item;
// save prefrences
Preferences.saveSettings(getActivity());
dialog.cancel();
toastLong(R.string.finding_map);
}
});
AlertDialog alert = builder.create();
alert.show();
break;
case DIALOG_CLEAR_DEPLOYMENT:
AlertDialog.Builder clearBuilder = new AlertDialog.Builder(getActivity());
clearBuilder.setMessage(getString(R.string.confirm_clear)).setCancelable(false).setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
mHandler.post(deleteAllMaps);
}
}).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog clearDialog = clearBuilder.create();
clearDialog.show();
break;
case DIALOG_ADD_DEPLOYMENT:
LayoutInflater factory = LayoutInflater.from(getActivity());
final View textEntryView = factory.inflate(R.layout.add_map, null);
final AddMapView addMapView = new AddMapView(textEntryView);
// with existing map details
if (edit) {
final List<ListMapModel> listMap = mListMapModel.loadMapById(mId, mapId);
if (listMap.size() > 0) {
addMapView.setMapName(listMap.get(0).getName());
addMapView.setMapDescription(listMap.get(0).getDesc());
addMapView.setMapUrl(listMap.get(0).getUrl());
addMapView.setMapId(listMap.get(0).getId());
}
}
final AlertDialog.Builder addBuilder = new AlertDialog.Builder(getActivity());
addBuilder.setTitle(R.string.enter_map_details).setView(textEntryView).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// edit was selected
if (edit) {
if (!addMapView.updateMapDetails())
toastLong(R.string.fix_error);
else
mHandler.post(refreshMapList);
} else {
if (!addMapView.addMapDetails())
toastLong(R.string.fix_error);
else
mHandler.post(fetchMapList);
}
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
AlertDialog deploymentDialog = addBuilder.create();
deploymentDialog.show();
break;
}
}
Aggregations