use of com.ushahidi.android.app.models.ListMapModel 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;
}
}
use of com.ushahidi.android.app.models.ListMapModel in project Ushahidi_Android by ushahidi.
the class ListMapFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
mListMapModel = new ListMapModel();
this.dialog = new ProgressDialog(getActivity());
this.dialog.setCancelable(true);
this.dialog.setIndeterminate(true);
this.dialog.setMessage(getString(R.string.please_wait));
if (Util.isHoneycomb()) {
listView.setLongClickable(true);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemLongClickListener(new ActionModeHelper(this, listView));
} else {
registerForContextMenu(listView);
}
// filter map list
if (view != null) {
if (view.mSearchMap != null) {
view.mSearchMap.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable arg0) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!(TextUtils.isEmpty(s.toString()))) {
filter = s.toString();
mHandler.post(filterMapList);
} else {
mHandler.post(fetchMapList);
}
}
});
}
}
if (savedInstanceState != null) {
int position = savedInstanceState.getInt(STATE_CHECKED, -1);
if (position > -1) {
listView.setItemChecked(position, true);
}
}
}
Aggregations