• Stars
    star
    1,040
  • Rank 44,297 (Top 0.9 %)
  • Language
    Java
  • Created about 8 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

Extension for itemtouchhelper with swipe settling,recover and no conflict with recyclerview

itemtouchhelper-extension

This library add something for swipe item settling, recover base on the Itemtouchhelper.

This used in the repo code-reader

Download Sample

Screenshot

item swipe with spring

item swipe with no spring

item swipe with recycler view width

Installation

dependencies {
    compile 'com.loopeer.library:itemtouchhelperextension:1.0.6'
}

Usages

mCallback = new ItemTouchHelperCallback();
mItemTouchHelper = new ItemTouchHelperExtension(mCallback);
mItemTouchHelper.attachToRecyclerView(mRecyclerView);

ItemTouchHelperCallback just set as Itemtouchhelper. Set your swipe content view translationX by moving in method onChildDraw

public class ItemTouchHelperCallback extends ItemTouchHelperExtension.Callback {

    @Override
    public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
        return makeMovementFlags(0, ItemTouchHelper.START);
    }

    @Override
    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
        return false;
    }
    
    ...

    @Override
    public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
        MainRecyclerAdapter.ItemBaseViewHolder holder = (MainRecyclerAdapter.ItemBaseViewHolder) viewHolder;
        holder.mViewContent.setTranslationX(dX);
    }
}

At last you can let your viewholder implements Extension to set swipe settling width

@Override
public float getActionWidth() {
    return mActionContainer.getWidth();
}

This will use whole recyclerview width when you do not add the width

Additional Drag Feature

If you want to add drag item feature.You just do super.onChildDraw in method onChildDraw of the class ItemTouchHelperCallback. Just like bottom:

  @Override
    public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
        if (dY != 0 && dX == 0) super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
       ...
    }

Click Action Button To Close Opened

If you want to close item after click action btn in the swipe item. You show add

    mItemTouchHelperExtension.closeOpened();

License

Copyright 2016 Loopeer

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.

More Repositories

1

CardStackView

One Custom view for show something just like cards with animations.
Java
2,179
star
2

shadow

Deprecated because of the performance not fine. Android custom shadow view, can replace your CardView
Kotlin
1,371
star
3

code-reader

One Multi program language code reader
Kotlin
947
star
4

AlertTransition

AlertTransition is a extensible library for making view controller transitions, especially for alert transitions.
Swift
580
star
5

SpringHeader

An implementation of spring-like header (known as pull-to-refresh) that using CoordinatorLayout.
Java
177
star
6

ScrollTableView

Android one demo of horizontal and vertical scroll custom table view
Java
112
star
7

ImageGroupView

Android image group view. One android custom view you can show and add image
Java
73
star
8

PullSwitcher

Help to switch fragment easier
Java
50
star
9

LoginLib

ๅฏน็™ปๅฝ•ๆณจๅ†Œไธญๅ‘้€้ชŒ่ฏ็ ๆŒ‰้’ฎๅ’ŒๆไบคๆŒ‰้’ฎ็š„ๅฐ่ฃ…ใ€‚
Java
29
star
10

MultiTextTagView

Android Multi Tag View
Java
23
star
11

quickcms

laravel quick cms
HTML
20
star
12

LPAlbum

an albums that can preview, multiple-choice
Swift
17
star
13

AutoLoopPager

One library can make pager slide loop, and add your custom view easier.
Java
17
star
14

AttributedStringWrapper

a simple packaging for NSAttributedString to make the developers easy to use
Swift
16
star
15

CoordinateLayoutDemo

Android One Test of CoordinatorLayout
Java
14
star
16

ProjectDevelopModule

Java
11
star
17

AndroidLearnNote

Some note from learning Android
Java
8
star
18

PullToRefreshAndLoadMore

Android pull to refresh, load more
Java
3
star
19

android-kotlin-ext

One library of kotlin extension functions for android
Kotlin
3
star
20

easypush

A package for push messages
PHP
2
star
21

android-plugin-loopeermodel

an Android Studio plugin for generating model using loopeer data dictionary.
Java
1
star
22

QRCodeScan

Java
1
star
23

FilterDropMenu

Java
1
star
24

bangduobao

ๅธฎๅคšๅฎ้ฆ–้กต้™ๆ€ๆ–‡ไปถ
HTML
1
star
25

LoopeerLogin

Java
1
star
26

DriveIndicator

Java
1
star