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
class Emitter(private val stateObservable: Observable<State>) { | |
private val subject = BehaviorSubject.create<Data>() | |
init { | |
stateObservable.subscribe { stateChanged(it) } | |
} | |
private fun stateChanged(state: State) { | |
when (state) { |
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
class Emitter { | |
fun defaultStateObservable(): Observable<Data> | |
fun specialStateObservable(): Observable<Data> | |
} |
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
class Emitter { | |
fun defaultStateObservable(): Observable<Data> | |
fun specialStateObservable(): Observable<Data> | |
} |
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
class Emitter(private val stateObservable: Observable<State>) { | |
init { | |
stateObservable.subscribe { stateChanged(it) } | |
} | |
private fun stateChanged(state: State) { | |
} | |
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
class Emitter(private val stateObservable: Observable<State>) { | |
private val subject = BehaviorSubject.create<Data>() | |
private var subscriberCount = AtomicInteger() | |
private val onSubscribeConsumer: (() -> Unit) = { | |
if (subscriberCount.getAndIncrement() == 0) subscribeToObservable() | |
} | |
private val onDisposeConsumer: (() -> Unit) = { | |
if (subscriberCount.decrementAndGet() == 0) unsubscribeFromObservable() | |
} |
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
interface SampleRepository { | |
fun getData(): Observable<Data> | |
} |
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
class SampleRepositoryImpl(private val emitter: Emitter) : SampleRepository { | |
override fun getData(): Observable<Data> = emitter.stateObservable() | |
} |
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
fun recognizeText() { | |
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.image) | |
val visionImage = FirebaseVisionImage.fromBitmap(bitmap) | |
val detector = FirebaseVision.getInstance().visionTextDetector | |
detector.detectInImage(visionImage) | |
.addOnSuccessListener { | |
for (block in it.blocks) { | |
val boundingBox = block.boundingBox | |
val cornerPoints = block.cornerPoints |
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
<provider | |
android:name="android.support.v4.content.FileProvider" | |
android:authorities="${applicationId}.provider" | |
android:exported="false" | |
android:grantUriPermissions="true"> | |
<meta-data | |
android:name="android.support.FILE_PROVIDER_PATHS" | |
android:resource="@xml/provider_paths"/> | |
</provider> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<paths> | |
<files-path | |
name="images" | |
path="." /> | |
</paths> |
OlderNewer