Search in sources :

Example 1 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader in project SmoothRefreshLayout by dkzwm.

the class TestHorizontalRecyclerViewActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_horizontal_recyclerview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_horizontal_recyclerView);
    mRecyclerView = findViewById(R.id.recyclerView_with_horizontal_recyclerView);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3, LinearLayoutManager.HORIZONTAL, false));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new HorizontalRecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_horizontal_recyclerView);
    MaterialHeader header = new MaterialHeader(this);
    header.setColorSchemeColors(new int[] { Color.RED, Color.BLUE, Color.GREEN, Color.BLACK });
    header.setPadding(PixelUtl.dp2px(this, 25), 0, PixelUtl.dp2px(this, 25), 0);
    mRefreshLayout.setHeaderView(header);
    MaterialFooter footer = new MaterialFooter(this);
    footer.setProgressBarColors(new int[] { Color.RED, Color.BLUE, Color.GREEN, Color.BLACK });
    mRefreshLayout.setFooterView(footer);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setEnableAutoLoadMore(true);
    mRefreshLayout.setEnablePinContentView(true);
    mRefreshLayout.setEnablePinRefreshViewWhileLoading(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(final boolean isRefresh) {
            if (!isRefresh) {
                Toast.makeText(TestHorizontalRecyclerViewActivity.this, R.string.has_been_triggered_to_load_more, Toast.LENGTH_SHORT).show();
            }
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (isRefresh) {
                        mCount = 0;
                        List<String> list = DataUtil.createList(mCount, 20);
                        mCount += 20;
                        mAdapter.updateData(list);
                    } else {
                        List<String> list = DataUtil.createList(mCount, 20);
                        mCount += 20;
                        mAdapter.appendData(list);
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 3000);
        }

        @Override
        public void onRefreshComplete(boolean isSuccessful) {
            Toast.makeText(TestHorizontalRecyclerViewActivity.this, R.string.sr_refresh_complete, Toast.LENGTH_SHORT).show();
        }
    });
    mRefreshLayout.setDurationToClose(800);
    mRefreshLayout.autoRefresh(false);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) MaterialFooter(me.dkzwm.widget.srl.extra.footer.MaterialFooter) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) HorizontalRecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.HorizontalRecyclerViewAdapter)

Example 2 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader in project SmoothRefreshLayout by dkzwm.

the class TestHorizontalRefreshActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_horizontal_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_horizontal_refresh);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_horizontal_refresh);
    MaterialHeader header = new MaterialHeader(this);
    header.setColorSchemeColors(new int[] { Color.RED, Color.BLUE, Color.GREEN, Color.BLACK });
    header.setPadding(PixelUtl.dp2px(this, 25), 0, PixelUtl.dp2px(this, 25), 0);
    mRefreshLayout.setHeaderView(header);
    MaterialFooter footer = new MaterialFooter(this);
    footer.setProgressBarColors(new int[] { Color.RED, Color.BLUE, Color.GREEN, Color.BLACK });
    mRefreshLayout.setFooterView(footer);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setDisablePerformLoadMore(false);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                    Toast.makeText(TestHorizontalRefreshActivity.this, R.string.sr_refresh_complete, Toast.LENGTH_SHORT).show();
                }
            }, 4000);
        }
    });
    mRefreshLayout.setRatioToKeep(1);
    mRefreshLayout.setRatioToRefresh(1);
    mRefreshLayout.autoRefresh(false);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) MaterialFooter(me.dkzwm.widget.srl.extra.footer.MaterialFooter) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter)

Example 3 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader in project SmoothRefreshLayout by dkzwm.

the class WithWebViewActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_webview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.with_webView);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_webView);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setEnablePinContentView(true);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setEnablePinRefreshViewWhileLoading(true);
    mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mWebView.loadUrl("https://github.com/dkzwm");
        }

        @Override
        public void onRefreshComplete(boolean isSuccessful) {
        }
    });
    mWebView = findViewById(R.id.webView_with_webView);
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            mRefreshLayout.refreshComplete();
        }
    });
    mRefreshLayout.autoRefresh(false);
    mAutoRefreshUtil = new QuickConfigAutoRefreshUtil(mWebView);
    mRefreshLayout.setLifecycleObserver(mAutoRefreshUtil);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) QuickConfigAutoRefreshUtil(me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil) WebView(android.webkit.WebView) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) WebViewClient(android.webkit.WebViewClient)

Example 4 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader in project SmoothRefreshLayout by dkzwm.

the class TestNextRefreshAtOnceActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.enable_next_pull_to_refresh_at_once);
    mTextView = findViewById(R.id.textView_test_refresh_desc);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setDisableLoadMore(true);
    mRefreshLayout.setEnableNextPtrAtOnce(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mCount++;
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                    String times = getString(R.string.number_of_refresh) + mCount;
                    mTextView.setText(times);
                }
            }, 2000);
        }
    });
    mRefreshLayout.autoRefresh(true);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter)

Example 5 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader in project SmoothRefreshLayout by dkzwm.

the class TestPullToRefreshActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.pull_to_refresh);
    mTextView = findViewById(R.id.textView_test_refresh_desc);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setEnablePullToRefresh(true);
    mRefreshLayout.setDisableLoadMore(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mCount++;
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                    String times = getString(R.string.number_of_refresh) + mCount;
                    mTextView.setText(times);
                }
            }, 2000);
        }
    });
    mRefreshLayout.autoRefresh(false);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter)

Aggregations

MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)6 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)4 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)2 MaterialFooter (me.dkzwm.widget.srl.extra.footer.MaterialFooter)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)1 ArrayList (java.util.ArrayList)1 HorizontalRecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.HorizontalRecyclerViewAdapter)1 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)1 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)1 QuickConfigAutoRefreshUtil (me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil)1