Skip to content

Latest commit

 

History

History
136 lines (110 loc) · 6.64 KB

README.md

File metadata and controls

136 lines (110 loc) · 6.64 KB

Kotlin.Android

Meme

Android recommended architecture

Android Architecture

Clean architecture

Architecture layers

MVVM

Repository

NB

Independence of UI and datasource (database or api)

Nice to have

Reading matter

Productivity

udacity

Apps

Gotchas

var vs val

var can be assigned to multiple times, whereas val can be initialized or assigned to only once.
The @={} notation, which importantly includes the "=" sign, receives data changes to the property and listen to user updates at the same time.

If you create a binding adapter for a LiveData property in your viewModel, you do not need to give the binding adapter the LiveData type, just the inner type. Eg:

Fragment

@BindingAdapter(value =["searchResults"])
fun setArchiveTextVisibility(textView: TextView, searchResults: PagedList<StorySummary>?){
    textView.visibility = if(searchResults.isNullOrEmpty()) View.VISIBLE else View.GONE
}

Viewmodel

val searchResults: LiveData<PagedList<StorySummary>>

fragment_search.xml

<TextView
    app:searchResults="@{viewModel.searchResults}"
    />

Packages

Packages group related classes. Packages are declared with the package keyword, and any Kotlin file with a package declaration at the beginning can contain declarations of classes, functions, or interfaces. (Equivalent of C# namespaces)

Command line compilation

Command line without bothering about path variables