Example usage for android.app ProgressDialog ProgressDialog

List of usage examples for android.app ProgressDialog ProgressDialog

Introduction

In this page you can find the example usage for android.app ProgressDialog ProgressDialog.

Prototype

public ProgressDialog(Context context, int theme) 

Source Link

Document

Creates a Progress dialog.

Usage

From source file:com.ztspeech.simutalk2.weibo.PostRecordTask.java

public void showLoading() {
    if (loadingDialog == null) {
        loadingDialog = new ProgressDialog(context, R.style.mydialog);
        loadingDialog.setMessage(context.getString(R.string.loading));
        loadingDialog.setIndeterminate(true);
        loadingDialog.setCancelable(true);
        loadingDialog.setOnCancelListener(new OnCancelListener() {
            @Override//from w  ww . j ava  2s.co m
            public void onCancel(DialogInterface dialog) {
                onLoadingCacel();
            }
        });
    }
    isCancel = false;
    loadingDialog.show();
}

From source file:de.da_sense.moses.client.LoginActivity.java

/**
 * Handles the click on the login button.
 * Gets called on click on the login button.
 * @param v View//  w  w w.  ja v a2s. c  om
 */
public void handleClick(View v) {
    String email = editTextEmail.getText().toString().trim();
    String password = editTextPassword.getText().toString();
    String deviceID = HardwareAbstraction.extractDeviceIdFromSharedPreferences();

    // validate the format of email and password before sending anything to server
    if (!validateEmail() || !validatePassword()) {
        return;
    }
    // show ProgressDialog while checking and verifying entered credentials
    loginDialog = new ProgressDialog(LoginActivity.this, ProgressDialog.STYLE_SPINNER);
    loginDialog.setTitle(getString(R.string.checking_credentials));
    loginDialog.setMessage(getString(R.string.verifying_credentials));
    loginDialog.setCanceledOnTouchOutside(false);
    loginDialog.show();
    // request a login/session from the server
    new RequestLogin(new ReqLogin(), email, password, deviceID).send();
}

From source file:io.github.pwlin.cordova.plugins.pdialog.PDialog.java

/**
 * Initializing the progress dialog and set various parameters
 * /*from  w  w  w.  jav  a 2 s . co m*/
 * @param rawArgs
 * @see https://github.com/pwlin/cordova-plugin-pdialog/blob/master/README.md
 */
private void init(final String rawArgs) {
    final CordovaInterface cordova = this.cordova;
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (PDialog.pDialogObj != null) {
                PDialog.pDialogObj.dismiss();
                PDialog.pDialogObj = null;
            }
            JSONObject argsObj = null;
            try {
                argsObj = new JSONObject(rawArgs);
            } catch (JSONException e) {
                // e.printStackTrace();
            }

            int theme = 5; // ProgressDialog.THEME_DEVICE_DEFAULT_LIGHT
            if (argsObj.has("theme")) {
                String themeArg = null;
                try {
                    themeArg = argsObj.getString("theme");
                } catch (JSONException e) {
                    // e.printStackTrace();
                }
                if ("TRADITIONAL".equals(themeArg)) {
                    theme = 1; // ProgressDialog.THEME_TRADITIONAL
                } else if ("DEVICE_DARK".equals(themeArg)) {
                    theme = 4; // ProgressDialog.THEME_DEVICE_DEFAULT_DARK
                }
                if ("HOLO_DARK".equals(themeArg)) {
                    theme = 2; // ProgressDialog.THEME_HOLO_DARK
                }
                if ("HOLO_LIGHT".equals(themeArg)) {
                    theme = 3; // ProgressDialog.THEME_HOLO_LIGHT
                }
            }

            int style = ProgressDialog.STYLE_SPINNER;
            if (argsObj.has("progressStyle")) {
                try {
                    if ("HORIZONTAL".equals(argsObj.getString("progressStyle"))) {
                        style = ProgressDialog.STYLE_HORIZONTAL;
                    }
                } catch (JSONException e) {
                    // e.printStackTrace();
                }
            }

            boolean cancelable = true;
            if (argsObj.has("cancelable")) {
                try {
                    if (argsObj.getBoolean("cancelable") == false) {
                        cancelable = false;
                    }
                } catch (JSONException e) {
                    // e.printStackTrace();
                }
            }

            String title = "";
            if (argsObj.has("title")) {
                try {
                    title = argsObj.getString("title");
                } catch (JSONException e) {
                    // e.printStackTrace();
                }
            }

            String message = "";
            if (argsObj.has("message")) {
                try {
                    message = argsObj.getString("message");
                } catch (JSONException e) {
                    // e.printStackTrace();
                }
            }

            PDialog.pDialogObj = new ProgressDialog(cordova.getActivity(), theme);
            PDialog.pDialogObj.setProgressStyle(style);
            PDialog.pDialogObj.setCancelable(cancelable);
            PDialog.pDialogObj.setCanceledOnTouchOutside(cancelable);
            PDialog.pDialogObj.setTitle(title);
            PDialog.pDialogObj.setMessage(message);
            PDialog.pDialogObj.show();
        };
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

protected void setDialog() {
    dialog = new ProgressDialog(this, R.style.welcome_dialog);
    dialog.setCancelable(false);//from   w  ww. ja  v  a  2 s.c o  m
    dialog.show();
    LayoutInflater inflater = LayoutInflater.from(this);
    View v = inflater.inflate(R.layout.wlecome_dialog, null);// view
    LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 
    // main.xmlImageView
    ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img);
    TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// ??
    // 
    Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.loading_animation);
    // ImageView
    spaceshipImage.startAnimation(hyperspaceJumpAnimation);
    // tipTextView.setText(msg);// ?
    dialog.setContentView(layout);
}

From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java

/**
 * Copies an item onto the current destination in the copy preferences
 * @param item The item to copy//from   w w w  .ja  v a 2s .  c  om
 */
private void copy(final Item item) {
    final BaseApplication app = (BaseApplication) getActivity().getApplication();
    final IOneDriveClient oneDriveClient = app.getOneDriveClient();
    final ItemReference parentReference = new ItemReference();
    parentReference.id = getCopyPrefs().getString(COPY_DESTINATION_PREF_KEY, null);

    final ProgressDialog dialog = new ProgressDialog(getActivity(), ProgressDialog.STYLE_HORIZONTAL);
    dialog.setTitle("Copying item");
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setMessage("Waiting for copy to complete");

    final IProgressCallback<Item> progressCallback = new IProgressCallback<Item>() {
        @Override
        public void progress(final long current, final long max) {
            dialog.setMax((int) current);
            dialog.setMax((int) max);
        }

        @Override
        public void success(final Item item) {
            dialog.dismiss();
            final String string = getString(R.string.copy_success_message, item.name,
                    item.parentReference.path);
            Toast.makeText(getActivity(), string, Toast.LENGTH_LONG).show();
        }

        @Override
        public void failure(final ClientException error) {
            dialog.dismiss();
            new AlertDialog.Builder(getActivity()).setTitle(R.string.error_title).setMessage(error.getMessage())
                    .setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            dialog.dismiss();
                        }
                    }).create().show();
        }
    };

    final DefaultCallback<AsyncMonitor<Item>> callback = new DefaultCallback<AsyncMonitor<Item>>(
            getActivity()) {
        @Override
        public void success(final AsyncMonitor<Item> itemAsyncMonitor) {
            final int millisBetweenPoll = 1000;
            itemAsyncMonitor.pollForResult(millisBetweenPoll, progressCallback);
        }
    };
    oneDriveClient.getDrive().getItems(item.id).getCopy(item.name, parentReference).buildRequest()
            .create(callback);
    dialog.show();
}

From source file:com.nextgis.woody.activity.MainActivity.java

protected void loadData() {
    final MainApplication app = (MainApplication) getApplication();
    final Account account = app.getAccount(Constants.ACCOUNT_NAME);

    class DownloadTask extends AsyncTask<Account, Integer, String> {
        private ProgressDialog mProgressDialog;
        private String mCurrentMessage;

        @Override//from w  ww  . jav  a2s  .  c om
        protected void onPreExecute() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
                mProgressDialog = new ProgressDialog(MainActivity.this,
                        android.R.style.Theme_Material_Light_Dialog_Alert);
            else
                mProgressDialog = new ProgressDialog(MainActivity.this);

            mProgressDialog.setTitle(R.string.processing);
            mProgressDialog.setMax(Constants.KEY_COUNT + 2);
            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            mProgressDialog.setCancelable(false);

            mProgressDialog.show();
        }

        @Override
        protected String doInBackground(Account... params) {
            final String sLogin = app.getAccountLogin(account);
            final String sPassword = app.getAccountPassword(account);
            final String URL = app.getAccountUrl(account);

            if (null == URL || null == sLogin) {
                return getString(R.string.error_auth);
            }

            int progress = 0;

            Connection connection = new Connection("tmp", sLogin, sPassword, URL);

            if (!connection.connect(false)) {
                return getString(R.string.error_sign_up);
            }

            // Setup progress dialog.
            mCurrentMessage = getString(R.string.look_for_city);
            publishProgress(progress++);
            connection.loadChildren();

            // 1. Get city resource by key.
            INGWResource resource = null;
            for (int i = 0; i < connection.getChildrenCount(); ++i) {
                resource = connection.getChild(i);
                if (resource.getKey().equals(SettingsConstants.CITY_KEY)) {
                    break;
                }
                resource = null;
            }

            // Check if the city is found.
            if (null == resource) {
                return getString(R.string.error_city_found);
            }

            mCurrentMessage = getString(R.string.create_base_map);
            publishProgress(progress++);

            // 2. Add background layer on map.

            RemoteTMSLayerUI layer = new RemoteTMSLayerUI(getApplicationContext(), mMap.createLayerStorage());
            layer.setName(SettingsConstants.BASEMAP_NAME);
            layer.setURL(SettingsConstants.BASEMAP_URL);
            layer.setTMSType(GeoConstants.TMSTYPE_OSM);
            layer.setMaxZoom(20);
            layer.setMinZoom(GeoConstants.DEFAULT_MIN_ZOOM);
            layer.setVisible(true);
            layer.setCacheSizeMultiply(2);
            mMap.addLayer(layer);

            // 3. Get tables for map.

            mCurrentMessage = getString(R.string.start_fill_layer);
            publishProgress(progress++);

            ResourceGroup cityGroup = (ResourceGroup) resource;
            cityGroup.loadChildren();
            Resource cityResource;
            for (int i = 0; i < cityGroup.getChildrenCount(); ++i) {
                cityResource = (Resource) cityGroup.getChild(i);

                if (cityResource.getKey().equals(Constants.KEY_MAIN)) {
                    publishProgress(progress++);

                    // Add trees layer on map.
                    NGWVectorLayerUI ngwVectorLayer = new NGWVectorLayerUI(getApplicationContext(),
                            mMap.createLayerStorage(cityResource.getKey()));

                    ngwVectorLayer.setName(Constants.KEY_MAIN);
                    ngwVectorLayer.setRemoteId(cityResource.getRemoteId());
                    ngwVectorLayer.setAccountName(account.name);
                    ngwVectorLayer.setSyncType(com.nextgis.maplib.util.Constants.SYNC_ALL);
                    ngwVectorLayer.setMinZoom(GeoConstants.DEFAULT_MIN_ZOOM);
                    ngwVectorLayer.setMaxZoom(GeoConstants.DEFAULT_MAX_ZOOM);
                    ngwVectorLayer.setVisible(true);

                    // Set style based on state field.

                    mMap.addLayer(ngwVectorLayer);

                    try {
                        ngwVectorLayer.createFromNGW(null);
                    } catch (NGException | IOException | JSONException e) {
                        mMap.delete();

                        e.printStackTrace();
                        return e.getLocalizedMessage();
                    }
                } else if (isLookupTable(cityResource)) {
                    publishProgress(progress++);

                    NGWLookupTable ngwTable = new NGWLookupTable(getApplicationContext(),
                            mMap.createLayerStorage(cityResource.getKey()));

                    ngwTable.setName(cityResource.getKey());
                    ngwTable.setRemoteId(cityResource.getRemoteId());
                    ngwTable.setAccountName(account.name);
                    ngwTable.setSyncType(com.nextgis.maplib.util.Constants.SYNC_DATA);
                    mMap.addLayer(ngwTable);

                    try {
                        ngwTable.fillFromNGW(null);
                    } catch (NGException | IOException | JSONException e) {
                        mMap.delete();

                        e.printStackTrace();
                        return e.getLocalizedMessage();
                    }
                }
            }

            mMap.save();

            return getString(R.string.success_filled);
        }

        @Override
        protected void onProgressUpdate(Integer... progress) {
            mProgressDialog.setProgress(progress[0]);
            mProgressDialog.setMessage(mCurrentMessage);
        }

        @Override
        protected void onPostExecute(String result) {
            if (mProgressDialog.isShowing())
                mProgressDialog.dismiss();
            Toast.makeText(MainActivity.this, result, Toast.LENGTH_LONG).show();
            refreshActivityView();
        }
    }

    new DownloadTask().execute(account);
}

From source file:mobile.tiis.appv2.LoginActivity.java

@Override
protected void onCreate(Bundle starter) {
    super.onCreate(starter);
    setContentView(R.layout.login_activity);

    // We load the KeyStore
    try {/*from   w  w  w.jav  a 2s .c  o m*/
        /// We initialize a default Keystore
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        // We initialize a new SSLSocketFacrory
        MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
        // We set that all host names are allowed in the socket factory
        socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        // We set the SSL Factory
        client.setSSLSocketFactory(socketFactory);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CertificateException e) {
        e.printStackTrace();
    } catch (UnrecoverableKeyException e) {
        e.printStackTrace();
    } catch (KeyStoreException e) {
        e.printStackTrace();
    } catch (KeyManagementException e) {
        e.printStackTrace();
    }

    client.setTimeout(DEFAULT_TIMEOUT);
    client.setMaxConnections(20);

    app = (BackboneApplication) getApplication();
    databaseHandler = app.getDatabaseInstance();
    if (checkPlayServices()) {
        gcm = GoogleCloudMessaging.getInstance(this);
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        if (isInternetAvailable()) {
            /**
             * registering the appv2 to Google Cloud Messaging
             */
            regId = getRegistrationId(getApplicationContext());
            Log.d(TAG, "regID = " + regId);
            if (regId.equals("")) {
                registerInBackground();
            }
        }
    } else {
        Log.i(TAG, "No valid Google Play Services APK found.");
    }

    //DatabaseHandler.getDBFile(this);
    //Delete vaccinationQueueRows that are not from today
    TextView titleText = (TextView) findViewById(R.id.login_screen_title);
    TextView ministryName = (TextView) findViewById(R.id.ministry_name);
    ministryName.setTypeface(BackboneActivity.Rosario_Regular);
    titleText.setTypeface(BackboneActivity.Rosario_Regular);
    //        getActionBar().setBackgroundDrawable(new ColorDrawable(this.getResources().getColor(R.color.light_blue_600)));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
    }

    String dateNow = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
    databaseHandler.deleteVaccinationQueueEntriesOfOtherDays(dateNow);

    app.LAST_FRAGMENT = "mobile.tiis.appv2.fragments.HomeFragment";
    app.LAST_FRAGMENT_TITLE = getString(R.string.home);

    //Starting the repeating synchronisation procedure that happens every 5 minutes
    login_preferences = getSharedPreferences(LOGINPREFERENCE, Context.MODE_PRIVATE);

    if (getIntent().hasExtra(BackboneActivity.LANGUAGELOGIN)) {
        languagePosition = getIntent().getIntExtra(BackboneActivity.LANGUAGELOGIN, 0);
        Log.d(TAGG, "Language Position before select = " + languagePosition + "");
    }

    progressDialog = new ProgressDialog(this, 0);
    language = (MaterialSpinner) findViewById(R.id.lang_spinner);
    listLanguage = new ArrayList<String>();
    listLanguage.add("Swahili");
    listLanguage.add("English");

    //Get username and password
    usernameEditText = (MaterialEditText) findViewById(R.id.username);
    usernameEditText.setFocusableInTouchMode(true);
    passwordEditText = (MaterialEditText) findViewById(R.id.password);
    passwordEditText.setFocusableInTouchMode(true);

    //Listen for a Login button click
    loginButton = (Button) findViewById(R.id.login_btn);
    SingleTextViewAdapter adapter = new SingleTextViewAdapter(this, R.layout.single_text_spinner_item_drop_down,
            listLanguage);
    language.setAdapter(adapter);

    language.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i) {
            case 0:
                languagePosition = 0;
                setLocale("sw");
                Log.d(TAGG, "selected position is " + i + " I put 0");
                break;
            case 1:
                languagePosition = 1;
                setLocale("en");
                Log.d(TAGG, "selected position is " + i + " I put 1");
                break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    loginButton.setOnClickListener(this);
    getSavedConfigurations();
}