Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.kroegerama:recycler-swipe-stack

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.kroegerama:recycler-swipe-stack

A helper library to create stacked and swipeable items inside a RecyclerView.

  • 0.9.3
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Recycler Swipe Stack

An easy to use helper for RecyclerViews. StackLayoutManager and ItemTouchHelperCallback.


Publish

License

ArtifactVersion
recycler-swipe-stackMaven Central
implementation("com.kroegerama:recycler-swipe-stack:$VERSION")

Preview

Preview

Usage

1. Create your SwiperConfig
val config = SwiperConfig(
    showCount = 5,
    swipeDirections = SwipeDirection.LEFT or SwipeDirection.RIGHT or SwipeDirection.UP,
    stackDirection = StackDirection.Down,
    itemTranslate = 0.02f,
    itemRotation = 15f,
    itemScale = .0f
)
2. Create a SwipeListener
private val listener = object : SwipeListener {
    override fun onSwipe(
        viewHolder: RecyclerView.ViewHolder,
        dX: Float,
        dY: Float,
        direction: Int
    ) {
    }

    override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
        Timber.d("onSwiped($direction)")
        //example: remove item from Adapter (and call notifyItemRemoved,
        //if your adapter doesn't do it automatically)
        itemAdapter.removeAt(viewHolder.bindingAdapterPosition)
    }

    override fun onSwipeEnd(viewHolder: RecyclerView.ViewHolder) {
        Timber.d("onSwipeEnd()")
    }

    override fun isSwipeAllowed(viewHolder: RecyclerView.ViewHolder) = viewHolder is MyViewHolder
}
3. Setup the library
3a Use the helper function
recycler.setupStack(
    config,
    listener
) {
    itemAnimator = DefaultItemAnimator().apply {
        addDuration = 200
        removeDuration = 200
    }
    adapter = myAdapter
}
3b Or setup the classes yourself
Create an ItemTouchHelper and a StackLayoutManager
val itemTouchHelper = ItemTouchHelper(StackSwipeTouchHelperCallback(listener, config))
val layoutManager = StackLayoutManager(config)
Setup your RecyclerView
recycler.layoutManager = layoutManager
itemTouchHelper.attachToRecyclerView(recycler)

FAQs

Package last updated on 22 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc