List of usage examples for android.app ProgressDialog setOnDismissListener
public void setOnDismissListener(@Nullable OnDismissListener listener)
From source file:com.fabernovel.alertevoirie.HomeActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setIndeterminate(true);// ww w . j ava 2 s .c o m pd.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dialog_shown) removeDialog(DIALOG_PROGRESS); } }); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { AVService.getInstance(HomeActivity.this).cancelTask(); finish(); } }); pd.setMessage(getString(R.string.ui_message_loading)); return pd; default: return super.onCreateDialog(id); } }
From source file:com.fabernovel.alertevoirie.NewsActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setIndeterminate(true);/* ww w.jav a 2 s . c o m*/ pd.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { removeDialog(DIALOG_PROGRESS); } }); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { AVService.getInstance(NewsActivity.this).cancelTask(); finish(); } }); pd.setMessage(getString(R.string.ui_message_loading)); return pd; default: return super.onCreateDialog(id); } }
From source file:com.coinblesk.client.SendPaymentFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = super.onCreateView(inflater, container, savedInstanceState); assert view != null; final ProgressDialog dialog = new ProgressDialog(this.getActivity()); dialog.setMessage(getString(R.string.fragment_send_dialog_scanning)); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override//from w w w . j ava 2 s. co m public void onShow(DialogInterface dialog) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); } }); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); LocalBroadcastManager.getInstance(getActivity()) .sendBroadcast(new Intent(Constants.STOP_CLIENTS_ACTION)); } }); /*view.setOnTouchListener(new View.OnTouchListener() { private float startPoint = 0; @Override public boolean onTouch(View v, MotionEvent event) { float heightValue = event.getY(); switch (MotionEventCompat.getActionMasked(event)) { case (MotionEvent.ACTION_DOWN): startPoint = heightValue; return true; case (MotionEvent.ACTION_MOVE): if (heightValue - startPoint > THRESHOLD) { if (!dialog.isShowing()) { dialog.show(); IntentFilter instantPaymentFinishedIntentFilter = new IntentFilter(Constants.INSTANT_PAYMENT_FAILED_ACTION); instantPaymentFinishedIntentFilter.addAction(Constants.INSTANT_PAYMENT_SUCCESSFUL_ACTION); LocalBroadcastManager .getInstance(getContext()) .registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(this); dialog.dismiss(); } }, instantPaymentFinishedIntentFilter); LocalBroadcastManager .getInstance(getContext()) .sendBroadcast(new Intent(Constants.START_CLIENTS_ACTION)); } } break; } return false; } });*/ return view; }
From source file:com.nanosheep.bikeroute.Feedback.java
@Override public Dialog onCreateDialog(final int id) { AlertDialog.Builder builder;/*from w w w. j av a2s .c o m*/ ProgressDialog pDialog; Dialog dialog; switch (id) { case R.id.send: pDialog = new ProgressDialog(this); pDialog.setCancelable(true); pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); pDialog.setMessage(getText(R.string.send_msg)); pDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(final DialogInterface arg0) { removeDialog(R.id.send); } }); pDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(final DialogInterface arg0) { submitHandler.cancel(true); } }); dialog = pDialog; break; case R.id.thanks: builder = new AlertDialog.Builder(this); builder.setMessage(getText(R.string.thanks_message)).setCancelable(true) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { dialog.dismiss(); finish(); } }); dialog = builder.create(); break; case R.id.feedback_fail: builder = new AlertDialog.Builder(this); builder.setMessage(getText(R.string.feedback_fail_message)).setCancelable(true) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { dialog.dismiss(); } }); dialog = builder.create(); break; default: dialog = null; } return dialog; }
From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java
public void onWrongConnectionState(int state, final INotifiableManager manager, final Command<?> source) { final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); switch (state) { case WifiHelper.WIFI_STATE_DISABLED: builder.setTitle("Wifi disabled"); builder.setMessage("This host is Wifi only. Should I activate Wifi?"); builder.setNeutralButton("Activate Wifi", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { final ProgressDialog pd = new ProgressDialog(mActivity); pd.setCancelable(true);//from w w w. j a va 2 s .c o m pd.setTitle("Activating Wifi"); pd.setMessage("Please wait while Wifi is activated."); pd.show(); (new Thread() { public void run() { final WifiHelper helper = WifiHelper.getInstance(mActivity); helper.enableWifi(true); int wait = 0; while (wait <= MAX_WAIT_FOR_WIFI * 1000 && helper.getWifiState() != WifiHelper.WIFI_STATE_ENABLED) { try { sleep(500); wait += 500; } catch (InterruptedException e) { } } manager.retryAll(); pd.cancel(); mDialogShowing = false; } }).start(); } }); showDialog(builder); break; case WifiHelper.WIFI_STATE_ENABLED: final Host host = HostFactory.host; final WifiHelper helper = WifiHelper.getInstance(mActivity); final String msg; if (host != null && host.access_point != null && !host.access_point.equals("")) { helper.connect(host); msg = "Connecting to " + host.access_point + ". Please wait"; } else { msg = "Waiting for Wifi to connect to your LAN."; } final ProgressDialog pd = new ProgressDialog(mActivity); pd.setCancelable(true); pd.setTitle("Connecting"); pd.setMessage(msg); mWaitForWifi = new Thread() { public void run() { mDialogShowing = true; pd.show(); (new Thread() { public void run() { int wait = 0; while (wait <= MAX_WAIT_FOR_WIFI * 1000 && helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) { try { sleep(500); wait += 500; } catch (InterruptedException e) { } } pd.cancel(); mDialogShowing = false; } }).start(); pd.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { if (helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) { builder.setTitle("Wifi doesn't seem to connect"); builder.setMessage( "You can open the Wifi settings or wait " + MAX_WAIT_FOR_WIFI + " seconds"); builder.setNeutralButton("Wifi Settings", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { mDialogShowing = false; mActivity.startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK)); } }); builder.setCancelable(true); builder.setNegativeButton("Wait", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { mDialogShowing = false; mActivity.runOnUiThread(mWaitForWifi); //had to make the Thread a field because of this line } }); mActivity.runOnUiThread(new Runnable() { public void run() { final AlertDialog alert = builder.create(); try { if (!mDialogShowing) { alert.show(); mDialogShowing = true; } } catch (Exception e) { e.printStackTrace(); } } }); } } }); } }; mActivity.runOnUiThread(mWaitForWifi); } }