use of eu.davidea.viewholders.FlexibleViewHolder in project FlexibleAdapter by davideas.
the class FlexibleAdapter method addListener.
/**
* Initializes the listener(s) of this Adapter.
* <p>This method is automatically called from the Constructor.</p>
*
* @param listener the object(s) instance(s) of any listener
* @return this Adapter, so the call can be chained
* @see #removeListener(Object)
* @since 5.0.0-b6
*/
@CallSuper
public FlexibleAdapter<T> addListener(Object listener) {
if (listener == null) {
log.e("Invalid listener class: null");
return this;
}
log.i("Adding listener class %s as:", getClassName(listener));
if (listener instanceof OnItemClickListener) {
log.i("- OnItemClickListener");
mItemClickListener = (OnItemClickListener) listener;
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnClickListener(holder);
}
}
if (listener instanceof OnItemLongClickListener) {
log.i("- OnItemLongClickListener");
mItemLongClickListener = (OnItemLongClickListener) listener;
// Restore the event
for (FlexibleViewHolder holder : getAllBoundViewHolders()) {
holder.getContentView().setOnLongClickListener(holder);
}
}
if (listener instanceof OnItemMoveListener) {
log.i("- OnItemMoveListener");
mItemMoveListener = (OnItemMoveListener) listener;
}
if (listener instanceof OnItemSwipeListener) {
log.i("- OnItemSwipeListener");
mItemSwipeListener = (OnItemSwipeListener) listener;
}
if (listener instanceof OnDeleteCompleteListener) {
log.i("- OnDeleteCompleteListener");
mDeleteCompleteListener = (OnDeleteCompleteListener) listener;
}
if (listener instanceof OnStickyHeaderChangeListener) {
log.i("- OnStickyHeaderChangeListener");
mStickyHeaderChangeListener = (OnStickyHeaderChangeListener) listener;
}
if (listener instanceof OnUpdateListener) {
log.i("- OnUpdateListener");
mUpdateListener = (OnUpdateListener) listener;
mUpdateListener.onUpdateEmptyView(getMainItemCount());
}
if (listener instanceof OnFilterListener) {
log.i("- OnFilterListener");
mFilterListener = (OnFilterListener) listener;
}
return this;
}
Aggregations