Skip to content

Instantly share code, notes, and snippets.

View GianpaMX's full-sized avatar

Juan Russell GianpaMX

View GitHub Profile
operator fun invoke(): Flow<State> = timeApi
.ticker()
.combine(transitionApi.observeTransitionLog()) { now, transition ->
transition.toState(now)
}
.distinctUntilChanged()
.onEach {
try {
if (it is State.Pomodoro) turnOnZenMode() else turnOffZenMode()
} catch (e: Exception) {
@Provides
fun provideTimeApi() = object : TimeApi {
override fun now() = Instant.now().epochSecond.toInt()
override fun ticker(): Flow<Int> = kotlinx.coroutines.channels
.ticker(1_000)
.receiveAsFlow()
.map { now() }
}
@GianpaMX
GianpaMX / .bash_profile
Created January 15, 2020 16:24
Android Dev Env
$ cat .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="/usr/local/sbin:$PATH"
export PATH="/usr/local/bin:${PATH}"
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
export ANDROID_HOME="/usr/local/share/android-sdk"
export ANDROID_NDK="$ANDROID_HOME/ndk-bundle"
env:
global:
- ANDROID_HOME=$HOME/android-sdk
- ANDROID_SDK_ROOT=$ANDROID_HOME
- PATH=$ANDROID_HOME/tools/bin:$PATH
- PATH=$ANDROID_HOME/platform-tools:$PATH
- PATH=$ANDROID_HOME/emulator:$PATH
language: java
jdk:
- oraclejdk8
class Presenter {
fun m() {
val questions = if(version == j) [ {A.text="English"}, {B}, {C} ] else [ {A.text = "japones"}, {B}, {C}, {D}]
view.showQuestions(questions)
}
}
interface View {
class FormActivityTest {
companion object {
val ANY_NAME = "Gianpa"
val ANY_PHONE = "5512341234"
}
// For dealing with threads and ViewModels
@Rule
@JvmField
android {
...
defaultConfig {
...
testInstrumentationRunner "io.github.gianpamx.android.architecture.CustomTestRunner"
...
}
...
class CustomTestRunner : AndroidJUnitRunner() {
@Throws(InstantiationException::class, IllegalAccessException::class, ClassNotFoundException::class)
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
return super.newApplication(cl, TestApp::class.java!!.getName(), context)
}
}
interface TestAppComponent {
...
fun inject(formActivityTest: FormActivityTest)
...
}