Example usage for android.app ProgressDialog hide

List of usage examples for android.app ProgressDialog hide

Introduction

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

Prototype

public void hide() 

Source Link

Document

Hide the dialog, but do not dismiss it.

Usage

From source file:com.wecanstudio.xdsjs.save.Model.net.RxNetworking.java

public static <T> Observable.Transformer<T, T> bindConnecting(final ProgressDialog pd) {
    return new Observable.Transformer<T, T>() {
        @Override//from   ww w.  j a  v a2s .c om
        public Observable<T> call(Observable<T> original) {
            return original.doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    pd.show();
                }
            }).doOnCompleted(new Action0() {
                @Override
                public void call() {
                    pd.hide();
                }
            }).doOnError(new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    pd.hide();
                }
            });
        }
    };
}

From source file:xyz.valentin.marineoh.BaseActivity.java

@OnClick(R.id.findItineraryButtonBaseActivity)
public void findItineraries() {
    //        getSupportFragmentManager()
    //                .beginTransaction()
    //                .show(mTestFragment)
    //                .commit();

    final ProgressDialog progressDialog = ProgressDialog.show(this, "", "Recherche en cours...", true);

    if ((TextUtils.isEmpty(mOriginEditText.getText()) && !mUseGeolocationToggleButton.isChecked())
            || TextUtils.isEmpty(mDestinationEditText.getText())) {
        progressDialog.hide();
        return;// www  . j  ava2 s .  c om
    }

    final Intent intent = new Intent(this, ItinerariesActivity.class);

    if (mUseGeolocationToggleButton.isChecked()) {
        mItinerarySearch = new ItinerarySearch(mCurrentLocation, mDestinationEditText.getText().toString());
    } else {
        mItinerarySearch = new ItinerarySearch(mOriginEditText.getText().toString(),
                mDestinationEditText.getText().toString());
    }

    mItinerarySearch.search().enqueue(new Callback<Itinerary>() {
        @Override
        public void onResponse(Call<Itinerary> call, Response<Itinerary> response) {
            progressDialog.hide();

            mItinerarySearch.setItinerary(response.body());

            if (mItinerarySearch.getItinerary().getRoutes().size() == 0) {
                displayNoItineraryFoundDialog();
                return;
            }

            intent.putExtra("itinerarySearch", mItinerarySearch);
            startActivity(intent);
        }

        @Override
        public void onFailure(Call<Itinerary> call, Throwable t) {
            progressDialog.hide();
        }
    });
}

From source file:com.licenta.android.licenseapp.location.MapFragment.java

private void makeRequest() {
    String tag_json_obj = "json_obj_req";

    String url = "http://api.bandsintown.com/artists/Metallica/events/search.json?api_version=2.0" + "&app_id="
            + MyApplication.TAG;// w  w w.  java 2 s  .com

    final ProgressDialog pDialog = new ProgressDialog(getActivity());
    pDialog.setMessage("Loading...");
    pDialog.show();

    JsonObjectRequest jsonObjReq;
    jsonObjReq = new JsonObjectRequest(Request.Method.GET, url, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            Log.d(MyApplication.TAG, response.toString());
            pDialog.hide();
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d(MyApplication.TAG, "Error: " + error.getMessage());
            // hide the progress dialog
            pDialog.hide();
        }
    });

    // Adding request to request queue
    MyApplication.getInstance().addToRequestQueue(jsonObjReq, tag_json_obj);
}

From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override// ww w . ja  va2 s  .  c o  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    if (view != null)
        return view;

    view = inflater.inflate(R.layout.webview, container, false);
    assert view != null;

    final WebView webView = (WebView) view.findViewById(R.id.webView);

    WebSettings settings = webView.getSettings();
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);

    final ProgressDialog progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage(getResources().getString(R.string.loading));

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress < 100) {
                progressDialog.setProgress(newProgress);
                progressDialog.show();
            } else {
                progressDialog.hide();
            }
        }
    });

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view, @NotNull SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @SuppressWarnings("ConstantConditions")
        @Override
        public void onReceivedHttpAuthRequest(WebView view, @NotNull HttpAuthHandler handler, String host,
                String realm) {
            FHEMServerSpec currentServer = connectionService.getCurrentServer(getActivity());
            String url = currentServer.getUrl();
            String alternativeUrl = trimToNull(currentServer.getAlternateUrl());
            try {

                String fhemUrlHost = new URL(url).getHost();
                String alternativeUrlHost = alternativeUrl == null ? null : new URL(alternativeUrl).getHost();
                String username = currentServer.getUsername();
                String password = currentServer.getPassword();

                if (host.startsWith(fhemUrlHost)
                        || (alternativeUrlHost != null && host.startsWith(alternativeUrlHost))) {
                    handler.proceed(username, password);
                } else {
                    handler.cancel();

                    Intent intent = new Intent(Actions.SHOW_TOAST);
                    intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_authentication);
                    getActivity().sendBroadcast(intent);
                }

            } catch (MalformedURLException e) {
                Intent intent = new Intent(Actions.SHOW_TOAST);
                intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_host_connection);
                getActivity().sendBroadcast(intent);
                LOG.error("malformed URL: " + url, e);

                handler.cancel();
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if ("about:blank".equalsIgnoreCase(url)) {
                Optional<String> alternativeUrl = getAlternateLoadUrl();
                if (alternativeUrl.isPresent()) {
                    webView.loadUrl(alternativeUrl.get());
                }
            } else {
                onPageLoadFinishedCallback(view, url);
            }
        }
    });

    return view;
}

From source file:com.nextgis.mobile.map.LocalGeoJsonLayer.java

/**
 * Create a LocalGeoJsonLayer from the GeoJson data submitted by uri.
 *//*from w  w w  . j  ava2 s .  c  o m*/
protected static void create(final MapBase map, String layerName, Uri uri) {

    String sErr = map.getContext().getString(R.string.error_occurred);
    ProgressDialog progressDialog = new ProgressDialog(map.getContext());

    try {
        InputStream inputStream = map.getContext().getContentResolver().openInputStream(uri);
        if (inputStream != null) {

            progressDialog.setMessage(map.getContext().getString(R.string.message_loading_progress));
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setCancelable(true);
            progressDialog.show();

            int nSize = inputStream.available();
            int nIncrement = 0;
            progressDialog.setMax(nSize);

            //read all geojson
            BufferedReader streamReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));

            StringBuilder responseStrBuilder = new StringBuilder();

            String inputStr;
            while ((inputStr = streamReader.readLine()) != null) {
                nIncrement += inputStr.length();
                progressDialog.setProgress(nIncrement);
                responseStrBuilder.append(inputStr);
            }

            progressDialog.setMessage(map.getContext().getString(R.string.message_opening_progress));

            JSONObject geoJSONObject = new JSONObject(responseStrBuilder.toString());

            if (!geoJSONObject.has(GEOJSON_TYPE)) {
                sErr += ": " + map.getContext().getString(R.string.error_geojson_unsupported);
                Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
                progressDialog.hide();
                return;
            }

            //check crs
            boolean isWGS84 = true; //if no crs tag - WGS84 CRS

            if (geoJSONObject.has(GEOJSON_CRS)) {
                JSONObject crsJSONObject = geoJSONObject.getJSONObject(GEOJSON_CRS);

                //the link is unsupported yet.
                if (!crsJSONObject.getString(GEOJSON_TYPE).equals(GEOJSON_NAME)) {
                    sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported);
                    Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
                    progressDialog.hide();
                    return;
                }

                JSONObject crsPropertiesJSONObject = crsJSONObject.getJSONObject(GEOJSON_PROPERTIES);
                String crsName = crsPropertiesJSONObject.getString(GEOJSON_NAME);

                if (crsName.equals("urn:ogc:def:crs:OGC:1.3:CRS84")) { // WGS84
                    isWGS84 = true;
                } else if (crsName.equals("urn:ogc:def:crs:EPSG::3857")) { //Web Mercator
                    isWGS84 = false;
                } else {
                    sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported);
                    Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
                    progressDialog.hide();
                    return;
                }
            }

            //load contents to memory and reproject if needed
            JSONArray geoJSONFeatures = geoJSONObject.getJSONArray(GEOJSON_TYPE_FEATURES);

            if (0 == geoJSONFeatures.length()) {
                sErr += ": " + map.getContext().getString(R.string.error_geojson_crs_unsupported);
                Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
                progressDialog.hide();
                return;
            }

            List<Feature> features = geoJSONFeaturesToFeatures(geoJSONFeatures, isWGS84, map.getContext(),
                    progressDialog);

            create(map, layerName, features);
        }

    } catch (UnsupportedEncodingException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (FileNotFoundException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (IOException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    } catch (JSONException e) {
        Log.d(TAG, "Exception: " + e.getLocalizedMessage());
        sErr += ": " + e.getLocalizedMessage();
    }

    progressDialog.hide();
    //if we here something wrong occurred
    Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show();
}

From source file:ablgroup.daily2.authentification.AuthentificationFragment.java

private void createAccount(String email, String password) {
    Log.d(TAG, "createAccount:" + email);
    if (!validateForm()) {
        return;//from w  w w .j  a  v a 2s .c  o  m
    }

    final ProgressDialog pd = new ProgressDialog(AuthentificationFragment.this);
    pd.setMessage("loading");
    pd.show();

    // [START create_user_with_email]
    mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this,
            new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                    if (!task.isSuccessful()) {
                        Toast.makeText(AuthentificationFragment.this, R.string.auth_failed, Toast.LENGTH_SHORT)
                                .show();
                    }
                    pd.hide();
                }
            });
    // [END create_user_with_email]
}

From source file:ablgroup.daily2.authentification.AuthentificationFragment.java

private void signIn(String email, String password) {
    Log.d(TAG, "signIn:" + email);
    if (!validateForm()) {
        return;// w  ww .j  a v a2s  . c  om
    }

    final ProgressDialog pd = new ProgressDialog(AuthentificationFragment.this);
    pd.setMessage("loading");
    pd.show();

    // [START sign_in_with_email]
    mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(this,
            new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful());
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithEmail:failed", task.getException());
                        Toast.makeText(AuthentificationFragment.this, R.string.auth_failed, Toast.LENGTH_SHORT)
                                .show();
                    }

                    // [START_EXCLUDE]
                    if (!task.isSuccessful()) {
                        mStatusTextView.setText(R.string.auth_failed);
                    }
                    pd.hide();
                    // [END_EXCLUDE]
                }
            });
    // [END sign_in_with_email]
}

From source file:com.money.manager.ex.MainActivity.java

public void startServiceSyncDropbox() {
    if (mDropboxHelper != null && mDropboxHelper.isLinked()) {
        Intent service = new Intent(getApplicationContext(), DropboxServiceIntent.class);
        service.setAction(DropboxServiceIntent.INTENT_ACTION_SYNC);
        service.putExtra(DropboxServiceIntent.INTENT_EXTRA_LOCAL_FILE,
                MoneyManagerApplication.getDatabasePath(this.getApplicationContext()));
        service.putExtra(DropboxServiceIntent.INTENT_EXTRA_REMOTE_FILE, mDropboxHelper.getLinkedRemoteFile());
        //progress dialog
        final ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setCancelable(false);
        progressDialog.setMessage(getString(R.string.dropbox_syncProgress));
        progressDialog.setIndeterminate(true);
        progressDialog.show();/*ww w.  j  a  va 2 s  . c  om*/
        //create a messenger
        Messenger messenger = new Messenger(new Handler() {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == DropboxServiceIntent.INTENT_EXTRA_MESSENGER_NOT_CHANGE) {
                    // close dialog
                    if (progressDialog != null && progressDialog.isShowing())
                        progressDialog.hide();

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, R.string.dropbox_database_is_synchronized,
                                    Toast.LENGTH_LONG).show();
                        }
                    });
                } else if (msg.what == DropboxServiceIntent.INTENT_EXTRA_MESSENGER_START_DOWNLOAD) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, R.string.dropbox_download_is_starting,
                                    Toast.LENGTH_LONG).show();
                        }
                    });
                } else if (msg.what == DropboxServiceIntent.INTENT_EXTRA_MESSENGER_DOWNLOAD) {
                    // close dialog
                    if (progressDialog != null && progressDialog.isShowing())
                        progressDialog.hide();
                    // reload fragment
                    reloadAllFragment();
                } else if (msg.what == DropboxServiceIntent.INTENT_EXTRA_MESSENGER_START_UPLOAD) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, R.string.dropbox_upload_is_starting,
                                    Toast.LENGTH_LONG).show();
                        }
                    });
                } else if (msg.what == DropboxServiceIntent.INTENT_EXTRA_MESSENGER_UPLOAD) {
                    // close dialog
                    if (progressDialog != null && progressDialog.isShowing())
                        progressDialog.hide();

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, R.string.upload_file_to_dropbox_complete,
                                    Toast.LENGTH_LONG).show();
                        }
                    });
                }
            }
        });
        service.putExtra(DropboxServiceIntent.INTENT_EXTRA_MESSENGER, messenger);

        this.startService(service);
    }
}

From source file:net.kourlas.voipms_sms.Notifications.java

/**
 * Enable SMS notifications by configuring the VoIP.ms URL callback, registering for GCM and making the appropriate
 * changes to the application preferences.
 *
 * @param activity The source activity.//ww  w  . j a  v  a2s. c  om
 */
public void enableNotifications(final Activity activity) {
    if (preferences.getEmail().equals("") || preferences.getPassword().equals("")
            || preferences.getDid().equals("")) {
        Utils.showInfoDialog(activity,
                applicationContext.getString(R.string.notifications_callback_username_password_did));
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(activity);
    progressDialog.setMessage(activity.getString(R.string.notifications_callback_progress));
    progressDialog.setCancelable(false);
    progressDialog.show();

    new AsyncTask<Boolean, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Boolean... params) {
            try {
                String url = "https://www.voip.ms/api/v1/rest.php?" + "api_username="
                        + URLEncoder.encode(preferences.getEmail(), "UTF-8") + "&" + "api_password="
                        + URLEncoder.encode(preferences.getPassword(), "UTF-8") + "&" + "method=setSMS" + "&"
                        + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "enable=1" + "&"
                        + "url_callback_enable=1" + "&" + "url_callback=" + URLEncoder
                                .encode("http://voipmssms-kourlas.rhcloud.com/sms_callback?did={TO}", "UTF-8")
                        + "&" + "url_callback_retry=0";

                JSONObject result = Utils.getJson(url);
                String status = result.optString("status");
                return !(status == null || !status.equals("success"));
            } catch (Exception ex) {
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean success) {
            progressDialog.hide();

            DialogInterface.OnClickListener gcmOnClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    gcm.registerForGcm(activity, true, true);
                }
            };

            if (!success) {
                Utils.showAlertDialog(activity, null,
                        applicationContext.getString(R.string.notifications_callback_fail),
                        applicationContext.getString(R.string.ok), gcmOnClickListener, null, null);
            } else {
                Utils.showAlertDialog(activity, null,
                        applicationContext.getString(R.string.notifications_callback_success),
                        applicationContext.getString(R.string.ok), gcmOnClickListener, null, null);
            }
        }
    }.execute();
}

From source file:com.juick.android.MessageMenu.java

public void translateToRussian(final String body, final Utils.Function<Void, String[]> callback) {
    final ProgressDialog mDialog = new ProgressDialog(activity);
    mDialog.setMessage("Google Translate...");
    mDialog.setCancelable(true);//from ww w  .j a v a2  s  . co m
    mDialog.setCanceledOnTouchOutside(true);
    final ArrayList<HttpGet> actions = new ArrayList<HttpGet>();

    final String[] split = body.split("\\.");
    final String[] results = new String[split.length];
    final int[] pieces = new int[] { 0 };
    for (int i = 0; i < split.length; i++) {
        final String s = split[i];
        if (s.trim().length() == 0) {
            results[i] = split[i];
            synchronized (pieces) {
                pieces[0]++;
                if (pieces[0] == results.length) {
                    mDialog.hide();
                    callback.apply(results);
                }
            }
        } else {
            Uri.Builder builder = new Uri.Builder().scheme("http").authority("translate.google.com")
                    .path("translate_a/t");
            builder = builder.appendQueryParameter("client", "at");
            builder = builder.appendQueryParameter("v", "2.0");
            builder = builder.appendQueryParameter("sl", "auto");
            builder = builder.appendQueryParameter("tl", "ru");
            builder = builder.appendQueryParameter("hl", "en_US");
            builder = builder.appendQueryParameter("ie", "UTF-8");
            builder = builder.appendQueryParameter("oe", "UTF-8");
            builder = builder.appendQueryParameter("inputm", "2");
            builder = builder.appendQueryParameter("source", "edit");
            builder = builder.appendQueryParameter("text", s);
            final HttpClient client = new DefaultHttpClient();
            // AndroidHttpClient.newInstance("AndroidTranslate/2.4.2 2.3.6 (gzip)", activity);
            final HttpGet verb = new HttpGet(builder.build().toString());
            actions.add(verb);
            verb.setHeader("Accept-Charset", "UTF-8");
            final int finalI = i;
            final Thread thread = new Thread("google translate") {
                @Override
                public void run() {
                    final StringBuilder out = new StringBuilder("");
                    try {
                        final String retval = client.execute(verb, new BasicResponseHandler());
                        out.setLength(0);
                        out.append(retval);
                    } catch (IOException e) {
                        if (s.length() > 0)
                            out.append("[error: " + e.toString() + "]");
                        Log.e("com.juickadvanced", "Error calling google translate", e);
                    } finally {
                        client.getConnectionManager().shutdown();
                        synchronized (pieces) {
                            pieces[0]++;
                            results[finalI] = out.toString();
                            if (pieces[0] == results.length) {
                                activity.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        mDialog.hide();
                                        callback.apply(results);
                                    }
                                });
                            }
                        }
                    }
                }

            };
            thread.start();
        }

    }

    mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            for (HttpGet action : actions) {
                action.abort();
            }
            synchronized (pieces) {
                pieces[0] = -10000;
            }
            mDialog.hide();
        }
    });
    mDialog.show();
}