Skip to content

Instantly share code, notes, and snippets.

@KucherenkoIhor
Last active May 6, 2017 19:19
Show Gist options
  • Save KucherenkoIhor/5ba1eccc9cc90b23f75ca82f1238053f to your computer and use it in GitHub Desktop.
Save KucherenkoIhor/5ba1eccc9cc90b23f75ca82f1238053f to your computer and use it in GitHub Desktop.
public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity
implements BaseView {
private Unbinder mUnBinder;
private ProgressDialog mProgressDialog = null;
protected @NonNull abstract P getPresenterInstance();
protected P mPresenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPresenter = getPresenterInstance();
mPresenter.attachView(this);
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
super.setContentView(layoutResID);
mUnBinder = ButterKnife.bind(this);
}
@Override
protected void onDestroy() {
mPresenter.detachView();
mUnBinder.unbind();
super.onDestroy();
}
@Override
public View getContentView() {
return getWindow().getDecorView();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment