Skip to content

Instantly share code, notes, and snippets.

View Diolor's full-sized avatar

Dionysis Lorentzos Diolor

View GitHub Profile
@Diolor
Diolor / FilterButtonActivity.java
Created March 18, 2017 02:36
FilterButtonActivity
class MyActivity extends Activity implements StateView<FilterButtonState> {
private Button button;
@Inject
FilterButtonPresenter presenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// set some content views
Component.activity(this).inject(this); // dagger 2 injection
// build.gradle
apply plugin: EmailPlugin
// build src file
open class EmailPlugin : Plugin<Project> {
override fun apply(project: Project) {
// DO stuff
}
}
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
subject
.subscribeOn(Schedulers.computation())
.subscribe {
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
Observable
.merge(
just(Unit).subscribeOn(Schedulers.computation()),
just(Unit).subscribeOn(Schedulers.io())
)
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
Observable
.merge(
just(Unit),
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
Observable
.combineLatest(
subject.subscribeOn(io()),
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
Observable
.combineLatest(
just(Unit).observeOn(io()),
just(Unit).observeOn(computation())
) { _, _ ->
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
val connectable = subject
.observeOn(io())
.replay().refCount()
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val connectable = just(Unit)
.replay().refCount()
connectable
.subscribeOn(computation())
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val connectable = just(Unit)
.replay().refCount()
connectable
.subscribeOn(newThread())