Open Source Library for Holdable ViewHolder in RecyclerView

Overview

HoldableSwipeHandler

Open Source Library for Holdable ViewHolder in RecyclerView

Gradle Setup

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

dependencies {
    implementation 'com.github.yeon-kyu.HoldableSwipeHandler:HoldableSwipeHandler:1.0.4'
}

Latest Version : 1.0.4

ScreenShot Examples

๐ŸŒด ๐ŸŒด ๐ŸŒด ๐ŸŒด

How To Use in Activity/Fragment with RecyclerView

val yourRecyclerView : RecyclerView
val yourAdapter : RecyclerView.Adapter or ListAdapter ..

val swipeHelper = HoldableSwipeHelper(context, object : SwipeButtonAction {
  override fun onClickFirstButton(absoluteAdapterPosition: Int) {
    // do something if you want to get callback when 'holded' button is clicked
    viewModel.deleteNotification(yourAdapter.currentList[absoluteAdapterPosition].articleId)
  }
})

swipeHelper.apply {
  setBackgroundColor("#000000") // not necessary. default value is pink color 
  setFirstItemDrawable(ContextCompat.getDrawable(context, R.drawable.ic_check)!!) // not necessary. default value is a 'trash can' icon
  setFirstItemSideMarginDp(20) // not necessary. default value is 18. (in dip unit)
}

// the codes bellow are necessary
swipeHelper.addRecyclerViewListener(yourRecyclerview)
swipeHelper.addRecyclerViewDecoration(yourRecyclerview)
val itemTouchHelper = ItemTouchHelper(swipeHelper)
itemTouchHelper.attachToRecyclerView(yourRecyclerview)

About

Currently, just one 'Holded' Button is supported, but I will manage to support two or more items in the future.

Any Feedback or PR would be appreciated. Thank you.

License

Designed and developed by 2021 yeon-kyu

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.
You might also like...
Set of extra Transitions on top of Jetpack Transitions Library

Transitions Everywhere Set of extra Transitions on top of AndroidX Transitions Library. About Article about transitions and library Originally this li

FragmentTransactionExtended is a library which provide us a set of custom animations between fragments.

FragmentTransactionExtended FragmentTransactionExtended is a library which provide us a set of custom animations between fragments. FragmentTransactio

Android Rubber Picker Library
Android Rubber Picker Library

RubberPicker RubberPicker library contains the RubberSeekBar and RubberRangePicker, inspired by Cuberto's rubber-range-picker. Getting started Setting

EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the  Etsy app.
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the Etsy app.

EtsyBlur EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the past Etsy app. Try out the sa

Library project to display DialogFragment with a blur effect.
Library project to display DialogFragment with a blur effect.

BlurDialogFragment This project allows to display DialogFragment with a burring effect behind. The blurring part is achieved through FastBlur algorith

[] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!

DEPRECATED NineOldAndroids is deprecated. No new development will be taking place. Existing versions will (of course) continue to function. New applic

A Java library that models spring dynamics and adds real world physics to your app.

Rebound About Rebound is a java library that models spring dynamics. Rebound spring models can be used to create animations that feel natural by intro

Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management.  Made by Stfalcon
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.

PhotoEditor A Photo Editor library with simple, easy support for image editing using Paints, Text, Filters, Emoji and Sticker like stories. Features D

Comments
  • [์ˆ˜์ •] HoldableSwipeHandler ์ ์šฉํ•  ๋•Œ Builder ํŒจํ„ด ์ ์šฉ

    [์ˆ˜์ •] HoldableSwipeHandler ์ ์šฉํ•  ๋•Œ Builder ํŒจํ„ด ์ ์šฉ

    ๋ฐฐ๊ฒฝ

    • ๊ธฐ์กด์˜ HoldableSwipeHandler๋ฅผ ์ ์šฉํ•  ๋•Œ setXXXX, addXXXX ๋“ฑ์˜ ๋งค์†Œ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ RecyclerView์— ๊ธฐ๋Šฅ๋“ค์„ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค.(์†Œ์œ„ ์ž๋ฐ”๋นˆ์ฆˆ ํŒจํ„ด)
    • ์ด๋Ÿฌํ•œ ๋ฐฉ์‹์€ ๋ช‡๊ฐ€์ง€ ๋‹จ์ ์ด ์กด์žฌํ–ˆ๋‹ค.
      • ๊ฐ์ฒด ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•˜์—ฌ ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋งค์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด์•ผํ•˜๊ณ , ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง„๋‹ค.
      • ๊ฐ์ฒด๊ฐ€ ์™„์ „ํžˆ ์ƒ์„ฑ๋˜๊ธฐ ์ „๊นŒ์ง€๋Š” ์ผ๊ด€์„ฑ์ด ๋ฌด๋„ˆ์ง€๋Š” ์ƒํƒœ์— ๋†“์ด๊ฒŒ ๋œ๋‹ค.
    • HoldableSwipeHandler๋ฅผ ์ ์šฉํ•  ๋•Œ ์ทจํ•ด์•ผํ•˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ๋งŽ๋‹ค.
      • Context, RecyclerView, HoldingBackground ๋ฒ„ํŠผ ํด๋ฆญ์‹œ dismiss ์—ฌ๋ถ€, Swipe๋˜๋Š” ๋ทฐํ™€๋”์—์„œ ์ œ์™ธ๋  ViewType ๋“ฑ
    • HoldableSwipeHandler๋ฅผ ์ ์šฉํ•  ๋•Œ ์ทจํ•ด์•ผํ•˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ์ค‘ ์ผ๋ถ€๋Š” ํ•„์ˆ˜์ ์ด๊ณ , ์ผ๋ถ€๋Š” ์„ ํƒ์ ์ด๋‹ค.
      • Context, RecyclerView๋Š” ๋ฐ˜๋“œ์‹œ ์„ธํŒ…ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.
      • HoldingBackground์˜ Drawable, ButtonItem ์˜ side margin ๊ฐ’์€ default ๊ฐ’์ด ์žˆ์œผ๋ฉฐ, ์„ธํŒ…ํ•ด์ฃผ์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

    ๋ณ€๊ฒฝ ์‚ฌํ•ญ

    • Library๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ Builder ํŒจํ„ด์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
    • HoldebleSwipeHandler ํด๋ž˜์Šค๋ฅผ ์ƒˆ๋กœ ๋งŒ๋“ค์–ด์„œ ๊ทธ ๋‚ด๋ถ€์— HoldableSwipeHandler๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” Builder ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.
    • ๊ธฐ์กด์— ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์ž ์ž…์žฅ์—์„œ RecyclerView๋ฅผ ์„ธํŒ…ํ•  ๋•Œ, addRecyclerViewDecoration(), addRecyclerViewListener() ์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ๋”ฐ๋กœ ๋”ฐ๋กœ ํ˜ธ์ถœํ•˜๋„๋ก ํ•˜์˜€์—ˆ๋Š”๋ฐ, ์ด๋ฅผ ํ•ฉ์ณค๋‹ค.(๋‘˜ ๋‹ค ํ•„์š” ์ธ์ž๊ฐ€ ๊ฐ™์œผ๋ฉฐ ๋ฐ˜๋“œ์‹œ ํ˜ธ์ถœํ•ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ)
    • ํ•„์ˆ˜์ ์œผ๋กœ ๋„ฃ์–ด์ฃผ์–ด์•ผ ํ•˜๋Š” ์ธ์ž๊ฐ€ ์—†์œผ๋ฉด IllegalArgumentException์„ ๋˜์ง„๋‹ค.
      • ์ปดํŒŒ์ผํƒ€์ž„์— ์•Œ๋ ค์ค„ ์ˆ˜ ์žˆ์œผ๋ฉด Best ์ผ๊ฒƒ ๊ฐ™์€๋ฐ Runtime์— ๊ฐ€์„œ์•ผ ์•Œ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์€ ์•„์‰ฌ์šด ๊ฒƒ ๊ฐ™๋‹ค.
    • HoldableSwipeHelper ์—๋Š” @Deprecated ์–ด๋…ธํ…Œ์ด์…˜์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š”๋‹ค.
      • ๊ทธ๋Ÿฌ๋‚˜ ํ˜„์žฌ๋กœ์„œ์˜ ๊ธฐ๋Šฅ์€ ์ง€์›ํ•˜์ง€๋งŒ ์ถ”๊ฐ€ ์—…๋ฐ์ดํŠธ๋Š” HoldableSwipeHandler์—์„œ๋งŒ ์ ์šฉํ•  ์˜ˆ์ •์ด๋‹ค.

    ์‚ฌ์šฉ ์˜ˆ์‹œ

    Builder ํŒจํ„ด ์ ์šฉ ์ด์ „(์ž๋ฐ”๋นˆ์ฆˆ ํŒจํ„ด)

    val swipeHelper = HoldableSwipeHelper(requireContext(), object : SwipeButtonAction {
        override fun onClickFirstButton(absoluteAdapterPosition: Int) {
            playerList.removeAt(absoluteAdapterPosition)
            adapter.submitList(playerList.toList())
        }
    })
    
    swipeHelper.addRecyclerViewListener(binding.recyclerView)
    swipeHelper.addRecyclerViewDecoration(binding.recyclerView)
    swipeHelper.setDismissBackgroundOnClickedFirstItem(true)
    swipeHelper.setBackgroundColor("#ff0000")
    val itemTouchHelper = ItemTouchHelper(swipeHelper)
    itemTouchHelper.attachToRecyclerView(binding.recyclerView)
    

    Builder ํŒจํ„ด ์ ์šฉ ์ดํ›„(ํ˜„์žฌ)

    HoldableSwipeHandler.Builder(requireContext())
        .setOnRecyclerView(binding.recyclerView)
        .setSwipeButtonAction(object : SwipeButtonAction {
            override fun onClickFirstButton(absoluteAdapterPosition: Int) {
                playerList.removeAt(absoluteAdapterPosition)
                adapter.submitList(playerList.toList())
            }
        })
        .setBackgroundColor("#ff0000")
        .setDismissOnClickFirstItem(true)
        .build()
    
    opened by yeon-kyu 0
Releases(1.2.0)
  • 1.2.0(Mar 27, 2022)

    ๋ณ€๊ฒฝ ์‚ฌํ•ญ

    • ๊ธฐ์กด์˜ ์ž๋ฐ”๋นˆ์ฆˆ ํŒจํ„ด์—์„œ ๋‹จ์ ๋“ค์„ ๋ณด์™„ํ•˜๊ณ ์ž HoldableSwipeHandler๋ฅผ ์ ์šฉํ•  ๋•Œ Builder ํŒจํ„ด์„ ์ ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.
      • ๊ฐ€๋…์„ฑ, ๊ฐ์ฒด ์ƒ์„ฑ๊นŒ์ง€์˜ ๊นจ์ง€์ง€ ์•Š๋Š” ์ผ๊ด€์„ฑ, ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ์‰ฌ์šด ์ ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
    • ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ ์šฉํ•  ๋•Œ HoldableSwipeHelper์—์„œ addRecyclerViewDecoration(), addRecyclerViewListener() ์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ๊ฐ๊ฐ ํ˜ธ์ถœํ•˜๋„๋ก ํ–ˆ์—ˆ๋Š”๋ฐ, ์ด๋ฅผ ํ•ฉ์ณค๋‹ค.(๋‘˜ ๋‹ค ํ•„์š” ์ธ์ž๊ฐ€ ๊ฐ™์œผ๋ฉฐ ๋ฐ˜๋“œ์‹œ ํ˜ธ์ถœํ•ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ)
    • ํ•„์ˆ˜์ ์œผ๋กœ ๋„ฃ์–ด์ฃผ์–ด์•ผ ํ•˜๋Š” ์ธ์ž๊ฐ€ ์—†์œผ๋ฉด IllegalArgumentException์„ ๋˜์ง„๋‹ค.
    • HoldableSwipeHelper ์—๋Š” @Deprecated ์–ด๋…ธํ…Œ์ด์…˜์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š”๋‹ค.
      • ๊ทธ๋Ÿฌ๋‚˜ ํ˜„์žฌ๋กœ์„œ์˜ ๊ธฐ๋Šฅ์€ ์ง€์›ํ•˜์ง€๋งŒ ์ถ”๊ฐ€ ์—…๋ฐ์ดํŠธ๋Š” HoldableSwipeHandler์—์„œ๋งŒ ์ ์šฉํ•  ์˜ˆ์ •์ด๋‹ค.

    ๋ณ€๊ฒฝ์‚ฌํ•ญ PR ๋งํฌ : https://github.com/yeon-kyu/HoldableSwipeHandler/pull/1#issue-1182583064

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Feb 23, 2022)

    • ํŠน์ • ItemViewType์—๋Š” Swipe ๋ถˆ๊ฐ€๋Šฅํ•˜๊ฒŒ ๊ฐ€๋Šฅํ•˜๋„๋ก ์ˆ˜์ •
      • excludeFromHoldableViewHolder() ์ด์šฉ
    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Jan 3, 2022)

    • ์•„์ดํ…œ ์‚ญ์ œ๋ ๋•Œ HoldingBackground๊ฐ€ ์ข…์ข… ๋‚จ์•„์žˆ๋Š” ๋ฒ„๊ทธ ์ˆ˜์ •
    • ๋ทฐํ™€๋”์˜ ๋ฐฐ๊ฒฝ์ด ํˆฌ๋ช…ํ•œ ๊ฒฝ์šฐ์˜ ๊ฐ์ข… UI ๋ฒ„๊ทธ ์ˆ˜์ •
    • ๋ทฐํ™€๋” ์ž์ฒด์˜ ํด๋ฆญ๋ฆฌ์Šค๋„ˆ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ๊ฐ์ข… ์ด์Šˆ ์ฒ˜๋ฆฌ
    Source code(tar.gz)
    Source code(zip)
  • 1.0.10(Jan 3, 2022)

    • ๋ณด์ด์ง€ ์•Š๋Š” Drawable ๋‚จ์•„ ์žˆ๋Š” ์ด์Šˆ ํ•ด๊ฒฐ
    • Holding๋œ ๋ทฐํ™€๋”์— ๋Œ€ํ•ด ์‚ญ์ œ์‹œ ๋‹ค์Œ ์žฌํ™œ์šฉ๋˜๋Š” ๋ทฐํ™€๋”์˜ translationX๊ฐ€ ์›๋ณต๋˜์ง€ ์•Š๋˜ ์ด์Šˆ ํ•ด๊ฒฐ
    Source code(tar.gz)
    Source code(zip)
  • 1.0.9(Jan 3, 2022)

    • setDismissBackgroundOnClickedFirstItem() ํ•จ์ˆ˜๋กœ ์•„์ดํ…œ ํด๋ฆญ ์‹œ Holded ๋ทฐํ™€๋”์˜ Background ์•ˆ๋ณด์ด๊ฒŒ ํ•  ์ง€ ์„ ํƒ ๊ฐ€๋Šฅ
      • default๋Š” true
    Source code(tar.gz)
    Source code(zip)
  • 1.0.8(Jan 1, 2022)

    • ๋ทฐํ™€๋”์˜ background๊ฐ€ ํˆฌ๋ช…ํ•œ ๊ฒฝ์šฐ, Holding๋œ background๊ฐ€ ๋ทฐํ™€๋”๋ฅผ ์นจ๋ฒ”ํ•˜๋Š” ์ด์Šˆ ์ฒ˜๋ฆฌ
    Source code(tar.gz)
    Source code(zip)
  • 1.0.7(Dec 29, 2021)

  • 1.0.5(Dec 29, 2021)

  • 1.0.4(Dec 28, 2021)

    • ํ•จ์ˆ˜๋ช… ๋‚ด์— ์˜คํƒ€ ์ˆ˜์ •
    • ๊ธฐ๋Šฅ์ƒ ์ˆ˜์ •์‚ฌํ•ญ ์—†์Œ
    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Dec 28, 2021)

    RecyclerView ์˜ ItemDecoration์„ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ override ํ•˜์ง€ ์•Š๊ณ  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋‚ด๋ถ€์—์„œ ํ•˜๋„๋ก ์ˆ˜์ •. ๋งŒ์•ฝ ์‚ฌ์šฉ์ž๊ฐ€ ์ด๋ฅผ ์ปค์Šคํ…€ํ•˜๋ ค๋ฉด ์ด๊ฒƒ์„ ๋‹ค์‹œ overrideํ•˜๋ฉด ๋œ๋‹ค.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Dec 28, 2021)

  • 1.0.0-alpha3(Dec 28, 2021)

  • 1.0.0-alpha2(Dec 28, 2021)

  • 1.0.0-alpha(Dec 28, 2021)

  • 0.0.1(Dec 28, 2021)

  • 0.0.0(Dec 28, 2021)

Owner
null
This is an open-source project connected to Formaloo CDP

Twitter Rank Android Application This is an open-source project connected to Formaloo CDP to calculate a tweeter and his/her followings rank. For each

Formaloo 11 Jun 12, 2022
FastHub - Yet another open-source GitHub client app but unlike any other app

FastHub - Yet another open-source GitHub client app but unlike any other app

zeromake 15 Nov 20, 2022
An Android library which provides simple Item animations to RecyclerView items

RecyclerViewItemAnimators Library Travis master: This repo provides: Appearance animations Simple animators for the item views Quick start You can now

Gabriele Mariotti 3.1k Dec 16, 2022
FadingToolbar is an animation library which fades out your footer view in a ScrollView/RecyclerView and fades in a toolbar title

FadingToolbar is an animation library which fades out your footer view in a ScrollView/RecyclerView and fades in a toolbar title (analogue of the LargeTitle animation in iOS)

Hanna 9 Nov 3, 2022
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Enrique Lรณpez Maรฑas 3.6k Dec 29, 2022
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
A Java library that models spring dynamics and adds real world physics to your app.

Rebound About Rebound is a java library that models spring dynamics. Rebound spring models can be used to create animations that feel natural by intro

Facebook Archive 5.5k Jan 9, 2023
Android library for swipable gestures

Swipper Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conv

Mobile Development Group 105 Dec 30, 2022
Android Library that lights items for tutorials or walk-throughs etc...

Spotlight Gradle dependencies { implementation 'com.github.takusemba:spotlight:x.x.x' } Usage val spotlight = Spotlight.Builder(this) .setTarg

TakuSemba 3.4k Jan 4, 2023
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022