List of usage examples for android.app ProgressDialog STYLE_SPINNER
int STYLE_SPINNER
To view the source code for android.app ProgressDialog STYLE_SPINNER.
Click Source Link
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
/** * Show ProgressDialog/*from ww w. j a v a 2s . c om*/ */ @UiThread public void showProgressDialog(String message) { if (progressDialog != null) { return; } progressDialog = new ProgressDialog(activity); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage(message); progressDialog.show(); }
From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { if (getArguments() != null) { operationType = getArguments().getInt(ARGUMENT_TYPEID); intentId = getArguments().getString(ARGUMENT_INTENTID); iconId = getArguments().getInt(ARGUMENT_ICONID); title = getArguments().getString(ARGUMENT_TITLEID); message = getArguments().getString(ARGUMENT_MESSAGEID); parent = getArguments().getParcelable(ARGUMENT_NODEID); nbItems = getArguments().getInt(ARGUMENT_SIZE); operationId = getArguments().getString(ARGUMENT_OPERATIONID); }//from w w w . ja va 2s.c o m ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_application_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (operationId != null) { Operator.with(getActivity()).cancel(operationId); } dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }
From source file:com.tsroad.map.poisearch.PoiAroundSearchActivity.java
/** * //w w w. j a va2 s . co m */ private void showProgressDialog() { if (progDialog == null) progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setIndeterminate(false); progDialog.setCancelable(false); progDialog.setMessage("?"); progDialog.show(); }
From source file:org.starfishrespect.myconsumption.android.ui.AddSensorActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_sensor); Toolbar toolbar = getActionBarToolbar(); getSupportActionBar().setTitle(getString(R.string.title_add_sensor)); toolbar.setNavigationIcon(R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//ww w . j a va 2 s .c om public void onClick(View view) { Intent intent = getParentActivityIntent(); startActivity(intent); finish(); } }); spinnerSensorType = (Spinner) findViewById(R.id.spinnerSensorType); editTextSensorName = (EditText) findViewById(R.id.editTextSensorName); layoutSensorSpecificSettings = (LinearLayout) findViewById(R.id.layoutSensorSpecificSettings); buttonCreateSensor = (Button) findViewById(R.id.buttonCreateSensor); if (getIntent().getExtras() != null) { Bundle b = getIntent().getExtras(); if (b.containsKey("edit")) { try { editSensor = SingleInstance.getDatabaseHelper().getSensorDao().queryForId(b.getString("edit")); edit = true; editTextSensorName.setText(editSensor.getName()); sensorTypes = new String[1]; sensorTypes[0] = editSensor.getType(); layoutSensorSpecificSettings.removeAllViews(); selectedSensorType = sensorTypes[0].toLowerCase(); sensorView = SensorViewFactory.makeView(AddSensorActivity.this, selectedSensorType); sensorView.setEditMode(true); layoutSensorSpecificSettings.addView(sensorView); buttonCreateSensor.setText(R.string.button_edit_sensor); } catch (SQLException e) { finish(); } } } spinnerSensorType.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, sensorTypes)); if (!edit) { spinnerSensorType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { layoutSensorSpecificSettings.removeAllViews(); selectedSensorType = sensorTypes[position].toLowerCase(); sensorView = SensorViewFactory.makeView(AddSensorActivity.this, selectedSensorType); layoutSensorSpecificSettings.addView(sensorView); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); buttonCreateSensor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!MiscFunctions.isOnline(AddSensorActivity.this)) { MiscFunctions.makeOfflineDialog(AddSensorActivity.this).show(); return; } if (editTextSensorName.getText().toString().equals("") || !sensorView.areSettingsValid()) { new AlertDialog.Builder(AddSensorActivity.this).setTitle(R.string.dialog_title_error) .setMessage("You must fill all the fields in order to add a sensor !") .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); return; } new AsyncTask<Void, Boolean, Void>() { private ProgressDialog waitingDialog; @Override protected void onPreExecute() { waitingDialog = new ProgressDialog(AddSensorActivity.this); waitingDialog.setTitle(R.string.dialog_title_loading); waitingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); waitingDialog.setMessage( getResources().getString(R.string.dialog_message_loading_creating_sensor)); waitingDialog.show(); } @Override protected Void doInBackground(Void... params) { publishProgress(create()); return null; } @Override protected void onProgressUpdate(Boolean... values) { for (boolean b : values) { if (b) { new AlertDialog.Builder(AddSensorActivity.this) .setTitle(R.string.dialog_title_information) .setMessage(R.string.dialog_message_information_sensor_added) .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); setResult(RESULT_OK); Intent intent = new Intent(AddSensorActivity.this, ChartActivity.class); intent.putExtra(Config.EXTRA_FIRST_LAUNCH, true); startActivity(intent); } }) .show(); } else { new AlertDialog.Builder(AddSensorActivity.this) .setTitle(R.string.dialog_title_error) .setMessage(R.string.dialog_message_error_sensor_not_added) .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } } } @Override protected void onPostExecute(Void aVoid) { waitingDialog.dismiss(); } }.execute(); } }); } else { buttonCreateSensor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Boolean, Void>() { private ProgressDialog waitingDialog; @Override protected void onPreExecute() { waitingDialog = new ProgressDialog(AddSensorActivity.this); waitingDialog.setTitle(R.string.dialog_title_loading); waitingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); waitingDialog.setMessage( getResources().getString(R.string.dialog_message_loading_editing_sensor)); waitingDialog.show(); } @Override protected Void doInBackground(Void... params) { publishProgress(edit()); return null; } @Override protected void onProgressUpdate(Boolean... values) { for (boolean b : values) { if (b) { new AlertDialog.Builder(AddSensorActivity.this) .setTitle(R.string.dialog_title_information) .setMessage(R.string.dialog_message_information_sensor_edited) .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); setResult(Activity.RESULT_OK); finish(); } }) .show(); } else { new AlertDialog.Builder(AddSensorActivity.this) .setTitle(R.string.dialog_title_error) .setMessage(R.string.dialog_message_error_sensor_not_added) .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } } } @Override protected void onPostExecute(Void aVoid) { waitingDialog.dismiss(); } }.execute(); } }); } }
From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java
private void setupRecyclerViewAsync(@NonNull final ViewGroup viewGroup) { final ProgressDialog progressDialog = ProgressDialog.show(this, getResources().getString(R.string.progress_loading_posts), getResources().getString(R.string.progress_please_wait), true, false); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); DatabaseLink.DatabaseListener listener = new DatabaseLink.DatabaseListener() { @Override// w ww .ja v a 2 s . c om void onGetResponse(String str) { final Post[] posts; try { JSONObject json = new JSONObject(str); posts = DatabaseLink.parseJson(json); } catch (JSONException e) { onError("JSON is invalid. Error: " + e.getMessage() + ", JSON: " + str); return; } if (progressDialog.isShowing()) progressDialog.dismiss(); final Post[] sortedPosts = sortPosts(posts); runOnUiThread(new Runnable() { @Override public void run() { // Inflate layout post_list View rootView = View.inflate(PostListActivity.this, R.layout.post_list, null); RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.post_list); // Setup refresh action SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) rootView .findViewById(R.id.swipe_refresh); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { recreate(); } }); // Set adapter with posts recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(sortedPosts)); // Add to ViewGroup viewGroup.addView(rootView); } }); } @Override void onError(String error) { if (progressDialog.isShowing()) progressDialog.dismiss(); new AlertDialog.Builder(progressDialog.getContext()).setTitle("Error").setMessage(error).show(); } }; Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) DatabaseLink.instance.getPostsWithTag(listener, intent.getStringExtra(SearchManager.QUERY)); else DatabaseLink.instance.getAllPosts(listener); Log.v("TrafficTimeWaste", "Querying db..."); }
From source file:edu.pdx.its.portal.routelandia.DatePickUp.java
/** * Method handle when user click on get statistics button* */// w w w . j a v a2 s.c o m public void addListenerOnButton() { btnDepartureDate = (Button) findViewById(R.id.btnDepartureDate); btnDepartureDate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadingDialog = new ProgressDialog(DatePickUp.this); loadingDialog.setMessage("Fetching statistics from server..."); loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); loadingDialog.setCancelable(false); loadingDialog.show(); TrafficStat.getStatsResultListFor(startPoint, endPoint, departureTime, weekDay, DatePickUp.this); /* } catch (APIException e) { // TODO: RESTART ACTIVITY AFTER TELLING USER THAT THEY NEED TO DO SOMETHING!! // (Did they pick bad points? Going to have to read the e.getResultWrapper().getParsedResponse() JSON to see...) int response = e.getResultWrapper().getHttpStatus(); if(response == 400) { new ErrorPopup("Error", "Please select two points along the same color highway segment.").givePopup(DatePickUp.this).show(); ((Activity)v.getContext()).onBackPressed(); } else if(response == 404 || response == 412){ new ErrorPopup("Error", "Could not complete request: \n\n" + e.getMessage()).givePopup(DatePickUp.this).show(); } else if(response >= 500 && response < 600){ new ErrorPopup("Server Error", "There was an error on the server. Please try again later.").givePopup(DatePickUp.this).show(); } else{ new ErrorPopup("Error", "Could not complete request: \n\n" + e.getMessage()).givePopup(DatePickUp.this).show(); } } */ } }); }
From source file:jp.envision.android.cloudfingerpaint.CloudFingerPaint.java
@Override public boolean onOptionsItemSelected(MenuItem item) { mPaint.setXfermode(null);/* www . jav a2s .com*/ mPaint.setAlpha(0xFF); switch (item.getItemId()) { case COLOR_MENU_ID: new ColorPickerDialog(this, this, mPaint.getColor()).show(); return true; case PRINT_MENU_ID: progressDialog = new ProgressDialog(this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage("???s..."); progressDialog.setCancelable(true); progressDialog.show(); (new Thread(runnable)).start(); return true; case EMBOSS_MENU_ID: if (mPaint.getMaskFilter() != mEmboss) { mPaint.setMaskFilter(mEmboss); } else { mPaint.setMaskFilter(null); } return true; case BLUR_MENU_ID: if (mPaint.getMaskFilter() != mBlur) { mPaint.setMaskFilter(mBlur); } else { mPaint.setMaskFilter(null); } return true; case ERASE_MENU_ID: mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); return true; case SRCATOP_MENU_ID: mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); mPaint.setAlpha(0x80); return true; case CLEAR_MENU_ID: Log.d(TAG, "Clear canvas."); myView.clear_all(); return true; } return super.onOptionsItemSelected(item); }
From source file:de.gebatzens.sia.SetupActivity.java
public void startDownloadingSchool() { final ProgressDialog d = new ProgressDialog(this); d.setTitle(SIAApp.SIA_APP.school.name); d.setMessage(getString(R.string.downloading_image)); d.setCancelable(false);/* www. j a v a 2 s. c o m*/ d.setProgressStyle(ProgressDialog.STYLE_SPINNER); d.show(); new Thread() { @Override public void run() { if (!School.downloadImage(SIAApp.SIA_APP.school.image)) { runOnUiThread(new Runnable() { @Override public void run() { Snackbar.make(getWindow().getDecorView().findViewById(R.id.coordinator_layout), getString(R.string.download_error), Snackbar.LENGTH_LONG).show(); } }); } //workaround for a bug that causes an endless loading screen Subst.GGPlans subst = SIAApp.SIA_APP.api.getPlans(false); subst.save(); SIAApp.SIA_APP.school.fragments.getByType(FragmentData.FragmentType.PLAN).get(0).setData(subst); if (d.isShowing()) d.dismiss(); Intent i = new Intent(SetupActivity.this, MainActivity.class); //i.putExtra("reload", true); startActivity(i); finish(); } }.start(); }
From source file:org.adaway.helper.ImportExportHelper.java
/** * Exports all lists to adaway-export file on sdcard * * @param context/*from w ww . j av a2 s. c om*/ */ public static void exportLists(final Context context) { // do it in AsyncTask without blocking the user interface thread AsyncTask<Void, Void, Void> exportListsTask = new AsyncTask<Void, Void, Void>() { private ProgressDialog mApplyProgressDialog; @Override protected Void doInBackground(Void... unused) { THashSet<String> whitelist = ProviderHelper.getEnabledWhitelistHashSet(context); THashSet<String> blacklist = ProviderHelper.getEnabledBlacklistHashSet(context); THashMap<String, String> redirectionList = ProviderHelper.getEnabledRedirectionListHashMap(context); try { File sdcard = Environment.getExternalStorageDirectory(); if (sdcard.canWrite()) { File exportFile = new File(sdcard, "adaway-export"); FileWriter writer = new FileWriter(exportFile); BufferedWriter out = new BufferedWriter(writer); out.write(Constants.HEADER_EXPORT + Constants.LINE_SEPERATOR); // write blacklist Iterator<String> itrBlacklist = blacklist.iterator(); while (itrBlacklist.hasNext()) { out.write(Constants.LOCALHOST_IPv4 + " " + itrBlacklist.next() + Constants.LINE_SEPERATOR); } // write whitelist Iterator<String> itrWhitelist = whitelist.iterator(); while (itrWhitelist.hasNext()) { out.write(Constants.WHITELIST_ENTRY + " " + itrWhitelist.next() + Constants.LINE_SEPERATOR); } // write redirection list for (HashMap.Entry<String, String> item : redirectionList.entrySet()) { out.write(item.getValue() + " " + item.getKey() + Constants.LINE_SEPERATOR); } out.close(); } } catch (IOException e) { Log.e(Constants.TAG, "Could not write file " + e.getMessage()); } // return nothing as type is Void return null; } @Override protected void onPreExecute() { super.onPreExecute(); mApplyProgressDialog = new ProgressDialog(context); mApplyProgressDialog.setMessage(context.getString(R.string.export_dialog)); mApplyProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mApplyProgressDialog.setCancelable(false); mApplyProgressDialog.show(); } @Override protected void onPostExecute(Void unused) { super.onPostExecute(unused); mApplyProgressDialog.dismiss(); Toast toast = Toast.makeText(context, context.getString(R.string.export_success), Toast.LENGTH_LONG); toast.show(); } }; exportListsTask.execute(); }
From source file:org.adawaycn.helper.ImportExportHelper.java
/** * Exports all lists to adawaycn-export file on sdcard * * @param context/*from w ww.j av a 2 s. c o m*/ */ public static void exportLists(final Context context) { // do it in AsyncTask without blocking the user interface thread AsyncTask<Void, Void, Void> exportListsTask = new AsyncTask<Void, Void, Void>() { private ProgressDialog mApplyProgressDialog; @Override protected Void doInBackground(Void... unused) { THashSet<String> whitelist = ProviderHelper.getEnabledWhitelistHashSet(context); THashSet<String> blacklist = ProviderHelper.getEnabledBlacklistHashSet(context); THashMap<String, String> redirectionList = ProviderHelper.getEnabledRedirectionListHashMap(context); try { File sdcard = Environment.getExternalStorageDirectory(); if (sdcard.canWrite()) { File exportFile = new File(sdcard, "adawaycn-export"); FileWriter writer = new FileWriter(exportFile); BufferedWriter out = new BufferedWriter(writer); out.write(Constants.HEADER_EXPORT + Constants.LINE_SEPERATOR); // write blacklist Iterator<String> itrBlacklist = blacklist.iterator(); while (itrBlacklist.hasNext()) { out.write(Constants.LOCALHOST_IPv4 + " " + itrBlacklist.next() + Constants.LINE_SEPERATOR); } // write whitelist Iterator<String> itrWhitelist = whitelist.iterator(); while (itrWhitelist.hasNext()) { out.write(Constants.WHITELIST_ENTRY + " " + itrWhitelist.next() + Constants.LINE_SEPERATOR); } // write redirection list for (HashMap.Entry<String, String> item : redirectionList.entrySet()) { out.write(item.getValue() + " " + item.getKey() + Constants.LINE_SEPERATOR); } out.close(); } } catch (IOException e) { Log.e(Constants.TAG, "Could not write file " + e.getMessage()); } // return nothing as type is Void return null; } @Override protected void onPreExecute() { super.onPreExecute(); mApplyProgressDialog = new ProgressDialog(context); mApplyProgressDialog.setMessage(context.getString(R.string.export_dialog)); mApplyProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mApplyProgressDialog.setCancelable(false); mApplyProgressDialog.show(); } @Override protected void onPostExecute(Void unused) { super.onPostExecute(unused); mApplyProgressDialog.dismiss(); Toast toast = Toast.makeText(context, context.getString(R.string.export_success), Toast.LENGTH_LONG); toast.show(); } }; exportListsTask.execute(); }