Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Databing 替换 ButterKnife #79

Open
gongjie opened this issue Sep 16, 2020 · 0 comments
Open

Databing 替换 ButterKnife #79

gongjie opened this issue Sep 16, 2020 · 0 comments

Comments

@gongjie
Copy link

gongjie commented Sep 16, 2020

  1. mvp工程下的build.gradle文件中的android模块下增加

    buildFeatures { dataBinding = true }

  2. XActivity的更改如下:

    增加泛型:public abstract class XActivity<P extends IPresent, DataBinding extends ViewDataBinding> extends RxAppCompatActivity implements IView<P>{}

    定义变量:protected DataBinding mDataBinding;

    修改布局的设置onCreate方法中:mDataBinding = DataBindingUtil.setContentView(this, getLayoutId()); bindUI(mDataBinding.getRoot());

  3. XFragment的更改如下:

    增加泛型:public abstract class XFragment<P extends IPresent, DataBinding extends ViewDataBinding> extends RxFragment implements IView<P> {}

    定义变量:protected DataBinding mDataBinding;

    修改布局的设置onCreateView方法中:mViewDataBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false); rootView = mViewDataBinding.getRoot(); bindUI(rootView);

  4. LazyFragment的更改如下:

    增加泛型:public class LazyFragment<DataBinding extends ViewDataBinding> extends RxFragment{}

    定义变量:protected DataBinding mDataBinding;

    修改布局的设置setContentView中:(if分支)mViewDataBinding = DataBindingUtil.inflate(getLayoutInflater(), layoutResID, container, false); View view = mViewDataBinding.getRoot();

    (else分支)mViewDataBinding = DataBindingUtil.inflate(getLayoutInflater(), layoutResID, container, false); rootView = mViewDataBinding.getRoot();

  5. XLazyFragment的更改如下:

    增加泛型:public abstract class XLazyFragment<P extends IPresent, DataBinding extends ViewDataBinding> extends LazyFragment<DataBinding> implements IView<P> {
    以上都是个人拙见,有需要的可以替换使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant