Created
April 1, 2016 09:18
-
-
Save wutianlong/588f8061579cd33461078919912f1685 to your computer and use it in GitHub Desktop.
DoubleClick----RxJava
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
public void doubleClickDetect(View view){ | |
Observable<Void> observable = RxView.clicks(view).share(); | |
observable.buffer(observable.debounce(200, TimeUnit.MILLISECONDS)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new Action1<List<Void>>() { | |
@Override | |
public void call(List<Void> voids) { | |
if(voids.size() >= 2){ | |
//double click detected | |
} | |
} | |
}, new Action1<Throwable>() { | |
@Override | |
public void call(Throwable throwable) { | |
Timber.e(throwable, "error"); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
reference Url : http://sixwolf.net/blog/2016/03/31/%E6%B5%85%E6%9E%90ReactiveX%E7%9A%84%E5%A4%9A%E6%92%AD/#reactivex