List of usage examples for android.app ProgressDialog setTitle
@Override public void setTitle(CharSequence title)
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
/** * this function will initialize the ui showing the current image and reload * everything to make sure it is shown correctly *///from w ww .j a v a 2s. c om private void initUI() { // set the actionBar title and subtitle if (actionBar != null) { actionBar.setTitle(R.string.send_image); actionBar.setSubtitle(name); // actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor // (R.color.action_bar_transparent))); // // set the statusBar color // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) // getActivity().getWindow().setStatusBarColor(getResources().getColor(R // .color.action_bar_transparent)); } // instantiate the ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager); viewPager.setAdapter(new MyPagerAdapter()); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { changePage(position, false, false); } @Override public void onPageScrollStateChanged(int state) { } }); //Cancel button pressed getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // just return to the chatFragment mListener.onReturnClick(); } }); //Send button pressed getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // create the progressDialog that is to be shown while saving // the image ProgressDialog progressDialog = new ProgressDialog(getContext()); if (images.size() > 1) progressDialog.setTitle( String.format(getResources().getString(R.string.sending_images), images.size())); else progressDialog.setTitle(R.string.sending_image); // run the sendImage in a new thread because I am saving the // image and this should be done in a new thread new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start(); } }); // generate the overview only if there are at least 2 images if (images.size() > 1) { // the layoutParams for the imageView which has the following attributes: // width = height = 65dp // margin = 5dp getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE); int a = Constants.dipToPixel(getContext(), 65); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a); int b = Constants.dipToPixel(getContext(), 5); imageViewParams.setMargins(b, b, b, b); // the layoutParams for the backgroundView which has the following // attributes: // width = height = 71dp // margin = 2dp int c = Constants.dipToPixel(getContext(), 71); RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c); int d = Constants.dipToPixel(getContext(), 2); backgroundParams.setMargins(d, d, d, d); // the layoutParams for the relativeLayout containing the image and // the background which has the following attributes: // width = height = wrap_content LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content); linearLayout.removeAllViewsInLayout(); int i = 0; for (Message msg : images) { // set up the imageView ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams(imageViewParams); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // load the bitmap async AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a, true); imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker)); imageView.setOnClickListener(new overviewSelectListener(i++)); bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri())); // set up the background View background = new View(getContext()); background.setLayoutParams(backgroundParams); background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark)); // make it invisible in the beginning background.setVisibility(View.GONE); // create the relativeLayout containing them RelativeLayout relativeLayout = new RelativeLayout(getContext()); relativeLayout.setLayoutParams(relativeLayoutParams); relativeLayout.addView(background); relativeLayout.addView(imageView); // combination of Message and overviewViews msg.setLayout(relativeLayout); msg.setBackground(background); linearLayout.addView(relativeLayout); } } else getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE); changePage(current, true, true); showSystemUI(); }
From source file:fm.smart.r1.activity.ItemActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); // this should be called once image has been chosen by user // using requestCode to pass item id - haven't worked out any other way // to do it/*from www. j a v a 2 s. c om*/ // if (requestCode == SELECT_IMAGE) if (resultCode == Activity.RESULT_OK) { // TODO check if user is logged in if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid navigation back to this? LoginActivity.return_to = ItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id")); startActivity(intent); // TODO in this case forcing the user to rechoose the image // seems a little // rude - should probably auto-submit here ... } else { // Bundle extras = data.getExtras(); // String sentence_id = (String) extras.get("sentence_id"); final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Uploading image ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add_image = new Thread() { public void run() { // TODO needs to check for interruptibility String sentence_id = Integer.toString(requestCode); Uri selectedImage = data.getData(); // Bitmap bitmap = Media.getBitmap(getContentResolver(), // selectedImage); // ByteArrayOutputStream bytes = new // ByteArrayOutputStream(); // bitmap.compress(Bitmap.CompressFormat.JPEG, 40, // bytes); // ByteArrayInputStream fileInputStream = new // ByteArrayInputStream( // bytes.toByteArray()); // TODO Might have to save to file system first to get // this // to work, // argh! // could think of it as saving to cache ... // add image to sentence FileInputStream is = null; FileOutputStream os = null; File file = null; ContentResolver resolver = getContentResolver(); try { Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); // ByteArrayInputStream bais = new // ByteArrayInputStream(bytes.toByteArray()); // FileDescriptor fd = // resolver.openFileDescriptor(selectedImage, // "r").getFileDescriptor(); // is = new FileInputStream(fd); String filename = "test.jpg"; File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE); file = new File(dir, filename); os = new FileOutputStream(file); // while (bais.available() > 0) { // / os.write(bais.read()); // } os.write(bytes.toByteArray()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } if (is != null) { try { is.close(); } catch (IOException e) { } } } // File file = new // File(Uri.decode(selectedImage.toString())); // ensure item is in users default list ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, (String) item.item_node.atts.get("id"), ItemActivity.this); Result result = ItemActivity.add_item_result; if (ItemActivity.add_item_result.success() || ItemActivity.add_item_result.alreadyInList()) { // ensure sentence is in users default list ItemActivity.add_sentence_list_result = addSentenceToList(sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id, ItemActivity.this); result = ItemActivity.add_sentence_list_result; if (ItemActivity.add_sentence_list_result.success()) { String media_entity = "http://test.com/test.jpg"; String author = "tansaku"; String author_url = "http://smart.fm/users/tansaku"; Log.d("DEBUG-IMAGE-URI", selectedImage.toString()); ItemActivity.add_image_result = addImage(file, media_entity, author, author_url, "1", sentence_id, (String) item.item_node.atts.get("id"), Main.default_study_list_id); result = ItemActivity.add_image_result; } } final Result display = result; myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(display.getTitle()); dialog.setMessage(display.getMessage()); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (ItemActivity.add_image_result != null && ItemActivity.add_image_result.success()) { ItemListActivity.loadItem(ItemActivity.this, item.item_node.atts.get("id").toString()); } } }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add_image.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add_image.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add_image.start(); } } }
From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { final BaseApplication application = (BaseApplication) getActivity().getApplication(); final IOneDriveClient oneDriveClient = application.getOneDriveClient(); if (requestCode == REQUEST_CODE_SIMPLE_UPLOAD && data != null && data.getData() != null && data.getData().getScheme().equalsIgnoreCase(SCHEME_CONTENT)) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setTitle(R.string.upload_in_progress_title); dialog.setMessage(getString(R.string.upload_in_progress_message)); dialog.setIndeterminate(false);/*from w w w . j a v a 2 s . co m*/ dialog.setCancelable(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgressNumberFormat(getString(R.string.upload_in_progress_number_format)); dialog.show(); final AsyncTask<Void, Void, Void> uploadFile = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(final Void... params) { try { final ContentResolver contentResolver = getActivity().getContentResolver(); final ContentProviderClient contentProvider = contentResolver .acquireContentProviderClient(data.getData()); final byte[] fileInMemory = FileContent.getFileBytes(contentProvider, data.getData()); contentProvider.release(); // Fix up the file name (needed for camera roll photos, etc) final String filename = FileContent.getValidFileName(contentResolver, data.getData()); final Option option = new QueryOption("@name.conflictBehavior", "fail"); oneDriveClient.getDrive().getItems(mItemId).getChildren().byId(filename).getContent() .buildRequest(Collections.singletonList(option)) .put(fileInMemory, new IProgressCallback<Item>() { @Override public void success(final Item item) { dialog.dismiss(); Toast.makeText(getActivity(), application.getString(R.string.upload_complete, item.name), Toast.LENGTH_LONG).show(); refresh(); } @Override public void failure(final ClientException error) { dialog.dismiss(); if (error.isError(OneDriveErrorCodes.NameAlreadyExists)) { Toast.makeText(getActivity(), R.string.upload_failed_name_conflict, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), application.getString(R.string.upload_failed, filename), Toast.LENGTH_LONG).show(); } } @Override public void progress(final long current, final long max) { dialog.setProgress((int) current); dialog.setMax((int) max); } }); } catch (final Exception e) { Log.e(getClass().getSimpleName(), e.getMessage()); Log.e(getClass().getSimpleName(), e.toString()); } return null; } }; uploadFile.execute(); } }
From source file:jp.co.rediscovery.arflight.ManagerFragment.java
/** * ??IDeviceController?/*from w w w . j a v a 2s. co m*/ * @param controller */ protected void stopController(final IDeviceController controller) { runOnUiThread(new Runnable() { @Override public void run() { final boolean show_progress = controller.isStarted(); final ProgressDialog dialog; if (show_progress) { dialog = new ProgressDialog(getActivity()); dialog.setTitle(R.string.disconnecting); dialog.setIndeterminate(true); dialog.show(); } else { dialog = null; } queueEvent(new Runnable() { @Override public void run() { try { controller.stop(); } catch (final Exception e) { Log.w(TAG, e); } if (dialog != null) { runOnUiThread(new Runnable() { @Override public void run() { dialog.dismiss(); } }); } } }); } }); }
From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java
/** * Copies an item onto the current destination in the copy preferences * @param item The item to copy/*from w w w . ja v a 2 s . com*/ */ private void copy(final Item item) { final BaseApplication app = (BaseApplication) getActivity().getApplication(); final IOneDriveClient oneDriveClient = app.getOneDriveClient(); final ItemReference parentReference = new ItemReference(); parentReference.id = getCopyPrefs().getString(COPY_DESTINATION_PREF_KEY, null); final ProgressDialog dialog = new ProgressDialog(getActivity(), ProgressDialog.STYLE_HORIZONTAL); dialog.setTitle("Copying item"); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMessage("Waiting for copy to complete"); final IProgressCallback<Item> progressCallback = new IProgressCallback<Item>() { @Override public void progress(final long current, final long max) { dialog.setMax((int) current); dialog.setMax((int) max); } @Override public void success(final Item item) { dialog.dismiss(); final String string = getString(R.string.copy_success_message, item.name, item.parentReference.path); Toast.makeText(getActivity(), string, Toast.LENGTH_LONG).show(); } @Override public void failure(final ClientException error) { dialog.dismiss(); new AlertDialog.Builder(getActivity()).setTitle(R.string.error_title).setMessage(error.getMessage()) .setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }).create().show(); } }; final DefaultCallback<AsyncMonitor<Item>> callback = new DefaultCallback<AsyncMonitor<Item>>( getActivity()) { @Override public void success(final AsyncMonitor<Item> itemAsyncMonitor) { final int millisBetweenPoll = 1000; itemAsyncMonitor.pollForResult(millisBetweenPoll, progressCallback); } }; oneDriveClient.getDrive().getItems(item.id).getCopy(item.name, parentReference).buildRequest() .create(callback); dialog.show(); }
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java
private void uploadPhoto() { final ProgressDialog progress = new ProgressDialog(DetailsActivity.this); progress.setMessage(getResources().getString(R.string.send)); progress.setTitle(getResources().getString(R.string.app_name)); progress.setProgressStyle(ProgressDialog.STYLE_SPINNER); progress.show();/*from w ww . j a v a2 s . co m*/ final File mediaFile = getStoredMediaFile(); RequestBody file = RequestBody .create(MediaType.parse(URLConnection.guessContentTypeFromName(mediaFile.getName())), mediaFile); rsapi.photoUpload(email, token, bahnhof.getId(), countryCode.toLowerCase(), file) .enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { progress.dismiss(); switch (response.code()) { case 202: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_completed); break; case 400: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_bad_request); break; case 401: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_token_invalid); break; case 409: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_conflict); break; case 413: new SimpleDialogs().confirm(DetailsActivity.this, R.string.upload_too_big); break; default: new SimpleDialogs().confirm(DetailsActivity.this, String.format(getText(R.string.upload_failed).toString(), response.code())); } } @Override public void onFailure(Call<Void> call, Throwable t) { Log.e(TAG, "Error uploading photo", t); progress.dismiss(); new SimpleDialogs().confirm(DetailsActivity.this, String.format(getText(R.string.upload_failed).toString(), t.getMessage())); } }); }
From source file:info.staticfree.android.units.Units.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ABOUT: { final Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.dialog_about_title); builder.setIcon(R.drawable.icon); try {/*from w w w. j a va 2 s . co m*/ final WebView wv = new WebView(this); final InputStream is = getAssets().open("README.xhtml"); wv.loadDataWithBaseURL("file:///android_asset/", inputStreamToString(is), "application/xhtml+xml", "utf-8", null); wv.setBackgroundColor(0); builder.setView(wv); } catch (final IOException e) { builder.setMessage(R.string.err_no_load_about); e.printStackTrace(); } builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK); } }); return builder.create(); } case DIALOG_ALL_UNITS: { final Builder b = new Builder(Units.this); b.setTitle(R.string.dialog_all_units_title); final ExpandableListView unitExpandList = new ExpandableListView(Units.this); unitExpandList.setId(android.R.id.list); final String[] groupProjection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; // any selection below will select from the grouping description final Cursor cursor = managedQuery(UsageEntry.CONTENT_URI_CONFORM_TOP, groupProjection, null, null, UnitUsageDBHelper.USAGE_SORT); unitExpandList.setAdapter(new UnitsExpandableListAdapter(cursor, this, android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 }, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 })); unitExpandList.setCacheColorHint(0); unitExpandList.setOnChildClickListener(allUnitChildClickListener); b.setView(unitExpandList); return b.create(); } case DIALOG_UNIT_CATEGORY: { final Builder b = new Builder(new ContextThemeWrapper(this, android.R.style.Theme_Black)); final String[] from = { UsageEntry._UNIT }; final int[] to = { android.R.id.text1 }; b.setTitle("all units"); final String[] projection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; final Cursor c = managedQuery(UsageEntry.CONTENT_URI, projection, null, null, UnitUsageDBHelper.USAGE_SORT); dialogUnitCategoryList = new SimpleCursorAdapter(this, android.R.layout.select_dialog_item, c, from, to); b.setAdapter(dialogUnitCategoryList, dialogUnitCategoryOnClickListener); return b.create(); } case DIALOG_LOADING_UNITS: { final ProgressDialog pd = new ProgressDialog(this); pd.setIndeterminate(true); pd.setTitle(R.string.app_name); pd.setMessage(getText(R.string.dialog_loading_units)); return pd; } default: throw new IllegalArgumentException("Unknown dialog ID:" + id); } }
From source file:com.flipzu.flipzu.Recorder.java
protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from w ww . j av a 2s . c o m*/ ProgressDialog pDialog; AlertDialog aDialog; AlertDialog.Builder builder; switch (id) { case CONNECTING_DIALOG_ID: pDialog = new ProgressDialog(Recorder.this); pDialog.setTitle(null); pDialog.setMessage("Connecting..."); dialog = pDialog; break; case DISCONNECTING_DIALOG_ID: pDialog = new ProgressDialog(Recorder.this); pDialog.setTitle(null); pDialog.setMessage("Closing broadcast, please wait..."); dialog = pDialog; break; case AUTH_FAILED_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("Auth failed. Please logout and try again.").setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(AUTH_FAILED_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case CONNECTION_LOST_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("Connection lost :-(").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(CONNECTION_LOST_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case NO_INTERNET_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("No Internet connection").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(NO_INTERNET_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case MIC_FAILED_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("Microphone initialization failed! Please try restarting the App.") .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(MIC_FAILED_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case SLOW_NETWORK_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("Network speed is too slow! Disconnected.").setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(SLOW_NETWORK_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case SLOW_CPU_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage("We can't process audio fast enough, so we're disconnecting. Sorry :(") .setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(SLOW_CPU_DIALOG_ID); clearNotifications(); } }); aDialog = builder.create(); dialog = aDialog; break; case BIND_FACEBOOK_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage( "Please visit http://flipzu.com ('Settings' section) to bind your Facebook account. Then Re-Login on this app.") .setCancelable(false).setTitle("Facebook Share") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(BIND_FACEBOOK_DIALOG_ID); } }); aDialog = builder.create(); dialog = aDialog; break; case BIND_TWITTER_DIALOG_ID: builder = new AlertDialog.Builder(this); builder.setMessage( "Please visit http://flipzu.com ('Settings' section) to bind your Twitter account. Then Re-Login on this app.") .setCancelable(false).setTitle("Twitter Share") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismissDialog(BIND_TWITTER_DIALOG_ID); } }); aDialog = builder.create(); dialog = aDialog; break; default: dialog = null; } return dialog; }
From source file:com.arantius.tivocommander.SeasonPass.java
public void reorderApply(View unusedView) { Utils.log("SeasonPass::reorderApply() " + Boolean.toString(mInReorderMode)); boolean noChange = true; ArrayList<String> subIds = new ArrayList<String>(); for (int i = 0; i < mSubscriptionIds.size(); i++) { if (mSubscriptionIds.get(i) != mSubscriptionIdsBeforeReorder.get(i)) { noChange = false;/*from www. j a va 2 s . c o m*/ } subIds.add(mSubscriptionData.get(i).path("subscriptionId").asText()); } final ProgressDialog d = new ProgressDialog(this); final MindRpcResponseListener onReorderComplete = new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { if (d.isShowing()) { d.dismiss(); } // Flip the buttons. findViewById(R.id.reorder_enable).setVisibility(View.VISIBLE); findViewById(R.id.reorder_apply).setVisibility(View.GONE); // Turn off the drag handles. mInReorderMode = false; mListAdapter.notifyDataSetChanged(); } }; if (noChange) { // If there was no change, switch the UI back immediately. onReorderComplete.onResponse(null); } else { // Otherwise show a dialog while we do the RPC. d.setIndeterminate(true); d.setTitle("Saving ..."); d.setMessage("Saving new season pass order. " + "Patience please, this takes a while."); d.setCancelable(false); d.show(); SubscriptionsReprioritize req = new SubscriptionsReprioritize(subIds); MindRpc.addRequest(req, onReorderComplete); } }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PROGRESS_DIALOG: Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "show"); ProgressDialog progressDialog = new ProgressDialog(this); DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() { @Override/*from w ww. j av a 2 s. c o m*/ public void onClick(DialogInterface dialog, int which) { Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "cancel"); dialog.dismiss(); getFileTask.cancel(true); getFileTask.setGoogleDriveFormDownloadListener(null); } }; progressDialog.setTitle(getString(R.string.downloading_data)); progressDialog.setMessage(alertMsg); progressDialog.setIndeterminate(true); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setCancelable(false); progressDialog.setButton(getString(R.string.cancel), loadingButtonListener); return progressDialog; case GOOGLE_USER_DIALOG: AlertDialog.Builder gudBuilder = new AlertDialog.Builder(this); gudBuilder.setTitle(getString(R.string.no_google_account)); gudBuilder.setMessage(getString(R.string.google_set_account)); gudBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); gudBuilder.setCancelable(false); return gudBuilder.create(); } return null; }