Search in sources :

Example 96 with ProgressDialog

use of android.app.ProgressDialog in project Android by WilliamYi96.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button button = (Button) findViewById(R.id.button);
    editText = (EditText) findViewById(R.id.edit_text);
    imageView = (ImageView) findViewById(R.id.image_view);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    //get the string of EditText and then toast it
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch((v.getId())) {
                case R.id.button:
                    String inputText = editText.getText().toString();
                    Toast.makeText(MainActivity.this, inputText, Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;
            }
        }
    });
    //change the picture when button is clicked
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.button:
                    imageView.setImageResource(R.drawable.img_2);
                    break;
                default:
                    break;
            }
        }
    });
    //dynamic progress bar(visible or not)
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.button:
                    if (progressBar.getVisibility() == View.GONE) {
                        progressBar.setVisibility(View.VISIBLE);
                    } else {
                        progressBar.setVisibility(View.GONE);
                    }
                    break;
                default:
                    break;
            }
        }
    });
    //dynamic progress bar(increasing numbers)
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.button:
                    int progress = progressBar.getProgress();
                    progress = progress + 10;
                    progressBar.setProgress(progress);
                    break;
                default:
                    break;
            }
        }
    });
    //alert dialog
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.button:
                    AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
                    dialog.setTitle("This is dialog");
                    dialog.setMessage("Something important.");
                    //dialog.setCancelable(false);
                    dialog.setCancelable(true);
                    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });
                    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });
                    dialog.show();
                    break;
                default:
                    break;
            }
        }
    });
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.button:
                    ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
                    progressDialog.setTitle("This is ProgressDialog");
                    progressDialog.setMessage("Loading....");
                    progressDialog.setCancelable(true);
                    progressDialog.show();
                    break;
                default:
                    break;
            }
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Button(android.widget.Button) DialogInterface(android.content.DialogInterface) ProgressDialog(android.app.ProgressDialog) ImageView(android.widget.ImageView) View(android.view.View)

Example 97 with ProgressDialog

use of android.app.ProgressDialog in project saga-android by AnandChowdhary.

the class Updater method checkForUpdates.

public static void checkForUpdates(final Context context, boolean visibility) {
    final int versionCode = getVersionCode(context);
    final ProgressDialog progressDialog = new ProgressDialog(context);
    String updateUrl = "https://www.dropbox.com/s/bka9o3p43oki217/saga.json?raw=1";
    if (visibility) {
        progressDialog.setTitle(context.getString(R.string.update));
        progressDialog.setMessage(context.getString(R.string.update_checking));
        progressDialog.setCancelable(true);
        progressDialog.show();
    }
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, updateUrl, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            try {
                int updateVersionCode = response.getInt("versionCode");
                if (updateVersionCode > versionCode && versionCode != 0) {
                    if (progressDialog.isShowing()) {
                        progressDialog.cancel();
                    }
                    final String apkUrl = response.getString("apkUrl");
                    String changelog = response.getString("changelog");
                    AlertDialog dialog = new AlertDialog.Builder(context).setTitle(context.getString(R.string.new_update)).setMessage(changelog).setPositiveButton(context.getString(R.string.update_now), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            File myFile = new File(Utils.getStoragePath(context), "update.apk");
                            if (myFile.exists())
                                myFile.delete();
                            Uri uri = Uri.parse(apkUrl);
                            DownloadManager dMgr = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
                            DownloadManager.Request dr = new DownloadManager.Request(uri);
                            String filename = "update.apk";
                            dr.setTitle(context.getString(R.string.app_name) + " " + context.getString(R.string.update));
                            dr.setDestinationUri(Uri.fromFile(new File(Utils.getStoragePath(context) + "/" + filename)));
                            //                                        dr.setDestinationInExternalPublicDir("/Saga/", filename);
                            dMgr.enqueue(dr);
                        }
                    }).setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    }).setCancelable(false).create();
                    dialog.show();
                } else {
                    if (progressDialog.isShowing()) {
                        progressDialog.cancel();
                        Toast.makeText(context, context.getString(R.string.no_update), Toast.LENGTH_SHORT).show();
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            if (progressDialog.isShowing()) {
                progressDialog.cancel();
                Toast.makeText(context, context.getString(R.string.error_connect), Toast.LENGTH_SHORT).show();
            }
        }
    });
    request.setShouldCache(false);
    VolleySingleton.getInstance(context).getRequestQueue().add(request);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) VolleyError(com.android.volley.VolleyError) DialogInterface(android.content.DialogInterface) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest) Request(com.android.volley.Request) JSONException(org.json.JSONException) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) DownloadManager(android.app.DownloadManager) Response(com.android.volley.Response) JSONObject(org.json.JSONObject) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest) File(java.io.File)

Example 98 with ProgressDialog

use of android.app.ProgressDialog in project boxing by Bilibili.

the class BoxingBottomSheetFragment method showProgressDialog.

private void showProgressDialog() {
    if (mDialog == null) {
        mDialog = new ProgressDialog(getActivity());
        mDialog.setIndeterminate(true);
        mDialog.setMessage(getString(R.string.handling));
    }
    if (!mDialog.isShowing()) {
        mDialog.show();
    }
}
Also used : ProgressDialog(android.app.ProgressDialog)

Example 99 with ProgressDialog

use of android.app.ProgressDialog in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class OpenCellIdActivity method onAcceptedClicked.

public void onAcceptedClicked(View v) {
    pd = new ProgressDialog(this);
    pd.setMessage(getString(R.string.getting_ocid_key));
    pd.show();
    OpenCellIdKeyDownloaderTask ocikd = new OpenCellIdKeyDownloaderTask();
    //starts background thread
    ocikd.execute();
}
Also used : ProgressDialog(android.app.ProgressDialog)

Example 100 with ProgressDialog

use of android.app.ProgressDialog in project android-bootstrap by AndroidBootstrap.

the class BootstrapAuthenticatorActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(int id) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getText(string.message_signing_in));
    dialog.setIndeterminate(true);
    dialog.setCancelable(true);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        public void onCancel(final DialogInterface dialog) {
            if (authenticationTask != null) {
                authenticationTask.cancel(true);
            }
        }
    });
    return dialog;
}
Also used : DialogInterface(android.content.DialogInterface) ProgressDialog(android.app.ProgressDialog)

Aggregations

ProgressDialog (android.app.ProgressDialog)247 DialogInterface (android.content.DialogInterface)43 Intent (android.content.Intent)20 View (android.view.View)17 File (java.io.File)17 Handler (android.os.Handler)12 FrameLayout (android.widget.FrameLayout)12 TextView (android.widget.TextView)10 IOException (java.io.IOException)10 JSONObject (org.json.JSONObject)10 LinearLayout (android.widget.LinearLayout)9 ArrayList (java.util.ArrayList)9 SuppressLint (android.annotation.SuppressLint)8 Display (android.view.Display)8 Activity (android.app.Activity)7 Uri (android.net.Uri)7 AsyncTask (android.os.AsyncTask)7 Bundle (android.os.Bundle)6 KeyEvent (android.view.KeyEvent)6 ImageView (android.widget.ImageView)6