List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.example.pyrkesa.frag.User_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);//from w w w . j ava 2s . c o m rootView = inflater.inflate(R.layout.user_fragment, container, false); userList = (ListView) rootView.findViewById(R.id.lt_user); // custom dialog final Dialog dialog = new Dialog(rootView.getContext()); d = dialog; userIcons = getResources().obtainTypedArray(R.array.userIcons);// load icons from userIcons1 = getResources().obtainTypedArray(R.array.userIcons1); userItems = new ArrayList<UserItem>(); adapter = new UserAdapter(getActivity(), userItems, getActivity()); userList.setAdapter(adapter); ImageButton addButton = (ImageButton) rootView.findViewById(R.id.add); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ModelFactory model = (ModelFactory) ModelFactory.getContext(); if (model.user.type == 1) { dialog.setContentView(R.layout.adduser_dialog); dialog.setTitle("Ajouter un utilisateur "); dialogTypes = getResources().getStringArray(R.array.user_type_dialog); // load Button dialogButtonOk = (Button) dialog.findViewById(R.id.button_ok); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.button_cancel); final EditText Newlogin = (EditText) dialog.findViewById(R.id.dialogLogin); final EditText NewPW = (EditText) dialog.findViewById(R.id.dialogPW); final Spinner NewType = (Spinner) dialog.findViewById(R.id.dialogType); ArrayList<String> types = new ArrayList<String>(); for (String t : dialogTypes) { types.add(t); } NewType.setAdapter(new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, types)); dialogButtonCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialogButtonOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<String> temp = new ArrayList<String>(); String login = Newlogin.getText().toString(); String password = NewPW.getText().toString(); String type = NewType.getSelectedItem().toString(); if (login.equalsIgnoreCase("") && password.equalsIgnoreCase("") && type != null) { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Veuillez remplir toutes les informations.").show(); } else { temp.add(login); temp.add(password); if (type.equalsIgnoreCase("admin")) { temp.add("1"); } else if (type.equalsIgnoreCase("utilisateur")) { temp.add("0"); } else { temp.add("0"); } } new addUser().execute(temp); } }); dialog.show(); } else { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Opration interdite : Droits d'administration requis.").show(); } } }); // adding user items new LoadAllUser().execute(); return rootView; }
From source file:org.glucosio.android.activity.MainActivity.java
public void showExportCsvDialog() { final Dialog exportDialog = new Dialog(MainActivity.this, R.style.GlucosioTheme); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(exportDialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.WRAP_CONTENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; exportDialog.setContentView(R.layout.dialog_export); exportDialog.getWindow().setAttributes(lp); exportDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); exportDialog.getWindow().setDimAmount(0.5f); exportDialog.show();//from w w w . ja va 2s . com exportDialogDateFrom = (TextView) exportDialog.findViewById(R.id.activity_export_date_from); exportDialogDateTo = (TextView) exportDialog.findViewById(R.id.activity_export_date_to); exportRangeButton = (RadioButton) exportDialog.findViewById(R.id.activity_export_range); final RadioButton exportAllButton = (RadioButton) exportDialog.findViewById(R.id.activity_export_all); final TextView exportButton = (TextView) exportDialog.findViewById(R.id.dialog_export_add); final TextView cancelButton = (TextView) exportDialog.findViewById(R.id.dialog_export_cancel); exportRangeButton.setChecked(true); exportDialogDateFrom.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar now = Calendar.getInstance(); DatePickerDialog dpd = DatePickerDialog.newInstance(MainActivity.this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); dpd.show(getFragmentManager(), "fromDateDialog"); dpd.setMaxDate(now); } }); exportDialogDateTo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar now = Calendar.getInstance(); DatePickerDialog dpd = DatePickerDialog.newInstance(MainActivity.this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); dpd.show(getFragmentManager(), "toDateDialog"); dpd.setMaxDate(now); } }); exportRangeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean isChecked = exportRangeButton.isChecked(); exportDialogDateFrom.setEnabled(true); exportDialogDateTo.setEnabled(true); exportAllButton.setChecked(!isChecked); } }); exportAllButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean isChecked = exportAllButton.isChecked(); exportDialogDateFrom.setEnabled(false); exportDialogDateTo.setEnabled(false); exportRangeButton.setChecked(!isChecked); exportButton.setEnabled(true); } }); exportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validateExportDialog()) { exportPresenter.onExportClicked(exportAllButton.isChecked()); exportDialog.dismiss(); } else { showSnackBar(getResources().getString(R.string.dialog_error), Snackbar.LENGTH_LONG); } } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { exportDialog.dismiss(); } }); }
From source file:org.glucosio.android.fragment.OverviewFragment.java
private void showA1cDialog() { final Dialog a1CDialog = new Dialog(getActivity(), R.style.GlucosioTheme); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(a1CDialog.getWindow().getAttributes()); a1CDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; a1CDialog.setContentView(R.layout.dialog_a1c); a1CDialog.getWindow().setAttributes(lp); a1CDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); a1CDialog.getWindow().setDimAmount(0.5f); a1CDialog.setCanceledOnTouchOutside(true); a1CDialog.show();//from w w w . j a v a 2 s . com ListView a1cListView = (ListView) a1CDialog.findViewById(R.id.dialog_a1c_listview); A1cEstimateAdapter customAdapter = new A1cEstimateAdapter(getActivity(), R.layout.dialog_a1c_item, presenter.getA1cEstimateList()); a1cListView.setAdapter(customAdapter); }
From source file:com.woofy.haifa.MapActivity.java
private boolean initMap() { if (mMap == null) { SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mMap = mapFrag.getMap();/*from w ww.ja va 2s . c o m*/ if (mMap != null) { mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { // Getting view from the layout file LayoutInflater inflater = LayoutInflater.from(MapActivity.this); View v = inflater.inflate(R.layout.info_window, null); TextView locality = (TextView) v.findViewById(R.id.tv_locality); locality.setText(marker.getTitle()); // TextView title = (TextView) v.findViewById(R.id.tv_lat); // title.setText(marker.getTitle()); TextView address = (TextView) v.findViewById(R.id.tv_lng); address.setText(marker.getSnippet()); ImageView img = (ImageView) v.findViewById(R.id.imageView1); if (lastbitmap != null) { img.setImageBitmap(lastbitmap); } if (pic_map.containsKey(marker.getTitle())) { img.setImageBitmap(pic_map.get(marker.getTitle())); } if (marker.getTitle().equals("You")) { img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.you_marker)); } if (marker.getSnippet().length() < 30) { // img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.bad_dog)); new HttpLib.MarkerPic(marker.getTitle(), img, marker).execute(); // HttpLib.DownloadImageTask task=new HttpLib.DownloadImageTask(img,marker); // task.execute("http://52.1.192.145/uploads/img_1434327703156_kgqsjhlevp9fj6tcs7su32gj43.jpg"); // Vector<BasicNameValuePair> vec = new Vector<BasicNameValuePair>(); vec.add(new BasicNameValuePair("name", marker.getTitle())); new HttpLib.MarkerInfoWindow(vec, marker).execute(); } return v; // return null; } @Override public View getInfoContents(Marker marker) { View v = getLayoutInflater().inflate(R.layout.info_window, null); TextView tvLocality = (TextView) v.findViewById(R.id.tv_locality); TextView tvLat = (TextView) v.findViewById(R.id.tv_lat); TextView tvLng = (TextView) v.findViewById(R.id.tv_lng); TextView tvSnippet = (TextView) v.findViewById(R.id.tv_snippet); // ImageView img = (ImageView) v.findViewById(R.id.imageView1); LatLng ll = marker.getPosition(); tvLocality.setText(marker.getTitle()); // tvLat.setText("Dogs: " + "Woofy, Goofy"); // tvLng.setText("Click for more info"); // tvSnippet.setText(marker.getSnippet()); ImageView img = (ImageView) v.findViewById(R.id.imageView1); if (lastbitmap != null) { img.setImageBitmap(lastbitmap); Log.d("Set bitmap", "Set bitmap"); } else { new HttpLib.MarkerPic(marker.getTitle(), img, marker).execute(); } if (marker.getSnippet().length() < 30) { // img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.bad_dog)); // HttpLib.DownloadImageTask task=new HttpLib.DownloadImageTask(img,marker); // task.execute("http://52.1.192.145/uploads/img_1434327703156_kgqsjhlevp9fj6tcs7su32gj43.jpg"); // Vector<BasicNameValuePair> vec = new Vector<BasicNameValuePair>(); vec.add(new BasicNameValuePair("name", marker.getTitle())); new HttpLib.MarkerInfoWindow(vec, marker).execute(); } return v; } }); mMap.setOnMapLongClickListener(new OnMapLongClickListener() { @Override public void onMapLongClick(final LatLng point) { final Dialog dialog = new Dialog(MapActivity.this); dialog.setContentView(R.layout.alert_layout); dialog.setCancelable(true); dialog.show(); // .setMessage(R.string.really_quit) Button b = (Button) dialog.findViewById(R.id.yesmeet); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String t1 = ((EditText) dialog.findViewById(R.id.meet_name)).getText().toString(); // String t2 = ((EditText)dialog.findViewById(R.id.editText1111)).getText().toString(); if (meet != null) meet.remove(); MarkerOptions options; options = new MarkerOptions().title(t1).position(point) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)) .anchor(.5f, .5f) //center the icon .draggable(true); Marker mar = mMap.addMarker(options); // MeetingMarkers.add(mar); meet = mar; dialog.dismiss(); } }); Button b1 = (Button) dialog.findViewById(R.id.nomeet); b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); } }); mMap.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { if (SystemClock.uptimeMillis() - show_people_last_updated > 1000) { show_people_last_updated = SystemClock.uptimeMillis(); showPeople(); } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { lastbitmap = null; marker.hideInfoWindow(); marker.showInfoWindow(); return false; } }); mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Log.d("Open profile page", marker.getTitle()); Intent intent = new Intent(MapActivity.this, Profile.class); intent.putExtra("name", marker.getTitle()); startActivity(intent); } }); mMap.setOnMarkerDragListener(new OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker marker) { marker.remove(); MarkerOptions options; options = new MarkerOptions().title(marker.getTitle()).position(marker.getPosition()) .icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker)) .anchor(.5f, .5f) //center the icon .draggable(true); String name = marker.getTitle(); if (selected_markers.contains(name)) { selected_markers.remove(name); } else { selected_markers.add(name); options.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_checked)); } Marker addmarker = mMap.addMarker(options); PersonMarkers.add(addmarker); } @Override public void onMarkerDragEnd(Marker marker) { } @Override public void onMarkerDrag(Marker arg0) { } }); } } return (mMap != null); }
From source file:su.comp.bk.ui.BkEmuActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_COMPUTER_MODEL: final CharSequence[] models; List<String> modelList = new ArrayList<String>(); for (Configuration model : Configuration.values()) { int modelNameId = getResources().getIdentifier(model.name().toLowerCase(), "string", getPackageName());// w w w . j a va 2s. c o m modelList.add((modelNameId != 0) ? getString(modelNameId) : model.name()); } models = modelList.toArray(new String[modelList.size()]); return new AlertDialog.Builder(this).setTitle(R.string.menu_select_model).setSingleChoiceItems(models, getComputerConfiguration().ordinal(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Mark selected item by tag ListView listView = ((AlertDialog) dialog).getListView(); listView.setTag(Integer.valueOf(which)); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Get tagged selected item, if any ListView listView = ((AlertDialog) dialog).getListView(); Integer selected = (Integer) listView.getTag(); if (selected != null) { Configuration config = Configuration.values()[selected]; if (computer.getConfiguration() != config) { // Set new computer configuration and restart activity setComputerConfiguration(config); restartActivity(null); } } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing on cancel } }).create(); case DIALOG_ABOUT: Dialog aboutDialog = new Dialog(this); aboutDialog.setTitle(R.string.menu_about); aboutDialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); aboutDialog.setContentView(R.layout.about_dialog); aboutDialog.getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_info); TextView versionTextView = (TextView) aboutDialog.findViewById(R.id.about_version); try { versionTextView.setText(getResources().getString(R.string.about_version, getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); } catch (NameNotFoundException e) { } return aboutDialog; case DIALOG_DISK_MANAGER: Dialog fddManagerDialog = new Dialog(this); fddManagerDialog.setTitle(R.string.menu_disk_manager); fddManagerDialog.setContentView(R.layout.fdd_mgr_dialog); return fddManagerDialog; case DIALOG_DISK_MOUNT_ERROR: return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.err) .setMessage(R.string.dialog_disk_mount_error).setPositiveButton(R.string.ok, null).create(); } return null; }
From source file:org.computeforcancer.android.PrefsFragment.java
private void setupSelectionListDialog(final PrefsListItemWrapper item, final Dialog dialog) throws RemoteException { dialog.setContentView(R.layout.prefs_layout_dialog_selection); if (item.ID == R.string.prefs_client_log_flags_header) { final ArrayList<SelectionDialogOption> options = new ArrayList<SelectionDialogOption>(); String[] array = getResources().getStringArray(R.array.prefs_client_log_flags); for (String option : array) options.add(new SelectionDialogOption(option)); ListView lv = (ListView) dialog.findViewById(R.id.selection); new PrefsSelectionDialogListAdapter(getActivity(), lv, R.id.selection, options); // setup confirm button action Button confirm = (Button) dialog.findViewById(R.id.confirm); confirm.setOnClickListener(new OnClickListener() { @Override/*from w ww.j a va2 s .c om*/ public void onClick(View v) { ArrayList<String> selectedOptions = new ArrayList<String>(); for (SelectionDialogOption option : options) if (option.selected) selectedOptions.add(option.name); if (Logging.DEBUG) Log.d(Logging.TAG, selectedOptions.size() + " log flags selected"); new SetCcConfigAsync().execute(formatOptionsToCcConfig(selectedOptions)); dialog.dismiss(); } }); } else if (item.ID == R.string.prefs_power_source_header) { final ArrayList<SelectionDialogOption> options = new ArrayList<SelectionDialogOption>(); options.add(new SelectionDialogOption(getResources().getString(R.string.prefs_power_source_ac), BOINCActivity.monitor.getPowerSourceAc())); options.add(new SelectionDialogOption(getResources().getString(R.string.prefs_power_source_usb), BOINCActivity.monitor.getPowerSourceUsb())); options.add(new SelectionDialogOption(getResources().getString(R.string.prefs_power_source_wireless), BOINCActivity.monitor.getPowerSourceWireless())); options.add(new SelectionDialogOption(getResources().getString(R.string.prefs_power_source_battery), clientPrefs.run_on_batteries, true)); ListView lv = (ListView) dialog.findViewById(R.id.selection); new PrefsSelectionDialogListAdapter(getActivity(), lv, R.id.selection, options); // setup confirm button action Button confirm = (Button) dialog.findViewById(R.id.confirm); confirm.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try { for (SelectionDialogOption option : options) { if (option.name == getResources().getString(R.string.prefs_power_source_ac)) BOINCActivity.monitor.setPowerSourceAc(option.selected); if (option.name == getResources().getString(R.string.prefs_power_source_usb)) BOINCActivity.monitor.setPowerSourceUsb(option.selected); if (option.name == getResources().getString(R.string.prefs_power_source_wireless)) BOINCActivity.monitor.setPowerSourceWireless(option.selected); if (option.name == getResources().getString(R.string.prefs_power_source_battery)) { clientPrefs.run_on_batteries = option.selected; new WriteClientPrefsAsync().execute(clientPrefs); //async task triggers layout update } } dialog.dismiss(); } catch (RemoteException e) { } } }); } // generic cancel button Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java
@Override protected Dialog onCreateDialog(int id, Bundle bundle) { switch (id) { case NEWS_DIALOG: { String str = bundle.getString("news_html"); Builder bldr = new AlertDialog.Builder(this); bldr.setTitle("News"); bldr.setCancelable(true);//w ww . j a v a 2 s . c o m bldr.setMessage(Html.fromHtml(str)); return bldr.create(); } case CONTACT_REMOVE_DIALOG: return null; case ABOUT_DIALOG: { final Dialog dialog = new Dialog(this); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.about_dialog); dialog.setTitle(getString(R.string.aboutButton)); TextView tos = (TextView) dialog.findViewById(R.id.aboutTermsOfService); tos.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.termsOfServiceURL) + "'>" + getResources().getString(R.string.termsOfService) + "</a>")); tos.setMovementMethod(LinkMovementMethod.getInstance()); TextView pp = (TextView) dialog.findViewById(R.id.aboutPrivacyPolicy); pp.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.privacyPolicyURL) + "'>" + getResources().getString(R.string.privacyPolicy) + "</a>")); pp.setMovementMethod(LinkMovementMethod.getInstance()); Button okButton = (Button) dialog.findViewById(R.id.okButton); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); return dialog; } default: return null; } }
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { RadioButton satellite;//from www . j a v a 2s. co m RadioButton regular; switch (id) { case DIALOG_LAYERS: satellite = (RadioButton) dialog.findViewById(R.id.layer_google_satellite); regular = (RadioButton) dialog.findViewById(R.id.layer_google_regular); satellite.setChecked(mSharedPreferences.getBoolean(Constants.SATELLITE, false)); regular.setChecked(!mSharedPreferences.getBoolean(Constants.SATELLITE, false)); mTraffic.setChecked(mSharedPreferences.getBoolean(Constants.TRAFFIC, false)); mSpeed.setChecked(mSharedPreferences.getBoolean(Constants.SPEED, false)); mAltitude.setChecked(mSharedPreferences.getBoolean(Constants.ALTITUDE, false)); mDistance.setChecked(mSharedPreferences.getBoolean(Constants.DISTANCE, false)); mCompass.setChecked(mSharedPreferences.getBoolean(Constants.COMPASS, false)); mLocation.setChecked(mSharedPreferences.getBoolean(Constants.LOCATION, false)); break; case DIALOG_URIS: mGallery.setAdapter(mMediaAdapter); default: break; } super.onPrepareDialog(id, dialog); }
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onBackPressed() { if (touchActive) { if (onChildOnMapView) { if ((trackerModelWithMarker != null) && (trackerModelWithMarker.getMarker().isInfoWindowShown())) { trackerModelWithMarker.getMarker().hideInfoWindow(); }/*from w w w . ja va2 s .c om*/ displayTrackers(); trackerList.setVisibility(View.VISIBLE); onChildOnMapView = false; userZoomAndPanOnMap = false; zoomToBoundingBox(); } else { final Dialog exitQuery = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); exitQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); exitQuery.setCancelable(true); exitQuery.setContentView(R.layout.exit_app_query); ClearTextView cancel = (ClearTextView) exitQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { exitQuery.cancel(); } }); ClearTextView exit = (ClearTextView) exitQuery.findViewById(R.id.exit); exit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { exitApplication(); startupDone = false; exitQuery.cancel(); } }); exitQuery.show(); exitQuery.getWindow().setDimAmount(0.5f); exitQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } } }
From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java
@Override protected Dialog onCreateDialog(int id) { final Dialog dialog; Calendar cal;/*w w w . j a va 2 s .com*/ Button buttonApply; applyViewValues(); switch (id) { case (DIALOG_PICK_BEGIN_ID): cal = getCalendarFromTimestamp(mTimer.getString("begin")); dialog = new Dialog(this); dialog.setContentView(R.layout.date_time_picker); dialog.setTitle(R.string.set_time_begin); setDateAndTimePicker(dialog, cal); dialogRegisterCancel(dialog); buttonApply = (Button) dialog.findViewById(R.id.ButtonApply); buttonApply.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onTimerBeginSet(getCalendarFromPicker(dialog)); } }); dialog.show(); break; case (DIALOG_PICK_END_ID): cal = getCalendarFromTimestamp(mTimer.getString("end")); dialog = new Dialog(this); dialog.setContentView(R.layout.date_time_picker); dialog.setTitle(R.string.set_time_end); setDateAndTimePicker(dialog, cal); dialogRegisterCancel(dialog); buttonApply = (Button) dialog.findViewById(R.id.ButtonApply); buttonApply.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onTimerEndSet(getCalendarFromPicker(dialog)); } }); dialog.show(); break; case (DIALOG_PICK_REPEATED_ID): CharSequence[] days = getResources().getTextArray(R.array.weekdays); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getText(R.string.choose_days)); builder.setMultiChoiceItems(days, mCheckedDays, new OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { mCheckedDays[which] = isChecked; String text = setRepeated(mCheckedDays, mTimer); mRepeatings.setText(text); } }); dialog = builder.create(); break; case (DIALOG_PICK_TAGS_ID): CharSequence[] tags = new CharSequence[DreamDroid.TAGS.size()]; boolean[] selectedTags = new boolean[DreamDroid.TAGS.size()]; int tc = 0; for (String tag : DreamDroid.TAGS) { tags[tc] = tag; if (mSelectedTags.contains(tag)) { selectedTags[tc] = true; } else { selectedTags[tc] = false; } tc++; } mTagsChanged = false; mOldTags = new ArrayList<String>(); mOldTags.addAll(mSelectedTags); builder = new AlertDialog.Builder(this); builder.setTitle(getText(R.string.choose_tags)); builder.setMultiChoiceItems(tags, selectedTags, new OnMultiChoiceClickListener() { /* * (non-Javadoc) * * @see android.content.DialogInterface. * OnMultiChoiceClickListener * #onClick(android.content.DialogInterface, int, boolean) */ @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { String tag = DreamDroid.TAGS.get(which); mTagsChanged = true; if (isChecked) { if (!mSelectedTags.contains(tag)) { mSelectedTags.add(tag); } } else { int idx = mSelectedTags.indexOf(tag); if (idx >= 0) { mSelectedTags.remove(idx); } } } }); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mTagsChanged) { // TODO Update current Tags String tags = Tag.implodeTags(mSelectedTags); mTimer.put(Timer.TAGS, tags); mTags.setText(tags); } dialog.dismiss(); removeDialog(DIALOG_PICK_TAGS_ID); } }); builder.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mSelectedTags.clear(); mSelectedTags.addAll(mOldTags); dialog.dismiss(); removeDialog(DIALOG_PICK_TAGS_ID); } }); dialog = builder.create(); break; default: dialog = null; } return dialog; }