Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/TUBB/SwipeMenu

[DEPRECATED] A swipe menu for horizontal/vertical, support left/right and top/bottom directions
https://github.com/TUBB/SwipeMenu

listview recyclerview scrollview swipe-menu

Last synced: about 1 month ago
JSON representation

[DEPRECATED] A swipe menu for horizontal/vertical, support left/right and top/bottom directions

Awesome Lists containing this project

README

        

SwipeMenu
=========
A swipe menu for `horizontal/vertical`, support `left/right and top/bottom` directions, low coupling, can fast rapid integration into your project

Features
========

* Support LinearLayoutManager、GridLayoutManager and StaggeredGridLayoutManager for RecyclerView (`only horizontal`)
* Support ListView and GridView (`only horizontal`)
* Support ScrollView (`only horizontal` and the `[SwipeHorizontal/SwipeVertical]MenuLayout` must be the direct child of ScrollView's direct child )
* On-off swipe ability
* Not intercept item touch event
* Left/Right and Top/Bottom menu support, free switch

Preview
=======
![DEMO](https://github.com/TUBB/SwipeMenu/blob/master/art/demo.gif)

Usage
=====

Add to dependencies
```
dependencies {
compile 'com.tubb.smrv:swipemenu-recyclerview:5.4.8'
}
```

#### Horizontal
Just use `SwipeHorizontalMenuLayout`, we use `SwipeHorizontalMenuLayout` ViewGroup to combine item content view and `left/right(at least one)` swipe menu
```xml



```

If you have so many items, you may be want to use our custom RecyclerView
```xml

```

### Vertical
Just use `SwipeVerticalMenuLayout`, we use `SwipeVerticalMenuLayout` ViewGroup to combine item content view and `top/bottom (at least one)` swipe menu
```xml

```

More details please see the demo project

## Listeners
We add a [SwipeSwitchListener][2] for actions like open/close
```java
sml.setSwipeListener(new SwipeSwitchListener() {
@Override
public void beginMenuClosed(SwipeMenuLayout swipeMenuLayout) {
Log.e(TAG, "left menu closed");
}

@Override
public void beginMenuOpened(SwipeMenuLayout swipeMenuLayout) {
Log.e(TAG, "left menu opened");
}

@Override
public void endMenuClosed(SwipeMenuLayout swipeMenuLayout) {
Log.e(TAG, "right menu closed");
}

@Override
public void endMenuOpened(SwipeMenuLayout swipeMenuLayout) {
Log.e(TAG, "right menu opened");
}
});
```

If you case a few actions, just use [SimpleSwipeSwitchListener][3]
```java
sml.setSwipeListener(new SimpleSwipeSwitchListener(){
@Override
public void beginMenuClosed(SwipeMenuLayout swipeMenuLayout) {
Log.e(TAG, "left menu closed");
}
});
```

We also add a [SwipeFractionListener][4] for complete fraction action
```java
sml.setSwipeFractionListener(new SwipeFractionListener() {
@Override
public void beginMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
Log.e(TAG, "top menu swipe fraction:"+fraction);

}

@Override
public void endMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
Log.e(TAG, "bottom menu swipe fraction:"+fraction);
}
});
```

If you case a few actions, just use [SimpleSwipeFractionListener][5]
```java
sml.setSwipeFractionListener(new SimpleSwipeFractionListener(){
@Override
public void beginMenuSwipeFraction(SwipeMenuLayout swipeMenuLayout, float fraction) {
Log.e(TAG, "top menu swipe fraction:"+fraction);
}
});
```

Custom
======

Supported custom attrs:

* `sml_scroller_duration` Scroller duration(ms), `sml:sml_scroller_duration="250"`
* `sml_auto_open_percent` Swipe menu auto open percent(relative to menu's width), `sml:sml_auto_open_percent="0.5"`
* `sml_scroller_interpolator` Scroller open/close interpolation, `sml:sml_scroller_interpolator="@android:anim/bounce_interpolator"`

```xml





```

Thanks
======

Inspired by [baoyongzhang/SwipeMenuListView][1]

License
-------

Copyright 2016 TUBB

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.

[1]: https://github.com/baoyongzhang/SwipeMenuListView
[2]: https://github.com/TUBB/SwipeMenu/tree/master/library/src/main/java/com/tubb/smrv/listener/SwipeSwitchListener.java
[3]: https://github.com/TUBB/SwipeMenu/tree/master/library/src/main/java/com/tubb/smrv/listener/SimpleSwipeSwitchListener.java
[4]: https://github.com/TUBB/SwipeMenu/tree/master/library/src/main/java/com/tubb/smrv/listener/SwipeFractionListener.java
[5]: https://github.com/TUBB/SwipeMenu/tree/master/library/src/main/java/com/tubb/smrv/listener/SimpleSwipeFractionListener.java