Skip to content

Instantly share code, notes, and snippets.

View Sethathi's full-sized avatar
🏗️

Sethathi Morokole Sethathi

🏗️
View GitHub Profile
// 1. What would happen if a user pressed back button before `fetchProfileDetailsFromServer` completes
// 2. How can we improve this code?
class ProfileActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profile)
loadProfileDetails()
}
<!-- How could we optimise this? -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_top"
android:text="Full Name"
<!-- What's wrong with this layout, how can it be improve? -->
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/fullnameLayout"
# Which dispatcher should be used for which use case?
## Dispatchers
a) Dispatchers.Main
b) Dispatchers.IO
c) Dispatchers.Default