List of usage examples for android.app AlertDialog show
public void show()
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * ??? (vin)//from www. j a va 2 s. c o m */ private void getCarSettingsFromServer() { String vin = getEditViewText(rootView, R.id.vin_edit); GetCarSettingsByVinTask getCarSettingsByVinTask = new GetCarSettingsByVinTask(getContext(), vin, new GetCarSettingsByVinTask.OnGetCarSettingsFinished() { @Override public void onFinished(String result) { final List<String> modelNames; final List<JSONObject> jsonObjects; try { JSONArray jsonArray = new JSONArray(result); jsonObjects = new ArrayList<JSONObject>(); // ??string list modelNames = new ArrayList<String>(); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Country country; Brand brand; Manufacturer manufacturer; Series series; Model model; // ?ID? if (jsonObject.has("countryId")) country = vehicleModel.getCountryById(jsonObject.getString("countryId")); else country = vehicleModel.countries.get(0); if (jsonObject.has("brandId")) brand = country.getBrandById(jsonObject.getString("brandId")); else brand = country.brands.get(0); if (jsonObject.has("manufacturerId")) manufacturer = brand .getManufacturerById(jsonObject.getString("manufacturerId")); else manufacturer = brand.manufacturers.get(0); if (jsonObject.has("seriesId")) series = manufacturer.getSeriesById(jsonObject.getString("seriesId")); else series = manufacturer.serieses.get(0); if (jsonObject.has("modelId")) model = series.getModelById(jsonObject.getString("modelId")); else model = series.models.get(0); // ??list?? jsonObjects.add(jsonObject); modelNames.add(manufacturer.name + " " + series.name + " " + model.name); } String[] tempArray = new String[modelNames.size() + 1]; for (int i = 0; i < modelNames.size(); i++) { tempArray[i] = modelNames.get(i); } showModelChooseDialog(tempArray, new OnChooseModelFinished() { @Override public void onFinished(int index) throws JSONException { // ????? if (index == modelNames.size()) { selectCarManually(); } // ? else { JSONObject jsonObject = jsonObjects.get(index); Country country = vehicleModel .getCountryById(jsonObject.getString("countryId")); Brand brand = country.getBrandById(jsonObject.getString("brandId")); Manufacturer manufacturer = brand .getManufacturerById(jsonObject.getString("manufacturerId")); Series series = manufacturer .getSeriesById(jsonObject.getString("seriesId")); Model model = series.getModelById(jsonObject.getString("modelId")); // ?idspinner? lastCountryIndex = vehicleModel.getCountryNames().indexOf(country.name); lastBrandIndex = country.getBrandNames().indexOf(brand.name); lastManufacturerIndex = brand.getManufacturerNames() .indexOf(manufacturer.name); lastSeriesIndex = manufacturer.getSeriesNames().indexOf(series.name); lastModelIndex = series.getModelNames().indexOf(model.name); // ?? updateCarSettings(); // UI updateUi(); } } }); } catch (JSONException e) { Log.d("DFCarChecker", "Json?" + e.getMessage()); } } @Override public void onFailed(String result) { // ?? Log.d("DFCarChecker", "???" + result); if (result.equals("VIN??")) { View view1 = ((Activity) getContext()).getLayoutInflater() .inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText("?"); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1) .setPositiveButton(R.string.ok, null) .setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { // ? selectCarManually(); showView(rootView, R.id.brand_input, true); } }).create(); dialog.show(); // ?? updateUi(); } else { // ?? Log.d("DFCarChecker", "???" + result); Toast.makeText(getContext(), result, Toast.LENGTH_LONG).show(); } } }); getCarSettingsByVinTask.execute(); }
From source file:net.homelinux.penecoptero.android.citybikes.donation.app.MainActivity.java
private void fillData(boolean all) { if (mNDBAdapter != null && mNDBAdapter.isConfigured()) { Bundle data = new Bundle(); if (!all) { GeoPoint center = locator.getCurrentGeoPoint(); if (center == null) { //Do something.. int nid = settings.getInt("network_id", -1); //Log.i("CityBikes","Current network is id: "+Integer.toString(nid)); if (nid != -1) { try { mNDBAdapter.load(); JSONObject network = mNDBAdapter.getNetworks(nid); //Log.i("CityBikes",network.toString()); double lat = Integer.parseInt(network.getString("lat")) / 1E6; double lng = Integer.parseInt(network.getString("lng")) / 1E6; Location fallback = new Location("fallback"); fallback.setLatitude(lat); fallback.setLongitude(lng); locator.setFallbackLocation(fallback); locator.unlockCenter(); center = locator.getCurrentGeoPoint(); } catch (Exception e) { //Log.i("CityBikes","We re fucked, that network aint existin"); e.printStackTrace(); }//from w ww. j av a 2 s. co m } else { //Log.i("CityBikes","We re fucked, why re we here?"); } } data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6()); data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6()); data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius()); } progressDialog = new ProgressDialog(this); progressDialog.setTitle(""); progressDialog.setMessage(getString(R.string.loading)); progressDialog.show(); try { mDbHelper.sync(all, data); } catch (Exception e) { ////Log.i("openBicing", "Error Updating?"); e.printStackTrace(); progressDialog.dismiss(); } ; } else { //Log.i("CityBikes","First time!!! :D"); try { mNDBAdapter.update(); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); alertDialog.setTitle(R.string.bike_network_alert_title); alertDialog.setMessage(getString(R.string.bike_network_alert_text)); alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); alertDialog.show(); } catch (Exception e) { e.printStackTrace(); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error), Toast.LENGTH_LONG); toast.show(); } } }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
private void fillData(boolean all) { if (mNDBAdapter != null && mNDBAdapter.isConfigured()) { Bundle data = new Bundle(); if (!all) { GeoPoint center = locator.getCurrentGeoPoint(); if (center == null) { //Do something.. int nid = settings.getInt("network_id", -1); //Log.i("CityBikes","Current network is id: "+Integer.toString(nid)); if (nid != -1) { try { mNDBAdapter.load(); JSONObject network = mNDBAdapter.getNetworks(nid); //Log.i("CityBikes",network.toString()); double lat = Integer.parseInt(network.getString("lat")) / 1E6; double lng = Integer.parseInt(network.getString("lng")) / 1E6; Location fallback = new Location("fallback"); fallback.setLatitude(lat); fallback.setLongitude(lng); locator.setFallbackLocation(fallback); locator.unlockCenter(); center = locator.getCurrentGeoPoint(); } catch (Exception e) { //Log.i("CityBikes","We re fucked, that network aint existin"); e.printStackTrace(); }//from ww w . j a va 2 s. com } else { //Log.i("CityBikes","We re fucked, why re we here?"); } } data.putInt(StationsDBAdapter.CENTER_LAT_KEY, center.getLatitudeE6()); data.putInt(StationsDBAdapter.CENTER_LNG_KEY, center.getLongitudeE6()); data.putInt(StationsDBAdapter.RADIUS_KEY, hOverlay.getRadius()); } progressDialog = new ProgressDialog(this); progressDialog.setTitle(""); progressDialog.setMessage(getString(R.string.loading)); progressDialog.show(); try { mDbHelper.sync(all, data); } catch (Exception e) { ////Log.i("openBicing", "Error Updating?"); e.printStackTrace(); progressDialog.dismiss(); } ; } else { //Log.i("CityBikes","First time!!! :D"); try { mNDBAdapter.update(); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_map); alertDialog.setTitle(R.string.bike_network_alert_title); alertDialog.setMessage(getString(R.string.bike_network_alert_text)); alertDialog.setButton(getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.automatic), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showAutoNetworkDialog(0); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.manual), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showBikeNetworks(); } }); alertDialog.show(); } catch (Exception e) { e.printStackTrace(); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error), Toast.LENGTH_LONG); toast.show(); } } infoLayer.update(); }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
protected void exportContent(final String narrativeId, final boolean isTemplate) { if (MediaPhone.DIRECTORY_TEMP == null) { UIUtilities.showToast(MediaPhoneActivity.this, R.string.export_missing_directory, true); return;/*from w w w . j a v a 2 s.co m*/ } if (IOUtilities.isInternalPath(MediaPhone.DIRECTORY_TEMP.getAbsolutePath())) { UIUtilities.showToast(MediaPhoneActivity.this, R.string.export_potential_problem, true); } // important to keep awake to export because we only have one chance to display the export options // after creating mov or smil file (will be cancelled on screen unlock; Android is weird) // TODO: move to a better (e.g. notification bar) method of exporting? UIUtilities.acquireKeepScreenOn(getWindow()); final CharSequence[] items = { getString(R.string.export_mov), getString(R.string.export_html), getString(R.string.export_smil, getString(R.string.app_name)) }; AlertDialog.Builder builder = new AlertDialog.Builder(MediaPhoneActivity.this); builder.setTitle(R.string.export_narrative_title); // builder.setMessage(R.string.send_narrative_hint); //breaks dialog builder.setIcon(android.R.drawable.ic_dialog_info); builder.setNegativeButton(android.R.string.cancel, null); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { ContentResolver contentResolver = getContentResolver(); NarrativeItem thisNarrative; if (isTemplate) { thisNarrative = NarrativesManager.findTemplateByInternalId(contentResolver, narrativeId); } else { thisNarrative = NarrativesManager.findNarrativeByInternalId(contentResolver, narrativeId); } final ArrayList<FrameMediaContainer> contentList = thisNarrative.getContentList(contentResolver); // random name to counter repeat sending name issues String exportId = MediaPhoneProvider.getNewInternalId().substring(0, 8); final String exportName = String.format(Locale.ENGLISH, "%s-%s", getString(R.string.app_name).replaceAll("[^a-zA-Z0-9]+", "-").toLowerCase(Locale.ENGLISH), exportId); Resources res = getResources(); final Map<Integer, Object> settings = new Hashtable<Integer, Object>(); settings.put(MediaUtilities.KEY_AUDIO_RESOURCE_ID, R.raw.ic_audio_playback); // some output settings (TODO: make sure HTML version respects these) settings.put(MediaUtilities.KEY_BACKGROUND_COLOUR, res.getColor(R.color.export_background)); settings.put(MediaUtilities.KEY_TEXT_COLOUR_NO_IMAGE, res.getColor(R.color.export_text_no_image)); settings.put(MediaUtilities.KEY_TEXT_COLOUR_WITH_IMAGE, res.getColor(R.color.export_text_with_image)); settings.put(MediaUtilities.KEY_TEXT_BACKGROUND_COLOUR, res.getColor(R.color.export_text_background)); // TODO: do we want to do getDimensionPixelSize for export? settings.put(MediaUtilities.KEY_TEXT_SPACING, res.getDimensionPixelSize(R.dimen.export_icon_text_padding)); settings.put(MediaUtilities.KEY_TEXT_CORNER_RADIUS, res.getDimensionPixelSize(R.dimen.export_icon_text_corner_radius)); settings.put(MediaUtilities.KEY_TEXT_BACKGROUND_SPAN_WIDTH, Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB); settings.put(MediaUtilities.KEY_MAX_TEXT_FONT_SIZE, res.getDimensionPixelSize(R.dimen.export_maximum_text_size)); settings.put(MediaUtilities.KEY_MAX_TEXT_CHARACTERS_PER_LINE, res.getInteger(R.integer.export_maximum_text_characters_per_line)); settings.put(MediaUtilities.KEY_MAX_TEXT_HEIGHT_WITH_IMAGE, res.getDimensionPixelSize(R.dimen.export_maximum_text_height_with_image)); if (contentList != null && contentList.size() > 0) { switch (item) { case 0: settings.put(MediaUtilities.KEY_OUTPUT_WIDTH, res.getInteger(R.integer.export_mov_width)); settings.put(MediaUtilities.KEY_OUTPUT_HEIGHT, res.getInteger(R.integer.export_mov_height)); settings.put(MediaUtilities.KEY_IMAGE_QUALITY, res.getInteger(R.integer.camera_jpeg_save_quality)); // all image files are compatible - we just convert to JPEG when writing the movie, // but we need to check for incompatible audio that we can't convert to PCM boolean incompatibleAudio = false; for (FrameMediaContainer frame : contentList) { for (String audioPath : frame.mAudioPaths) { if (!AndroidUtilities.arrayContains(MediaUtilities.MOV_AUDIO_FILE_EXTENSIONS, IOUtilities.getFileExtension(audioPath))) { incompatibleAudio = true; break; } } if (incompatibleAudio) { break; } } if (incompatibleAudio) { AlertDialog.Builder builder = new AlertDialog.Builder(MediaPhoneActivity.this); builder.setTitle(android.R.string.dialog_alert_title); builder.setMessage(R.string.mov_export_mov_incompatible); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setNegativeButton(android.R.string.cancel, null); builder.setPositiveButton(R.string.button_continue, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { exportMovie(settings, exportName, contentList); } }); AlertDialog alert = builder.create(); alert.show(); } else { exportMovie(settings, exportName, contentList); } break; case 1: settings.put(MediaUtilities.KEY_OUTPUT_WIDTH, res.getInteger(R.integer.export_html_width)); settings.put(MediaUtilities.KEY_OUTPUT_HEIGHT, res.getInteger(R.integer.export_html_height)); runExportNarrativesTask(new BackgroundRunnable() { private int mTaskResult = 0; @Override public int getTaskId() { return mTaskResult; } @Override public boolean getShowDialog() { return true; } @Override public void run() { ArrayList<Uri> filesToSend = HTMLUtilities.generateNarrativeHTML(getResources(), new File(MediaPhone.DIRECTORY_TEMP, exportName + MediaUtilities.HTML_FILE_EXTENSION), contentList, settings); if (filesToSend == null || filesToSend.size() <= 0) { mTaskResult = R.id.export_creation_failed; } else { sendFiles(filesToSend); } } }); break; case 2: settings.put(MediaUtilities.KEY_OUTPUT_WIDTH, res.getInteger(R.integer.export_smil_width)); settings.put(MediaUtilities.KEY_OUTPUT_HEIGHT, res.getInteger(R.integer.export_smil_height)); settings.put(MediaUtilities.KEY_PLAYER_BAR_ADJUSTMENT, res.getInteger(R.integer.export_smil_player_bar_adjustment)); runExportNarrativesTask(new BackgroundRunnable() { private int mTaskResult = 0; @Override public int getTaskId() { return mTaskResult; } @Override public boolean getShowDialog() { return true; } @Override public void run() { ArrayList<Uri> filesToSend = SMILUtilities.generateNarrativeSMIL(getResources(), new File(MediaPhone.DIRECTORY_TEMP, exportName + MediaUtilities.SMIL_FILE_EXTENSION), contentList, settings); if (filesToSend == null || filesToSend.size() <= 0) { mTaskResult = R.id.export_creation_failed; } else { sendFiles(filesToSend); } } }); break; } } else { UIUtilities.showToast(MediaPhoneActivity.this, (isTemplate ? R.string.export_template_failed : R.string.export_narrative_failed)); } dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:reportsas.com.formulapp.Formulario.java
public void HabilitarParametros(Menu menu) { for (int i = 0; i < encuesta.getParametros().size(); i++) { switch (encuesta.getParametros().get(i).getIdParametro()) { // Captura GPS case 1:/*w ww . j a va 2 s. c o m*/ menu.getItem(2).setVisible(true); parametroGPS = new ParametrosRespuesta(1); manejador = (LocationManager) getSystemService(LOCATION_SERVICE); if (!manejador.isProviderEnabled(LocationManager.GPS_PROVIDER)) { AlertDialog alert = null; final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("El sistema GPS esta desactivado, Debe activarlo!").setCancelable(false) .setPositiveButton("Activar GPS", new DialogInterface.OnClickListener() { public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) { startActivity( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); } }); alert = builder.create(); alert.show(); } Criteria criterio = new Criteria(); criterio.setCostAllowed(false); criterio.setAltitudeRequired(false); criterio.setAccuracy(Criteria.ACCURACY_FINE); proveedor = manejador.getBestProvider(criterio, true); Location localizacion = manejador.getLastKnownLocation(proveedor); capturarLocalizacion(localizacion); manejador.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30000, 0, this); Toast toast1; if (parametroGPS.getValor().equals("Posicion Desconocida")) { toast1 = Toast.makeText(this, "Posicion Desconocida.", Toast.LENGTH_SHORT); } else { toast1 = Toast.makeText(this, "Localizacin obtenida exitosamente.", Toast.LENGTH_SHORT); } toast1.show(); break; // Captura Imgen case 2: menu.getItem(0).setVisible(true); break; // Lectura de Codigo case 3: menu.getItem(1).setVisible(true); break; default: break; } } }
From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java
public void displayalertdialog(double latitude, double longitude, String address, int success) { final double lat = latitude; final double lng = longitude; if (success == 1) { final AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Congratulations!"); // Setting Dialog Message alertDialog.setMessage("Your parking spot has been blocked"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss();//from w w w . j a v a 2 s.co m AlertDialog alertDialog1 = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this) .create(); // Setting Dialog Title alertDialog1.setTitle("Do you want to get directions?"); alertDialog1.setButton2("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.e("GetIndividualParkingSpots", "Inside Yes"); Intent yesintent = new Intent(GetIndividualParkingSpotDetails.this, GoogleDirectionsActivity.class); yesintent.putExtra(GetParkingLots.LATITUDE, lat); yesintent.putExtra(GetParkingLots.LONGITUDE, lng); startActivity(yesintent); Log.e("GetIndividualParkingSpots", "After Calling Intent"); } }); alertDialog1.setButton3("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent nointent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(nointent); } }); alertDialog1.show(); } }); // Showing Alert Message alertDialog.show(); if (chk_default.isChecked()) { Log.i("GetIndividualParkingSpotDetails", "Inside Checkbox if "); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till long " + toTime); Log.i("GetIndividualParkingSpotDetails", " Spot has been blocked till DateTime" + DateTimeHelpers.convertToTimeFromLong(toTime)); Log.i("GetIndividualParkingSpotDetails", "Inside if checkbox address" + address); scheduleNotification(getNotification( "You parked the car in" + address + "Your parking spot id is " + theParkingSpotName)); } } else { AlertDialog alertDialog = new AlertDialog.Builder(GetIndividualParkingSpotDetails.this).create(); // Setting Dialog Title alertDialog.setTitle("Sorry!"); // Setting Dialog Message alertDialog.setMessage("There was a problem processing your request"); // Setting Icon to Dialog // alertDialog.setIcon(R.drawable.tick); // Setting OK Button alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Intent intent = new Intent(GetIndividualParkingSpotDetails.this, GetParkingLots.class); startActivity(intent); } }); // Showing Alert Message alertDialog.show(); } }
From source file:jmri.enginedriver.threaded_application.java
public void checkExit(final Activity activity) { final AlertDialog.Builder b = new AlertDialog.Builder(activity); b.setIcon(android.R.drawable.ic_dialog_alert); b.setTitle(R.string.exit_title);// w w w .j a v a2 s. c o m b.setMessage(R.string.exit_text); b.setCancelable(true); b.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { firstCreate = true; sendMsg(comm_msg_handler, message_type.DISCONNECT, ""); //trigger disconnect / shutdown sequence } }); b.setNegativeButton(R.string.no, null); AlertDialog alert = b.create(); alert.show(); }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * /* w ww . j ava 2 s. co m*/ * @param arrayId * @param editViewId */ private void choose(final int arrayId, final int editViewId) { View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create(); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); final ListView listView = new ListView(view1.getContext()); listView.setAdapter(new ArrayAdapter<String>(view1.getContext(), android.R.layout.simple_list_item_1, view1.getResources().getStringArray(arrayId))); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dialog.dismiss(); String temp = (String) listView.getItemAtPosition(i); setEditViewText(rootView, editViewId, temp); } }); contentArea.addView(listView); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); dialog.show(); }
From source file:com.fvd.nimbus.PaintActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { ContentResolver cr;/*from w w w. ja va 2 s . co m*/ InputStream is; if (requestCode == TAKE_PHOTO) { showProgress(false); if (resultCode == -1) { try { if (data != null) { if (data.hasExtra("data")) { //Bitmap bm = ; drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap((Bitmap) data.getParcelableExtra("data"), 0); drawView.setVisibility(View.VISIBLE); } } else { if (outputFileUri != null) { cr = getContentResolver(); try { is = cr.openInputStream(outputFileUri); Bitmap bmp = BitmapFactory.decodeStream(is); if (bmp.getWidth() != -1 && bmp.getHeight() != -1) { drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap(bmp, 0); drawView.setVisibility(View.VISIBLE); } } catch (Exception e) { appSettings.appendLog("paint:onCreate " + e.getMessage()); } } } } catch (Exception e) { appSettings.appendLog("main:onActivityResult: exception - " + e.getMessage()); } } ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0); } else if (requestCode == TAKE_PICTURE) { showProgress(false); if (resultCode == -1 && data != null) { boolean temp = false; try { Uri resultUri = data.getData(); String drawString = resultUri.getPath(); InputStream input = getContentResolver().openInputStream(resultUri); drawView.setVisibility(View.INVISIBLE); drawView.recycle(); drawView.setBitmap(BitmapFactory.decodeStream(input), 0); //drawView.forceRedraw(); drawView.setVisibility(View.VISIBLE); } catch (Exception e) { appSettings.appendLog("main:onActivityResult " + e.getMessage()); } } ((ViewAnimator) findViewById(R.id.top_switcher)).setDisplayedChild(0); } else if (requestCode == SHOW_SETTINGS) { switch (resultCode) { case RESULT_FIRST_USER + 1: Intent i = new Intent(getApplicationContext(), PrefsActivity.class); startActivity(i); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 2: if (appSettings.sessionId.length() == 0) showLogin(); else { appSettings.sessionId = ""; //serverHelper.getInstance().setSessionId(appSettings.sessionId); Editor e = prefs.edit(); e.putString("userMail", userMail); e.putString("userPass", ""); e.putString("sessionId", appSettings.sessionId); e.commit(); showLogin(); } break; case RESULT_FIRST_USER + 3: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName))); } catch (Exception e) { } case RESULT_FIRST_USER + 4: Uri uri = Uri.parse( "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 5: final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no alert dialog shown //alertDialogShown = null; // canceled setResult(RESULT_CANCELED); // and finish //finish(); } }); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setTitle(getString(R.string.license_title)); // and show //alertDialogShown = alertDialog; try { alertDialog.show(); } catch (final java.lang.Exception e) { // nothing to do } catch (final java.lang.Error e) { // nothing to do } break; default: break; } } if (requestCode == 3) { if (resultCode == RESULT_OK || resultCode == RESULT_FIRST_USER) { userMail = data.getStringExtra("userMail"); userPass = data.getStringExtra("userPass"); if (resultCode == RESULT_OK) sendRequest("user:auth", String.format("\"email\":\"%s\",\"password\":\"%s\"", userMail, userPass)); else serverHelper.getInstance().sendOldRequest("user_register", String.format( "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}", userMail, userPass), ""); } } else if (requestCode == 11) { if (appSettings.sessionId != "") { sessionId = appSettings.sessionId; userPass = appSettings.userPass; sendShot(); } } else if (requestCode == 4) { if (resultCode == RESULT_OK) { String id = data.getStringExtra("id").toString(); serverHelper.getInstance().shareShot(id); } } else if (resultCode == RESULT_OK) { drawView.setColour(dColor); setPaletteColor(dColor); Uri resultUri = data.getData(); String drawString = resultUri.getPath(); String galleryString = getGalleryPath(resultUri); if (galleryString != null) { drawString = galleryString; } // else another file manager was used else { if (drawString.contains("//")) { drawString = drawString.substring(drawString.lastIndexOf("//")); } } // set the background to the selected picture if (drawString.length() > 0) { Drawable drawBackground = Drawable.createFromPath(drawString); drawView.setBackgroundDrawable(drawBackground); } } }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * ?//from w w w .ja va 2 s . c om * @param array * @param mCallback * @throws JSONException */ private void showModelChooseDialog(String[] array, final OnChooseModelFinished mCallback) throws JSONException { array[array.length - 1] = ""; View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create(); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); final ListView listView = new ListView(view1.getContext()); listView.setAdapter( new ArrayAdapter<String>(view1.getContext(), android.R.layout.simple_list_item_1, array)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { try { mCallback.onFinished(i); dialog.dismiss(); } catch (JSONException e) { e.printStackTrace(); } } }); contentArea.addView(listView); setTextView(view1, R.id.title, getResources().getString(R.string.select_model)); dialog.show(); }