This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
467 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# RxSlideUp | ||
Reactive listeners for [SlideUp library][1] | ||
|
||
[ ![Download](https://api.bintray.com/packages/ztrap-llc/maven/RxSlideUp/images/download.svg) ](https://bintray.com/ztrap-llc/maven/RxSlideUp/_latestVersion) | ||
--- | ||
## Install | ||
|
||
gradle | ||
```groove | ||
compile 'ru.ztrap:RxSlideUp:1.0.0' | ||
``` | ||
|
||
maven | ||
```maven | ||
<dependency> | ||
<groupId>ru.ztrap</groupId> | ||
<artifactId>RxSlideUp</artifactId> | ||
<version>1.0.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
|
||
```java | ||
View slideView = findViewById(R.id.slideView); | ||
SlideUp slideUp = new SlideUp.Builder(slideView) | ||
.withStartState(SlideUp.State.HIDDEN) | ||
.withStartGravity(Gravity.BOTTOM) | ||
.build(); | ||
|
||
//listening SlideUp.Listener.Events | ||
RxSlideUp.events(slideUp).subscribe(); | ||
|
||
//listening SlideUp.Listener.Slide | ||
RxSlideUp.slide(slideUp).subscribe(); | ||
|
||
//listening SlideUp.Listener.Visibility | ||
RxSlideUp.visibility(slideUp).subscribe(); | ||
``` | ||
|
||
That's all! Enjoy reactive programming with [RxJava][2], [SlideUp][1] and RxSlideUp! | ||
|
||
## License | ||
|
||
Copyright 2017 zTrap | ||
|
||
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/mancj/SlideUp-Android | ||
[2]: https://github.com/ReactiveX/RxJava/tree/1.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
buildscript { | ||
version = VERSION_NAME | ||
group = GROUP | ||
ext { | ||
versions = [ | ||
support : '25.3.1', | ||
SlideUp : '2.2.5', | ||
Rx : [ | ||
Java : '1.3.0', | ||
Android : '1.2.1' | ||
] | ||
] | ||
} | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
maven { url 'https://maven.google.com' } | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.3.2' | ||
classpath 'com.novoda:bintray-release:0.3.4' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
maven { url 'https://maven.google.com' } | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} | ||
apply plugin: 'android-reporting' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Maven stuff | ||
VERSION_NAME=1.0.0 | ||
VERSION_CODE=1 | ||
GROUP=ru.ztrap | ||
|
||
POM_DESCRIPTION=Reactive listeners for SlideUp library | ||
POM_URL=https://github.com/zTrap/RxSlideUp | ||
POM_SCM_URL=https://github.com/zTrap/RxSlideUp | ||
POM_SCM_CONNECTION=scm:git@github.com:zTrap/RxSlideUp.git | ||
POM_SCM_DEV_CONNECTION=scm:git@github.com:zTrap/RxSlideUp.git | ||
POM_LICENCE_NAME=The Apache Software License, Version 2.0 | ||
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt | ||
POM_LICENCE_DIST=repo | ||
POM_DEVELOPER_ID=ztrap | ||
POM_DEVELOPER_NAME=Peter Gulko | ||
|
||
POM_ORG_DEVELOPER_ID=ztrap-llc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.novoda.bintray-release' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 12 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
dependencies { | ||
compile "com.android.support:appcompat-v7:${versions.support}" | ||
compile "com.github.mancj:SlideUp-Android:${versions.SlideUp}" | ||
compile "io.reactivex:rxandroid:${versions.Rx.Android}" | ||
compile "io.reactivex:rxjava:${versions.Rx.Java}" | ||
} | ||
apply from: '../push_maven.gradle' | ||
apply from: '../push_jcenter.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_NAME=RxSlideUp | ||
POM_ARTIFACT_ID=RxSlideUp | ||
POM_PACKAGING=aar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ru.ztrap.rxslideup"> | ||
|
||
<application android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true"/> | ||
</manifest> |
49 changes: 49 additions & 0 deletions
49
library/src/main/java/ru/ztrap/rxslideup/EventsOnSubscribe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ru.ztrap.rxslideup; | ||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
import ru.ztrap.rxslideup.events.SlideUpEvent; | ||
import rx.Subscriber; | ||
import rx.android.MainThreadSubscription; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
class EventsOnSubscribe extends SlideUpOnSubscribe<SlideUpEvent> { | ||
|
||
EventsOnSubscribe(SlideUp slideUp) { | ||
super(slideUp); | ||
} | ||
|
||
@Override | ||
public void call(final Subscriber<? super SlideUpEvent> subscriber) { | ||
MainThreadSubscription.verifyMainThread(); | ||
final SlideUp.Listener eventListener = new SlideUp.Listener.Events() { | ||
int visibility = mSlideUp.getSliderView().getVisibility(); | ||
float percent = mSlideUp.isVisible() ? 0 : 100; | ||
@Override | ||
public void onSlide(float percent) { | ||
this.percent = percent; | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(new SlideUpEvent(mSlideUp, percent, visibility)); | ||
} | ||
} | ||
|
||
@Override | ||
public void onVisibilityChanged(int visibility) { | ||
this.visibility = visibility; | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(new SlideUpEvent(mSlideUp, percent, visibility)); | ||
} | ||
} | ||
}; | ||
subscriber.add(new MainThreadSubscription() { | ||
@Override | ||
protected void onUnsubscribe() { | ||
mSlideUp.removeSlideListener(eventListener); | ||
} | ||
}); | ||
mSlideUp.addSlideListener(eventListener); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ru.ztrap.rxslideup; | ||
|
||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
import ru.ztrap.rxslideup.events.SlideUpEvent; | ||
import rx.Observable; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
public class RxSlideUp { | ||
private RxSlideUp(){ | ||
throw new AssertionError("no instance"); | ||
} | ||
|
||
public static Observable<Float> slide(SlideUp slideUp){ | ||
return Observable.unsafeCreate(new SlideOnSubscribe(slideUp)); | ||
} | ||
|
||
public static Observable<Integer> visibility(SlideUp slideUp){ | ||
return Observable.unsafeCreate(new VisibilityOnSubscribe(slideUp)); | ||
} | ||
|
||
public static Observable<SlideUpEvent> events(SlideUp slideUp){ | ||
return Observable.unsafeCreate(new EventsOnSubscribe(slideUp)); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
library/src/main/java/ru/ztrap/rxslideup/SlideOnSubscribe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ru.ztrap.rxslideup; | ||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
import rx.Subscriber; | ||
import rx.android.MainThreadSubscription; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
class SlideOnSubscribe extends SlideUpOnSubscribe<Float> { | ||
|
||
SlideOnSubscribe(SlideUp slideUp) { | ||
super(slideUp); | ||
} | ||
|
||
@Override | ||
public void call(final Subscriber<? super Float> subscriber) { | ||
MainThreadSubscription.verifyMainThread(); | ||
final SlideUp.Listener eventListener = new SlideUp.Listener.Slide(){ | ||
@Override | ||
public void onSlide(float v) { | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(v); | ||
} | ||
} | ||
}; | ||
subscriber.add(new MainThreadSubscription() { | ||
@Override | ||
protected void onUnsubscribe() { | ||
mSlideUp.removeSlideListener(eventListener); | ||
} | ||
}); | ||
mSlideUp.addSlideListener(eventListener); | ||
if (!mSlideUp.isAnimationRunning()){ | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(mSlideUp.isVisible() ? 0 : 100f); | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
library/src/main/java/ru/ztrap/rxslideup/SlideUpOnSubscribe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.ztrap.rxslideup; | ||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
import rx.Observable; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
abstract class SlideUpOnSubscribe<T> implements Observable.OnSubscribe<T> { | ||
final SlideUp mSlideUp; | ||
|
||
SlideUpOnSubscribe(SlideUp slideUp){ | ||
mSlideUp = slideUp; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
library/src/main/java/ru/ztrap/rxslideup/VisibilityOnSubscribe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package ru.ztrap.rxslideup; | ||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
import rx.Subscriber; | ||
import rx.android.MainThreadSubscription; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
class VisibilityOnSubscribe extends SlideUpOnSubscribe<Integer> { | ||
|
||
VisibilityOnSubscribe(SlideUp slideUp) { | ||
super(slideUp); | ||
} | ||
|
||
@Override | ||
public void call(final Subscriber<? super Integer> subscriber) { | ||
MainThreadSubscription.verifyMainThread(); | ||
final SlideUp.Listener eventListener = new SlideUp.Listener.Visibility() { | ||
@Override | ||
public void onVisibilityChanged(int v) { | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(v); | ||
} | ||
} | ||
}; | ||
subscriber.add(new MainThreadSubscription() { | ||
@Override | ||
protected void onUnsubscribe() { | ||
mSlideUp.removeSlideListener(eventListener); | ||
} | ||
}); | ||
mSlideUp.addSlideListener(eventListener); | ||
if (!mSlideUp.isAnimationRunning()){ | ||
if(!subscriber.isUnsubscribed()) { | ||
subscriber.onNext(mSlideUp.getSliderView().getVisibility()); | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
library/src/main/java/ru/ztrap/rxslideup/events/SlideUpEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ru.ztrap.rxslideup.events; | ||
|
||
import com.mancj.slideup.SlideUp; | ||
|
||
/** | ||
* @author zTrap | ||
* date 30.05.2017. | ||
*/ | ||
public class SlideUpEvent { | ||
private final float mPercent; | ||
private final int mVisibility; | ||
private final SlideUp mSlideUp; | ||
|
||
public SlideUpEvent(SlideUp slideUp, float percent, int visibility) { | ||
mSlideUp = slideUp; | ||
mPercent = percent; | ||
mVisibility = visibility; | ||
} | ||
|
||
public int visibility() { | ||
return mVisibility; | ||
} | ||
|
||
public float percent() { | ||
return mPercent; | ||
} | ||
|
||
public SlideUp slideUp() { | ||
return mSlideUp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
publish { | ||
dryRun = false | ||
bintrayUser = project.hasProperty('bintray.user') ? project.property('bintray.user') : System.getenv('BINTRAY_USER') | ||
bintrayKey = project.hasProperty('bintray.apikey') ? project.property('bintray.apikey') : System.getenv('BINTRAY_API_KEY') | ||
|
||
userOrg = project.property("POM_ORG_DEVELOPER_ID") | ||
groupId = project.property("GROUP") | ||
artifactId = project.property("POM_ARTIFACT_ID") | ||
publishVersion = project.property("VERSION_NAME") | ||
desc = project.property("POM_DESCRIPTION") | ||
website = project.property("POM_URL") | ||
} |
Oops, something went wrong.