Search in sources :

Example 1 with SinaRefreshView

use of com.lcodecore.tkrefreshlayout.header.SinaRefreshView in project TwinklingRefreshLayout by lcodecorex.

the class ScienceActivity method setupGridView.

private void setupGridView(GridView gridView) {
    final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
    SinaRefreshView headerView = new SinaRefreshView(this);
    headerView.setArrowResource(R.drawable.arrow);
    headerView.setTextColor(0xff745D5C);
    //        TextHeaderView headerView = (TextHeaderView) View.inflate(this,R.layout.header_tv,null);
    refreshLayout.setHeaderView(headerView);
    LoadingView loadingView = new LoadingView(this);
    refreshLayout.setBottomView(loadingView);
    adapter = new ScienceAdapter();
    gridView.setAdapter(adapter);
    adapter.refreshCard();
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            ToastUtil.show("item clicked!");
        }
    });
    refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {

        @Override
        public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.refreshCard();
                    refreshLayout.finishRefreshing();
                }
            }, 2000);
        }

        @Override
        public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.loadMoreCard();
                    refreshLayout.finishLoadmore();
                }
            }, 2000);
        }
    });
}
Also used : SinaRefreshView(com.lcodecore.tkrefreshlayout.header.SinaRefreshView) ScienceAdapter(com.lcodecore.twinklingrefreshlayout.adapter.ScienceAdapter) Handler(android.os.Handler) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) SinaRefreshView(com.lcodecore.tkrefreshlayout.header.SinaRefreshView) LoadingView(com.lcodecore.tkrefreshlayout.footer.LoadingView) TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) LoadingView(com.lcodecore.tkrefreshlayout.footer.LoadingView) AdapterView(android.widget.AdapterView)

Aggregations

Handler (android.os.Handler)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 RefreshListenerAdapter (com.lcodecore.tkrefreshlayout.RefreshListenerAdapter)1 TwinklingRefreshLayout (com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout)1 LoadingView (com.lcodecore.tkrefreshlayout.footer.LoadingView)1 SinaRefreshView (com.lcodecore.tkrefreshlayout.header.SinaRefreshView)1 ScienceAdapter (com.lcodecore.twinklingrefreshlayout.adapter.ScienceAdapter)1