List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java
/** * Show the license text retrieved from the server. * * @param licenseText Message text to be shown as the license. * @param title Title of the license.//from w ww . jav a 2 s. com */ private void showAgreement(final String licenseText, final String title) { AuthenticationActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final Dialog dialog = new Dialog(context, R.style.Dialog); dialog.setContentView(R.layout.dialog_license); dialog.setCancelable(false); WebView webView = (WebView) dialog.findViewById(R.id.webViewLicense); webView.loadDataWithBaseURL(null, licenseText, Constants.MIME_TYPE, Constants.ENCODING_METHOD, null); TextView textViewTitle = (TextView) dialog.findViewById(R.id.textViewDeviceNameTitle); textViewTitle.setText(title); Button btnAgree = (Button) dialog.findViewById(R.id.dialogButtonOK); Button btnCancel = (Button) dialog.findViewById(R.id.dialogButtonCancel); btnAgree.setOnClickListener(new OnClickListener() { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public void onClick(View v) { Preference.putBoolean(context, Constants.PreferenceFlag.IS_AGREED, true); dialog.dismiss(); //load the next intent based on ownership type startDeviceAdminPrompt(); } }); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); CommonUtils.clearClientCredentials(context); cancelEntry(); } }); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == Constants.DEFAULT_REPEAT_COUNT) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == Constants.DEFAULT_REPEAT_COUNT) { return true; } return false; } }); dialog.show(); } }); }
From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java
/** * ??//w w w.java 2 s . c om * @param message * @param positive * @param negative * @param positiveEnable * @param negativeEnable */ private void showDefaultCardDialog(String message, String positive, String negative, boolean positiveEnable, boolean negativeEnable) { message = "??????????"; //newDialog? Dialog dialog = new Dialog(getActivity(), R.style.MyDialogStyleBottom); //ContentView dialog.setContentView(R.layout.sms_default_card_dialog); dialog.findViewById(R.id.select_card).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub selectReceiveBankCard(); } }); dialog.findViewById(R.id.add_card).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub addReceiveBankCard(); } }); dialog.findViewById(R.id.select_card).setEnabled(positiveEnable); dialog.findViewById(R.id.add_card).setEnabled(negativeEnable); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.show(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
private void createSearchDialog() { final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_search_tools, R.string.search_tools_title); final ScrollView scrollView = (ScrollView) dialog.findViewById(R.id.search_tools_dialog_scroll_view); final AutoCompleteTextView inputField = (AutoCompleteTextView) dialog .findViewById(R.id.search_tools_input_field); final LinearLayout rowsContainer = (LinearLayout) dialog.findViewById(R.id.search_tools_row_container); final Button viewInMapButton = (Button) dialog.findViewById(R.id.search_tools_view_in_map_button); final Button jumpToBottomButton = (Button) dialog.findViewById(R.id.search_tools_jump_to_bottom_button); Button dismissButton = (Button) dialog.findViewById(R.id.search_tools_dismiss_button); List<PropertyDescription> subscribables; PropertyDescription newestSubscribable = null; final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault()); Date cachedUpdateDateTime;//from w ww .ja v a 2 s. co m Date newestUpdateDateTime; SubscriptionEntry cachedEntry; Response response; final JSONArray toolsArray; ArrayAdapter<String> adapter; String format = "JSON"; String downloadPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) .toString() + "/FiskInfo/Offline/"; final JSONObject tools; final List<String> vesselNames; final Map<String, List<Integer>> toolIdMap = new HashMap<>(); byte[] data = new byte[0]; cachedEntry = user.getSubscriptionCacheEntry(getString(R.string.fishing_facility_api_name)); if (fiskInfoUtility.isNetworkAvailable(getActivity())) { subscribables = barentswatchApi.getApi().getSubscribable(); for (PropertyDescription subscribable : subscribables) { if (subscribable.ApiName.equals(getString(R.string.fishing_facility_api_name))) { newestSubscribable = subscribable; break; } } } else if (cachedEntry == null) { Dialog infoDialog = dialogInterface.getAlertDialog(getActivity(), R.string.tools_search_no_data_title, R.string.tools_search_no_data, -1); infoDialog.show(); return; } if (cachedEntry != null) { try { cachedUpdateDateTime = simpleDateFormat .parse(cachedEntry.mLastUpdated.equals(getActivity().getString(R.string.abbreviation_na)) ? "2000-00-00T00:00:00" : cachedEntry.mLastUpdated); newestUpdateDateTime = simpleDateFormat .parse(newestSubscribable != null ? newestSubscribable.LastUpdated : "2000-00-00T00:00:00"); if (cachedUpdateDateTime.getTime() - newestUpdateDateTime.getTime() < 0) { response = barentswatchApi.getApi().geoDataDownload(newestSubscribable.ApiName, format); try { data = FiskInfoUtility.toByteArray(response.getBody().in()); } catch (IOException e) { e.printStackTrace(); } if (new FiskInfoUtility().writeMapLayerToExternalStorage(getActivity(), data, newestSubscribable.Name.replace(",", "").replace(" ", "_"), format, downloadPath, false)) { SubscriptionEntry entry = new SubscriptionEntry(newestSubscribable, true); entry.mLastUpdated = newestSubscribable.LastUpdated; user.setSubscriptionCacheEntry(newestSubscribable.ApiName, entry); user.writeToSharedPref(getActivity()); } } else { String directoryFilePath = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString() + "/FiskInfo/Offline/"; File file = new File(directoryFilePath + newestSubscribable.Name + ".JSON"); StringBuilder jsonString = new StringBuilder(); BufferedReader bufferReader = null; try { bufferReader = new BufferedReader(new FileReader(file)); String line; while ((line = bufferReader.readLine()) != null) { jsonString.append(line); jsonString.append('\n'); } } catch (IOException e) { e.printStackTrace(); } finally { if (bufferReader != null) { try { bufferReader.close(); } catch (Exception e) { e.printStackTrace(); } } } data = jsonString.toString().getBytes(); } } catch (ParseException e) { e.printStackTrace(); Log.e(TAG, "Invalid datetime provided"); } } else { response = barentswatchApi.getApi().geoDataDownload(newestSubscribable.ApiName, format); try { data = FiskInfoUtility.toByteArray(response.getBody().in()); } catch (IOException e) { e.printStackTrace(); } if (new FiskInfoUtility().writeMapLayerToExternalStorage(getActivity(), data, newestSubscribable.Name.replace(",", "").replace(" ", "_"), format, downloadPath, false)) { SubscriptionEntry entry = new SubscriptionEntry(newestSubscribable, true); entry.mLastUpdated = newestSubscribable.LastUpdated; user.setSubscriptionCacheEntry(newestSubscribable.ApiName, entry); } } try { tools = new JSONObject(new String(data)); toolsArray = tools.getJSONArray("features"); vesselNames = new ArrayList<>(); adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_dropdown_item_1line, vesselNames); for (int i = 0; i < toolsArray.length(); i++) { JSONObject feature = toolsArray.getJSONObject(i); String vesselName = (feature.getJSONObject("properties").getString("vesselname") != null && !feature.getJSONObject("properties").getString("vesselname").equals("null")) ? feature.getJSONObject("properties").getString("vesselname") : getString(R.string.vessel_name_unknown); List<Integer> toolsIdList = toolIdMap.get(vesselName) != null ? toolIdMap.get(vesselName) : new ArrayList<Integer>(); if (vesselName != null && !vesselNames.contains(vesselName)) { vesselNames.add(vesselName); } toolsIdList.add(i); toolIdMap.put(vesselName, toolsIdList); } inputField.setAdapter(adapter); } catch (JSONException e) { dialogInterface.getAlertDialog(getActivity(), R.string.search_tools_init_error, R.string.search_tools_init_info, -1).show(); Log.e(TAG, "JSON parse error"); e.printStackTrace(); return; } if (searchToolsButton.getTag() != null) { inputField.requestFocus(); inputField.setText(searchToolsButton.getTag().toString()); inputField.selectAll(); } inputField.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String selectedVesselName = ((TextView) view).getText().toString(); List<Integer> selectedTools = toolIdMap.get(selectedVesselName); Gson gson = new Gson(); String toolSetDateString; Date toolSetDate; rowsContainer.removeAllViews(); for (int toolId : selectedTools) { JSONObject feature; Feature toolFeature; try { feature = toolsArray.getJSONObject(toolId); if (feature.getJSONObject("geometry").getString("type").equals("LineString")) { toolFeature = gson.fromJson(feature.toString(), LineFeature.class); } else { toolFeature = gson.fromJson(feature.toString(), PointFeature.class); } toolSetDateString = toolFeature.properties.setupdatetime != null ? toolFeature.properties.setupdatetime : "2038-00-00T00:00:00"; toolSetDate = simpleDateFormat.parse(toolSetDateString); } catch (JSONException | ParseException e) { dialogInterface.getAlertDialog(getActivity(), R.string.search_tools_init_error, R.string.search_tools_init_info, -1).show(); e.printStackTrace(); return; } ToolSearchResultRow row = rowsInterface.getToolSearchResultRow(getActivity(), R.drawable.ikon_kystfiske, toolFeature); long toolTime = System.currentTimeMillis() - toolSetDate.getTime(); long highlightCutoff = ((long) getResources().getInteger(R.integer.milliseconds_in_a_day)) * ((long) getResources().getInteger(R.integer.days_to_highlight_active_tool)); if (toolTime > highlightCutoff) { int colorId = ContextCompat.getColor(getActivity(), R.color.error_red); row.setDateTextViewTextColor(colorId); } rowsContainer.addView(row.getView()); } viewInMapButton.setEnabled(true); inputField.setTag(selectedVesselName); searchToolsButton.setTag(selectedVesselName); jumpToBottomButton.setVisibility(View.VISIBLE); jumpToBottomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new Handler().post(new Runnable() { @Override public void run() { scrollView.scrollTo(0, rowsContainer.getBottom()); } }); } }); } }); viewInMapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String vesselName = inputField.getTag().toString(); highlightToolsInMap(vesselName); dialog.dismiss(); } }); dismissButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog)); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show(); }
From source file:com.nononsenseapps.notepad.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DELETE_LIST: final Dialog deleteDialog = new Dialog(this); deleteDialog.setContentView(R.layout.delete_list_dialog); deleteDialog.setTitle(R.string.menu_deletelist); Button dYesButton = (Button) deleteDialog.findViewById(R.id.d_dialog_yes); dYesButton.setOnClickListener(new OnClickListener() { @Override/* www .j a v a2 s .c o m*/ public void onClick(View v) { deleteCurrentList(); deleteDialog.dismiss(); } }); Button dNoButton = (Button) deleteDialog.findViewById(R.id.d_dialog_no); dNoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { deleteDialog.cancel(); } }); return deleteDialog; case CREATE_LIST: final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.create_list_dialog); dialog.setTitle(R.string.menu_createlist); EditText title = (EditText) dialog.findViewById(R.id.editTitle); title.setText(""); Button yesButton = (Button) dialog.findViewById(R.id.dialog_yes); yesButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText title = (EditText) dialog.findViewById(R.id.editTitle); createList(title.getText().toString()); title.setText(""); dialog.dismiss(); } }); Button noButton = (Button) dialog.findViewById(R.id.dialog_no); noButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActionBar().setSelectedNavigationItem(currentListPos); dialog.cancel(); } }); return dialog; case RENAME_LIST: final Dialog renameDialog = new Dialog(this); renameDialog.setContentView(R.layout.rename_list_dialog); renameDialog.setTitle(R.string.menu_renamelist); CharSequence currentTitle = ""; if (mSectionsPagerAdapter != null) currentTitle = mSectionsPagerAdapter.getPageTitle(currentListPos); EditText renameTitle = (EditText) renameDialog.findViewById(R.id.renameTitle); renameTitle.setText(currentTitle); Button rYesButton = (Button) renameDialog.findViewById(R.id.r_dialog_yes); rYesButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EditText renameTitle = (EditText) renameDialog.findViewById(R.id.renameTitle); renameList(renameTitle.getText().toString()); renameTitle.setText(""); renameDialog.dismiss(); } }); Button rNoButton = (Button) renameDialog.findViewById(R.id.r_dialog_no); rNoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { renameDialog.cancel(); } }); return renameDialog; default: return null; } }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
private void createProximityAlertSetupDialog() { final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_proximity_alert_create, R.string.create_proximity_alert); Button setProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_create_alert_watcher_button); Button stopCurrentProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_stop_existing_alert_button); Button cancelButton = (Button) dialog.findViewById(R.id.create_proximity_alert_cancel_button); SeekBar seekbar = (SeekBar) dialog.findViewById(R.id.create_proximity_alert_seekBar); final EditText radiusEditText = (EditText) dialog.findViewById(R.id.create_proximity_alert_range_edit_text); final Switch formatSwitch = (Switch) dialog.findViewById(R.id.create_proximity_alert_format_switch); final double seekBarStepSize = (double) (getResources() .getInteger(R.integer.proximity_alert_maximum_warning_range_meters) - getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)) / 100; radiusEditText.setText(// w ww. j a v a 2s. co m String.valueOf(getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters))); formatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { buttonView.setText(getString(R.string.range_format_nautical_miles)); } else { buttonView.setText(getString(R.string.range_format_meters)); } } }); seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { String range = String.valueOf( (int) (getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters) + (seekBarStepSize * progress))); radiusEditText.setText(range); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); setProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String toastText; if (proximityAlertWatcher == null) { toastText = getString(R.string.proximity_alert_set); } else { toastText = getString(R.string.proximity_alert_replace); } if (proximityAlertWatcher != null) { proximityAlertWatcher.cancel(true); } mGpsLocationTracker = new GpsLocationTracker(getActivity()); double latitude, longitude; if (mGpsLocationTracker.canGetLocation()) { latitude = mGpsLocationTracker.getLatitude(); cachedLat = latitude; longitude = mGpsLocationTracker.getLongitude(); cachedLon = longitude; } else { mGpsLocationTracker.showSettingsAlert(); return; } if (formatSwitch.isChecked()) { cachedDistance = Double.valueOf(radiusEditText.getText().toString()) * getResources().getInteger(R.integer.meters_per_nautical_mile); } else { cachedDistance = Double.valueOf(radiusEditText.getText().toString()); } dialog.dismiss(); Response response; try { String apiName = "fishingfacility"; String format = "OLEX"; String filePath; String fileName = "collisionCheckToolsFile"; response = barentswatchApi.getApi().geoDataDownload(apiName, format); if (response == null) { Log.d(TAG, "RESPONSE == NULL"); throw new InternalError(); } if (fiskInfoUtility.isExternalStorageWritable()) { String directoryPath = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(); String directoryName = "FiskInfo"; filePath = directoryPath + "/" + directoryName + "/"; InputStream zippedInputStream = null; try { TypedInput responseInput = response.getBody(); zippedInputStream = responseInput.in(); zippedInputStream = new GZIPInputStream(zippedInputStream); InputSource inputSource = new InputSource(zippedInputStream); InputStream input = new BufferedInputStream(inputSource.getByteStream()); byte data[]; data = FiskInfoUtility.toByteArray(input); InputStream inputStream = new ByteArrayInputStream(data); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); FiskInfoPolygon2D serializablePolygon2D = new FiskInfoPolygon2D(); String line; boolean startSet = false; String[] convertedLine; List<Point> shape = new ArrayList<>(); while ((line = reader.readLine()) != null) { Point currPoint = new Point(); if (line.length() == 0 || line.equals("")) { continue; } if (Character.isLetter(line.charAt(0))) { continue; } convertedLine = line.split("\\s+"); if (line.length() > 150) { Log.d(TAG, "line " + line); } if (convertedLine[0].startsWith("3sl")) { continue; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && startSet) { if (shape.size() == 1) { // Point serializablePolygon2D.addPoint(shape.get(0)); shape = new ArrayList<>(); } else if (shape.size() == 2) { // line serializablePolygon2D.addLine(new Line(shape.get(0), shape.get(1))); shape = new ArrayList<>(); } else { serializablePolygon2D.addPolygon(new Polygon(shape)); shape = new ArrayList<>(); } startSet = false; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && !startSet) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); startSet = true; } else if (convertedLine[3].equalsIgnoreCase("Brunsirkel")) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); } } reader.close(); new FiskInfoUtility().serializeFiskInfoPolygon2D(filePath + fileName + "." + format, serializablePolygon2D); tools = serializablePolygon2D; } catch (IOException e) { e.printStackTrace(); } catch (ArrayIndexOutOfBoundsException e) { Log.e(TAG, "Error when trying to serialize file."); Toast error = Toast.makeText(getActivity(), "Ingen redskaper i omrdet du definerte", Toast.LENGTH_LONG); e.printStackTrace(); error.show(); return; } finally { try { if (zippedInputStream != null) { zippedInputStream.close(); } } catch (IOException e) { e.printStackTrace(); } } } else { Toast.makeText(v.getContext(), R.string.download_failed, Toast.LENGTH_LONG).show(); dialog.dismiss(); return; } } catch (Exception e) { Log.d(TAG, "Could not download tools file"); Toast.makeText(getActivity(), R.string.download_failed, Toast.LENGTH_LONG).show(); } runScheduledAlarm(getResources().getInteger(R.integer.zero), getResources().getInteger(R.integer.proximity_alert_interval_time_seconds)); Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show(); } }); if (proximityAlertWatcher != null) { TypedValue outValue = new TypedValue(); stopCurrentProximityAlertWatcherButton.setVisibility(View.VISIBLE); getResources().getValue(R.dimen.proximity_alert_dialog_button_text_size_small, outValue, true); float textSize = outValue.getFloat(); setProximityAlertWatcherButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setTextSize(textSize); cancelButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; dialog.dismiss(); } }); } cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog)); dialog.show(); }
From source file:nf.frex.android.FrexActivity.java
private void prepareDecorationsDialog(final Dialog dialog) { final Registry<DistanceFunction> distanceFunctions = Registries.distanceFunctions; int checkedIndex = distanceFunctions.getIndex(view.getDistanceFunctionId()); ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, distanceFunctions.getIds()); arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final Spinner distanceFunctionSpinner = (Spinner) dialog.findViewById(R.id.distance_function_spinner); distanceFunctionSpinner.setAdapter(arrayAdapter); distanceFunctionSpinner.setSelection(checkedIndex, false); final SeekBarConfigurer dilationSeekBarConfigurer = SeekBarConfigurer.create( (SeekBar) dialog.findViewById(R.id.dilation_seek_bar), -3.0, 1.0, true, view.getDistanceDilation()); final SeekBarConfigurer translateXSeekBarConfigurer = SeekBarConfigurer.create( (SeekBar) dialog.findViewById(R.id.transl_x_seek_bar), -2.5, 2.5, false, view.getDistanceTranslateX()); final SeekBarConfigurer translateYSeekBarConfigurer = SeekBarConfigurer.create( (SeekBar) dialog.findViewById(R.id.transl_y_seek_bar), -2.5, 2.5, false, view.getDistanceTranslateY()); final CheckBox turbulenceCheckBox = (CheckBox) dialog.findViewById(R.id.turbulence); turbulenceCheckBox.setChecked(view.getGeneratorConfig().isTurbulenceEnabled()); final SeekBarConfigurer turbIntensSeekBarConfigurer = SeekBarConfigurer.create( (SeekBar) dialog.findViewById(R.id.turb_intens_seek_bar), -1.0, 1.0, true, view.getGeneratorConfig().getTurbulenceIntensity()); final SeekBarConfigurer turbScaleSeekBarConfigurer = SeekBarConfigurer.create( (SeekBar) dialog.findViewById(R.id.turb_scale_seek_bar), -1.0, 1.0, true, view.getGeneratorConfig().getTurbulenceScale()); Button randomButton = (Button) dialog.findViewById(R.id.random_button); randomButton.setOnClickListener(new View.OnClickListener() { @Override/*from w ww . j av a2 s . com*/ public void onClick(View v) { distanceFunctionSpinner.setSelection((int) (Math.random() * distanceFunctions.getSize())); dilationSeekBarConfigurer.setRandomValue(); translateXSeekBarConfigurer.setRandomValue(); translateYSeekBarConfigurer.setRandomValue(); if (Math.random() < 0.5) { turbIntensSeekBarConfigurer.setRandomValue(); turbScaleSeekBarConfigurer.setRandomValue(); } } }); Button okButton = (Button) dialog.findViewById(R.id.ok_button); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int index = distanceFunctionSpinner.getSelectedItemPosition(); dialog.dismiss(); view.setDecoratedFractal(true); view.setDistanceFunctionId(distanceFunctions.getId(index)); view.setDistanceDilation(dilationSeekBarConfigurer.getValue()); view.setDistanceTranslateX(translateXSeekBarConfigurer.getValue()); view.setDistanceTranslateY(translateYSeekBarConfigurer.getValue()); view.getGeneratorConfig().setTurbulenceEnabled(turbulenceCheckBox.isChecked()); view.getGeneratorConfig().setTurbulenceIntensity(turbIntensSeekBarConfigurer.getValue()); view.getGeneratorConfig().setTurbulenceScale(turbScaleSeekBarConfigurer.getValue()); view.recomputeAll(); } }); Button cancelButton = (Button) dialog.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); }
From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java
public void updateProfile() { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.change_profile_info_dialog); dialog.setTitle(getResources().getString(R.string.change_profile_info) + ":"); final HoloEditText name = (HoloEditText) dialog.findViewById(R.id.name); final HoloEditText url = (HoloEditText) dialog.findViewById(R.id.url); final HoloEditText location = (HoloEditText) dialog.findViewById(R.id.location); final HoloEditText description = (HoloEditText) dialog.findViewById(R.id.description); name.setText(thisUser.getName());/*from w ww .j a v a 2s. c o m*/ try { url.setText(thisUser.getURLEntity().getDisplayURL()); } catch (Exception e) { } location.setText(thisUser.getLocation()); description.setText(thisUser.getDescription()); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); Button change = (Button) dialog.findViewById(R.id.change); change.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ok = true; String nameS = null; String urlS = null; String locationS = null; String descriptionS = null; if (name.getText().length() <= 20 && ok) { if (name.getText().length() > 0) { nameS = name.getText().toString(); sharedPrefs.edit() .putString("twitter_users_name_" + sharedPrefs.getInt("current_account", 1), nameS) .commit(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.name_char_length), Toast.LENGTH_SHORT) .show(); } if (url.getText().length() <= 100 && ok) { if (url.getText().length() > 0) { urlS = url.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.url_char_length), Toast.LENGTH_SHORT) .show(); } if (location.getText().length() <= 30 && ok) { if (location.getText().length() > 0) { locationS = location.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.location_char_length), Toast.LENGTH_SHORT).show(); } if (description.getText().length() <= 160 && ok) { if (description.getText().length() > 0) { descriptionS = description.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.description_char_length), Toast.LENGTH_SHORT).show(); } if (ok) { new UpdateInfo(nameS, urlS, locationS, descriptionS).execute(); dialog.dismiss(); } } }); dialog.show(); }
From source file:com.klinker.android.twitter.ui.profile_viewer.ProfilePager.java
public void updateProfile() { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.change_profile_info_dialog); dialog.setTitle(getResources().getString(R.string.change_profile_info) + ":"); final HoloEditText name = (HoloEditText) dialog.findViewById(R.id.name); final HoloEditText url = (HoloEditText) dialog.findViewById(R.id.url); final HoloEditText location = (HoloEditText) dialog.findViewById(R.id.location); final HoloEditText description = (HoloEditText) dialog.findViewById(R.id.description); Button cancel = (Button) dialog.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override//w ww . j a va2 s. c o m public void onClick(View v) { dialog.dismiss(); } }); Button change = (Button) dialog.findViewById(R.id.change); change.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean ok = true; String nameS = null; String urlS = null; String locationS = null; String descriptionS = null; if (name.getText().length() <= 20 && ok) { if (name.getText().length() > 0) { nameS = name.getText().toString(); sharedPrefs.edit() .putString("twitter_users_name_" + sharedPrefs.getInt("current_account", 1), nameS) .commit(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.name_char_length), Toast.LENGTH_SHORT) .show(); } if (url.getText().length() <= 100 && ok) { if (url.getText().length() > 0) { urlS = url.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.url_char_length), Toast.LENGTH_SHORT) .show(); } if (location.getText().length() <= 30 && ok) { if (location.getText().length() > 0) { locationS = location.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.location_char_length), Toast.LENGTH_SHORT).show(); } if (description.getText().length() <= 160 && ok) { if (description.getText().length() > 0) { descriptionS = description.getText().toString(); } } else { ok = false; Toast.makeText(context, getResources().getString(R.string.description_char_length), Toast.LENGTH_SHORT).show(); } if (ok) { new UpdateInfo(nameS, urlS, locationS, descriptionS).execute(); dialog.dismiss(); } } }); dialog.show(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.UtilityOnClickListeners.java
public OnClickListener getHelpDialogOnClickListener() { return new OnClickListener() { @Override//from ww w. j a va 2 s .c o m public void onClick(View v) { final DialogInterface dialogInterface = new UtilityDialogs(); final Dialog dialog = dialogInterface.getDialog(v.getContext(), R.layout.dialog_settings, R.string.about); final Button closeDialogButton = (Button) dialog.findViewById(R.id.settings_dialog_close_button); final LinearLayout fieldContainer = (LinearLayout) dialog .findViewById(R.id.dialog_user_settings_main_container); closeDialogButton.setText(v.getContext().getString(R.string.back_to_settings)); closeDialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.dismiss(); } }); dialog.show(); } }; }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
public void createBackup(final boolean RecoveryBackup) { String prefix;/* ww w .j a va 2 s . c o m*/ String CurrentName; String EXT; if (RecoveryBackup) { prefix = "recovery"; EXT = mDevice.getRecoveryExt(); CurrentName = mDevice.getRecoveryVersion(); } else { prefix = "kernel"; EXT = mDevice.getKernelExt(); CurrentName = mDevice.getKernelVersion(); } final Dialog dialog = new Dialog(mContext); dialog.setTitle(R.string.setname); dialog.setContentView(R.layout.dialog_input); final Button bGoBackup = (Button) dialog.findViewById(R.id.bGoBackup); final EditText etFileName = (EditText) dialog.findViewById(R.id.etFileName); final CheckBox optName = (CheckBox) dialog.findViewById(R.id.cbOptInput); final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-" + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.HOUR) + ":" + Calendar.getInstance().get(Calendar.MINUTE) + EXT; optName.setText(CurrentName); optName.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { etFileName.setEnabled(!optName.isChecked()); } }); etFileName.setHint(NameHint); bGoBackup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String EXT; File Path; final int JOB; if (RecoveryBackup) { EXT = mDevice.getRecoveryExt(); Path = PathToRecoveryBackups; JOB = FlashUtil.JOB_BACKUP_RECOVERY; } else { EXT = mDevice.getKernelExt(); Path = PathToKernelBackups; JOB = FlashUtil.JOB_BACKUP_KERNEL; } String Name = ""; if (optName.isChecked()) { Name = optName.getText().toString() + EXT; } else { if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) { Name = etFileName.getText().toString(); } if (Name.equals("")) { Name = String.valueOf(etFileName.getHint()); } if (!Name.endsWith(EXT)) { Name = Name + EXT; } } final File fBACKUP = new File(Path, Name); Runnable rBackup = new Runnable() { @Override public void run() { FlashUtil BackupCreator = new FlashUtil(mShell, mContext, mDevice, fBACKUP, JOB); BackupCreator.setRunAtEnd(ReloadBackupDrawer); BackupCreator.execute(); } }; if (fBACKUP.exists()) { Toast.makeText(mContext, R.string.backupalready, Toast.LENGTH_SHORT).show(); } else { rBackup.run(); } dialog.dismiss(); } }); dialog.show(); }