Skip to content

Commit

Permalink
[ViperAiViewHolder] improv: add bindViews method
Browse files Browse the repository at this point in the history
it allows to easily bind data from dataobject to views on ViewHolder bind
  • Loading branch information
mkoslacz committed Apr 12, 2017
1 parent 4c61857 commit 5ebfe7d
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mateuszkoslacz.moviper.base.view.viewholder.autoinject;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.mateuszkoslacz.moviper.base.view.viewholder.ViperViewHolder;
import com.mateuszkoslacz.moviper.iface.presenter.ViperPresenter;
import com.mateuszkoslacz.moviper.iface.view.MvpDataView;
Expand All @@ -19,5 +22,25 @@ public ViperAiViewHolder(android.view.View itemView) {
injectViews(itemView);
}

abstract protected void injectViews(android.view.View itemView);
@Override
public void setDataObject(DataObject dataObject) {
super.setDataObject(dataObject);
bindViews();
}

/**
* It's called only once, on ViewHolder creation ({@link RecyclerView.Adapter#onCreateViewHolder(ViewGroup,
* int)}. Inject view references and other reusable components here.
*/
protected void injectViews(android.view.View itemView) {
// stub
}

/**
* It's called multiple times, on ViewHolder binding ({@link RecyclerView.Adapter#onBindViewHolder(RecyclerView.ViewHolder,
* int)}}. Bind data from DataObject to views here.
*/
protected void bindViews() {
// stub
}
}

0 comments on commit 5ebfe7d

Please sign in to comment.