Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Date: 15.11.2016
- * Time: 9:41
- *
- * @author Savin Mikhail
- * @author Alexey Korshun
- */
- public abstract class MvpViewHolder extends RecyclerView.ViewHolder {
- private MvpDelegate mMvpDelegate;
- private final MvpDelegate mParentDelegate;
- public MvpViewHolder(MvpDelegate<?> parentDelegate, final View itemView) {
- super(itemView);
- mParentDelegate = parentDelegate;
- }
- @Nullable
- protected MvpDelegate getMvpDelegate() {
- if (mMvpDelegate == null && getMvpChildId() != null) {
- mMvpDelegate = new MvpDelegate<>(this);
- mMvpDelegate.setParentDelegate(mParentDelegate, getMvpChildId());
- }
- return mMvpDelegate;
- }
- protected void destroyMvpDelegate() {
- if (getMvpDelegate() != null) {
- getMvpDelegate().onSaveInstanceState();
- getMvpDelegate().onDetach();
- mMvpDelegate = null;
- }
- }
- protected void createMvpDelegate() {
- if (getMvpDelegate() != null) {
- getMvpDelegate().onCreate();
- getMvpDelegate().onAttach();
- getMvpDelegate().onSaveInstanceState();
- }
- }
- protected abstract String getMvpChildId();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement