android_BaseActivity的定义

/**
 * Author:DoctorWei
 * Time:2018/11/2 18:33
 * Description:定义一个Activity的基类 用于加载布局 获取控件和业务处理
 * email:[email protected]
 */
public abstract class BaseActivity extends AppCompatActivity {
    @Override
    public void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        initView();
        initData();
    }

    protected abstract void initData();

    protected abstract void initView();

    protected abstract int getLayoutId();
    //写一个全局的跳转
    public  void openActivityWithIntent(@NonNull Class activity,@NonNull Bundle bundle){
        Intent intent=new Intent(this,activity);
        if (bundle!=null) {
            intent.putExtras(bundle);
        }
        startActivity(intent);
    }
    public Bundle getIntentBundle(){
        Bundle bundle = getIntent().getExtras();
        return bundle;
    }
}

 

你可能感兴趣的:(android_BaseActivity的定义)