This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Usually we define the dagger component in custom application class, which will init before any activity. 1. Create Custom Application Class class SmartPhoneApplication: Appl…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Please read this article first. If the MemoryCardModule has a parameter memorySize, @Module class MemoryCardModule(private val memorySize: Int) { @Provides fun providesMemor…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In this article we introduced created an abstract function getSmartPhone() and call it to get SmartPhone instance. We can also inject it into another class. This article I'l…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Please read last article before reading this one. Assuming class SmartPhone has another dependency Battery, and Battery is an interface, NickelCadmiumBattery is its implemen…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In last article we mentioned we need to add @Inject before dependency class's constructor. However some classes might came from 3rd party library, then we cannot modify them…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Import Dagger Please check this note 2. Change Class's Constructor Before: class SmartPhone(...) { ... } After: class SmartPhone @Inject constructor(...) { ... } 3. Creat…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. val parallelRequest = listOf(request1A, request1B) workManager .beginWith(parallelRequest) .then(request2) .then(request3) .enqueue()
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Read Work Manager - One Time Request link 2. Modify UploadWorker class UploadWorker(context: Context, params: WorkerParameters): Worker(context, params) { override fun do…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Read Work Manager - One Time Request link 2. Write Function private fun setPeriodicWorkRequest() { val periodicWorkRequest = PeriodicWorkRequest .Builder(UploadWorker::cl…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Read previous note note 2. Add User Permissions in AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 3. Edit Function SetOn…</uses-permission></uses-permission>
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Set up Gradle for Work Manager Please check this note. 2. Create Worker Class class UploadWorker(context: Context, params: WorkerParameters): Worker(context, params) { ov…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In AndroidManifest.xml, add: <manifest ...> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> ... </manifest> In MainActivity.kt: class MainActivity : AppCompatActivity() { private val channelID = "com.mxy.notif…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Set up Gradle Check this note. 2. Set up Internet Permissions Check this note. 3. Create Class RetrofitInstance class RetrofitInstance { companion object { val BASE_URL =…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Go to Settings of Android Studio, add the plugin "JSON To Kotlin Class). 2. Right click a folder, now under "New" option we have an option "Kotlin data class File from JS…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In AndroidManifest.xml: <manifest ...> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> </uses-permission></uses-permission></manifest>
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. For example, in table "student_info", we want to change column "student_course" to "student_subject". @Database(entities = [Student::class], version = 2, autoMigrations = [ …
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. We want to add email to the Student entity. 1. Edit Entity Origin: @Entity(tableName = "student_info") data class Student( @PrimaryKey(autoGenerate = true) @ColumnInfo(name …
Constrains: Cannot user @Attribute(.unique). All properties must have default values or be optional. All relationships must be optional. Process: Add iCloud capability, check CloudKit option, provide it a CloudKit container. Add Background…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Entity @Entity(tableName = "subscriber_data_table") data class Subscriber( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "subscriber_id") val id: Int, @ColumnInfo(name…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Enable DataBinding android { dataBinding { enable = true } } Kapt plugins { id("kotlin-kapt") } Lifecycle Reference dependencies { val lifecycle_version = "2.8.0" // ViewMod…
1. Create a file PreviewContainer @MainActor let previoewContainer: ModelContainer = { do { let container = try ModelContainer(for: Match.self, configurations: ModelConfiguration(isStoredInMemoryOnly: true)) let match = Match(...) containe…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. A Live Data Builder can execute a coroutine block and set the value to the live data attributes. Example: class MainActivityViewModel: ViewModel() { private val usersReposit…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. LifeCycleScope is similar to ViewModelScope, just it is used for life cycle owner (e.g. Activity, Fragment). Usage: lifeCycleScope { ... }
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. When not using ViewModelScope: class MainActivityViewModel: ViewModel() { private val myJob = Job() private val myScope = CoroutineScope(Dispatchers.IO + myJob) fun getUserD…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Assume we have these two function, private suspend fun getStock1(): Int { delay(1000) return 2 } private suspend fun getStock2(): Int { delay(2000) return 3 } and we want to…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. CoroutineScope(Dispatchers.IO).launch { // heavy tasks withContext(Dispatchers.Main) { // UI changes } }
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Import Coroutine Latest version can be found here. In app's build.gradle, add the dependencies: dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-co…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Add Recycler View Create a new project and drag a recycler view component to activity_main.xml, give it id name "recyclerView". 2. Create a Layout for List Item Name it l…
This is my note for Udemy lesson: Advanced Android Bootcamp 2024. First, check my previous note Then in HomeFragment, do: val bundle = bundleOf("user_name" to binding.editTextText.text.toString()) it.findNavController().navigate(R.id.actio…