Search in sources :

Example 11 with RefreshLayout

use of com.scwang.smartrefresh.layout.api.RefreshLayout in project SmartRefreshLayout by scwang90.

the class BannerPracticeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_practice_banner);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    final RefreshLayout refreshLayout = (RefreshLayout) findViewById(R.id.refreshLayout);
    mAdapter = new QuickAdapter();
    recyclerView.addItemDecoration(new DividerItemDecoration(this, VERTICAL));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mAdapter);
    final List<Movie> movies = new Gson().fromJson(JSON_MOVIES, new TypeToken<ArrayList<Movie>>() {
    }.getType());
    mAdapter.replaceData(movies);
    refreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(@NonNull final RefreshLayout refreshLayout) {
            refreshLayout.getLayout().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mAdapter.getItemCount() < 2) {
                        List<Movie> movies = new Gson().fromJson(JSON_MOVIES, new TypeToken<ArrayList<Movie>>() {
                        }.getType());
                        mAdapter.replaceData(movies);
                    }
                    refreshLayout.finishRefresh();
                }
            }, 2000);
        }
    });
    refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            mAdapter.addData(movies);
            refreshLayout.finishLoadMoreWithNoMoreData();
        }
    });
    // 添加Header
    View header = LayoutInflater.from(this).inflate(R.layout.listitem_movie_header, recyclerView, false);
    Banner banner = (Banner) header;
    banner.setImageLoader(new GlideImageLoader());
    banner.setImages(BANNER_ITEMS);
    banner.start();
    mAdapter.addHeaderView(banner);
    mAdapter.openLoadAnimation();
    // 状态栏透明和间距处理
    StatusBarUtil.immersive(this);
    StatusBarUtil.setPaddingSmart(this, toolbar);
    StatusBarUtil.setPaddingSmart(this, recyclerView);
    StatusBarUtil.setMargin(this, findViewById(R.id.header));
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurView));
}
Also used : OnLoadMoreListener(com.scwang.smartrefresh.layout.listener.OnLoadMoreListener) Banner(com.youth.banner.Banner) Gson(com.google.gson.Gson) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) TypeToken(com.google.gson.reflect.TypeToken) RecyclerView(android.support.v7.widget.RecyclerView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) Toolbar(android.support.v7.widget.Toolbar)

Example 12 with RefreshLayout

use of com.scwang.smartrefresh.layout.api.RefreshLayout in project weibo by dingdangmao123.

the class WeicoFG method CreateView.

@Override
public void CreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, View v) {
    target.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            msg.hide(false);
            Intent i = new Intent(getActivity(), Message.class);
            startActivity(i);
        }
    });
    title.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final EasyPopup mCirclePop;
            mCirclePop = new EasyPopup(getActivity()).setContentView(R.layout.popmenu).setFocusAndOutsideEnable(true).createPopup();
            TextView t1 = mCirclePop.getView(R.id.t1);
            TextView t2 = mCirclePop.getView(R.id.t2);
            TextView t3 = mCirclePop.getView(R.id.t3);
            t1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "new";
                    if (current != 1) {
                        reset = true;
                        current = 1;
                    } else {
                        reset = false;
                    }
                    title.setText("最新微博");
                    Refresh(1);
                }
            });
            t2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "hot";
                    if (current != 2) {
                        reset = true;
                        current = 2;
                    } else {
                        reset = false;
                    }
                    title.setText("热门微博");
                    Refresh(1);
                }
            });
            t3.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    mCirclePop.dismiss();
                    type = "care";
                    if (current != 3) {
                        reset = true;
                        current = 3;
                    } else {
                        reset = false;
                    }
                    title.setText("我关注的");
                    Refresh(1);
                }
            });
            mCirclePop.showAtAnchorView(v, VerticalGravity.BELOW, HorizontalGravity.ALIGN_LEFT, 0, 0);
        }
    });
    adapter = new WeicoAdapter(data, getActivity());
    tl.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
    msg = new QBadgeView(getActivity());
    msg.bindTarget(target).setBadgeGravity(Gravity.END | Gravity.TOP);
    getMessage();
    rf.autoRefresh();
}
Also used : Message(com.gapcoder.weico.Message.Message) Intent(android.content.Intent) QBadgeView(q.rorbin.badgeview.QBadgeView) EasyPopup(com.zyyoona7.lib.EasyPopup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) QBadgeView(q.rorbin.badgeview.QBadgeView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) TextView(android.widget.TextView) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) WeicoAdapter(com.gapcoder.weico.Index.Adapter.WeicoAdapter)

Example 13 with RefreshLayout

use of com.scwang.smartrefresh.layout.api.RefreshLayout in project weibo by dingdangmao123.

the class UserList method init.

@Override
public void init() {
    if ((uid = getIntent().getIntExtra("uid", 0)) == 0)
        return;
    type = getIntent().getStringExtra("type");
    if (type.equals("fans"))
        title.setText("粉丝");
    else
        title.setText("关注");
    adapter = new UserListAdapter(data, this);
    tl.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    tl.setAdapter(adapter);
    rf.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            Refresh(1);
        }
    });
    rf.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            Refresh(0);
        }
    });
    rf.autoRefresh();
}
Also used : SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 14 with RefreshLayout

use of com.scwang.smartrefresh.layout.api.RefreshLayout in project yoo_home_Android by culturer.

the class RecommendFragment method initRefresh.

private void initRefresh() {
    final RefreshLayout refreshLayout = contentView.findViewById(R.id.mrefreshLayout);
    refreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshLayout refreshlayout) {
            // 传入false表示刷新失败
            refreshlayout.finishRefresh(2000);
            refresh(refreshlayout);
        }
    });
    refreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            loadMore(refreshlayout);
            // 传入false表示加载失败
            refreshlayout.finishLoadmore(2000);
        }
    });
}
Also used : RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener)

Example 15 with RefreshLayout

use of com.scwang.smartrefresh.layout.api.RefreshLayout in project EnableHands by LeviWGG.

the class NewsFragment method initView.

@Override
public void initView() {
    smartRefreshLayout.setOnLoadmoreListener(new OnLoadmoreListener() {

        @Override
        public void onLoadmore(RefreshLayout refreshlayout) {
            smartRefreshLayout.finishLoadmore(2000);
            mPresenter.getNewsInfo();
        }
    });
    mPresenter.getNewsInfo();
    showProgressDialog("加载中");
}
Also used : SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) OnLoadmoreListener(com.scwang.smartrefresh.layout.listener.OnLoadmoreListener)

Aggregations

RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)40 View (android.view.View)26 Toolbar (android.support.v7.widget.Toolbar)24 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)22 OnRefreshListener (com.scwang.smartrefresh.layout.listener.OnRefreshListener)20 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)17 RecyclerView (android.support.v7.widget.RecyclerView)15 OnLoadmoreListener (com.scwang.smartrefresh.layout.listener.OnLoadmoreListener)12 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)11 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)10 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)10 AdapterView (android.widget.AdapterView)10 SimpleMultiPurposeListener (com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener)9 BaseRecyclerAdapter (com.scwang.refreshlayout.adapter.BaseRecyclerAdapter)7 RefreshHeader (com.scwang.smartrefresh.layout.api.RefreshHeader)7 TextView (android.widget.TextView)6 ImageView (android.widget.ImageView)5 RefreshState (com.scwang.smartrefresh.layout.constant.RefreshState)5 ClassicsHeader (com.scwang.smartrefresh.layout.header.ClassicsHeader)5 OnLoadMoreListener (com.scwang.smartrefresh.layout.listener.OnLoadMoreListener)5