Back to project page FrameLite.
The source code is released under:
GNU General Public License
If you think the Android project FrameLite 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.miku.framelite; /*from w w w . j a va2s . com*/ import com.miku.framelite.utils.ViewUtils; import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface.OnCancelListener; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.widget.Toast; /** * * ????activity,????activity??????id??click????????? * * @author xr.lee * */ public class FrameBaseActivity extends Activity { protected final static int PROGRESS_DIALOG = 20140317; protected final static String DIALOG_TITLE = "DIALOG_TITLE"; protected final static String DIALOG_MSG = "DIALOG_MSG"; protected final static String DIALOG_CANCELABLE = "DIALOG_CANCELABLE"; private OnCancelListener mProgressDialogCancelListener; protected Context mContext; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext=this; } public void setContentView(int layoutResID) { super.setContentView(layoutResID); init(); } public void setContentView(View view, LayoutParams params) { super.setContentView(view, params); init(); } public void setContentView(View view) { super.setContentView(view); init(); } private void init() { if (this instanceof OnClickListener) { ViewUtils.bindViewIds(this, FrameBaseActivity.class,null, (OnClickListener) this); } else { ViewUtils.bindViewIds(this, FrameBaseActivity.class,null, null); } } @Override @Deprecated protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { case PROGRESS_DIALOG: { ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(""); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); return progressDialog; } default: return super.onCreateDialog(id, args); } } @Override @Deprecated protected void onPrepareDialog(int id, Dialog dialog, Bundle args) { switch (id) { case PROGRESS_DIALOG: { if (args != null) { String msg = args.getString(DIALOG_MSG); ProgressDialog d = (ProgressDialog) dialog; try { d.setOnCancelListener(mProgressDialogCancelListener); } catch (Exception e) { e.printStackTrace(); } d.setMessage(msg == null ? "" : msg); d.setCancelable(args.getBoolean(DIALOG_CANCELABLE, true)); } } break; default: { super.onPrepareDialog(id, dialog, args); } break; } } /** * ??????? * * @param msg */ protected void showProgressDialog(String msg) { showProgressDialog(msg, true, null); } /** * ??????? * * @param msg * @param isCancelable */ protected void showProgressDialog(String msg, boolean isCancelable) { showProgressDialog(msg, isCancelable, null); } protected void showProgressDialog(String msg, boolean isCancelable, OnCancelListener listener) { Bundle b = new Bundle(); b.putString(DIALOG_MSG, msg); b.putBoolean(DIALOG_CANCELABLE, isCancelable); mProgressDialogCancelListener = listener; showDialog(PROGRESS_DIALOG, b); } /** * ????????? */ protected void dismissProgressDialog() { try { dismissDialog(PROGRESS_DIALOG); } catch (Exception e) { } } /** * ?????? * * @param msg */ protected void showToast(String msg) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } }