Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Mochamad Iqbal Dwi Cahyo mochadwi

I may be slow to respond.
View GitHub Profile
mochadwi /
Last active Mar 20, 2020
Passing extras with intent while using intent with action ACTION_GET_CONTENT
mochadwi / SafeActivity.kt
Last active Feb 16, 2020
Wrapper to handle nullable activity and returns non-null activity
View SafeActivity.kt
fun Activity?.safeActivity(action: Activity.() -> Unit) {
val isActivityStillRuns = this != null && (!this?.isDestroyed() || !this?.isFinishing())
if (isActivityStillRuns) {
// usage:
fun initSomething() = this@YourActivity.safeActivity {
val adapter = YourAdapter(this, listOf())
mochadwi /
Last active Apr 5, 2020
Release script to automate versioning and git tagging


  • Add Triple-T dependencies
  • Setup the service account on GCP & link to Play Store (explained in the of Triple-T)
  • Create custom gradle task (to bump version) or see here
  • Use git-flow as branching model


  • Change $VERSION_NAME, $VERSION_CODE, $BUILD_GRADLE_FILE & $MODULE_NAME accordingly to your needs
mochadwi /
Last active Oct 8, 2020
(DEPRECATED) Extracting or Installing an AAB to APK.

DISCLAIMER, in Google Play Console you can download Universal APK directly. No need to use this extracting from AAB to APK method

Download Universal APK from AAB

Please make sure to run this script with your .aab file in the same folder.

The script has the following placeholders, which should be replaced for your specific environment/application:

  • $PASSWORD, $KEYSTORE_FILE, $ALIAS are the details used to sign the .aab in Android Studio
  • $PATH_TO_BUNDLE_TOOL is the path of the bundletool e.g. ~/Downloads/bundletool-all-0.8.0.jar
mochadwi /
Created Nov 21, 2019
Setup and Install JDK 8, 9, 10 in macOS with Homebrew

Oracle now force user to signup and accept the license agreement in the oracle website.

JDK 8 is still mostly used among java developer especially Android Developer.

Unfortunately, if we're on macOS there's a bad news that the homebrew community delete the entire JAVA/JDk cask and give replacement support to use AdoptOpenJDK.

brew tap adoptopenjdk/openjdk

brew cask install adoptopenjdk8
mochadwi / clean_architecture.txt
Created Nov 15, 2019 — forked from gpetuhov/clean_architecture.txt
Clean architecture tutorials (MVC, MVP, MVVM)
View clean_architecture.txt
Detailed intro
Demo project
mochadwi /
Last active Sep 11, 2020
AndroidX manual Migration script: Class, Artifact & Themes

Inpsired by:

Why this?

  • Use the same script, with additional "artifact" mapping (
  • Skip any "build" directory, regardless of module name: app (app/build), abc (abc/build)
  • Support view binding please comment if the class mapping is not updated (official from google also still not updated)
mochadwi /
Last active Mar 26, 2020
Certification - Mochamad Iqbal Dwi Cahyo

Skill Academy - Master Android Programming

Learning Android Arhictecture Components (LiveData, Navigation, Paging, WorkManager), Clean Architecture, Jetpack Compose, Firebase Push Notification.

Skill Academy

Mindorks Bootcamp - Android for Professionals

Building an Instagram apps, understanding the reactive programming (RxJava), clean architecture with MVVM, latest technology of android architecture components, a dependency injection with Dagger.

Mindorks Bootcamp

Kotlin Jetbrains TheAkademy - Kotlin for Android

Coming soon.

mochadwi / adapter.kt
Last active Jul 14, 2019
ObservableField vs. LiveData
View adapter.kt
class Adapter(list: ArrayList<String>) : RecyclerView.ViewHolder(binding.root) {
// 02. using observablefield
// variable binding is your item.xml, generated into -> ItemBinding
lateinit val binding: ItemBinding // this should be defined on your project.
fun changeVariableA(msg: String) {
binding.apply {
message = msg
executePendingBindings() // directly tells the binding to be updated, without delay