Deprecated

Overview

Deprecated

Android Arsenal

RecyclerViewPager

A ViewPager implemention base on RecyclerView. Support fling operation like gallary.

android.support.v4.view.ViewPager的完美替代品

Features:

  1. Base on RecyclerView.
  2. Custom fling factor.
  3. Custom paging trigger.
  4. Support Vertical and Horizontal orientation.
  5. Support FragmentViewPager (api 12+)
  6. Infinite-Loop-ViewPager
  7. Support TabLayout

特性:

  1. 扩展自RecyclerView.
  2. 可自定义fling滑动速率.
  3. 可自定义翻页触发条件.
  4. 支持垂直ViewPager.
  5. 支持Fragment (api 12+)
  6. 支持无限循环
  7. 支持和TabLayout配合使用

RecyclerViewPager RecyclerViewPager RecyclerViewPager

Usage

how to import?

add this into gradle

// Yes, I have switched to jitpack.io.

repositories {
    ...
    maven { url "https://jitpack.io" }
    ...
}

dependencies {
    ...
    compile 'com.github.lsjwzh.RecyclerViewPager:lib:v1.2.0@aar'
    ...
}

add proguard rules if need

-keep class com.lsjwzh.widget.recyclerviewpager.**
-dontwarn com.lsjwzh.widget.recyclerviewpager.**

Basic Usage:

It is easy to setup like a Recycler List View.

xml:

<com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="15dp"
    android:paddingRight="15dp"
    app:rvp_triggerOffset="0.1"
    app:rvp_singlePageFling="true"
    android:clipToPadding="false"/>

code:

RecyclerViewPager mRecyclerView = (RecyclerViewPager) view.findViewById(R.id.list);

// setLayoutManager like normal RecyclerView, you do not need to change any thing.
LinearLayoutManager layout = new LinearLayoutManager(getActivity(),LinearLayoutManager.HORIZONTAL,false);
mRecyclerView.setLayoutManager(layout);

//set adapter
//You just need to implement ViewPageAdapter by yourself like a normal RecyclerView.Adpater.
mRecyclerView.setAdapter(new RecyclerView.Adpater<X>());

// That is all.

Support TabLayout:

1.Add Dependency:

dependencies {
    ...
    compile 'com.github.lsjwzh.RecyclerViewPager:tablayoutsupport:v1.1.2@aar'
    ...
}

2.Call 'setupWithViewPager'

TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
TabLayoutSupport.setupWithViewPager(tabLayout, mRecyclerView, mAdapter);

Infinite Loop ViewPager:

<com.lsjwzh.widget.recyclerviewpager.LoopRecyclerViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="20dp"
        android:clipToPadding="false"
        android:paddingTop="15dp"
        android:paddingBottom="15dp"/>

You just need to use LoopRecyclerViewPager replace RecyclerViewPager. The usage of LoopRecyclerViewPager is the same as RecyclerViewPager. No matter what you specify position you want to scroll, LoopRecyclerViewPager will transform it to right position. Ex:In a LoopRecyclerViewPager with 10 items, scrollToPosition(1) will get same scroll behavior as scrollToPosition(11)scrollToPosition(21) and so on.

How to get actual position in LoopRecyclerViewPager:

    int actualPosition = mLoopRecyclerViewPager.transformToActualPosition(adapterPosition);

If you just want to get current actual position, you can do it like this:

    int actualCurrentPosition = mLoopRecyclerViewPager.getActualCurrentPosition();

Release Notes:

1.2.0 update support lib to 26.0.2
1.1.2 merge some fix.
1.1.1 merge some fix.
1.1.0stable fix bug:LoopViewPager position confusion;LoopViewPager non stop spinning;
1.1.0beta5 feat: TabLayoutSupport Lib supports LoopViewPager
1.1.0beta4 fix bug:support ItemDecorations;
1.1.0beta3 support reverse;
1.1.0 refactor;support TabLayout;
1.0.11 support infinite loop
1.0.10 make touch gesture smother;
1.0.8 override swapAdapter;support singlePageFling;
1.0.7 remove redandunt codes; support cancel action
1.0.6 resolve potential id conflicting on FragmentViewPagerApdater
1.0.4 fix bug : exception happens if  ItemView LayoutParam is not MarginLayoutParam
1.0.3 add method: getCurrentPosition
1.0.2 support FragmentViewPager, add OnPageChangedListener
1.0.1 fix bug: smoothScrollToPosition index out of range
1.0.0 reimplement RecyclerViewPager without coping RecyclerView's codes.

0.5.4 add 'HorizontalCenterLayoutManager' to implement ViewPager
0.5.3 fix bug: setHasStableIds not work
0.1.0

Special Thanks:

saadfarooq taxomania

ToDo:

Vertical ViewPager FragmentViewPager observe OnPageChanged Infinite-Loop-ViewPager ~~Support TabLayout ~~ Support ViewPagerIndicator Wrap Content? dispatchTouchEvent override demo

License

Copyright 2015 lsjwzh

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • 1.0.8 aar in maven repository have problem

    1.0.8 aar in maven repository have problem

    I wrote a project using your lib, when package release variant, proguard fail, and print the following errors:

    Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'int access$102(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager,int)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'float access$202(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager,float)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'float access$300(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'int access$400(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager,int,int)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'int access$500(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'int access$100(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'java.util.List access$600(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager Warning: com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager$ScrollListener: can't find referenced method 'android.support.v7.widget.RecyclerView$OnScrollListener access$700(com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager)' in program class com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager

    I thought maybe you forgot to clean project before assembling the aar file.

    Hope this bug could be fixed!

    opened by lyrixliu 13
  • 小BUG,偶尔滑动不会调用addOnPageChangedListener

    小BUG,偶尔滑动不会调用addOnPageChangedListener

    //                    添加  页面滑动监听,                   
     mLoopPagerView.addOnPageChangedListener(new RecyclerViewPager.OnPageChangedListener() {
              @Override                       
         public void OnPageChanged(int i, int i1) {                           
             LogUtil.e(i + "i==" + i1);                     
    
    opened by sunwenming 12
  • How to use when migrate to AndroidX?

    How to use when migrate to AndroidX?

    My profile show error: java.lang.IllegalAccessError: Field 'androidx.recyclerview.widget.RecyclerView$ViewHolder.mPosition' is inaccessible to class 'androidx.appcompat.widget.ViewHolderDelegate' (declaration of 'androidx.appcompat.widget.ViewHolderDelegate'

    opened by mrminhhuy 9
  • issue loop

    issue loop

    Hi I used RVPager in fragmentviewpager. when I enable the loop, I can only flip to left because flip to right changes the tap to next tab. Can you help me to fix it? Thanks and Best Regards

    question 
    opened by myscreen 9
  • not compatible with Smart-Adapter library ?

    not compatible with Smart-Adapter library ?

    https://github.com/mrmans0n/smart-adapters

    Item

    public class Item {
        public String number;
    
        public Item(String number) {
            this.number = number;
        }
    }
    

    ItemView

    public class ItemView extends BindableLayout<Item> {
        @InjectView(R.id.text) public TextView text;
    
        public ItemView(Context context) {
            super(context);
        }
    
        @Override
        public int getLayoutId() {
            return R.layout.item_layout;
        }
    
        @Override
        public void onViewInflated() {
            ButterKnife.inject(this);
        }
    
        @Override
        public void bind(Item item) {
            this.text.setText(item.number);
        }
    }
    
    RecyclerMultiAdapter adapter = SmartAdapter.empty().map(Item.class, ItemView.class).into(this.mRecyclerView);
            for(int i = 0; i < 30; i++) {
                adapter.addItem(new Item("" + i));
            }
    
            LinearLayoutManager layout = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
            mRecyclerView.setLayoutManager(layout);
            mRecyclerView.setHasFixedSize(true);
            mRecyclerView.setAdapter(adapter);
    

    Error Exception on launch :

    Caused by: java.lang.IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers.
                at android.support.v7.widget.RecyclerView$Adapter.setHasStableIds(RecyclerView.java:5114)
                at com.lsjwzh.widget.recyclerviewpager.RecyclerViewPagerAdapter.setHasStableIds(RecyclerViewPagerAdapter.java:57)
                at com.lsjwzh.widget.recyclerviewpager.RecyclerViewPagerAdapter.<init>(RecyclerViewPagerAdapter.java:22)
                at com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager.setAdapter(RecyclerViewPager.java:108)
                at ir.fadesign.myapplication.MainActivity.onCreate(MainActivity.java:40)
    
    opened by DJafari 8
  • onPageChanged alternative.

    onPageChanged alternative.

    I'm sorry if this is a dumb question...

    I'm attempting to switch over from a VieePager to this library.

    However I can't seem to figure out if there is a way to mimic the onPageSelected(int position) method in any of the RecyclerView listeners.

    Would you have any advice as to how to get this function with your library.

    Thank you.

    opened by JonathanMerritt 8
  • No other view can be put before recyclerviewpager?

    No other view can be put before recyclerviewpager?

    i have tried to use com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager and some other elements, but no luck, error occured. I found that if there is any viewgroup set before the RecyclerViewPager, it will crash.

        <ImageView
            android:id="@+id/test"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:contentDescription="@null" />
    </LinearLayout>
    
    <com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager
        android:id="@+id/sliding_viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@android:color/transparent" />
    

    the above xml layout will give error ClassCastException: android.widget.ImageView cannot be cast to android.view.ViewGroup

    opened by rush0621 7
  • Non stop spinning when using LoopRecyclerViewPager

    Non stop spinning when using LoopRecyclerViewPager

    Hi, sometimes when i swipe it starts spinning endlessly. Looks like sometimes it fails to snap scrolled item. When i tap on it, it stops spinning. It's hard to reproduce it, but it happens from time to time. Any one else experienced that?

    opened by arvydaszenitech 4
  • Going to Infinite Scroll.

    Going to Infinite Scroll.

    mRecyclerViewPager.smoothScrollToPosition(position);

    When I am going to apply this code in onCreate then it will be Infinite scroll happens. suggest me the solution ASAP. @lsjwzh

    opened by dalwadi2 4
  • fix bug:unable to collapse toolbar when we scroll recyclerview vertic…

    fix bug:unable to collapse toolbar when we scroll recyclerview vertic…

    fix bug:unable to collapse toolbar when we scroll recyclerview vertically by touching down on RecyclerViewPager widget which is nested in CoordinatorLayout and RecyclerView.

    opened by thinwonton 4
  • onViewAttachedToWindow() not called

    onViewAttachedToWindow() not called

    Hi,

    I am trying to update the ViewHolder just as the View appears on the Window from the Adapter. However, I am unable to do so, as the onViewAttachedToWindow() callback is not triggered as views are recycled and displayed in the pager.

    Please state the best way to achieve this. Using onBindViewHolder() callback, the layout can be changed when not visible on screen. Essentially I have a View Animator holding several ImageViews for a slideshow. My dilemma is: I only wish to add Images to the layout when the view is becoming visible in the RecyclerViewPager.

    Moreover, is there a way to limit the number of Views created in the pager? I'm looking for a method similar to the standard ViewPager's setOffscreenPageLimit(int pages)

    Thanks, Arjun

    enhancement 
    opened by arjs1000 4
  • Api 26.1.0 compatibility

    Api 26.1.0 compatibility

    • Starting with API 26.1.0, TabLayout$setOnTabSelectedListener() is deprecated in favor of addOnTabSelectedListener. This leads to the TabLayoutSupport to crash the app when using said API level. This fix removes the deprecated method in favor of the new one.
    • Updated the build tools version and compile sdk version to API level 28 as well as the gradle plugin versions for compatibility with Android Studio 3.3.
    • Updated dependency versions
    opened by leondzn 0
  • RecyclerViewPager line 289

    RecyclerViewPager line 289

                if (Build.VERSION.SDK_INT < 16) {
                    getViewTreeObserver().removeGlobalOnLayoutListener(this);
                } else {
                    getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }
    
    opened by 1280103995 0
Releases(v1.2.0)
Owner
lsjwzh
lsjwzh
Deprecated in favour of https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html

Deprecated: use https://developer.android.com/reference/android/support/v4/view/animation/PathInterpolatorCompat.html instead. android-cubic-bezier-in

Codesoup 161 Jan 1, 2023
HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.

Version 5.2.0 HockeySDK-Android implements support for using HockeyApp in your Android applications. The following features are currently supported: C

Bit Stadium GmbH 280 Dec 13, 2022
[Deprecated] Little bites of Material Design

Working with shared elements Commit - 8872619 Working with shared elements, explode transition, and animations Commit - 901d62c Playing with the new m

Saul Molinero 2.8k Dec 25, 2022
Samples in Material Animation (Deprecated)

Material-Animation-Samples (Deprecated) or watch it on youtube #Samples: Samples in material animation will be added through the next two monthes. Lay

Ahmed Tarek 228 Dec 7, 2021
Replacement for deprecated official Android crop image function

The MIT License (MIT) Copyright (c) 2012 Jan Muller Permission is hereby granted, free of charge, to any person obtaining a copy of this software and

Jan Muller 561 Nov 25, 2022
(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.

BottomBar (Deprecated) I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious

Iiro Krankka 8.4k Dec 29, 2022
[Deprecated] Android Library that implements Snackbars (former known as Undobar) from Google's Material Design documentation.

UndoBar This lib is deprecated in favor of Google's Design Support Library which includes a Snackbar and is no longer being developed. Thanks for all

Kai Liao 577 Nov 25, 2022
[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.

#[Deprecated] Google has finally released a proper solution for unit testing. Therefore this plugin will no longer be activlty maintained. android-stu

Evan Tatarka 236 Dec 30, 2022
[Deprecated] AKA VectorDrawableCompat: A 7+ backport of VectorDrawable

###@Deprecated Unfortunatenly this library is no longer maintained, we encourage you to use first party VectorDrawableCompat coming soon to support li

Telly 658 Oct 9, 2022
[Deprecated] Sexy way to execute async/background tasks on Android

Groundy library for Android @Deprecated Unfortunatenly this library is no longer maintained, we encourage you to use other widely supported solutions

Telly 228 Nov 14, 2022
Deprecated

Deprecated RecyclerViewPager A ViewPager implemention base on RecyclerView. Support fling operation like gallary. android.support.v4.view.ViewPager的完美

lsjwzh 3.5k Jan 7, 2023
SwitchButton 是 Android 上的一个开关按钮控件 【Deprecated】【Stop maintenance】

SwitchButton 【Deprecated】【Stop maintenance】停止维护了,推荐使用:https://github.com/zcweng/SwitchButton SwitchButton 是 Android 上的一个开关按钮控件 示例 APP 扫描二维码或点我下载 特性 支持

Nameless 334 Nov 15, 2022
Samples in Material Animation (Deprecated)

Material-Animation-Samples (Deprecated) or watch it on youtube #Samples: Samples in material animation will be added through the next two monthes. Lay

Ahmed Tarek 228 Dec 7, 2021