kandi background
Explore Kits

GravitySnapHelper | A SnapHelper that snaps a RecyclerView to an edge. | RecyclerView library

 by   rubensousa Java Version: 2.2.1 License: Apache-2.0

 by   rubensousa Java Version: 2.2.1 License: Apache-2.0

Download this library from

kandi X-RAY | GravitySnapHelper Summary

GravitySnapHelper is a Java library typically used in User Interface, RecyclerView applications. GravitySnapHelper has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
A SnapHelper that snaps a RecyclerView to an edge.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • GravitySnapHelper has a medium active ecosystem.
  • It has 4727 star(s) with 606 fork(s). There are 97 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 5 open issues and 57 have been closed. On average issues are closed in 118 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of GravitySnapHelper is 2.2.1
GravitySnapHelper Support
Best in #RecyclerView
Average in #RecyclerView
GravitySnapHelper Support
Best in #RecyclerView
Average in #RecyclerView

quality kandi Quality

  • GravitySnapHelper has 0 bugs and 0 code smells.
GravitySnapHelper Quality
Best in #RecyclerView
Average in #RecyclerView
GravitySnapHelper Quality
Best in #RecyclerView
Average in #RecyclerView

securitySecurity

  • GravitySnapHelper has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • GravitySnapHelper code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
GravitySnapHelper Security
Best in #RecyclerView
Average in #RecyclerView
GravitySnapHelper Security
Best in #RecyclerView
Average in #RecyclerView

license License

  • GravitySnapHelper is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
GravitySnapHelper License
Best in #RecyclerView
Average in #RecyclerView
GravitySnapHelper License
Best in #RecyclerView
Average in #RecyclerView

buildReuse

  • GravitySnapHelper releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • GravitySnapHelper saves you 661 person hours of effort in developing the same functionality from scratch.
  • It has 1532 lines of code, 81 functions and 32 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
GravitySnapHelper Reuse
Best in #RecyclerView
Average in #RecyclerView
GravitySnapHelper Reuse
Best in #RecyclerView
Average in #RecyclerView
Top functions reviewed by kandi - BETA

kandi has reviewed GravitySnapHelper and discovered the below as its top functions. This is intended to give you an instant insight into GravitySnapHelper implemented functionality, and help decide if they suit your requirements.

  • Find the view which corresponds to a layout manager .
  • Intercept the touch event .
  • Creates and returns a LinearScroller with the given layout manager .
  • Calculates the shortest distance to the end of a RecyclerView .
  • Scrolls to a specific position
  • Snap to the next view .
  • Enables or disables the snapping view .
  • Returns the snap helper .
  • Snap this sprite to the previous position .

GravitySnapHelper Key Features

setMaxFlingDistance or setMaxFlingSizeFraction - changes the max fling distance allowed.

setScrollMsPerInch - changes the scroll speed.

setGravity - changes the gravity of the SnapHelper.

setSnapToPadding - enables snapping to padding (default is false)

smoothScrollToPosition and scrollToPosition

RTL support out of the box

Setup

copy iconCopydownload iconDownload
implementation 'com.github.rubensousa:gravitysnaphelper:2.2.1'

How to use

copy iconCopydownload iconDownload
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)

Start snapping

copy iconCopydownload iconDownload
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)

Center snapping

copy iconCopydownload iconDownload
val snapHelper = GravitySnapHelper(Gravity.CENTER)
snapHelper.attachToRecyclerView(recyclerView)

License

copy iconCopydownload iconDownload
Copyright 2018 The Android Open Source Project
Copyright 2019 Rúben Sousa

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.

How to show a subСollection when navigating to a specific document in Firestore

copy iconCopydownload iconDownload
private final FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("TurnKeyFactory")
    .collection("TheKeyOpens");
private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("Factory exit key(Factory)")
    .collection("TheKeyOpens");
-----------------------
private final FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("TurnKeyFactory")
    .collection("TheKeyOpens");
private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("Factory exit key(Factory)")
    .collection("TheKeyOpens");

RecyclerView PagerSnapHelper Snap on Start/Top instead of center Android

copy iconCopydownload iconDownload
 // remember to initialize snaphelper
 snapHelper = object : GravitySnapHelper(Gravity.TOP){
        override fun findTargetSnapPosition(
            layoutManager: RecyclerView.LayoutManager,
            velocityX: Int,
            velocityY: Int
        ): Int {
            val centerView = findSnapView(layoutManager) ?: return RecyclerView.NO_POSITION
            val position = layoutManager.getPosition(centerView)
            var targetPosition = -1
            if (layoutManager.canScrollHorizontally()) {
                targetPosition = if (velocityX < 0) {
                    position - 1
                } else {
                    position + 1
                }
            }
            if (layoutManager.canScrollVertically()) {

               // Log.d("debug", "velocityY $velocityY")
                targetPosition = if (velocityY < 0) {
                    position - 1
                } else {
                    position + 1
                }
            }
            val firstItem = 0
            val lastItem = layoutManager.itemCount - 1
            targetPosition = Math.min(lastItem, Math.max(targetPosition, firstItem))
            return targetPosition
        }



    }

    // lower the value higher the speed of scroll 
    // default is 100f
    snapHelper.scrollMsPerInch = 40f

    snapHelper.attachToRecyclerView(binding?.yourRecyclerView)

Community Discussions

Trending Discussions on GravitySnapHelper
  • How to show a subСollection when navigating to a specific document in Firestore
  • RecyclerView PagerSnapHelper Snap on Start/Top instead of center Android
  • Is there any way to reset persistence data in firebase database
Trending Discussions on GravitySnapHelper

QUESTION

How to show a subСollection when navigating to a specific document in Firestore

Asked 2021-Apr-20 at 05:54

I have a collection on Firestore inside it there are documents, they are displayed in the RecyclerView in my application, how can I make it so that when this document is clicked, its subcollection opens?

When you click on a document, the following happens:

    private FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
    private final CollectionReference collectionReference = firebaseFirestore.collection("Items");

    AdapterFactoryKeysSnap adapterFactoryKeysSnap;
    RecyclerView rv_keys_factory;
    RecyclerView.LayoutManager RLM_keys_factory;
    ProgressBar pb_keys_factory;

    private void RecyclerViewFactory() {
        Query query = collectionReference.orderBy("TurnKeyFactory", Query.Direction.DESCENDING);

        FirestoreRecyclerOptions<ItemKeys> firestoreRecyclerOptions = new FirestoreRecyclerOptions.Builder<ItemKeys>()
                .setQuery(query, ItemKeys.class).build();

        adapterFactoryKeysSnap = new AdapterFactoryKeysSnap((ClickKeysBlanc) getContext(), getContext(), firestoreRecyclerOptions);
        rv_keys_factory = requireView().findViewById(R.id.rv_keys_factory);
        RLM_keys_factory = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
        SnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
        snapHelper.attachToRecyclerView(rv_keys_factory);
        rv_keys_factory.setHasFixedSize(false);
        rv_keys_factory.setLayoutManager(RLM_keys_factory);
        rv_keys_factory.setNestedScrollingEnabled(true);
        rv_keys_factory.setAdapter(adapterFactoryKeysSnap);
        adapterFactoryKeysSnap.startListening();
        pb_keys_factory = requireView().findViewById(R.id.pb_keys_factory);
        Objects.requireNonNull(rv_keys_factory.getAdapter()).setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
        pb_keys_factory.setVisibility(View.GONE);
    }

The application understands which document was clicked due to "TurnKeyFactory". Inside this document is a subСollection called "TheKeyOpens".

I found a way to implement what was conceived inside this document, I write the following

"Factory exit key(Factory)"- name document

    private final FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
    private final CollectionReference collectionReference = firebaseFirestore.collection("Items").document("Factory exit key(Factory)").collection("TheKeyOpens");

The whole problem is that after I write this, it appears in all documents of the main collection, not in the specific selected.

I thought that if my application opens the selected document by "TurnKeyFactory" it will work if I write like this:

    private final FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
    private final CollectionReference collectionReference = firebaseFirestore.collection("Items").document("TurnKeyFactory").collection("TheKeyOpens");

But it didn't work.Help solve the problem.

Need to

Items->
    - Factory exit key(Factory)->
        - TheKeyOpens->
            -TheKeyOpens 1
            -TheKeyOpens 2
            -TheKeyOpens 3
    - TurnKeyFactory: “1”

    - Factory exit key(Customs)->
        - TheKeyOpens->
            -TheKeyOpens 1
            -TheKeyOpens 2
            -TheKeyOpens 3
    - TurnKeyFactory: “2”

enter image description hereenter image description here

ANSWER

Answered 2021-Apr-20 at 05:54

I thought that if my application opens the selected document by "TurnKeyFactory" it will work if I write like this:

private final FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("TurnKeyFactory")
    .collection("TheKeyOpens");

This reference doesn't work because you are passing an incorrect ID to the document() method. The ID of the document should be "Factory exit key(Factory)" as seen in the screenshot and not "TurnKeyFactory" as you actually added. In order to make it work, please use the following reference:

private final CollectionReference collectionReference = firebaseFirestore
    .collection("Items")
    .document("Factory exit key(Factory)")
    .collection("TheKeyOpens");

Source https://stackoverflow.com/questions/67172290

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install GravitySnapHelper

Add this to your build.gradle:.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.