Giter Site home page Giter Site logo

99kyuu / smartswipe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luckybilly/smartswipe

0.0 1.0 0.0 16.38 MB

An android library to make swipe more easier and more powerful. https://luckybilly.github.io/SmartSwipe-tutorial/

License: Apache License 2.0

Java 100.00%

smartswipe's Introduction

SmartSwipe

library smart-swipe smart-swipe-support smart-swipe-x
latest version Download Download Download

中文文档,更详尽

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:

  • SmartSwipeBack:
    All Activities slide back in an easy way via a single line code.
    without any super activity class; without translucent theme; without any code into BaseActivity; without any code into xml layout files;
  • SmartSwipeRefresh:
    With a single line code to achieve swipe refresh and load more. Compatible with vertical and horizontal
  • SwipeConsumerExclusiveGroup:
    Manages a set of exclusive SwipeConsumers, can only open one at a time.

Demo

download demo.apk

Stretch
StretchConsumer
Space
SpaceConsumer
Translucent Sliding
TranslucentSlidingConsumer
Drawer above
DrawerConsumer
Drawer behind
(factor is settable)
SlidingConsumer
Doors Open
DoorConsumer
Shutters Open
ShuttersConsumer

Create a cover

Doors open Shutters Open Drawer Open

Activity sliding back

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

  • without any super activity class;
  • without translucent theme;
  • without any code into BaseActivity;
  • without any code into xml layout files;
Back via release velocity
StayConsumer
Translucent Sliding Back
ActivitySlidingBackConsumer
Back with bezier
BezierBackConsumer
Like doors open
ActivityDoorBackConsumer
Like shutters open
ActivityShuttersBackConsumer
Global Usage
SmartSwipeBack

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);

Click here For more Details

SmartSwipe features:

  • support for 4 directions swipe( left/top/right/bottom)
  • supports adding multiple SwipeConsumers to the same View(/Activity)
  • supports nested usage
  • support to use for list items in ListView and RecyclerView and the list itself
  • compat for NestedScroll (android support library and androidX)
  • A dozen of built-in SwipeConsumers effects

Thanks

smartswipe's People

Contributors

luckybilly avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.