Java Code Examples for android.app.progressdialog#dismiss()

The following examples show how to use android.app.progressdialog#dismiss() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexDex.java    From pokemon-go-xposed-mitm with GNU General Public License v3.0 6 votes vote down vote up
public static void showUiBlocker(Activity startActivity, CharSequence title, CharSequence msg) {
    if(debug) {
        Log.d(TAG, "showUiBlocker() for " + startActivity);
    }
    uiBlockedActivity = startActivity;
    final ProgressDialog progressDialog = new ProgressDialog(startActivity);
    progressDialog.setMessage(msg);
    progressDialog.setTitle(title);
    progressDialog.setIndeterminate(true);
    dexOptProgressObserver = new Observer() {
        @Override
        public void update(Observable observable, Object o) {
            if(o==Integer.valueOf(PROGRESS_COMPLETE)) {
                progressDialog.dismiss();
            }
        }
    };
    
    progressDialog.show();
}
 
Example 2
Source File: SettingsFragment.java    From secrecy with Apache License 2.0 6 votes vote down vote up
void moveStorageRoot(String path, ProgressDialog progressDialog) {
    File oldRoot = Storage.getRoot();
    try {
        org.apache.commons.io.FileUtils.copyDirectory(oldRoot, new File(path));
        Storage.setRoot(path);
        Preference vault_root = findPreference(Config.VAULT_ROOT);
        vault_root.setSummary(Storage.getRoot().getAbsolutePath());
        Util.toast(getActivity(),
                String.format(getString(R.string.Settings__moved_vault), path), Toast.LENGTH_LONG);
    } catch (Exception E) {
        Util.alert(context,
                context.getString(R.string.Error__moving_vault),
                context.getString(R.string.Error__moving_vault_message),
                Util.emptyClickListener,
                null);
        progressDialog.dismiss();
        return;
    }
    try {
        org.apache.commons.io.FileUtils.deleteDirectory(oldRoot);
    } catch (IOException ignored) {
        //ignore
    }
    progressDialog.dismiss();
}
 
Example 3
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
public void click4(View v){
	final ProgressDialog pd = new ProgressDialog(this);
	//���ý���������ʽ
	pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	//���ý��������ֵ
	pd.setMax(100);
	pd.setTitle("�����Թ��У����Ժ�");
	Thread t = new Thread(){
		@Override
		public void run() {
			try {
				for (int i = 0; i <= 100; i++) {
		pd.setProgress(i);
					sleep(50);
	}
} catch (InterruptedException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
			pd.dismiss();
		}
	};
	t.start();
	pd.show();
}
 
Example 4
Source File: ProductDetailActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
private void addFavourite() {

        mProgress = new ProgressDialog(this);
        mProgress.setMessage("Adding to favourite ...");
        mProgress.show();

        mDatabaseFavourite.child(product_id).child(mAuth.getCurrentUser().getUid()).child("time").setValue(getCurrentTimeInString());
        mDatabaseFavourite.child(product_id).child(mAuth.getCurrentUser().getUid()).child("colorNo").setValue(colorNo);

        Snackbar snackbar = Snackbar.make(activity_product_detail_layout, "Added to favourite", Snackbar.LENGTH_LONG);
        snackbar.show();

        mProgress.dismiss();
    }
 
Example 5
Source File: ContactActivity.java    From iqra-android with MIT License 5 votes vote down vote up
private void handleFailure(String errorMessage, ProgressDialog progress) {
    // called when response HTTP status is "4XX" (eg. 401, 403, 404)
    progress.dismiss();
    // unlockScreenOrientation();

    if (errorMessage == null) {
        Log.e("API result problem: ", "Socket Timeout");
        Toast.makeText(getApplicationContext(), getResources().getString(R.string.server_connection_lost), Toast.LENGTH_SHORT).show();
    } else {
        Log.e("API result problem: ", errorMessage);
        Toast.makeText(getApplicationContext(), getResources().getString(R.string.something_went_wrong), Toast.LENGTH_SHORT).show();
    }
}
 
Example 6
Source File: TcpdumpPacketCapture.java    From android-packet-capture with MIT License 5 votes vote down vote up
public static void initialiseCapture(Activity _activity) {
    activity = _activity;
    progressBox = new ProgressDialog(activity);
    progressBox.setTitle("Initialising Capture");
    progressBox.setMessage("Please wait while packet capture is initialised...");
    progressBox.setIndeterminate(true);
    progressBox.setCancelable(false);
    progressBox.show();
    if (rootTcpdumpShell != null) {
        if(!isInitialised)
            throw new RuntimeException("rootTcpdump shell: not null, initialized:false");
        startTcpdumpCapture();
        progressBox.dismiss();
    }
    else {
        rootTcpdumpShell = new Shell.Builder().
            useSU().
            setWantSTDERR(false).
            setMinimalLogging(true).
            open(new Shell.OnCommandResultListener() {
                @Override
                public void onCommandResult(int commandVal, int exitVal, List<String> out) {
                    //Callback checking successful shell start.
                    if (exitVal == Shell.OnCommandResultListener.SHELL_RUNNING) {
                        isInitialised = true;
                        progressBox.setMessage("Starting packet capture..");
                        startTcpdumpCapture();
                        progressBox.dismiss();
                    }
                    else {
                        progressBox.setMessage("There was an error starting root shell. Please grant root permissions or try again.");
                    }
                }
            });
    }
}
 
Example 7
Source File: Sounds.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
protected static void downloadData(Context c, final Runnable onFinish) {
    final ProgressDialog dlg = new ProgressDialog(c);
    dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dlg.setCancelable(false);
    dlg.setCanceledOnTouchOutside(false);
    dlg.show();

    final Runnable onFinish2 = () -> {
        if (onFinish != null)
            onFinish.run();
        dlg.dismiss();
    };
    Ion.with(App.get()).load(App.API_URL + "/sounds/sounds.json").progressDialog(dlg)
            .asString(StandardCharsets.UTF_8).setCallback((exp, result) -> {
                if (exp != null) {
                    Crashlytics.logException(exp);
                } else {
                    FileOutputStream outputStream = null;
                    try {
                        if (!new JSONObject(result).getString("name").equals("sounds")) return;

                        outputStream = App.get().openFileOutput("sounds.json", Context.MODE_PRIVATE);
                        outputStream.write(result.getBytes());

                        loadSounds();
                    } catch (Exception e) {
                        //Crashlytics.logException(e);
                    } finally {
                        Utils.close(outputStream);
                    }
                }
                onFinish2.run();
            });
}
 
Example 8
Source File: BaseActivity.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public void dismissDialog(ProgressDialog progressDialog) {
    try {
        progressDialog.dismiss();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example 9
Source File: RxOkHttp.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
private static UIProgressResponseListener progressResponseListener(ProgressDialog dialog) {
    return new UIProgressResponseListener() {
        @Override
        public void onUIResponseProgress(long bytesRead, long contentLength, boolean done) {
            int  progress = (int) ((100 * bytesRead) / contentLength);
            if (bytesRead <= 0) {
                dialog.show();
            }
            if (done) {
                dialog.dismiss();
            }
            dialog.setProgress(progress);
        }
    };
}
 
Example 10
Source File: BottomSheetSlotsDialogFragment.java    From intra42 with Apache License 2.0 5 votes vote down vote up
private boolean deleteSlot(ProgressDialog progressDialog) {
    if (!deleteSlotCanBeProceed(progressDialog)) return true;
    SparseArray<Slots> verifySlots = deleteSlotGetVerificationData();

    boolean isSuccess = true;
    progressDialog.setMax(slotsGroup.group.size());
    int i = 0;

    for (Slots slot : slotsGroup.group) {
        progressDialog.setProgress(i);
        ++i;

        Slots apiData = verifySlots.get(slot.id);
        if (apiData != null && apiData.isBooked != slot.isBooked) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(activity, R.string.slots_delete_dialog_error_booked, Toast.LENGTH_SHORT).show();
                }
            });
            continue;
        }

        ApiService api = app.getApiService();
        Call<Slots> call = api.destroySlot(slot.id);

        try {
            if (!call.execute().isSuccessful())
                isSuccess = false;
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (dialogFragment.isAdded() && !dialogFragment.isStateSaved())
        progressDialog.dismiss();
    return isSuccess;
}
 
Example 11
Source File: LrcJaeger.java    From LrcJaeger with Apache License 2.0 5 votes vote down vote up
private void download(final ArrayList<SongItem> listAll, final LrcJaeger activity) {
    if (listAll.size() > 0) {
        final ProgressDialog progressDialog = new ProgressDialog(activity);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setTitle(activity.getString(R.string.title_downloading));
        progressDialog.setProgress(0);
        progressDialog.setMax(listAll.size());
        progressDialog.show();

        activity.mTask = new BulkDownloadTask(new BulkDownloadTask.EventListener() {
            @Override
            public void onFinish(int downloaded) {
                progressDialog.dismiss();
                sendEmptyMessage(MSG_UPDATE_LRC_ICON_ALL);

                String text = String.format(activity.getString(R.string.toast_lrc_downloaded),
                        downloaded, listAll.size());
                Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onProgressUpdate(int progress) {
                progressDialog.setProgress(progress);
            }
        });
        activity.mTask.execute(listAll.toArray(new SongItem[1]));
    }
}
 
Example 12
Source File: AccountSettingsActivity.java    From Zom-Android-XMPP with GNU General Public License v3.0 5 votes vote down vote up
private void migrateAccountConfirmed ()
{

    if (!mIsMigrating) {

        mIsMigrating = true;

        Server[] servers = Server.getServers(this);
        final ProgressDialog progress = new ProgressDialog(this);
        progress.setIndeterminate(true);
        progress.setTitle(R.string.upgrade_progress_action);
        progress.show();

        MigrateAccountTask maTask = new MigrateAccountTask(this, (ImApp) getApplication(), mProviderId, mAccountId, new MigrateAccountTask.MigrateAccountListener() {
            @Override
            public void migrateComplete(OnboardingAccount account) {
                mIsMigrating = false;
                progress.dismiss();
                Toast.makeText(AccountSettingsActivity.this, R.string.upgrade_complete, Toast.LENGTH_SHORT).show();
                finish();
            }

            @Override
            public void migrateFailed(long providerId, long accountId) {
                Toast.makeText(AccountSettingsActivity.this, R.string.upgrade_failed, Toast.LENGTH_SHORT).show();
                mIsMigrating = false;
                progress.dismiss();

            }
        });
        maTask.execute(servers);
    }

}
 
Example 13
Source File: DialogUtils.java    From WMRouter with Apache License 2.0 5 votes vote down vote up
public static void dismiss(ProgressDialog dialog) {
    if (dialog != null) {
        try {
            dialog.dismiss();
        } catch (Exception ignored) {
        }
    }
}
 
Example 14
Source File: AccountSettingsActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
private void migrateAccountConfirmed ()
{

    if (!mIsMigrating) {

        mIsMigrating = true;

        Server[] servers = Server.getServers(this);
        final ProgressDialog progress = new ProgressDialog(this);
        progress.setIndeterminate(true);
        progress.setTitle(R.string.upgrade_progress_action);
        progress.show();

        MigrateAccountTask maTask = new MigrateAccountTask(this, (ImApp) getApplication(), mProviderId, mAccountId, new MigrateAccountTask.MigrateAccountListener() {
            @Override
            public void migrateComplete(OnboardingAccount account) {
                mIsMigrating = false;
                progress.dismiss();
                Toast.makeText(AccountSettingsActivity.this, R.string.upgrade_complete, Toast.LENGTH_SHORT).show();
                finish();
            }

            @Override
            public void migrateFailed(long providerId, long accountId) {
                Toast.makeText(AccountSettingsActivity.this, R.string.upgrade_failed, Toast.LENGTH_SHORT).show();
                mIsMigrating = false;
                progress.dismiss();

            }
        });
        maTask.execute(servers);
    }

}
 
Example 15
Source File: OpenFitActivity.java    From OpenFit with MIT License 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    final String message = intent.getStringExtra(OpenFitIntent.INTENT_EXTRA_MSG);
    Log.d(LOG_TAG, "Received Google Fit: " + message);
    if(message.equals(OpenFitIntent.INTENT_GOOGLE_FIT)) {
        Boolean enabled = intent.getBooleanExtra(OpenFitIntent.INTENT_EXTRA_DATA, false);
        if(enabled) {
            Log.d(LOG_TAG, "Google Fit Enabled");
            preference_checkbox_googlefit.setChecked(true);
            oPrefs.saveBoolean("preference_checkbox_googlefit", true);
        }
        else {
            Log.d(LOG_TAG, "Google Fit Disabled");
            preference_checkbox_googlefit.setChecked(false);
            oPrefs.saveBoolean("preference_checkbox_googlefit", false);
        }
    }
    if(message.equals(OpenFitIntent.INTENT_GOOGLE_FIT_SYNC)) {
        Log.d(LOG_TAG, "Google Fit Sync requested");
        if(mClient.isConnected()) {
            Toast.makeText(getActivity(), R.string.toast_google_fit_sync, Toast.LENGTH_SHORT).show();
            progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage(getString(R.string.progress_dialog_syncing));
            progressDialog.show();
        }
        else {
            Log.d(LOG_TAG, "Google Fit Sync not connected");
            Toast.makeText(getActivity(), R.string.toast_google_fit_sync_failure, Toast.LENGTH_SHORT).show();
        }
    }
    if(message.equals(OpenFitIntent.INTENT_GOOGLE_FIT_SYNC_STATUS)) {
        Boolean status = intent.getBooleanExtra(OpenFitIntent.INTENT_EXTRA_DATA, false);
        String info = intent.getStringExtra(OpenFitIntent.INTENT_EXTRA_INFO);
        if(progressDialog != null) {
            progressDialog.dismiss();
        }
        if(status) {
            Log.d(LOG_TAG, "Google Fit Sync completed");
            Toast.makeText(getActivity(), R.string.toast_google_fit_sync_success, Toast.LENGTH_SHORT).show();
        }
        else if(info != null && info.equals(OpenFitIntent.INTENT_BILLING_NO_PURCHASE)) {
            Log.d(LOG_TAG, "Google Fit Sync failed, no premium");
            Toast.makeText(getActivity(), R.string.toast_google_fit_sync_no_purchase, Toast.LENGTH_SHORT).show();
        }
        else {
            Log.d(LOG_TAG, "Google Fit Sync failed");
            Toast.makeText(getActivity(), R.string.toast_google_fit_sync_failure, Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 16
Source File: CommonDialogUtils.java    From product-emm with Apache License 2.0 4 votes vote down vote up
/**
 * Stops progressDialog.
 * @param progressDialog -Progress dialog which needs to be stopped.
 */
public static void stopProgressDialog(ProgressDialog progressDialog) {
	if (progressDialog != null && progressDialog.isShowing()) {
		progressDialog.dismiss();
	}
}
 
Example 17
Source File: CommonDialogUtils.java    From product-emm with Apache License 2.0 4 votes vote down vote up
/**
 * Stops progressDialog.
 * @param progressDialog -Progress dialog which needs to be stopped.
 */
public static void stopProgressDialog(ProgressDialog progressDialog) {
	if (progressDialog != null && progressDialog.isShowing()) {
		progressDialog.dismiss();
	}
}
 
Example 18
Source File: MainActivity.java    From android-packet-capture with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final Button bt = (Button)findViewById(R.id.button_packet_capture);
    progressbox = new ProgressDialog(this);
    progressbox.setTitle("Initialising");
    progressbox.setMessage("Requesting root permissions..");
    progressbox.setIndeterminate(true);
    progressbox.setCancelable(false);
    progressbox.show();
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            final Boolean isRootAvailable = Shell.SU.available();
            Boolean processExists = false;
            String pid = null;
            if(isRootAvailable) {
                List<String> out = Shell.SH.run("ps | grep tcpdump.bin");
                if(out.size() == 1) {
                    processExists = true;
                    pid = (out.get(0).split("\\s+"))[1];
                }
                else if(out.size() == 0) {
                    if (loadTcpdumpFromAssets() != 0)
                        throw new RuntimeException("Copying tcpdump binary failed.");
                }
                else
                    throw new RuntimeException("Searching for running process returned unexpected result.");
            }

            final Boolean processExistsFinal = processExists;
            final String pidFinal = pid;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (!isRootAvailable) {
                        ((TextView)findViewById(R.id.main_tv)).setText("Root permission denied or phone is not rooted!");
                        (findViewById(R.id.button_packet_capture)).setEnabled(false);
                    }
                    else {
                        if(processExistsFinal){
                            ((TextView)findViewById(R.id.main_tv)).setText("Tcpdump already running at pid: " + pidFinal );
                            bt.setText("Stop  Capture");
                            bt.setTag(1);
                        }
                        else {
                            ((TextView)findViewById(R.id.main_tv)).setText("Initialization Successful.");
                            bt.setTag(0);
                        }
                    }
                }
            });
            progressbox.dismiss();
        }
    };
    new Thread(runnable).start();
}
 
Example 19
Source File: GPDialogs.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Dismiss {@link ProgressDialog} with check in one line.
 *
 * @param progressDialog the dialog to dismiss.
 */
public static void dismissProgressDialog(ProgressDialog progressDialog) {
    if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
    }
}
 
Example 20
Source File: DialogUtils.java    From Gizwits-SmartSocket_Android with MIT License 2 votes vote down vote up
/**
 * 数据加载对话框框消失方法,避免矿口句柄溢出
 * 
 * @param ctx
 *            依附的activity
 * @param pd
 *            目标对话框
 * 
 * 
 * */
public static void dismiss(Activity ctx, ProgressDialog pd) {
	if (pd != null && pd.isShowing() && ctx != null && !ctx.isFinishing())
		pd.dismiss();
}