Skip to content

Instantly share code, notes, and snippets.

View mochadwi's full-sized avatar
💭
I may be slow to respond.

Mochamad Iqbal Dwi Cahyo mochadwi

💭
I may be slow to respond.
View GitHub Profile
@mochadwi
mochadwi / README.md
Created April 12, 2019 18:51
Android - Getting non-null context on kotlin

buat temen-temen yang akses context dari fragment dengan cara

context!! //karena dia nullable bisa ganti sama ini ya

requireContext() // atau requireActivity()

@mochadwi
mochadwi / README.md
Created April 12, 2019 18:51
Android - RecyclerView detects ends

recycler_news_list.viewTreeObserver .addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { // progress.gone() | onScrollToBottom | aktifitas lainnya

 recycler_news_list.viewTreeObserver.removeOnGlobalLayoutListener(this)
                     }

})

@mochadwi
mochadwi / README.md
Created April 12, 2019 18:49
Android - Pre-lollipop crash
@mochadwi
mochadwi / README.md
Created April 12, 2019 18:43
Speed up gradle build

gradle (level app)

if (project.hasProperty('devBuild')) { splits.abi.enable = true splits.density.enable = true aaptOptions.cruncherEnabled = true }

buildTypes {

release {

@mochadwi
mochadwi / README.md
Created April 12, 2019 18:42
Data binding - SwipeRefereshLayout

@here ini untuk fungsi swiperefreshlayout, jadi kita ga perlu panggil view nya dari fragment, langsung set value dari vm, app:setRefreshing sama app:setOnRefreshListener udah bawaan dari swiperefreshlayoutnya, jadi gausah buat bindingadapter lagi

<android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeRefreshPaginate" android:layout_width="match_parent" android:layout_height="wrap_content" app:setOnRefreshListener="@{()->mListener.onRefresh()}" app:setRefreshing="@{mViewModel.isRequesting}">

@mochadwi
mochadwi / README.md
Created April 12, 2019 18:41
Android Best Practice
@mochadwi
mochadwi / README.md
Created April 12, 2019 18:40
Kotlin - Chained list asSequence

temen2 yg suka ketemu list of data, yuks mulai migrasi, buat large data jadiin sequence, biar maknyuss performance-nya https://itnext.io/kotlin-sequences-c5a3f6228eca

terutama untuk chained function, e.g:

list ?.functionEtc { [predicate] } ?.filter { [predicate] } ?.distinctyBy { [predicate] }