use of com.scwang.smartrefresh.listener.OnLoadmoreListener in project CollapsingRefresh by ckrgithub.
the class SmartRefreshLayout method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
Logd(TAG, "onFinish,onAttachedToWindow: ");
if (isInEditMode())
return;
if (mRefreshContent == null && mRefreshHeader == null && mRefreshFooter == null) {
onFinishInflate();
}
if (mKernel == null) {
mKernel = new RefreshKernelImpl();
}
if (mRefreshContent == null) {
for (int i = 0, len = getChildCount(); i < len; i++) {
View view = getChildAt(i);
if ((mRefreshHeader == null || view != mRefreshHeader.getView()) && (mRefreshFooter == null || view != mRefreshFooter.getView())) {
mRefreshContent = new RefreshContentWrapper(view);
}
}
if (mRefreshContent == null) {
mRefreshContent = new RefreshContentWrapper(getContext());
mRefreshContent.getView().setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
}
}
if (mFixedHeaderViewId > 0 && mFixedHeaderView == null) {
mFixedHeaderView = findViewById(mFixedHeaderViewId);
}
if (mFixedFooterViewId > 0 && mFixedFooterView == null) {
mFixedFooterView = findViewById(mFixedFooterViewId);
}
mRefreshContent.setupComponent(mKernel, mFixedHeaderView, mFixedFooterView);
if (mRefreshHeader == null) {
if (mEnablePureScrollMode) {
// 注释此效果 ckr by 2017.8.15
// mRefreshHeader = new FalsifyHeader(getContext());
} else {
mRefreshHeader = sHeaderCreater.createRefreshHeader(getContext(), this);
}
if (!(mRefreshHeader.getView().getLayoutParams() instanceof MarginLayoutParams)) {
if (mRefreshHeader.getSpinnerStyle() == SpinnerStyle.Scale) {
addView(mRefreshHeader.getView(), MATCH_PARENT, MATCH_PARENT);
} else {
addView(mRefreshHeader.getView(), MATCH_PARENT, WRAP_CONTENT);
}
}
}
if (mRefreshFooter == null) {
if (mEnablePureScrollMode) {
// 注释此效果 ckr by 2017.8.15
// mRefreshFooter = new RefreshFooterWrapper(new FalsifyHeader(getContext()));
// mEnableLoadmore = mEnableLoadmore || !mManualLoadmore;
} else {
mRefreshFooter = sFooterCreater.createRefreshFooter(getContext(), this);
mEnableLoadmore = mEnableLoadmore || (!mManualLoadmore && sManualFooterCreater);
}
if (!(mRefreshFooter.getView().getLayoutParams() instanceof MarginLayoutParams)) {
if (mRefreshFooter.getSpinnerStyle() == SpinnerStyle.Scale) {
addView(mRefreshFooter.getView(), MATCH_PARENT, MATCH_PARENT);
} else {
addView(mRefreshFooter.getView(), MATCH_PARENT, WRAP_CONTENT);
}
}
}
// 重新排序
bringChildToFront(mRefreshContent.getView());
// TODO: 2017/10/8 头部、内容、底部排序
if (mRefreshHeader.getSpinnerStyle() != SpinnerStyle.FixedBehind) {
if (isHeaderFixBehind) {
} else {
bringChildToFront(mRefreshHeader.getView());
}
}
if (mRefreshFooter.getSpinnerStyle() != SpinnerStyle.FixedBehind) {
bringChildToFront(mRefreshFooter.getView());
}
if (mRefreshListener == null) {
mRefreshListener = new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshlayout) {
refreshlayout.finishRefresh(3000);
}
};
}
if (mLoadmoreListener == null) {
mLoadmoreListener = new OnLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshlayout) {
refreshlayout.finishLoadmore(2000);
}
};
}
if (mPrimaryColors != null) {
mRefreshHeader.setPrimaryColors(mPrimaryColors);
mRefreshFooter.setPrimaryColors(mPrimaryColors);
}
try {
if (!mManualNestedScrolling && !isNestedScrollingEnabled() && getLayoutParams() instanceof CoordinatorLayout.LayoutParams) {
setNestedScrollingEnabled(true);
}
} catch (Throwable e) {
// try 不能删除
}
}
Aggregations