This file contains hidden or 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 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 { |
This file contains hidden or 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
| // build.gradle | |
| apply plugin: EmailPlugin | |
| // build src file | |
| open class EmailPlugin : Plugin<Project> { | |
| override fun apply(project: Project) { | |
| // DO stuff | |
| } | |
| } |
This file contains hidden or 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 interface Presenter<S, V extends StateView<S>> { | |
| void onStart(V view); | |
| void onStop(); | |
| } |
This file contains hidden or 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 class MainActivity extends AppCompatActivity { | |
| private final Disposable disposable = Observable.timer(5, TimeUnit.SECONDS) | |
| .subscribe(o -> | |
| new MyDialogFragment() | |
| .show(getSupportFragmentManager(), "DIALOG_TAG") | |
| ); | |
| @Override | |
| protected void onPause() { |
This file contains hidden or 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 class MainActivity extends AppCompatActivity { | |
| private final PublishSubject<Object> dialogDisplaySubject = PublishSubject.create(); | |
| private final Disposable disposable = dialogDisplaySubject | |
| .subscribe(o -> | |
| new MyDialogFragment() | |
| .show(getSupportFragmentManager(), "DIALOG_TAG") | |
| ); | |
| @Override |
This file contains hidden or 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
| private final PublishSubject<Void> viewClickedSubject = PublishSubject.create(); | |
| private final CompositeSubscription startStopCompositeSubscription = new CompositeSubscription(); | |
| @Override | |
| protected void onStart() { | |
| super.onStart(); | |
| view.setOnClickListener(v-> viewClickedSubject.onNext(null)); | |
| Subscription subscription = viewClickedSubject |
This file contains hidden or 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
| PublishSubject<Void> viewClickedSubject = PublishSubject.create(); | |
| CompositeSubscription startStopCompositeSubscription = new CompositeSubscription(); | |
| protected void onStart() { | |
| view.setOnClickListener(v-> viewClickedSubject.onNext(null)); | |
| Subscription subscription = viewClickedSubject | |
| .flatMap(aVoid-> api.getAlert()) | |
| .subscribe(this::makeAlertToast, Throwable::printStackTrace); |