List of usage examples for android.app ProgressDialog show
public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, OnCancelListener cancelListener)
From source file:com.szanata.cordova.plugins.ModalProgressDialog.java
private void activityStart(final String title, final String message, final boolean cancelable, final CallbackContext callbackContext) { activityStop(null);/*from w w w. j a v a2 s.com*/ Runnable runnable = new Runnable() { public void run() { spinnerDialog = ProgressDialog.show(cordova.getActivity(), title, message, true, cancelable, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { spinnerDialog = null; } }); callbackContext.success(); } }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:net.exclaimindustries.geohashdroid.wiki.WikiMessageEditor.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO); setContentView(R.layout.wikieditor); Button submitButton = (Button) findViewById(R.id.wikieditbutton); submitButton.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j av a 2 s . c om*/ public void onClick(View view) { // We don't want to let the Activity handle the dialog. That WILL // cause it to show up properly and all, but after a configuration // change (i.e. orientation shift), it won't show or update any text // (as far as I know), as we can't reassign the handler properly. // So, we'll handle it ourselves. mProgress = ProgressDialog.show(WikiMessageEditor.this, "", "", true, true, WikiMessageEditor.this); mConnectionHandler = new MessageConnectionRunner(mProgressHandler, WikiMessageEditor.this); mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread"); mWikiConnectionThread.start(); } }); // In the event the text changes, update the submit button accordingly. TextWatcher tw = new TextWatcher() { @Override public void afterTextChanged(Editable s) { resetSubmitButton(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Blah! } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // BLAH! } }; EditText editText = (EditText) findViewById(R.id.wikiedittext); editText.addTextChangedListener(tw); // Now, let's see if we have anything retained... try { RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance(); if (retain != null) { // We have something retained! Thus, we need to construct the // popup and update it with the right status, assuming the // thread's still going. if (retain.thread != null && retain.thread.isAlive()) { mProgress = ProgressDialog.show(WikiMessageEditor.this, "", "", true, true, WikiMessageEditor.this); mConnectionHandler = retain.handler; mConnectionHandler.resetHandler(mProgressHandler); mWikiConnectionThread = retain.thread; } } } catch (Exception ex) { } }
From source file:com.facebook.android.Places.java
public void getLocation() { /*/* w w w. j av a 2s . c om*/ * launch a new Thread to get new location */ new Thread() { @Override public void run() { Looper.prepare(); dialog = ProgressDialog.show(Places.this, "", getString(R.string.fetching_location), false, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { showToast("No location fetched."); } }); if (lm == null) { lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); } if (locationListener == null) { locationListener = new MyLocationListener(); } Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); String provider = lm.getBestProvider(criteria, true); if (provider != null && lm.isProviderEnabled(provider)) { lm.requestLocationUpdates(provider, 1, 0, locationListener, Looper.getMainLooper()); } else { /* * GPS not enabled, prompt user to enable GPS in the * Location menu */ new AlertDialog.Builder(Places.this).setTitle(R.string.enable_gps_title) .setMessage(getString(R.string.enable_gps)) .setPositiveButton(R.string.gps_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult( new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Places.this.finish(); } }).show(); } Looper.loop(); } }.start(); }
From source file:com.musevisions.android.SudokuSolver.SudokuSolverActivity.java
/** Called when the activity is first created. */ @Override// w w w .jav a2s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.solver); ((MainTabActivity) getParent()).setSolverActivity(this); InputStream is = getResources().openRawResource(R.raw.input_array); mCurrentInput = JSONHelper.getSudokuArray(is); mGridView = (GridView) findViewById(R.id.gridView); mGridView.setGameInput(mCurrentInput); mChkBruteForce = (CheckBox) findViewById(R.id.checkBruteForce); Button verify = (Button) findViewById(R.id.btnVerify); verify.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { /* Verify input, or if puzzle has been solved, output. */ int[] output = mGridView.getSolution(); int[] toVerify = output != null ? output : mCurrentInput; String error = SudokuCore.verify(toVerify); if (error != null) ShortToast(error); else ShortToast("Puzzle is valid"); } }); Button solve = (Button) findViewById(R.id.btnSolve); solve.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SolverMethod method = mChkBruteForce.isChecked() ? SolverMethod.SOLVER_BRUTE_FORCE : SolverMethod.SOLVER_OPTIMISED; mGridView.setSolution(null); SudokuSolverActivity.this.mSolver = new SudokuSolverTask(mCurrentInput, SudokuSolverActivity.this, mGridView, method); mDialog = ProgressDialog.show(SudokuSolverActivity.this, "Solving", "Please wait...", false, true, new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (mSolver != null) mSolver.cancel(true); } }); SudokuSolverActivity.this.mSolver.execute(); } }); Button about = (Button) findViewById(R.id.btnAbout); about.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CustomDialogs.createAbout(SudokuSolverActivity.this).show(); } }); }
From source file:org.liberty.android.fantastischmemo.downloader.DownloaderAnyMemo.java
@Override protected void initialRetrieve() { dlAdapter = new DownloadListAdapter(this, R.layout.filebrowser_item); dlStack = new Stack<ArrayList<DownloadItem>>(); mHandler = new Handler(); listView = (ListView) findViewById(R.id.file_list); listView.setAdapter(dlAdapter);/* w w w .j av a 2 s . com*/ mProgressDialog = ProgressDialog.show(this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { final ArrayList<DownloadItem> list = obtainCategories(); mHandler.post(new Runnable() { public void run() { dlAdapter.addList(list); sortAdapter(); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { Log.e(TAG, "Error obtaining categories", e); new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(getString(R.string.downloader_connection_error)) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setNeutralButton(getString(R.string.back_menu_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }) .create().show(); } }); } } }.start(); }
From source file:com.ubikod.urbantag.ContentViewerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle extras = getIntent().getExtras(); /* If we are coming from Notification delete notification */ if (extras.getInt(NotificationHelper.FROM_NOTIFICATION, -1) == NotificationHelper.NEW_CONTENT_NOTIF) { NotificationHelper notificationHelper = new NotificationHelper(this); notificationHelper.closeContentNotif(); } else if (extras.getInt(NotificationHelper.FROM_NOTIFICATION, -1) == NotificationHelper.NEW_PLACE_NOTIF) { NotificationHelper notificationHelper = new NotificationHelper(this); notificationHelper.closePlaceNotif(); }/*from w w w. j a v a2s. c om*/ /* Fetch content info */ ContentManager contentManager = new ContentManager(new DatabaseHelper(this, null)); Log.i(UrbanTag.TAG, "View content : " + extras.getInt(CONTENT_ID)); this.content = contentManager.get(extras.getInt(CONTENT_ID)); if (this.content == null) { Toast.makeText(this, R.string.error_occured, Toast.LENGTH_SHORT).show(); finish(); return; } setTitle(content.getName()); com.actionbarsherlock.app.ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.content_viewer); /* Find webview and create url for content */ final WebView webView = (WebView) findViewById(R.id.webview); final String URL = UrbanTag.API_URL + ACTION_GET_CONTENT.replaceAll("%", "" + this.content.getId()); /* Display progress animation */ final ProgressDialog progress = ProgressDialog.show(this, "", this.getResources().getString(R.string.loading_content), false, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { timeOutHandler.interrupt(); webView.stopLoading(); ContentViewerActivity.this.finish(); } }); /* Go fetch content */ contentFetcher = new Thread(new Runnable() { DefaultHttpClient httpClient; @Override public void run() { Looper.prepare(); Log.i(UrbanTag.TAG, "Fetching content..."); httpClient = new DefaultHttpClient(); try { String responseBody = httpClient.execute(new HttpGet(URL), new BasicResponseHandler()); webView.loadDataWithBaseURL("fake://url/for/encoding/hack...", responseBody, mimeType, encoding, ""); timeOutHandler.interrupt(); if (progress.isShowing()) progress.dismiss(); } catch (ClientProtocolException cpe) { new Handler().post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), R.string.error_loading_content, Toast.LENGTH_SHORT).show(); } }); timeOutHandler.interrupt(); progress.cancel(); } catch (IOException ioe) { new Handler().post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), R.string.error_loading_content, Toast.LENGTH_SHORT).show(); } }); timeOutHandler.interrupt(); progress.cancel(); } Looper.loop(); } }); contentFetcher.start(); /* TimeOut Handler */ timeOutHandler = new Thread(new Runnable() { private int INCREMENT = 1000; @Override public void run() { Looper.prepare(); try { for (int time = 0; time < TIMEOUT; time += INCREMENT) { Thread.sleep(INCREMENT); } Log.w(UrbanTag.TAG, "TimeOut !"); new Handler().post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), R.string.error_loading_content, Toast.LENGTH_SHORT).show(); } }); contentFetcher.interrupt(); progress.cancel(); } catch (InterruptedException e) { e.printStackTrace(); } Looper.loop(); } }); timeOutHandler.start(); }
From source file:org.kde.necessitas.ministro.MinistroActivity.java
private void checkNetworkAndDownload(final boolean update) { if (isOnline(this)) new CheckLibraries().execute(update); else {/*from w w w.java 2 s . c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(MinistroActivity.this); builder.setMessage(getResources().getString(R.string.ministro_network_access_msg)); builder.setCancelable(true); builder.setNeutralButton(getResources().getString(R.string.settings_msg), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final ProgressDialog m_dialog = ProgressDialog.show(MinistroActivity.this, null, getResources().getString(R.string.wait_for_network_connection_msg), true, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finishMe(); } }); getApplication().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (isOnline(MinistroActivity.this)) { try { getApplication().unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } runOnUiThread(new Runnable() { public void run() { m_dialog.dismiss(); new CheckLibraries().execute(update); } }); } } }, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); try { startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } catch (Exception e) { e.printStackTrace(); try { startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); } catch (Exception e1) { e1.printStackTrace(); } } dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finishMe(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java
@Override protected void initialRetrieve() { dlAdapter = new DownloadListAdapter(this, R.layout.filebrowser_item); dlStack = new Stack<List<DownloadItem>>(); categoryIdStack = new Stack<String>(); mHandler = new Handler(); listView = (ListView) findViewById(R.id.file_list); listView.setOnScrollListener(this); listView.setAdapter(dlAdapter);/*from ww w . j a v a 2s . c om*/ mProgressDialog = ProgressDialog.show(DownloaderSS.this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { categoryList = retrieveCategories(); mHandler.post(new Runnable() { public void run() { showRootCategories(); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_connection_error) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setPositiveButton(getString(R.string.ok_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .create().show(); } }); } } }.start(); }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderFE.java
@Override protected void initialRetrieve() { mHandler = new Handler(); dlAdapter = new DownloadListAdapter(this, R.layout.filebrowser_item); listView = (ListView) findViewById(R.id.file_list); listView.setAdapter(dlAdapter);// ww w .j a v a 2s . c om final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences.Editor editor = settings.edit(); String prevInput = settings.getString("prev_fe_input", ""); final EditText input = new EditText(this); input.setText(prevInput); new AlertDialog.Builder(this).setTitle(getString(R.string.fe_search_title)) .setMessage(getString(R.string.fe_search_message)).setView(input) .setPositiveButton(getString(R.string.ok_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String value = input.getText().toString(); editor.putString("prev_fe_input", value); editor.commit(); mProgressDialog = ProgressDialog.show(DownloaderFE.this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { final List<DownloadItem> dil = retrieveList(value); mHandler.post(new Runnable() { public void run() { dlAdapter.addList(dil); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderFE.this) .setTitle(R.string.downloader_connection_error) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setPositiveButton(getString(R.string.ok_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .create().show(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.cancel_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }).create().show(); }
From source file:org.liberty.android.fantastischmemo.downloader.DownloaderAnyMemo.java
@Override protected void openCategory(final DownloadItem di) { mProgressDialog = ProgressDialog.show(this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override/*w w w. j a v a 2s. c o m*/ public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { final ArrayList<DownloadItem> list = obtainDatabases(di); dlStack.push(dlAdapter.getList()); mHandler.post(new Runnable() { public void run() { dlAdapter.clear(); dlAdapter.addList(list); sortAdapter(); listView.setSelection(0); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { Log.e(TAG, "Error obtaining databases", e); new AlertDialog.Builder(DownloaderAnyMemo.this) .setTitle(getString(R.string.downloader_connection_error)) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setNeutralButton(getString(R.string.back_menu_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }) .create().show(); } }); } } }.start(); }