Search in sources :

Example 1 with MusicAdapter

use of com.lcodecore.twinklingrefreshlayout.adapter.MusicAdapter in project TwinklingRefreshLayout by lcodecorex.

the class MusicActivity method setupListView.

private void setupListView(ListView listView) {
    TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
    ProgressLayout headerView = new ProgressLayout(this);
    refreshLayout.setHeaderView(headerView);
    View exHeader = View.inflate(this, R.layout.header_music, null);
    refreshLayout.addFixedExHeader(exHeader);
    refreshLayout.setOverScrollRefreshShow(false);
    //        refreshLayout.setFloatRefresh(true);
    adapter = new MusicAdapter();
    listView.setAdapter(adapter);
    adapter.refreshCard();
    listView.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 : Handler(android.os.Handler) ProgressLayout(com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) MusicAdapter(com.lcodecore.twinklingrefreshlayout.adapter.MusicAdapter) AdapterView(android.widget.AdapterView)

Aggregations

Handler (android.os.Handler)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 RefreshListenerAdapter (com.lcodecore.tkrefreshlayout.RefreshListenerAdapter)1 TwinklingRefreshLayout (com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout)1 ProgressLayout (com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout)1 MusicAdapter (com.lcodecore.twinklingrefreshlayout.adapter.MusicAdapter)1