Back to project page droidkit-engines.
The source code is released under:
MIT License
If you think the Android project droidkit-engines listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.droidkit.sample; /*from w w w. j a va 2 s. co m*/ import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.support.v7.app.ActionBarActivity; import android.text.TextUtils; public class BaseActivity extends ActionBarActivity { protected static final Handler handler = new Handler(Looper.getMainLooper()); protected final Object progressDialogSync = new Object(); protected volatile ProgressDialog progressDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityHelper.tide(this); // ... } public void showProgressDialog(final String title, final String text) { runOnUiThread(new Runnable() { @Override public void run() { synchronized (progressDialogSync) { if (progressDialog == null) { progressDialog = new ProgressDialog(BaseActivity.this); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); } if (!TextUtils.isEmpty(title)) { progressDialog.setTitle(title); } else { progressDialog.setTitle(""); } if (!TextUtils.isEmpty(text)) { progressDialog.setMessage(text); } else { progressDialog.setMessage(""); } progressDialog.show(); } } }); } public void hideProgressDialog() { runOnUiThread(new Runnable() { @Override public void run() { if (progressDialog != null && progressDialog.isShowing()) { try { progressDialog.dismiss(); } catch (final IllegalArgumentException e) { // Sometimes we may get "View not attached to window manager" e.printStackTrace(); } } } }); } }