【发布时间】:2017-07-09 19:12:28
【问题描述】:
我正在尝试将触摸处理程序添加到FabricView,但似乎这样做我无法再绘制草图了。事实上,FabricView 本身定义了一个 Touch 处理程序,但似乎我的尝试 - 使用 RxAndroid2 - 清除了预定义的处理程序,而不是链接到它。
我想要的是能够使用我的处理程序,而无需清除现有的处理程序。
这是我主要活动的一部分(sketchview 是 FabricView 的一个实例)
sketchView.backgroundMode = FabricView.BACKGROUND_STYLE_NOTEBOOK_PAPER
RxView.touches(sketchView, {_ -> true}).subscribe { // setting to false let me sketch, but I don't get any toast
event -> when(event.action){
MotionEvent.ACTION_DOWN -> {
toast("Starting")
}
MotionEvent.ACTION_UP -> {
toast("Stopping")
}
else -> {}
}
}
这是我的 app.gradle 的摘录:
compile 'com.github.antwankakki:FabricView:latest'
compile 'com.rmtheis:tess-two:7.0.0'
compile "io.reactivex.rxjava2:rxjava:2.1.0"
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile "org.jetbrains.anko:anko-commons:$anko_version"
为了使用 FabricView,我们必须在根 gradle 构建的 allProjects 部分中包含 JitPack。
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
maven { url "https://jitpack.io" }
}
}
【问题讨论】:
标签: kotlin rx-android