Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Masatoshi Kubode kubode

🤔
View GitHub Profile
View RepositoryHandler.github.kt
import java.net.URI
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.kotlin.dsl.provideDelegate
val RepositoryHandler.github: Project.(repo: String) -> MavenArtifactRepository get() = { repo ->
maven {
url = URI("https://maven.pkg.github.com/$repo")
credentials {
View ArchitectureComponents.kt
val LifecycleOwner.disposeOn: Disposable.(Lifecycle.Event) -> Unit
get() = { disposeEvent -> disposeOn(lifecycle, disposeEvent) }
val LifecycleOwner.autoDispose: Disposable.() -> Unit
get() = { autoDispose(lifecycle) }
View MaskableTextView.kt
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffXfermode
import android.graphics.drawable.Drawable
import android.support.v7.widget.AppCompatTextView
import android.util.AttributeSet
@kubode
kubode / NestedScrollCoordinatorLayout.kt
Created Nov 15, 2017
Nested scroll CoordinatorLayout
View NestedScrollCoordinatorLayout.kt
import android.content.Context
import android.support.design.widget.CoordinatorLayout
import android.support.v4.view.NestedScrollingChild2
import android.support.v4.view.NestedScrollingChildHelper
import android.util.AttributeSet
import android.view.View
class NestedScrollCoordinatorLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
@kubode
kubode / FooTest.kt
Created Nov 8, 2017
Architecture Component immutable model cache pattern
View FooTest.kt
import android.arch.core.executor.testing.InstantTaskExecutorRule
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MediatorLiveData
import android.arch.lifecycle.MutableLiveData
import io.reactivex.subjects.SingleSubject
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import kotlin.test.assertEquals
@kubode
kubode / build.gradle
Created Oct 28, 2017
InstrumentationTestでRxIdlerを使おうとしたがダメだった ref: http://qiita.com/kubode/items/7cfc0767dcc560498725
View build.gradle
android {
buildTypes {
release {
multiDexKeepProguard 'multidex-config.pro'
...
}
}
}
@kubode
kubode / file0.txt
Last active Dec 1, 2017
AndroidOのfindViewByIdの仕様変更 ref: https://qiita.com/kubode/items/c7fe9c091fdf5533d36b
View file0.txt
// こっちだとTextView!!になるので
val text26_1 = findViewById<TextView>(android.R.id.text2)
// 型を明示するほうが良さそう
val text26_2: TextView = findViewById(android.R.id.text2)
@kubode
kubode / Diff.kt
Created Jul 20, 2017
DiffUtilを使ってRecyclerView.Adapterをいい感じにする ref: http://qiita.com/kubode/items/92c1190a6421ba055cc0
View Diff.kt
interface Diffable {
// otherと同じIDを持つかどうか
fun isTheSame(other: Diffable): Boolean = equals(other)
// otherと完全一致するかどうか
fun isContentsTheSame(other: Diffable): Boolean = equals(other)
}
private class Callback(
val old: List<Diffable>,
val new: List<Diffable>
@kubode
kubode / build.gradle
Last active May 18, 2017
Android Studio 3.0でのプロジェクト作成時の変更点 ref: http://qiita.com/kubode/items/b87f3a3cc1abc1616423
View build.gradle
android {
...
sourceSets.all {
java.srcDirs += "src/${name}/kotlin"
}
}