Search in sources :

Example 1 with RecyclerViewAdapter

use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.

the class TestQQActivityStyleActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_qq_activity_style);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_qq_activity_style);
    mRecyclerView = findViewById(R.id.recyclerView_test_qq_activity_style);
    mRadioGroup = findViewById(R.id.radioGroup_test_qq_activity_style_container);
    mRadioButtonNormal = findViewById(R.id.radioButton_test_qq_activity_style_normal);
    mRadioButtonActivity = findViewById(R.id.radioButton_test_qq_activity_style_activity);
    mRadioGroup.setOnCheckedChangeListener(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_qq_activity_style);
    mClassicHeader = new ClassicHeader(this);
    mClassicHeader.setLastUpdateTimeKey("header_last_update_time");
    mClassicFooter = new ClassicFooter(this);
    mClassicFooter.setLastUpdateTimeKey("footer_last_update_time");
    mRefreshLayout.setHeaderView(mClassicHeader);
    mRefreshLayout.setFooterView(mClassicFooter);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(final boolean isRefresh) {
            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();
                }
            }, 2000);
        }
    });
    mRefreshLayout.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {

        @Override
        public void onChanged(byte status, IIndicator indicator) {
            if (mRefreshLayout.isInStartPosition()) {
                mRadioGroup.setEnabled(true);
                mRadioButtonNormal.setEnabled(true);
                mRadioButtonActivity.setEnabled(true);
            } else {
                mRadioGroup.setEnabled(false);
                mRadioButtonNormal.setEnabled(false);
                mRadioButtonActivity.setEnabled(false);
            }
        }
    });
    mRefreshLayout.autoRefresh(false);
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) ClassicFooter(me.dkzwm.widget.srl.extra.footer.ClassicFooter) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) IIndicator(me.dkzwm.widget.srl.indicator.IIndicator)

Example 2 with RecyclerViewAdapter

use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.

the class TestNestedActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_nested);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mRecyclerView = findViewById(R.id.recyclerView_test_nested);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_nested);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshBegin(final boolean isRefresh) {
            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();
                }
            }, isRefresh ? 2000 : 10000);
        }

        @Override
        public void onRefreshComplete(boolean isSuccessful) {
        }
    });
    mRefreshLayout.getDefaultHeader().setPadding(0, PixelUtl.dp2px(this, 80), 0, PixelUtl.dp2px(this, 10));
    mRefreshLayout.setLoadMoreScrollTargetView(mRecyclerView);
    mRefreshLayout.setLifecycleObserver(new QuickConfigAppBarUtil());
    mRefreshLayout.autoRefresh(false);
}
Also used : QuickConfigAppBarUtil(me.dkzwm.widget.srl.utils.QuickConfigAppBarUtil) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) MaterialSmoothRefreshLayout(me.dkzwm.widget.srl.MaterialSmoothRefreshLayout) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with RecyclerViewAdapter

use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.

the class WithRecyclerViewInCoordinatorLayoutActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_recyclerview_in_coordinatorlayout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mRecyclerView = findViewById(R.id.recyclerView_with_recyclerView_in_coordinatorLayout);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_recyclerView_in_coordinatorLayout);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshBegin(final boolean isRefresh) {
            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();
                }
            }, 2000);
        }

        @Override
        public void onRefreshComplete(boolean isSuccessful) {
        }
    });
    mRefreshLayout.autoRefresh(false);
}
Also used : RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 4 with RecyclerViewAdapter

use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.

the class TestScrollToAutoRefreshActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_scroll_to_auto_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_scroll_to_auto_refresh);
    RecyclerView recyclerView = findViewById(R.id.recyclerView_test_scroll_to_auto_refresh);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    recyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_scroll_to_auto_refresh);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(final boolean isRefresh) {
            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();
                }
            }, 2000);
        }
    });
    mRefreshLayout.setEnableSmoothRollbackWhenCompleted(true);
    mRefreshLayout.autoRefresh(false);
    mAutoRefreshUtil = new QuickConfigAutoRefreshUtil(recyclerView);
    mRefreshLayout.setLifecycleObserver(mAutoRefreshUtil);
    findViewById(R.id.button_test_scroll_to_auto_refresh_left).setOnClickListener(this);
    findViewById(R.id.button_test_scroll_to_auto_refresh_right).setOnClickListener(this);
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) QuickConfigAutoRefreshUtil(me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 5 with RecyclerViewAdapter

use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.

the class WithRecyclerViewActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_recyclerview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.with_recyclerView);
    mRecyclerView = findViewById(R.id.recyclerView_with_recyclerView);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_recyclerView);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setEnableAutoLoadMore(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

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

                @Override
                public void run() {
                    if (isRefresh) {
                        mCount = 0;
                        List<String> list = DataUtil.createList(mCount, 15);
                        mCount += 15;
                        mAdapter.updateData(list);
                    } else {
                        List<String> list = DataUtil.createList(mCount, 15);
                        mCount += 15;
                        mAdapter.appendData(list);
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mRefreshLayout.setEnableSmoothRollbackWhenCompleted(true);
    mRefreshLayout.autoRefresh(false);
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)

Aggregations

RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 RecyclerView (android.support.v7.widget.RecyclerView)4 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)4 View (android.view.View)3 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)3 Toolbar (android.support.v7.widget.Toolbar)2 Nullable (android.support.annotation.Nullable)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 MaterialSmoothRefreshLayout (me.dkzwm.widget.srl.MaterialSmoothRefreshLayout)1 ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)1 QuickConfigAppBarUtil (me.dkzwm.widget.srl.utils.QuickConfigAppBarUtil)1 QuickConfigAutoRefreshUtil (me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil)1