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
import android.app.Activity | |
import androidx.fragment.app.Fragment | |
import android.app.Application | |
import android.app.Service | |
import android.view.View | |
import android.view.ViewParent | |
import com.bluelinelabs.conductor.Controller | |
import dagger.MapKey | |
import dagger.Module | |
import dagger.multibindings.Multibinds |
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
@Reusable | |
class RxKeyboardManager(private val activity: Activity, private val mainThread: Scheduler, private val imm: InputMethodManager) { | |
val keyboardStates = Observable.create<Boolean>({ | |
val globalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener { it.onNext(isKeyboardShown()) } | |
it.setCancellation { activity.window.decorView.viewTreeObserver.removeOnGlobalLayoutListener(globalLayoutListener) } | |
activity.window.decorView.viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener) | |
}, Emitter.BackpressureMode.LATEST) | |
.distinctUntilChanged() | |
.subscribeOn(mainThread) | |
.share() |
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 ComponentDependencies | |
inline fun <reified T : ComponentDependencies> Controller.findComponentDependencies(): T { | |
var currentController: Controller? = parentController | |
while (currentController !is HasComponentDependencies?) { | |
currentController = currentController?.parentController | |
} | |
val hasDaggerProviders = currentController ?: when { |
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 StupidIterator(val source: Iterator<*>): Iterator<String> { | |
private var nextElement: Any? = null | |
init { | |
acquireNextElement() | |
} | |
private fun acquireNextElement() { | |
nextElement = if (source.hasNext()) source.next().let { if (it is Iterator<*>) StupidIterator(it) else it } else null | |
} |
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
package com.tagakov.avdplayground | |
import android.animation.Animator | |
import android.animation.AnimatorSet | |
import android.animation.ValueAnimator | |
import android.os.Bundle | |
import android.os.Handler | |
import android.support.graphics.drawable.AnimatedVectorDrawableCompat | |
import android.support.v7.app.AppCompatActivity | |
import android.widget.ImageView |
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
typealias YourController = ListEditorController | |
//do not forget to rename component and module | |
//do not forget to add module to parent component | |
//do not forget to add HasControllerInjector to parent entity [Application, Activity, Controller] if not present | |
@Subcomponent(modules = [ComponentModule::class]) | |
interface RenameMeComponent : AndroidInjector<YourController> { | |
@Subcomponent.Builder | |
abstract class Builder : AndroidInjector.Builder<YourController>() |
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
typealias Epic<State> = (actions: Observable<Action>, currentState: CurrentState<State>) -> Observable<Action> | |
typealias CurrentState<State> = () -> State | |
class EpicMiddleware<State: Any> constructor(): Middleware<State> { | |
private val epics = PublishSubject.create<Epic<State>>() | |
override fun invoke(store: Store<State>, nextDispatcher: Dispatcher) : Dispatcher { | |
val actions = PublishSubject.create<Action>() | |
epics |
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 class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(new FrameLayout(this) {{ | |
setId(42); | |
}}); | |
if (savedInstanceState == null) { |
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 <T> magic(jobs: Observable<Completable>, hot: Observable<T>): Observable<T> { | |
return Observable.switchOnNext(jobs.map { it.andThen(hot) }.startWith(hot)) | |
} |
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
#!/usr/bin/env bash | |
REMOTE_MACHINE=${1} | |
APPLICATION_MODULE=${2} | |
ASSEMBLE_COMMAND=${3} | |
ASSEMBLE_TESTS_COMMAND=${4} | |
ANDROID_SDK_VERSION=${5} |
NewerOlder