Skip to content

Instantly share code, notes, and snippets.

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
Last active Mar 20, 2020
Passing extras with intent while using intent with action ACTION_GET_CONTENT
View README.md
@mochadwi
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) {
action.invoke()
}
}
// usage:
fun initSomething() = this@YourActivity.safeActivity {
val adapter = YourAdapter(this, listOf())
@mochadwi
mochadwi / README.md
Last active Apr 5, 2020
Release script to automate versioning and git tagging
View README.md

Pre-requisites

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

Notes

  • Change $VERSION_NAME, $VERSION_CODE, $BUILD_GRADLE_FILE & $MODULE_NAME accordingly to your needs
  • VERSION_NAME="vX.Y.Z"
@mochadwi
mochadwi / README.md
Last active Oct 8, 2020
(DEPRECATED) Extracting or Installing an AAB to APK.
View README.md

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
mochadwi / README.md
Created Nov 21, 2019
Setup and Install JDK 8, 9, 10 in macOS with Homebrew
View README.md

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
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
https://medium.com/@dmilicic/a-detailed-guide-on-developing-android-apps-using-the-clean-architecture-pattern-d38d71e94029
Demo project
https://github.com/android10/Android-CleanArchitecture
https://github.com/googlesamples/android-architecture
https://github.com/antoniolg/androidmvp
@mochadwi
mochadwi / README.md
Last active Sep 11, 2020
AndroidX manual Migration script: Class, Artifact & Themes
View README.md

Inpsired by:

Why this?

  • Use the same script, with additional "artifact" mapping (androidx-migrator-artifact.sh)
  • 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
mochadwi / README.md
Last active Mar 26, 2020
Certification - Mochamad Iqbal Dwi Cahyo
View README.md

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
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
}