Skip to content

Instantly share code, notes, and snippets.

View alan-rodriguez's full-sized avatar
🔪
​thou shalt .not()

Alan Rodriguez alan-rodriguez

🔪
​thou shalt .not()
View GitHub Profile
@alan-rodriguez
alan-rodriguez / XViewModel.kt
Last active May 21, 2018 03:53
Transformations extensions for lifecycle-livedata-ktx?
class XViewModel : ViewModel() {
private lateinit var org: LiveData<Int>
val mapped: LiveData<String> = org.map { "Here is a number:$it" }
val switched: LiveData<String> = org.switchMap(::doWork)
private fun doWork(i: Int): LiveData<String> = TODO()
}
@alan-rodriguez
alan-rodriguez / CodeJam.md
Created October 18, 2017 22:31
Kotlin Code Jam Exercise

Kotlin Code Jam

If you're familiar with Material Design, you've probably seen Chris Banes's Cheesesquare sample app. It illustrates the implementation of basic Material Design concepts using Material Components for Android (formerly known as the Design Support Library).

Convert Cheesesquare to Kotlin

Download Android Studio 3.0 and use the wizard to create a new Android project. Be sure to select "Include Kotlin Support"! Then try to port the Cheesesquare app to Kotlin. I suggest trying to do so from scratch on your own, but you can use Android Studio to convert Java code to Kotlin. It does not always result in the most idiomatic Kotlin, so check the output and try to make it more idiomatic.

Bonus: Use Bottom Navigation

Get rid of the Navigation Drawer and use BottomNavigationView to handle the navigation in MainActivity.