Giter Site home page Giter Site logo

multisnaprecyclerview's Introduction

MultiSnapRecyclerView

Gradle

dependencies {
    implementation 'com.github.takusemba:multisnaprecyclerview:x.x.x'
}

Features

Build Status Download License API

This is an Android Library for multiple snapping of RecyclerView. MultiSnapRecyclerView easily provides a snapping feature to your recycler view. What this does are clean, neat, and powerful.

  • gravitated snapping to start end and center.
  • snap count to specify the number of items to scroll over.
  • supports horizontal and vertical scrolling.
  • listener to be called when snapped.
  • sample code.
  • support reverse layout.

Make sure to use LinearManger. Other managers are not supported.



Usage

There are two ways to use MultiSnapRecyclerView.

You can either use MultiSnapRecyclerView in your layout.

<com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:msrv_gravity="start" or center, end
        app:msrv_interval="2" items to scroll over
        app:msrv_ms_per_inch="100" /> // speed of scrolling through.

Or you can simply attach MultiSnapHelper to your normal RecyclerView.

val multiSnapHelper = MultiSnapHelper(gravity, interval, speedMsPerInch)
multiSnapHelper.attachToRecyclerView(recyclerView)

Sample

Clone this repo and check out the app module.

Author

Licence

Copyright 2017 Taku Semba.

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.

multisnaprecyclerview's People

Contributors

aditya94a avatar takusemba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multisnaprecyclerview's Issues

Alternatives to msrv_speed_ms_per_inch

Hello and thank you for your library, it helped me a lot! However, I found an issue in your implementation.
In fact there are two issues in one:

  1. ms/inch is not a speed, it's inversion of speed, so the word "speed" in the attribute name is very confusing;
  2. It would be better to have some alternative attribute to define constant snap time.

I'll explain the second issue as it is more important.
If you swipe your recyclerview on a small screen in portrait mode with (for example) msrv_speed_ms_per_inch=50, it will change the page pretty fast. But if you'll try it on a bigger device (on a tablet), it will scroll really slow, because it has a larger surface and it takes more time to reach target point.

Instead, it would be better to declare a constant time for snap helper, that will be equally fast on both devices.

java.lang.IllegalArgumentException: other than LinearLayoutManger is not supported

use MultiSnapRecyclerView in a RecyclerView item

                MultiSnapRecyclerView snapRecyclerView = null;
                SkipAppAdapter appAdapter = new SkipAppAdapter(snapRecyclerView, data.getFastInDataBean());
                snapRecyclerView = holder.getView(R.id.snapRecycleView);
                LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
                snapRecyclerView.setLayoutManager(layoutManager);
                snapRecyclerView.setAdapter(appAdapter);

                snapRecyclerView.setOnSnapListener(new OnSnapListener() {
                    @Override
                    public void snapped() {
                        // do something
                    }
                });

Backward scrolling sometimes snaps twice

I have a horizontal MultiSnapRV, my XML code:

<com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView
        android:id="@+id/rv_weeks"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:msrv_gravity="start"
        app:msrv_snap_count="7" />

When I scroll it forward, it works amazing and smooth. But if I scroll backward, sometimes it scrolls 14 positions, not 7. Is it bug or I missed something?

Hi, thank you for the request.

Hi, thank you for the request.

I'm just wondering if recyclerView.smoothScrollToPosition(position) does not work for your case?
It would be helpful if you could give me a situation you want to scroll with `SnapHelpe

Snap Programatically

hey!
is it possible to snap to a particular position of the list?

e.g. something like rvLevels.scroolToPostion(postion);

RecyclerView scrolling is too slow.

Hi TakuSemba,

After attaching your code the recycler scroll works too slow.
Either it's just scroll to msrv_snap_count or if we define higher value then it skips all the items.

mLayout is null

When running the app, it throws "java.lang.IllegalArgumentException: other than LinearLayoutManger is not supported" being that at onAttachedToWindow, mLayout is null therefore is not an instance of LinearLayoutManager.

So what's happening here?

Any idea how to handle screen orientation?

Gravity: Center
Snap Count: 1
Orientation: Vertical
Portrait: showing multiple items depends on the item height
Landscape: showing one item in fullscreen
I did recycler_view.scrollToPosition() in onConfigurationChanged.
Portrait -> Landscape is working fine
Landscape -> Portrait: the item is in top, instead of center, until you scroll again

snap last item with ItemDecoration

It was able to snap last item at v1.3.4, however after upgrading to v2.0.1 it will bounce back to the previous item rather than focus on the last item.

2019-12-26 09-00-47 的螢幕擷圖

Snap to the clicked item of RecyclerView

Hi,

One more enhancement, if we click on any item of the RecyclerView then snap the selected position.

I.e. we can snap via two modes, one by touching the item or by scrolling to it.

A warning appear.

A warning appears when i swipe from the recyclerview.
The test machine is the Nexus 5x android 7.0 version api 24.
Can I ignore it?

E/RecyclerView: Smooth Scroll action is being updated too frequently. Make sure you are not changing it unless necessary

Import library issue

sorry, I forgot to upload jar to jCenter.
for now, you have to use this library importing through my maven repository like this

// set marven url
repositories {
  maven { url 'https://dl.bintray.com/takusemba/maven' }
}

// compile library in dependencies
dependencies {
    compile 'com.github.takusemba:multisnaprecyclerview:x.x.x'
}

Im adding this to jCenter now. After few hours you can import this library just like this below

dependencies {
    compile 'com.github.takusemba:multisnaprecyclerview:x.x.x'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.