Search in sources :

Example 1 with DefaultRefreshHeaderCreator

use of com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator 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;
        }
    });
}
Also used : Context(android.content.Context) RefreshHeader(com.scwang.smartrefresh.layout.api.RefreshHeader) RefreshFooter(com.scwang.smartrefresh.layout.api.RefreshFooter) DefaultRefreshFooterCreator(com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator) DefaultRefreshHeaderCreator(com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) ClassicsHeader(com.scwang.smartrefresh.layout.header.ClassicsHeader) NonNull(android.support.annotation.NonNull) ClassicsFooter(com.scwang.smartrefresh.layout.footer.ClassicsFooter)

Example 2 with DefaultRefreshHeaderCreator

use of com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator in project MVP by yuchengren.

the class BaseApplication method initRefreshView.

private void initRefreshView() {
    SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {

        @NonNull
        @Override
        public RefreshHeader createRefreshHeader(@NonNull Context context, @NonNull RefreshLayout layout) {
            return new MKRefreshHeader(context);
        }
    });
    SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {

        @NonNull
        @Override
        public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
            ClassicsFooter classicsFooter = new ClassicsFooter(context);
            ClassicsFooter.REFRESH_FOOTER_NOTHING = "没有更多数据啦";
            classicsFooter.setTextSizeTitle(14);
            classicsFooter.setAccentColorId(R.color.text_color_medium);
            return classicsFooter;
        }
    });
}
Also used : Context(android.content.Context) MKRefreshHeader(com.ycr.module.base.view.pullrefresh.MKRefreshHeader) RefreshHeader(com.scwang.smartrefresh.layout.api.RefreshHeader) RefreshFooter(com.scwang.smartrefresh.layout.api.RefreshFooter) DefaultRefreshFooterCreator(com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator) DefaultRefreshHeaderCreator(com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) NonNull(android.support.annotation.NonNull) MKRefreshHeader(com.ycr.module.base.view.pullrefresh.MKRefreshHeader) ClassicsFooter(com.ycr.lib.ui.pullrefresh.smart.footer.ClassicsFooter)

Aggregations

Context (android.content.Context)2 NonNull (android.support.annotation.NonNull)2 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)2 DefaultRefreshFooterCreator (com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator)2 DefaultRefreshHeaderCreator (com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator)2 RefreshFooter (com.scwang.smartrefresh.layout.api.RefreshFooter)2 RefreshHeader (com.scwang.smartrefresh.layout.api.RefreshHeader)2 RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)2 ClassicsFooter (com.scwang.smartrefresh.layout.footer.ClassicsFooter)1 ClassicsHeader (com.scwang.smartrefresh.layout.header.ClassicsHeader)1 ClassicsFooter (com.ycr.lib.ui.pullrefresh.smart.footer.ClassicsFooter)1 MKRefreshHeader (com.ycr.module.base.view.pullrefresh.MKRefreshHeader)1