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;
}
}
});
}
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);
}
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();
}
}
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();
}
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;
}
Aggregations