Home

Awesome

SmartSwipe

librarysmart-swipesmart-swipe-supportsmart-swipe-x
latest versionDownloadDownloadDownload

中文文档,更详尽

A smart swipe android library helps you make View (and Activity) swipes easier.

In addition, to facilitate the use, SmartSwipe encapsulates the following tool classes:

Demo

download demo.apk

Stretch<br/>StretchConsumerSpace<br/>SpaceConsumerTranslucent Sliding<br/>TranslucentSlidingConsumer
<img width="200" src="images/stretchConsumer.gif"><img width="200" src="images/spaceConsumer.gif"><img width="200" src="images/translucentSlidingConsumer.gif">
Drawer above<br/>DrawerConsumerDrawer behind<br/>(factor is settable)<br/>SlidingConsumer
<img width="200" src="images/drawerConsumer.gif"><img width="200" src="images/slidingConsumer.gif">
Doors Open<br/>DoorConsumerShutters Open<br/>ShuttersConsumer
<img width="200" src="images/doorConsumer.gif"><img width="200" src="images/shuttersConsumer.gif">

Create a cover

Doors openShutters OpenDrawer Open
<img width="200" src="images/cover_door.gif"><img width="200" src="images/cover_shutters.gif"><img width="200" src="images/cover_drawer.gif">

Activity sliding back

All Activities slide back in an easy way via a single line code.

Back via release velocity<br/>StayConsumerTranslucent Sliding Back<br/>ActivitySlidingBackConsumerBack with bezier<br/>BezierBackConsumer
<img width="200" src="images/stayConsumer.gif"><img width="200" src="images/activitySlidingBackConsumer.gif"><img width="200" src="images/bezierBackConsumer.gif">
Like doors open<br/>ActivityDoorBackConsumerLike shutters open<br/>ActivityShuttersBackConsumer<font color="blue">Global Usage</font><br/>SmartSwipeBack
<img width="200" src="images/activityDoorBackConsumer.gif"><img width="200" src="images/activityShuttersBackConsumer.gif"><img width="200" src="images/swipeBack.gif">

Usage

First add SmartSwipe to your project

implementation 'com.billy.android:smart-swipe:latestVersion'

Nested scrolling only compatible after android api above 21(android 5.0) with core library(smart-swipe)

Add extension library to compat for android support library or androidX like below:

implementation 'com.billy.android:smart-swipe:latestVersion'
//compat for android support library
implementation 'com.billy.android:smart-swipe-support:latestVersion'

or

implementation 'com.billy.android:smart-swipe:latestVersion'
//compat for android x
implementation 'com.billy.android:smart-swipe-x:latestVersion'

SmartSwipe can be used by chain programming within a single line code. The usage of API looks like follow:

SmartSwipe.wrap(...) 		//view or Activity
	.addConsumer(...) 		//add a SwipeConsumer
	.enableDirection(...) 	//Specifies which side of the slide the SwipeConsumer will consumes
	.setXxx(...) 			//[optional] some other Settings
	.addListener(...); 		//[optional] add listener(s) to the SwipeConsumer

Sample code:

//	When view cannot scroll vertically (or scrolling to the top/bottom), 
//	if continue to drag, the UI will show elastic stretching effect, 
//	and smooth recovery after release
SmartSwipe.wrap(view)
	.addConsumer(new StretchConsumer())
	.enableVertical();

Add more than one 'SwipeConsumer' to the same View. Such as:

SmartSwipe.wrap(view)
	.addConsumer(new StretchConsumer())
	.enableVertical() 					//Stretch effect at directions: top and bottom
	.addConsumer(new SpaceConsumer())
	.enableHorizontal() 				//Space effect at directions: left and right
	;

Click here for more details about SwipeConsumers

Activity slides back with a single line of code globally

SmartSwipeBack.activityBezierBack(application, null);	//bezier shows while swiping
SmartSwipeBack.activityStayBack(application, null);		//Back via release velocity
SmartSwipeBack.activitySlidingBack(application, null);	//sliding with pre-activity relative moves
SmartSwipeBack.activityDoorBack(application, null);		//finish activity like doors open
SmartSwipeBack.activityShuttersBack(application, null);	//finish activity like shutters open

Click here For more Details

Add swipe refresh to a View via a single line code

//the second parameter within xxxMode:
// false: works vertically(swipe down to refresh and swipe up to load more)
// true: works horizontally(swipe right to refresh and swipe right to load more) 
SmartSwipeRefresh.drawerMode(view, false).setDataLoader(loader);
SmartSwipeRefresh.behindMode(view, false).setDataLoader(loader);
SmartSwipeRefresh.scaleMode(view, false).setDataLoader(loader);
SmartSwipeRefresh.translateMode(view, false).setDataLoader(loader);

You can use default headers and footers, and you can also customize your own.

The refresh extension library(smart-swipe-refresh-ext: Download) will include some fancy third-party headers and footers.

here is the first one(Based on Ifxcyr/ArrowDrawable):

refresh arrow

Click here For more Details

SmartSwipe features:

Thanks