List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
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//from w w w.j a v a2 s . c o 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:org.mobisocial.corral.BackgroundableDownloadDialogFragment.java
@Override public void onProgress(final DownloadState state, final DownloadChannel channel, final int progress) { Dialog dl = getDialog();/*from w w w. j a va 2s . c o m*/ if (dl != null) { final ProgressDialog d = (ProgressDialog) dl; getActivity().runOnUiThread(new Runnable() { @Override public void run() { switch (state) { case DOWNLOAD_PENDING: d.setMessage("Download pending..."); break; case PREPARING_CONNECTION: d.setMessage("Preparing connection..."); break; case TRANSFER_IN_PROGRESS: if (progress > 0) { d.setMessage("Downloading file... (" + progress + "%)"); } else { d.setMessage("Downloading file..."); } break; case TRANSFER_COMPLETE: try { mResult = mFuture.getResult(); } catch (InterruptedException e) { Log.e(getClass().getSimpleName(), "impossible interrupt exception", e); } d.dismiss(); break; } } }); } }
From source file:com.ccxt.whl.activity.LoginActivity.java
/** * ??/*from w ww. java2 s .co m*/ */ public void s_reg_login(final String username, final String pwd) { if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); pd.show(); new Thread(new Runnable() { public void run() { try { // sdk EMChatManager.getInstance().createAccountOnServer(username, pwd); runOnUiThread(new Runnable() { public void run() { if (!LoginActivity.this.isFinishing()) pd.dismiss(); // ??? // DemoApplication.getInstance().setUserName(username); DemoApplication.getInstance().setUser(username); Toast.makeText(getApplicationContext(), "?", 0).show(); login(username, pwd); //finish(); } }); } catch (final Exception e) { runOnUiThread(new Runnable() { public void run() { if (!LoginActivity.this.isFinishing()) pd.dismiss(); if (e != null && e.getMessage() != null) { String errorMsg = e.getMessage(); if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) { Toast.makeText(getApplicationContext(), "?", 0).show(); } else if (errorMsg.indexOf("conflict") != -1) { login(username, pwd); //Toast.makeText(getApplicationContext(), "?", 0).show(); } else if (errorMsg.indexOf("not support the capital letters") != -1) { Toast.makeText(getApplicationContext(), "??????", 0).show(); } else { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), 1).show(); } } else { Toast.makeText(getApplicationContext(), ": ", 1).show(); } } }); } } }).start(); } }
From source file:cn.ucai.chatuidemo.activity.ContactlistFragment.java
/** * user???//from w w w .ja va2 s. co m */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, Toast.LENGTH_LONG).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, Toast.LENGTH_LONG).show(); } }); } } }).start(); }
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 ww.j a v a 2 s . c om*/ 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:fm.smart.r1.ItemActivity.java
public void addToList(final String item_id) { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Adding item to study goal ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add = new Thread() { public void run() { ItemActivity.add_item_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null)); myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(ItemActivity.add_item_result.getTitle()); dialog.setMessage(ItemActivity.add_item_result.getMessage()); ItemActivity.add_item_result = null; dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/* w ww.j a va 2 s.c o m*/ }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add.start(); }
From source file:cn.ucai.yizhesale.activity.ContactlistFragment.java
/** * ?/*from www . j a v a 2 s . c o m*/ * @param tobeDeleteUser */ public void deleteContact(final EMUser tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? EMUserDao dao = new EMUserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_LONG).show(); } }); } } }).start(); }
From source file:com.google.code.twisty.Twisty.java
/** Launch UI to pick a file to load and execute */ private void pickFile() { String storagestate = Environment.getExternalStorageState(); if (storagestate.equals(Environment.MEDIA_MOUNTED) || storagestate.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { final ProgressDialog pd = ProgressDialog.show(Twisty.this, "Scanning Media", "Searching for Games...", true);/*from w ww.j a va 2 s. c om*/ Thread t = new Thread() { public void run() { // populate our list of games: discovered_games = scanForGames(); pd.dismiss(); Message msg = new Message(); msg.what = PROMPT_FOR_GAME; dialog_handler.sendMessage(msg); } }; t.start(); } else showDialog(DIALOG_NO_SDCARD); // no sdcard to scan }
From source file:bikebadger.RideFragment.java
public void OpenGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Loading \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);//from w w w .j ava2 s . c o m pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.OpenGPXFile(path); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" loaded (" + mRideManager.mWaypoints.size() + ")", Color.BLACK); } }); } } }; mThread.start(); }
From source file:cmu.cconfs.instantMessage.activities.ContactlistFragment.java
/** * ?// w w w. j a v a 2 s . co m * * @param toDeleteUser */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); ((IMHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show(); } }); } } }).start(); }