use of com.scwang.smartrefresh.layout.constant.RefreshState in project SmartRefreshLayout by scwang90.
the class EmptyLayoutExampleFragmentInner method onViewCreated.
@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
final Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
}
});
mRefreshLayout = (RefreshLayout) root.findViewById(refreshLayout);
mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
mRefreshLayout.setOnRefreshListener(this);
mRecyclerView = (RecyclerView) root.findViewById(recyclerView);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
mEmptyLayout = root.findViewById(R.id.empty);
ImageView image = (ImageView) root.findViewById(R.id.empty_image);
image.setImageResource(R.drawable.ic_empty);
TextView empty = (TextView) root.findViewById(R.id.empty_text);
empty.setText("暂无数据下拉刷新");
/*主动演示刷新*/
if (mIsNeedDemo) {
mRefreshLayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
if (mIsNeedDemo) {
mRefreshLayout.autoRefresh();
}
}
}, 3000);
mRefreshLayout.setOnMultiPurposeListener(new SimpleMultiPurposeListener() {
@Override
public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
mIsNeedDemo = false;
}
});
}
}
use of com.scwang.smartrefresh.layout.constant.RefreshState in project SmartRefreshLayout by scwang90.
the class SmartRefreshLayout method notifyStateChanged.
// /*
// * 这段代码来自谷歌官方的 SwipeRefreshLayout
// * 应用场景已经在英文注释中解释清楚
// * 大部分第三方下拉刷新库都保留了这段代码,本库也不例外
// */
// @Override
// public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// // if this is a List < L or another view that doesn't support nested
// // scrolling, ignore this request so that the vertical scroll event
// // isn't stolen
// View target = mRefreshContent.getScrollableView();
// if ((android.os.Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView))
// && (target == null || ViewCompat.isNestedScrollingEnabled(target))) {
// super.requestDisallowInterceptTouchEvent(disallowIntercept);
// //} else {
// // Nope.
// }
// }
// </editor-fold>
// <editor-fold desc="状态更改 state changes">
protected void notifyStateChanged(RefreshState state) {
final RefreshState oldState = mState;
if (oldState != state) {
mState = state;
mViceState = state;
final OnStateChangedListener refreshHeader = mRefreshHeader;
final OnStateChangedListener refreshFooter = mRefreshFooter;
final OnStateChangedListener refreshListener = mOnMultiPurposeListener;
if (refreshHeader != null) {
refreshHeader.onStateChanged(this, oldState, state);
}
if (refreshFooter != null) {
refreshFooter.onStateChanged(this, oldState, state);
}
if (refreshListener != null) {
refreshListener.onStateChanged(this, oldState, state);
}
}
}
Aggregations