Search in sources :

Example 1 with ProgressLayout

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

the class WebActivity method onCreate.

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);
    TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refreshLayout);
    ProgressLayout header = new ProgressLayout(this);
    refreshLayout.setHeaderView(header);
    refreshLayout.setFloatRefresh(true);
    refreshLayout.setOverScrollRefreshShow(false);
    refreshLayout.setHeaderHeight(140);
    refreshLayout.setMaxHeadHeight(240);
    refreshLayout.setOverScrollHeight(200);
    refreshLayout.setEnableLoadmore(false);
    header.setColorSchemeResources(R.color.Blue, R.color.Orange, R.color.Yellow, R.color.Green);
    //        header.setColorSchemeColors(0xff4674e7,0xff0ba62c);
    mWebView = (WebView) findViewById(R.id.webView);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("https://dribbble.com/shots");
    refreshLayout.startRefresh();
    refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {

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

                @Override
                public void run() {
                    refreshLayout.finishRefreshing();
                }
            }, 4000);
        }
    });
}
Also used : TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) Handler(android.os.Handler) ProgressLayout(com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout) SuppressLint(android.annotation.SuppressLint)

Example 2 with ProgressLayout

use of com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout 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)

Example 3 with ProgressLayout

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

the class CoordinateActivity method setupRecyclerView.

private void setupRecyclerView(RecyclerView rv) {
    rv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    photoAdapter = new PhotoAdapter();
    rv.setAdapter(photoAdapter);
    final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
    ProgressLayout header = new ProgressLayout(this);
    refreshLayout.setHeaderView(header);
    refreshLayout.setFloatRefresh(true);
    refreshLayout.setEnableOverScroll(false);
    refreshLayout.setHeaderHeight(140);
    refreshLayout.setMaxHeadHeight(240);
    refreshLayout.setTargetView(rv);
    refreshCard();
    refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {

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

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

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

                @Override
                public void run() {
                    loadMoreCard();
                    refreshLayout.finishLoadmore();
                }
            }, 2000);
        }
    });
}
Also used : TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) PhotoAdapter(com.lcodecore.twinklingrefreshlayout.adapter.PhotoAdapter) Handler(android.os.Handler) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ProgressLayout(com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout)

Aggregations

Handler (android.os.Handler)3 RefreshListenerAdapter (com.lcodecore.tkrefreshlayout.RefreshListenerAdapter)3 TwinklingRefreshLayout (com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout)3 ProgressLayout (com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout)3 SuppressLint (android.annotation.SuppressLint)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 MusicAdapter (com.lcodecore.twinklingrefreshlayout.adapter.MusicAdapter)1 PhotoAdapter (com.lcodecore.twinklingrefreshlayout.adapter.PhotoAdapter)1