Methods Summary |
---|
public void | clear()Destroy created views.
if (mCurrentPresenter != null) {
mCurrentPresenter.onUnbindViewHolder(mCurrentViewHolder);
mParent.removeView(mCurrentViewHolder.view);
mCurrentViewHolder = null;
mCurrentPresenter = null;
}
|
public final android.view.ViewGroup | getParentViewGroup()
return mParent;
|
public void | init(android.view.ViewGroup parent, PresenterSelector presenterSelector)Initialize switcher with a parent view to insert view into and a
{@link PresenterSelector} for choose {@link Presenter} for object.
This will destroy any existing views.
clear();
mParent = parent;
mPresenterSelector = presenterSelector;
|
protected abstract void | insertView(android.view.View view)
|
protected void | onViewSelected(android.view.View view)Called when a view is bound to the object of {@link #select(Object)}.
|
public void | select(java.lang.Object object)
switchView(object);
showView(true);
|
private void | showView(boolean show)
if (mCurrentViewHolder != null) {
showView(mCurrentViewHolder.view, show);
}
|
protected void | showView(android.view.View view, boolean visible)
view.setVisibility(visible ? View.VISIBLE : View.GONE);
|
private void | switchView(java.lang.Object object)
Presenter presenter = mPresenterSelector.getPresenter(object);
if (presenter != mCurrentPresenter) {
showView(false);
clear();
mCurrentPresenter = presenter;
if (mCurrentPresenter == null) {
return;
}
mCurrentViewHolder = mCurrentPresenter.onCreateViewHolder(mParent);
insertView(mCurrentViewHolder.view);
} else {
if (mCurrentPresenter == null) {
return;
}
mCurrentPresenter.onUnbindViewHolder(mCurrentViewHolder);
}
mCurrentPresenter.onBindViewHolder(mCurrentViewHolder, object);
onViewSelected(mCurrentViewHolder.view);
|
public void | unselect()
showView(false);
|