List of usage examples for android.app ProgressDialog STYLE_HORIZONTAL
int STYLE_HORIZONTAL
To view the source code for android.app ProgressDialog STYLE_HORIZONTAL.
Click Source Link
From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java
/** * Create a LocalGeoJsonLayer from the GeoJson data submitted by uri. *//*from www . j ava 2s .c o m*/ protected static void create(final MapBase map, String layerName, Uri uri) { String sErr = map.getContext().getString(R.string.error_occurred); ProgressDialog progressDialog = new ProgressDialog(map.getContext()); try { InputStream inputStream = map.getContext().getContentResolver().openInputStream(uri); if (inputStream != null) { progressDialog.setMessage(map.getContext().getString(R.string.message_loading_progress)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.show(); int nSize = inputStream.available(); int nIncrement = 0; progressDialog.setMax(nSize); //read all geojson BufferedReader streamReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); StringBuilder responseStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) { nIncrement += inputStr.length(); progressDialog.setProgress(nIncrement); responseStrBuilder.append(inputStr); } progressDialog.setMessage(map.getContext().getString(R.string.message_opening_progress)); JSONObject geoJSONObject = new JSONObject(responseStrBuilder.toString()); if (!geoJSONObject.has(GEOJSON_TYPE)) { sErr += ": " + map.getContext().getString(R.string.error_geojson_unsupported); Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); progressDialog.hide(); return; } //check crs boolean isWGS84 = true; //if no crs tag - WGS84 CRS if (geoJSONObject.has(GEOJSON_CRS)) { JSONObject crsJSONObject = geoJSONObject.getJSONObject(GEOJSON_CRS); //the link is unsupported yet. if (!crsJSONObject.getString(GEOJSON_TYPE).equals(GEOJSON_NAME)) { sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported); Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); progressDialog.hide(); return; } JSONObject crsPropertiesJSONObject = crsJSONObject.getJSONObject(GEOJSON_PROPERTIES); String crsName = crsPropertiesJSONObject.getString(GEOJSON_NAME); if (crsName.equals("urn:ogc:def:crs:OGC:1.3:CRS84")) { // WGS84 isWGS84 = true; } else if (crsName.equals("urn:ogc:def:crs:EPSG::3857")) { //Web Mercator isWGS84 = false; } else { sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported); Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); progressDialog.hide(); return; } } //load contents to memory and reproject if needed JSONArray geoJSONFeatures = geoJSONObject.getJSONArray(GEOJSON_TYPE_FEATURES); if (0 == geoJSONFeatures.length()) { sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported); Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); progressDialog.hide(); return; } List<Feature> features = geoJSONFeaturesToFeatures(geoJSONFeatures, isWGS84, map.getContext(), progressDialog); create(map, layerName, features); } } catch (UnsupportedEncodingException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } catch (FileNotFoundException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } catch (IOException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } catch (JSONException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } progressDialog.hide(); //if we here something wrong occurred Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); }
From source file:com.ad.mediasharing.ADUploadMediaTask.java
@SuppressWarnings("deprecation") protected void onPreExecute() { Intent intent = new Intent(); pendingIntent = PendingIntent.getActivity(mActivity, 0, intent, 0); contentTitle = "Uploading Story..."; CharSequence contentText = uploadProgress + "% complete"; // Show the notification progress if (isPreferenceProgressEnabled) { notification = new Notification(R.drawable.ic_launcher_ctv, contentTitle, System.currentTimeMillis()); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT; notification.contentIntent = pendingIntent; notification.setLatestEventInfo(mActivity, contentTitle, contentText, pendingIntent); notificationManager.notify(NOTIFICATION_ID, notification); }/*from w w w . j a v a 2s. co m*/ // Show the alert progress bar if (isProgressBarEnabled) { pd = new ProgressDialog(mActivity); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setMessage(contentTitle); pd.setCancelable(false); pd.show(); } }
From source file:io.github.pwlin.cordova.plugins.pdialog.PDialog.java
/** * Initializing the progress dialog and set various parameters * /* w w w. j a v a 2 s.c o m*/ * @param rawArgs * @see https://github.com/pwlin/cordova-plugin-pdialog/blob/master/README.md */ private void init(final String rawArgs) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { @Override public void run() { if (PDialog.pDialogObj != null) { PDialog.pDialogObj.dismiss(); PDialog.pDialogObj = null; } JSONObject argsObj = null; try { argsObj = new JSONObject(rawArgs); } catch (JSONException e) { // e.printStackTrace(); } int theme = 5; // ProgressDialog.THEME_DEVICE_DEFAULT_LIGHT if (argsObj.has("theme")) { String themeArg = null; try { themeArg = argsObj.getString("theme"); } catch (JSONException e) { // e.printStackTrace(); } if ("TRADITIONAL".equals(themeArg)) { theme = 1; // ProgressDialog.THEME_TRADITIONAL } else if ("DEVICE_DARK".equals(themeArg)) { theme = 4; // ProgressDialog.THEME_DEVICE_DEFAULT_DARK } if ("HOLO_DARK".equals(themeArg)) { theme = 2; // ProgressDialog.THEME_HOLO_DARK } if ("HOLO_LIGHT".equals(themeArg)) { theme = 3; // ProgressDialog.THEME_HOLO_LIGHT } } int style = ProgressDialog.STYLE_SPINNER; if (argsObj.has("progressStyle")) { try { if ("HORIZONTAL".equals(argsObj.getString("progressStyle"))) { style = ProgressDialog.STYLE_HORIZONTAL; } } catch (JSONException e) { // e.printStackTrace(); } } boolean cancelable = true; if (argsObj.has("cancelable")) { try { if (argsObj.getBoolean("cancelable") == false) { cancelable = false; } } catch (JSONException e) { // e.printStackTrace(); } } String title = ""; if (argsObj.has("title")) { try { title = argsObj.getString("title"); } catch (JSONException e) { // e.printStackTrace(); } } String message = ""; if (argsObj.has("message")) { try { message = argsObj.getString("message"); } catch (JSONException e) { // e.printStackTrace(); } } PDialog.pDialogObj = new ProgressDialog(cordova.getActivity(), theme); PDialog.pDialogObj.setProgressStyle(style); PDialog.pDialogObj.setCancelable(cancelable); PDialog.pDialogObj.setCanceledOnTouchOutside(cancelable); PDialog.pDialogObj.setTitle(title); PDialog.pDialogObj.setMessage(message); PDialog.pDialogObj.show(); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Activity_WatchScanList.java
/** Called when the activity is first created. */ @Override//w ww. j a va 2s.c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device_list); tv_status = (TextView) findViewById(R.id.textView_Status); deviceList_Display = new ArrayList<Map<String, String>>(); adapter_deviceList_Display = new SimpleAdapter(this, deviceList_Display, android.R.layout.simple_list_item_2, new String[] { "title", "desc" }, new int[] { android.R.id.text1, android.R.id.text2 }); ListView listView_Devices = (ListView) findViewById(R.id.listView_deviceList); listView_Devices.setAdapter(adapter_deviceList_Display); //Set the list to download the data for the selected device and display it. listView_Devices.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { if (!bDevicesInList || watchPcc == null) return; final CharSequence[] downloadOptions = { "All Activities", "New Activities", "Wait For New Activities" }; AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); builder.setTitle("Download..."); builder.setItems(downloadOptions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int downloadSelection) { antFsProgressDialog = new ProgressDialog(Activity_WatchScanList.this); antFsProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); antFsProgressDialog.setMessage("Sending Request..."); antFsProgressDialog.setCancelable(false); antFsProgressDialog.setIndeterminate(false); fitFileList = new ArrayList<FitFile>(); if (downloadSelection == 0) // download all { if (watchPcc.requestDownloadAllActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 1) // download new { if (watchPcc.requestDownloadNewActivities(deviceInfoArray[pos].getDeviceUUID(), new DownloadActivitiesFinished(pos), new FileDownloadedReceiver(), new AntFsUpdateReceiver())) { antFsProgressDialog.show(); } } else if (downloadSelection == 2) { boolean reqSubmitted = watchPcc.listenForNewActivities( deviceInfoArray[pos].getDeviceUUID(), new IDownloadActivitiesFinishedReceiver() { @Override public void onNewDownloadActivitiesFinished(AntFsRequestStatus status) { //Only received on cancel right now, only thing to do is cancel dialog, already taken care of below } }, new FileDownloadedReceiver() { @Override public void onNewFitFileDownloaded(FitFile downloadedFitFile) { super.onNewFitFileDownloaded(downloadedFitFile); //Now show each file as we get it List<FitFile> newActivityOnly = new ArrayList<FitFile>(fitFileList); fitFileList.clear(); final Dialog_WatchData dataDialog = new Dialog_WatchData( deviceInfoArray[pos], newActivityOnly); runOnUiThread(new Runnable() { @Override public void run() { dataDialog.show(getSupportFragmentManager(), "DeviceData"); } }); } }); //Once the listener is started we leave this dialog open until it is cancelled //Note: Because the listener is an asynchronous process, you do not need to block the UI like the sample app does with this, you can leave it invisible to the user if (reqSubmitted) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity_WatchScanList.this); LayoutInflater inflater = Activity_WatchScanList.this.getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout View detailsView = inflater.inflate(R.layout.dialog_progresswaiter, null); TextView textView_status = (TextView) detailsView .findViewById(R.id.textView_Status); textView_status.setText("Waiting for new activities on " + deviceInfoArray[pos].getDisplayName() + "..."); builder.setView(detailsView); builder.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Let onCancelListener take care of business dialog.cancel(); } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (watchPcc != null) { watchPcc.cancelListenForNewActivities( deviceInfoArray[pos].getDeviceUUID()); } } }); AlertDialog waitDialog = builder.create(); waitDialog.show(); } } } }); AlertDialog alert = builder.create(); alert.show(); } }); resetPcc(); }
From source file:com.wheelermarine.publicAccessSites.Updater.java
@Override protected void onPreExecute() { // Setup the progress dialog box. progress = new ProgressDialog(context); progress.setTitle("Updating public accesses..."); progress.setMessage("Please wait."); progress.setCancelable(false);/*from w w w . ja v a2 s .c o m*/ progress.setIndeterminate(true); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.show(); }
From source file:edu.cmu.cs.cloudlet.android.CloudletActivity.java
protected void runConnection(String address, int port, VMInfo overlayVM) { if (this.connector != null) { this.connector.close(); }//from w w w . j ava2 s. c o m this.connector = new CloudletConnector(CloudletActivity.this, synthesisHandler); this.connector.setConnection(address, port, overlayVM); this.connector.start(); if (this.progDialog == null) { this.progDialog = new ProgressDialog(this); this.progDialog.setMessage("Connecting to " + address); this.progDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); this.progDialog.setCancelable(true); this.progDialog.setIcon(R.drawable.ic_launcher); } else { this.progDialog.setMessage("Connecting to " + address); } this.progDialog.show(); }
From source file:com.fortysevendeg.labs.bbc.rest.android.activities.BeerActivity.java
/** * Delete beer on server/*from w w w . j av a 2 s. co m*/ */ private void deleteBeer() { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setMessage(getString(R.string.connecting)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); APIService.get().deleteBeer(beerResponseEdit.getId(), new ContextAwareAPIDelegate<BeerResponse>(this, BeerResponse.class) { @Override public void onResults(BeerResponse beerResponse) { progressDialog.dismiss(); Toast.makeText(BeerActivity.this, R.string.beerDeleted, Toast.LENGTH_SHORT).show(); setResult(RESULT_OK); finish(); } @Override public void onError(Throwable e) { progressDialog.dismiss(); Toast.makeText(BeerActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); } }); }
From source file:nz.co.wholemeal.christchurchmetro.FavouritesActivity.java
private void initProgressDialog() { loadingRoutesProgressDialog = new ProgressDialog(this); loadingRoutesProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); loadingRoutesProgressDialog.setCancelable(false); loadingRoutesProgressDialog.setMax(MAX_PLATFORMS); loadingRoutesProgressDialog.setMessage(getString(R.string.loading_platforms)); loadingRoutesProgressDialog.show();//from w w w .j a v a 2 s . c o m }
From source file:org.webinos.android.app.wrt.ui.WidgetListActivity.java
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.activity_widget_list); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); } else {//from www . j a va 2 s . co m Log.i(TAG, "WidgetListActivity has no action bar."); } registerForContextMenu(getListView()); asyncRefreshHandler = new Handler() { @Override public void handleMessage(Message msg) { initList(); } }; mgr = WidgetManagerService.getWidgetManagerInstance(this, this); if (mgr != null) { mgr.addEventListener(this); initList(); } scanner = new WidgetImportHelper(this); /* populate stores array */ stores = getStores(); synchronized (this) { if (mgr == null) { blocked = true; runOnUiThread(new Runnable() { @Override public void run() { /* put up progress dialog until the service is * available */ Activity context = WidgetListActivity.this; progressDialog = new ProgressDialog(context); progressDialog.setCancelable(false); progressDialog.setMessage(context.getString(R.string.initialising_runtime)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIndeterminate(false); progressDialog.setMax(PROGRESS_MAX); progressDialog.show(); progressDialog.setProgressNumberFormat(null); } }); } } /* BroadcastReceiver to receive module loading progress */ progressBroadcastReceiver = new ProgressBroadcastReceiver(); }