Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.
- Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build
mkdir -p frameworks/base
package de.apuri.boing | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.Spring | |
import androidx.compose.animation.core.spring | |
import androidx.compose.foundation.BorderStroke | |
import androidx.compose.foundation.gestures.awaitFirstDown |
import androidx.lifecycle.get | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProvider | |
import androidx.lifecycle.ViewModelStore | |
import androidx.lifecycle.ViewModelStoreOwner | |
/** | |
* Returns a property delegate to access the wrapped value, which will be retained for the | |
* duration of the lifecycle of this [ViewModelStoreOwner]. | |
* |
Build "Sources for Android 29" so you can comfortably browse the Android API source in Android Studio.
mkdir android-sdk-source-build
cd android-sdk-source-build
mkdir -p frameworks/base
/* | |
MIT License | |
Copyright (c) 2019 Erik Hellman | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
import kotlinx.coroutines.experimental.android.Main | |
import kotlinx.coroutines.experimental.CoroutineScope | |
class ExampleActivity : Activity(), CoroutineScope by CoroutineScope(Dispatchers.Main) { | |
override fun onCreate(savedInstanceState: Bundle?) | |
super.onCreate(savedInstanceState) | |
val ui = Ui(this) // bind views, etc | |
val alphabets1 = Observable.intervalRange(0, 1, 1, 1, TimeUnit.SECONDS).map { id -> "A" + id } | |
val alphabets2 = Observable.intervalRange(0, 2, 2, 1, TimeUnit.SECONDS).map { id -> "B" + id } | |
Observable.zip(alphabets1, alphabets2, | |
BiFunction<String, String, String> { t1, t2 -> "$t1 $t2" }) | |
.subscribe(object : Observer<String> { | |
override fun onComplete() { | |
println("onComplete") | |
} |
#!/usr/bin/env bash | |
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very | |
# well, so I wrote my own script to do the simple job of converting package names. | |
# | |
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv | |
# | |
# It'll run faster on a clean build because then there are fewer files to scan over. | |
# | |
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`. |
public class MyItemDecoration extends RecyclerView.ItemDecoration { | |
private static final int[] ATTRS = new int[]{ android.R.attr.listDivider }; | |
private Drawable mDivider; | |
public MyItemDecoration(Context context) { | |
TypedArray a = context.obtainStyledAttributes(ATTRS); | |
mDivider = a.getDrawable(0); | |
a.recycle(); |
@file:Suppress("unused", "FunctionName", "IllegalIdentifier") | |
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.content.Context | |
import android.content.Intent | |
import android.os.Bundle | |
/** | |
* The best way to launch yourself an activity. Your implementation should enable the following api: |
class App : Application(), HasActivityInjector { | |
@Inject lateinit var activityInjector: DispatchingAndroidInjector<Activity> | |
override fun activityInjector(): AndroidInjector<Activity> { | |
return activityInjector | |
} | |
override fun onCreate() { | |
super.onCreate() |