Search in sources :

Example 1 with SmoothRefreshLayout

use of me.dkzwm.widget.srl.SmoothRefreshLayout in project SmoothRefreshLayout by dkzwm.

the class TestHorizontalScaleEffectActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_horizontal_scale_effect);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_horizontal_scale_effect);
    SmoothRefreshLayout refreshLayout = findViewById(R.id.smoothRefreshLayout_test_horizontal_scale_effect);
    refreshLayout.setDisableLoadMore(false);
    refreshLayout.setDurationToClose(800);
    refreshLayout.setLayoutManager(new HScaleLayoutManager());
    Interpolator interpolator = new Interpolator() {

        @Override
        public float getInterpolation(float input) {
            return (float) (--input * input * ((1.7 + 1f) * input + 1.7) + 1f);
        }
    };
    refreshLayout.setSpringBackInterpolator(interpolator);
}
Also used : HScaleLayoutManager(me.dkzwm.widget.srl.manager.HScaleLayoutManager) Interpolator(android.view.animation.Interpolator) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 2 with SmoothRefreshLayout

use of me.dkzwm.widget.srl.SmoothRefreshLayout in project SmoothRefreshLayout by dkzwm.

the class TestScaleEffectActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_scale_effect);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_scale_effect);
    ListView listView = findViewById(R.id.listView_test_scale_effect);
    ListViewAdapter adapter = new ListViewAdapter(this, getLayoutInflater());
    List<String> list = DataUtil.createList(0, 40);
    adapter.updateData(list);
    listView.setAdapter(adapter);
    SmoothRefreshLayout refreshLayout = findViewById(R.id.smoothRefreshLayout_test_scale_effect);
    refreshLayout.setDisableLoadMore(false);
    refreshLayout.setLayoutManager(new VScaleLayoutManager());
    refreshLayout.setDurationToClose(550);
    Interpolator interpolator = new Interpolator() {

        @Override
        public float getInterpolation(float input) {
            return (float) (--input * input * ((1.7 + 1f) * input + 1.7) + 1f);
        }
    };
    refreshLayout.setSpringBackInterpolator(interpolator);
}
Also used : ListView(android.widget.ListView) ListViewAdapter(me.dkzwm.widget.srl.sample.adapter.ListViewAdapter) VScaleLayoutManager(me.dkzwm.widget.srl.manager.VScaleLayoutManager) Interpolator(android.view.animation.Interpolator) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 3 with SmoothRefreshLayout

use of me.dkzwm.widget.srl.SmoothRefreshLayout in project SmoothRefreshLayout by dkzwm.

the class DemoApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    SmoothRefreshLayout.setDefaultCreator(new IRefreshViewCreator() {

        @Override
        public IRefreshView<IIndicator> createHeader(SmoothRefreshLayout layout) {
            ClassicHeader<IIndicator> header = new ClassicHeader<>(layout.getContext());
            header.setLastUpdateTimeKey("header_last_update_time");
            return header;
        }

        @Override
        public IRefreshView<IIndicator> createFooter(SmoothRefreshLayout layout) {
            ClassicFooter<IIndicator> footer = new ClassicFooter<>(layout.getContext());
            footer.setLastUpdateTimeKey("footer_last_update_time");
            return footer;
        }
    });
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) IRefreshViewCreator(me.dkzwm.widget.srl.IRefreshViewCreator) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) ClassicFooter(me.dkzwm.widget.srl.extra.footer.ClassicFooter) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 4 with SmoothRefreshLayout

use of me.dkzwm.widget.srl.SmoothRefreshLayout in project SmoothRefreshLayout by dkzwm.

the class TestInMotionLayoutSceneActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_inner_motionscene_start);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_inner_motionlayout_scene);
    RecyclerView recyclerView = findViewById(R.id.recyclerView_test_motionLayout_scene);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    RecyclerViewAdapter adapter = new RecyclerViewAdapter(this, getLayoutInflater());
    recyclerView.setAdapter(adapter);
    adapter.updateData(DataUtil.createList(0, 100));
    mMotionLayout = findViewById(R.id.motionLayout_test_motionLayout_scene);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_motionLayout_scene);
    mRefreshLayout.setOnHeaderEdgeDetectCallBack(new SmoothRefreshLayout.OnHeaderEdgeDetectCallBack() {

        @Override
        public boolean isNotYetInEdgeCannotMoveHeader(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
            return mMotionLayout.getProgress() != 0f || (child != null && child.canScrollVertically(-1));
        }
    });
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                }
            }, 1000);
        }
    });
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 5 with SmoothRefreshLayout

use of me.dkzwm.widget.srl.SmoothRefreshLayout in project SmoothRefreshLayout by dkzwm.

the class TestMotionLayoutSceneActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_motionscene_start);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_motionlayout_scene);
    RecyclerView recyclerView = findViewById(R.id.recyclerView_test_motionLayout_scene);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    RecyclerViewAdapter adapter = new RecyclerViewAdapter(this, getLayoutInflater());
    recyclerView.setAdapter(adapter);
    adapter.updateData(DataUtil.createList(0, 100));
    mMotionLayout = findViewById(R.id.motionLayout_test_motionLayout_scene);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_motionLayout_scene);
    mRefreshLayout.setOnHeaderEdgeDetectCallBack(new SmoothRefreshLayout.OnHeaderEdgeDetectCallBack() {

        @Override
        public boolean isNotYetInEdgeCannotMoveHeader(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
            return mMotionLayout.getProgress() != 0f || (child != null && child.canScrollVertically(-1));
        }
    });
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                }
            }, 1000);
        }
    });
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Aggregations

SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)6 IRefreshView (me.dkzwm.widget.srl.extra.IRefreshView)3 View (android.view.View)2 Interpolator (android.view.animation.Interpolator)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)2 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)2 ListView (android.widget.ListView)1 IRefreshViewCreator (me.dkzwm.widget.srl.IRefreshViewCreator)1 ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 HScaleLayoutManager (me.dkzwm.widget.srl.manager.HScaleLayoutManager)1 VScaleLayoutManager (me.dkzwm.widget.srl.manager.VScaleLayoutManager)1 ListViewAdapter (me.dkzwm.widget.srl.sample.adapter.ListViewAdapter)1