List of usage examples for android.app ProgressDialog isShowing
public boolean isShowing()
From source file:com.snsplus.soqlive.Fragment.Found_Fragment.java
/** * * *//*from w ww . ja va2s . co m*/ private void toggleLikeUserApi(final String vjUserId, final int isGuanzu) { String dialogText = mContext.getResources().getString(R.string.server_loading); final ProgressDialog mProgressDialog = mCustomProgressDialogUtil.getCustomProgressDialog(dialogText); ChinaHttpApi.toggleLikeUser(mContext, mAppData.getUserInfo().getUserId(), vjUserId, new ChinaHttpApi.Callback() { @Override public void onResponse(final String response) { LogUtil.i("ToggleUser", "result : " + response); mainHandler.post(new Runnable() { @Override public void run() { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); } boolean isSuccess = false; try { JSONObject temp = new JSONObject(response); isSuccess = temp.optBoolean("isSuccessFlag"); } catch (JSONException e) { e.printStackTrace(); } if (isSuccess) { //isFans 0 , 1 for (int i = 0; i < mFoundAdapter.listData.size(); i++) { if (mFoundAdapter.listData.get(i).userInfo.getUserId() .equalsIgnoreCase(vjUserId)) { if (isGuanzu == 0) { mFoundAdapter.listData.get(i).isFans = 1; } else { mFoundAdapter.listData.get(i).isFans = 0; } break; } } mUserInfor_Pref = new UserInfor_Pref(getActivity()); HashMap<String, Boolean> mLikeMap = mUserInfor_Pref.getUserLikeMap(); if (mLikeMap != null) { if (mLikeMap.containsKey(vjUserId)) { if (isGuanzu == 0) { mLikeMap.remove(vjUserId); mLikeMap.put(vjUserId, true); } else { mLikeMap.remove(vjUserId); } } else { if (isGuanzu == 0) { mLikeMap.put(vjUserId, true); } } } else { mLikeMap = new HashMap<String, Boolean>(); if (isGuanzu == 0) { mLikeMap.put(vjUserId, true); } } mUserInfor_Pref.saveUserLikeMap(mLikeMap); // ??? local mServerData_Pref.changeSaveGuanzuData(vjUserId, isGuanzu); mFoundAdapter.notifyDataSetChanged(); } } }); } @Override public void onErrorResponse(VolleyError error) { LogUtil.e(TAG, "error", error); if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); } } }); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Submits a Certification Request to the controller *///from www . j a va 2s .c o m private void requestAccess() { final String hostname = AppSettingsActivity.currentServer; if (!TextUtils.isEmpty(hostname)) { final ProgressDialog progress = new ProgressDialog(this); final Handler handler = new Handler() { public void handleMessage(Message msg) { if (progress.isShowing()) { progress.dismiss(); } } }; if (isActivityResumed()) { progress.show(); } new Thread() { public void run() { handler.sendEmptyMessage(ORPKCS10CertificationRequest.getInstance(getApplicationContext()) .submitCertificationRequest(hostname)); } }.start(); } }
From source file:com.xperia64.timidityae.FileBrowserFragment.java
public void saveWavPart2(final int position, final String finalval, final String needToRename) { ((TimidityActivity) getActivity()).writeFile(path.get(position), finalval); final ProgressDialog prog; prog = new ProgressDialog(getActivity()); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override// w ww . j a v a 2s. c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); prog.setTitle("Converting to WAV"); prog.setMessage("Converting..."); prog.setIndeterminate(false); prog.setCancelable(false); prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); prog.show(); new Thread(new Runnable() { @Override public void run() { while (!localfinished && prog.isShowing()) { prog.setMax(JNIHandler.maxTime); prog.setProgress(JNIHandler.currTime); try { Thread.sleep(25); } catch (InterruptedException e) { } } if (!localfinished) { JNIHandler.stop(); getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getActivity(), "Conversion canceled", Toast.LENGTH_SHORT).show(); if (!Globals.keepWav) { if (new File(finalval).exists()) new File(finalval).delete(); } else { getDir(currPath); } } }); } else { getActivity().runOnUiThread(new Runnable() { public void run() { String trueName = finalval; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null && needToRename != null) { if (Globals.renameDocumentFile(getActivity(), finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(getActivity(), "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); getDir(currPath); } }); } } }).start(); }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void tryConnect(final ProgressDialog pd, final int attempt, final String statusMessage, final RegistrationInfo info) { T.UI();/*w w w . j a v a 2 s .c o m*/ final Pausable pausable = this; if (attempt > XMPP_MAX_NUM_ATTEMPTS) { pd.dismiss(); String message = getString(R.string.registration_error); UIUtils.showDialog(mActivity, null, message, getString(R.string.try_again), null, null, null); mWizard.reInit(); mWizard.goBackToPrevious(); return; } pd.setMessage(statusMessage + attempt); if (!pd.isShowing()) pd.show(); L.d("Registration attempt #" + attempt); final String xmppServiceName = info.mCredentials.getXmppServiceName(); final String xmppAccount = info.mCredentials.getXmppAccount(); final String xmppPassword = info.mCredentials.getPassword(); final ConfigurationProvider cp = mService.getConfigurationProvider(); Configuration cfg = cp.getConfiguration(RegistrationWizard2.CONFIGKEY); final String invitorCode = (cfg == null) ? null : cfg.get(INVITOR_CODE_CONFIGKEY, null); final String invitorSecret = (cfg == null) ? null : cfg.get(INVITOR_SECRET_CONFIGKEY, null); Runnable runnable = new SafeRunnable() { @Override public void safeRun() { T.REGISTRATION(); try { if (CloudConstants.USE_XMPP_KICK_CHANNEL) { final ConnectionConfiguration xmppConfig = new XMPPConfigurationFactory(cp, mService.getNetworkConnectivityManager(), null) .getSafeXmppConnectionConfiguration(xmppServiceName); final XMPPConnection xmppCon = new XMPPConnection(xmppConfig); xmppCon.setLogger(new Logger() { @Override public void log(String message) { L.d(message); } }); xmppCon.connect(); xmppCon.login(xmppAccount, xmppPassword); final Thread t2 = new Thread(new SafeRunnable() { @Override protected void safeRun() throws Exception { L.d("REG Before disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); xmppCon.disconnect(); L.d("REG After disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); } }); t2.setDaemon(true); t2.start(); } postFinishRegistration(info.mCredentials.getUsername(), info.mCredentials.getPassword(), invitorCode, invitorSecret); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); mWizard.setCredentials(info.mCredentials); if (CloudConstants.USE_GCM_KICK_CHANNEL && !"".equals(mGCMRegistrationId)) { GoogleServicesUtils.saveGCMRegistrationId(mService, mGCMRegistrationId); } mService.setCredentials(mWizard.getCredentials()); mService.setRegisteredInConfig(true); final Intent launchServiceIntent = new Intent(mActivity, MainService.class); launchServiceIntent.putExtra(MainService.START_INTENT_JUST_REGISTERED, true); launchServiceIntent.putExtra(MainService.START_INTENT_MY_EMAIL, mWizard.getEmail()); mActivity.startService(launchServiceIntent); stopRegistrationService(); pd.dismiss(); mWizard.finish(); // finish } }); } catch (Exception e) { L.d("Exception while trying to end the registration process", e); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); tryConnect(pd, attempt + 1, statusMessage, info); } }); } } }; if (attempt == 1) { runOnWorker(runnable); } else { runDelayedOnWorker(runnable, XMPP_CHECK_DELAY_MILLIS); } }
From source file:com.android.gallery3d.ingest.IngestActivity.java
private void updateProgressDialog() { ProgressDialog dialog = getProgressDialog(); boolean indeterminate = (mProgressState.max == 0); dialog.setIndeterminate(indeterminate); dialog.setProgressStyle(indeterminate ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL); if (mProgressState.title != null) { dialog.setTitle(mProgressState.title); }//from ww w. j a va 2s. co m if (mProgressState.message != null) { dialog.setMessage(mProgressState.message); } if (!indeterminate) { dialog.setProgress(mProgressState.current); dialog.setMax(mProgressState.max); } if (!dialog.isShowing()) { dialog.show(); } }
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 . j a v a 2 s .co m*/ 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:com.ubiLive.GameCloud.activity.MainActivity.java
private void billingCheckContentLicense() { final ProgressDialog progressDialog = Utils.ShowProgressDialog(this, null, GameActivityRes.STRING_CHECKINGCONTENTLICENSE, null, false); progressDialog.show();/* w w w.j ava2 s . c o m*/ new Thread(new Runnable() { public void run() { if (-1 == BillingActivity.checkContentLicense(Constants.BILLING_KEYWORD, MainActivity.this)) {//Constants.BILLING_KEYWORD DebugLog.d(TAG, "====failed check content license ====="); MainActivity.this.runOnUiThread(new Runnable() { public void run() { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } Utils.ShowOKPrompt(MainActivity.this, GameActivityRes.STRING_ERROR, GameActivityRes.STRING_CHECKCONTENTLICENSEFAIL, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }, new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { // TODO Auto-generated method stub DebugLog.d(TAG, "KeyEvent.KEYCODE_BACK keyCode = " + keyCode); DebugLog.d(TAG, "KeyEvent.KEYCODE_BACK = " + KeyEvent.KEYCODE_BACK); if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } }); } }); } else {//verify license successfully DebugLog.d(TAG, "====successed check content license ====="); MainActivity.this.runOnUiThread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } //skip switchToWebOrGameActivity(); } }); } } }).start(); }
From source file:nf.frex.android.FrexActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return;//from w ww. j a v a2 s. c om } if (requestCode == R.id.manage_fractals && data.getAction().equals(Intent.ACTION_VIEW)) { final Uri imageUri = data.getData(); if (imageUri != null) { File imageFile = new File(imageUri.getPath()); String configName = FrexIO.getFilenameWithoutExt(imageFile); File paramFile = new File(imageFile.getParent(), configName + FrexIO.PARAM_FILE_EXT); try { FileInputStream fis = new FileInputStream(paramFile); try { readFrexDoc(fis, configName); } finally { fis.close(); } } catch (IOException e) { Toast.makeText(FrexActivity.this, getString(R.string.error_msg, e.getLocalizedMessage()), Toast.LENGTH_SHORT).show(); } } } else if (requestCode == R.id.settings) { view.getGenerator().setNumTasks(SettingsActivity.getNumTasks(this)); } else if (requestCode == SELECT_PICTURE_REQUEST_CODE) { final Uri imageUri = data.getData(); final ColorQuantizer colorQuantizer = new ColorQuantizer(); final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); final DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } colorQuantizer.cancel(); } }; final ColorQuantizer.ProgressListener progressListener = new ColorQuantizer.ProgressListener() { @Override public void progress(final String msg, final int iter, final int maxIter) { runOnUiThread(new Runnable() { @Override public void run() { progressDialog.setMessage(msg); progressDialog.setProgress(iter); } }); } }; progressDialog.setTitle(getString(R.string.get_pal_from_img_title)); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(cancelListener); progressDialog.setMax(colorQuantizer.getMaxIterCount()); progressDialog.show(); Thread thread = new Thread(new Runnable() { @Override public void run() { Bitmap bitmap; try { bitmap = FrexIO.readBitmap(getContentResolver(), imageUri, 256); } catch (IOException e) { alert("I/O error: " + e.getLocalizedMessage()); return; } ColorScheme colorScheme = colorQuantizer.quantize(bitmap, progressListener); progressDialog.dismiss(); if (colorScheme != null) { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: Got colorScheme"); String colorSchemeId = "$" + imageUri.toString(); colorSchemes.add(colorSchemeId, colorScheme); view.setColorSchemeId(colorSchemeId); view.setColorScheme(colorScheme); view.recomputeColors(); runOnUiThread(new Runnable() { @Override public void run() { Log.d(TAG, "SELECT_PICTURE_REQUEST_CODE: showDialog(R.id.colors)"); showDialog(R.id.colors); } }); } } }); thread.start(); } }
From source file:de.baumann.hhsmoodle.helper.helper_main.java
public static void onClose(final Activity activity) { PreferenceManager.setDefaultValues(activity, R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(activity); final ProgressDialog progressDialog; if (sharedPref.getBoolean("backup_aut", false)) { try {//w w w . j a va 2 s.c o m helper_security.encryptBackup(activity, "/bookmarks_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/courses_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/notes_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/random_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/subject_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/schedule_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } try { helper_security.encryptBackup(activity, "/todo_DB_v01.db"); } catch (Exception e) { e.printStackTrace(); } progressDialog = new ProgressDialog(activity); progressDialog.setMessage(activity.getString(R.string.app_close)); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.show(); new Handler().postDelayed(new Runnable() { public void run() { sharedPref.edit().putString("loadURL", "").apply(); helper_security.encryptDatabases(activity); if (progressDialog.isShowing()) { progressDialog.cancel(); } activity.finishAffinity(); } }, 1500); } else { sharedPref.edit().putString("loadURL", "").apply(); helper_security.encryptDatabases(activity); activity.finishAffinity(); } }
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);/*from www.j av 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(); }