Skip to content

Instantly share code, notes, and snippets.

View yaraki's full-sized avatar
🏠
Working from home

Yuichi Araki yaraki

🏠
Working from home
  • Google, Inc.
  • Tokyo
View GitHub Profile
@yaraki
yaraki / CreateLiveData.kt
Created July 9, 2018 06:44
LiveData + Kotlin Coroutines
package io.github.yaraki.coroutineex
import android.arch.lifecycle.LiveData
import android.content.Context
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.channels.SendChannel
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
@yaraki
yaraki / fluent.kt
Created July 11, 2018 13:07
Fluent testing for Kotlin in Japanese
package io.github.yaraki.superfluent
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.greaterThan
import org.junit.Test
class Sample {
@yaraki
yaraki / MainViewModel.kt
Created September 21, 2018 05:12
SharedPreferences as LiveData
package io.github.yaraki.playground
import android.app.Application
import android.arch.lifecycle.AndroidViewModel
import android.content.Context
class MainViewModel(application: Application) : AndroidViewModel(application) {
companion object {
const val PREF = "main"
@yaraki
yaraki / LiveDataWithTimeout.kt
Last active September 15, 2020 18:06
LiveData with timeout
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yaraki
yaraki / MainViewModel.kt
Created September 28, 2018 07:24
FPS as LiveData (with coroutine)
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@yaraki
yaraki / FirestoreLiveData.kt
Created May 20, 2019 07:53
Firebase Query as LiveData
/**
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
package com.example.firestore
import android.util.Log
import androidx.lifecycle.LiveData
import com.google.firebase.firestore.*
@yaraki
yaraki / FlowTest.kt
Created August 8, 2019 07:07
Sleep sort
package com.example.android.flow
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
@yaraki
yaraki / CoroutineTest.kt
Created August 14, 2019 12:50
Channel vs. Flow
package com.example.playground
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.produce
import kotlinx.coroutines.channels.toList
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.single
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.yield
package io.github.yaraki.miscex
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
@yaraki
yaraki / MainActivity.kt
Last active February 26, 2021 10:22
Just an idea
package com.example.android.codelab.animationdemo
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box