• Stars
    star
    429
  • Rank 101,271 (Top 2 %)
  • Language
    Java
  • License
    BSD 2-Clause "Sim...
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

Android Arsenal BSD Jitpack Build Status

RecyclerViewSwipeDismiss

A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

Preview

preview

How to use

  • Add these lines to your build.gradle
repositories {
	maven {
	    url "https://jitpack.io"
	}
}

dependencies {
	 compile 'com.github.CodeFalling:RecyclerViewSwipeDismiss:v1.1.3'
}
  • Build onTouchListener and bind it to your RecyclerView
SwipeDismissRecyclerViewTouchListener listener = new SwipeDismissRecyclerViewTouchListener.Builder(
        recyclerView,
        new SwipeDismissRecyclerViewTouchListener.DismissCallbacks() {
            @Override
            public boolean canDismiss(int position) {
                return true;
            }

            @Override
            public void onDismiss(View view) {
                // Do what you want when dismiss
                
            }
        })
        .setIsVertical(false)
        .setItemTouchCallback(
                new SwipeDismissRecyclerViewTouchListener.OnItemTouchCallBack() {
                    @Override
                    public void onTouch(int index) {
                    	// Do what you want when item be touched
                    }
                })
        .setItemClickCallback(new SwipeDismissRecyclerViewTouchListener.OnItemClickCallBack() {
                    @Override
                    public void onClick(int position) {
                        // Do what you want when item be clicked                    }
                })
        .setBackgroundId(R.drawable.bg_item_normal, R.drawable.bg_item_selected)
        .create();
recyclerView.setOnTouchListener(listener);

More

  • setIsVertical(false) means allow swipe in horizontal direction

  • listener.setEnabled(false) can disable swipe to dismiss

  • onTouch will be called when MOUSE_UP on item without swipe

  • onClick will be called when ACTION_UP on item within 1 second and move no more than a fixed distance

  • By use setBackgroundId, you can set background id for item's normal and pressed state, just like the normal effect in RecyclerView

Sample

You can see sample code in sample/MainActivity.java

More Repositories

1

CodeTerminal

Cross platform standalone terminal app extract from Visual Studio Code.
TypeScript
663
star
2

hexo-asset-image

Give asset image in hexo a absolutely path automatically
JavaScript
321
star
3

blog-admin

Write blog in emacs with hexo/org-page/nikola
Emacs Lisp
228
star
4

fcitx-remote-for-osx

A simulate fcitx-remote to handle osx input method in command line
Objective-C
198
star
5

iProxy

💎 Cross platform Web debugging proxy(fork of LightProxy、Linux & 多网卡支持)
TypeScript
152
star
6

ar-demo-mobile-browser

A AR demo on mobile browser(Android yet) powered by JavaScript
JavaScript
64
star
7

nlinum-relative

Emacs relative line number besed on nlinum-mode
Emacs Lisp
60
star
8

fcitx-vim-osx

Modified fcitx.vim for osx with https://github.com/CodeFalling/fcitx-remote-for-osx
Vim Script
57
star
9

dns-proxy-https

DNS proxy server over Google HTTPS DNS Service with socks supported
JavaScript
25
star
10

react-tiny

Tiny implementation of React step by step
JavaScript
22
star
11

inoreader-app

Unofficial electron app for inoreader
HTML
21
star
12

perfbook

《前端性能揭秘》勘误 & 答疑
HTML
14
star
13

localapp

Rust CLI to convert webpage into desktop app with tauri under 3 MB
Rust
12
star
14

my.vimrc

Vim Script
5
star
15

spacemacs-private

My spacemacs private layer based on spacemacs-base
Emacs Lisp
5
star
16

nuc6i7kyk-macos-efi

EFI for nuc6i7kyk macOS Catalina
C++
5
star
17

overdom

A tiny view library with JSX, mutate(data) = mutate(DOM).
TypeScript
5
star
18

UITimeField

A iOS time input inspired by Android's timer app
Objective-C
5
star
19

fastkill

Interactive CLI to kill process with port/pid/name
Rust
4
star
20

gtrans

VIm 的谷歌翻译插件(A google translater for vim)
Python
4
star
21

universal-indent-size

Set all indent size in emacs at once
Emacs Lisp
3
star
22

smart-im-osx

A emacs plugin to make your input method on Mac smarter.
Emacs Lisp
3
star
23

fyarn

使用 taobao npm 镜像源的高速 yarn,同时支持 electorn/node-sass 等二进制安装时的加速。
JavaScript
3
star
24

commit-history

The missing GitHub commit history graph of GitHub repos
TypeScript
3
star
25

nativefier-apps

Build apps with nativefier & github actions
3
star
26

vdom

basic virtual dom
JavaScript
2
star
27

web-perf-secret

A tiny book for web performance
CSS
2
star
28

easy-password

Easy way to manage password with memory.
JavaScript
2
star
29

cerebro-mac-switch-window

Cerebro plugin to switch window on macOS
Swift
2
star
30

ts-zero

Starter project for create Typescript library with zero-configuration build/watch/test/lint
JavaScript
1
star
31

hexo-theme-clean

A minimal hexo theme fork from hexo-theme-strict
CSS
1
star
32

shell-toggle-plus

Shell-toggle for emacs that can use eshell
Emacs Lisp
1
star
33

blogsite

CSS
1
star
34

any-inspector

Inspect any state with Redux DevTools.
TypeScript
1
star
35

gdb_printers

My own modified gdb printers
Python
1
star
36

homebrew-fcitx-remote-for-osx

brew tap for https://github.com/CodeFalling/fcitx-remote-for-osx
Ruby
1
star
37

autokey-macos

My personal autokey config for macos key-binding on linux
Python
1
star
38

leetcode-es6

This is a leetcode repository created by LeetCode Extension
JavaScript
1
star