use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.
the class RefreshStylesFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
StatusBarUtil.setPaddingSmart(getContext(), root.findViewById(R.id.toolbar));
View view = root.findViewById(recyclerView);
if (view instanceof RecyclerView) {
RecyclerView recyclerView = (RecyclerView) view;
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
recyclerView.setAdapter(new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2, this) {
@Override
public SmartViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
SmartViewHolder holder = super.onCreateViewHolder(parent, viewType);
if (viewType == 0) {
holder.itemView.setVisibility(View.GONE);
holder.itemView.setLayoutParams(new RecyclerView.LayoutParams(0, 0));
}
return holder;
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public int getItemViewType(int position) {
return position == 0 ? 0 : 1;
}
@Override
protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
holder.text(android.R.id.text1, model.name());
holder.text(android.R.id.text2, model.nameId);
holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
}
});
}
RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
if (refreshLayout != null) {
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull final RefreshLayout refreshLayout) {
refreshLayout.finishRefresh(3000);
refreshLayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
RefreshHeader refreshHeader = refreshLayout.getRefreshHeader();
if (refreshHeader instanceof RefreshHeaderWrapper) {
refreshLayout.setRefreshHeader(new PhoenixHeader(getContext()));
} else if (refreshHeader instanceof PhoenixHeader) {
refreshLayout.setRefreshHeader(new DropBoxHeader(getContext()));
} else if (refreshHeader instanceof DropBoxHeader) {
refreshLayout.setRefreshHeader(new FunGameHitBlockHeader(getContext()));
} else if (refreshHeader instanceof FunGameHitBlockHeader) {
refreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
} else {
refreshLayout.setRefreshHeader(new RefreshHeaderWrapper(new BallPulseFooter(getContext())));
}
refreshLayout.setPrimaryColorsId(R.color.colorPrimary, android.R.color.white);
}
}, 4000);
}
});
}
}
use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.
the class BottomSheetExampleFragment 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();
}
});
RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
refreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull final RefreshLayout refreshLayout) {
refreshLayout.getLayout().postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.loadMore(initData());
refreshLayout.finishLoadMore();
}
}, 2000);
}
});
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recyclerView);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
recyclerView.setAdapter(mAdapter = new BaseRecyclerAdapter<Void>(initData(), simple_list_item_2) {
@Override
protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
holder.text(android.R.id.text1, getString(R.string.item_example_number_title, position));
holder.text(android.R.id.text2, getString(R.string.item_example_number_abstract, position));
holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
}
});
((ViewGroup) refreshLayout.getLayout().getParent()).removeView(refreshLayout.getLayout());
BottomSheetDialog dialog = new BottomSheetDialog(getContext());
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
getActivity().finish();
}
});
dialog.setContentView(refreshLayout.getLayout());
dialog.show();
}
use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.
the class EmptyLayoutExampleFragmentOuter 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("暂无数据点击刷新");
((View) empty.getParent()).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doRefresh(0);
}
});
}
use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.
the class AssignDefaultExampleActivity method install.
/*
* 关键代码,需要在布局生成之前设置,建议代码放在 Application 中
*/
private static void install() {
// 设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@NonNull
@Override
public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
ClassicsHeader header = new ClassicsHeader(context).setSpinnerStyle(SpinnerStyle.FixedBehind);
header.setPrimaryColorId(R.color.colorPrimary);
header.setAccentColorId(android.R.color.white);
// 指定为经典Header,默认是 贝塞尔雷达Header
return header;
}
});
// 设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@NonNull
@Override
public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
// 内容不满一页时候启用加载更多
layout.setEnableLoadMoreWhenContentNotFull(true);
ClassicsFooter footer = new ClassicsFooter(context);
footer.setBackgroundResource(android.R.color.white);
// 设置为拉伸模式
footer.setSpinnerStyle(SpinnerStyle.Scale);
// 指定为经典Footer,默认是 BallPulseFooter
return footer;
}
});
}
use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.
the class EmptyLayoutExampleFragment 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));
mLoadingLayout = (LoadingLayout) root.findViewById(R.id.loading);
mLoadingLayout.showEmpty();
/*主动演示刷新*/
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;
}
});
}
}
Aggregations