1.出自“高仿京东商城”:

package com.itau.jingdong.ui.base;

import com.itau.jingdong.AppManager;
import com.itau.jingdong.config.Constants;
import com.itau.jingdong.image.ImageLoaderConfig;
import com.nostra13.universalimageloader.core.ImageLoader; import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler; /**
* @author Tau.Chen 陈涛
*
* @email [email protected],[email protected]
*
* @date 2013年9月12日
*
* @version V_1.0.0
*
* @description
*
*/
public abstract class BaseActivity extends Activity { public static final String TAG = BaseActivity.class.getSimpleName(); protected Handler mHandler = null; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
AppManager.getInstance().addActivity(this);
if (!ImageLoader.getInstance().isInited()) {
ImageLoaderConfig.initImageLoader(this, Constants.BASE_IMAGE_CACHE);
}
} @Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
} @Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
} @Override
protected void onRestart() {
// TODO Auto-generated method stub
super.onRestart();
} @Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
} @Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
} @Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
} /**
* 绑定控件id
*/
protected abstract void findViewById(); /**
* 初始化控件
*/
protected abstract void initView(); /**
* 通过类名启动Activity
*
* @param pClass
*/
protected void openActivity(Class<?> pClass) {
openActivity(pClass, null);
} /**
* 通过类名启动Activity,并且含有Bundle数据
*
* @param pClass
* @param pBundle
*/
protected void openActivity(Class<?> pClass, Bundle pBundle) {
Intent intent = new Intent(this, pClass);
if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
} /**
* 通过Action启动Activity
*
* @param pAction
*/
protected void openActivity(String pAction) {
openActivity(pAction, null);
} /**
* 通过Action启动Activity,并且含有Bundle数据
*
* @param pAction
* @param pBundle
*/
protected void openActivity(String pAction, Bundle pBundle) {
Intent intent = new Intent(pAction);
if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
} }
05-13 14:54