base类是基础,小伙伴先大致看一下思路后面等整个框架带领大家搭建起来以后我再给出项目的整个地址
返回父布局parentView
protected View parentView;
//onCreateView()里
parentView = inflater.inflate(getLayoutResId(), container, false);
return parentView;
//涉及getLayoutResId(),必须重写 方法
//创建方法获取
protected View getParentView() {
return parentView;
}
获取FragmentActivity对象
protected FragmentActivity activity;
//onCreate()里
activity = getSupportActivity();
获取LayoutInflater对象
protected LayoutInflater inflater;
//onCreateView里
this.inflater = inflater;
//获取
protected LayoutInflater getLayoutInflater() {
return inflater;
}
获取Context对象
protected Context mContext;
//onCreate()里
//前面获取了FragmentActivity对象
mContext = activity;
设置重写必要的方法
//onViewCreated里
setupActivityComponent(ReaderApplication.getsInstance().getAppComponent());
attachView();
initDatas();
configViews();
//方法
//必须重写的方法
public abstract
@LayoutRes
int getLayoutResId();
//设置dagger2桥梁
protected abstract void setActivityCompontent(AppComponent appComponent);
public abstract void attachView();
public abstract