This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add this line to libs.versions.toml | |
// under [versions] section | |
emoji2-emojipicker = "1.4.0" | |
// under [libraries] section | |
androidx-emoji2-emojipicker = { group = "androidx.emoji2", name = "emoji2-emojipicker", version.ref = "emoji2-emojipicker" } | |
// app-level build.gradle | |
implementation(libs.androidx.emoji2.emojipicker) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun processNullableName(name: String?) { | |
// Force unwrap !! | |
println("Name is: ${name!!}") | |
// Elvis operator ?: | |
println("Name is: ${name ?: "Kotlin"}") | |
// If statement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var name:String? = "Swift" | |
// force un-wrap | |
print("Name is \(name!)") | |
name = nil | |
// nil coalescing operator ?? | |
print("Name is ??: \(name ?? "Swift")") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.google.android.material.materialswitch.MaterialSwitch | |
android:layout_width="match_parent" | |
android:layout_height="48dp" | |
android:layout_margin="24dp" | |
android:checked="true | false" | |
android:text="MaterialSwitch Checked" | |
app:layout_constraintTop_toBottomOf="@id/ms_1" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.google.android.material.checkbox.MaterialCheckBox | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="24dp" | |
android:text="MaterialCheckBox" | |
app:checkedState="unchecked | checked | indeterminate" | |
app:errorShown="true" | |
app:errorAccessibilityLabel="Error label for accessible goes here" | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AndroidView(factory = { context -> | |
MaterialCheckBox(context).apply { | |
text = "Checkbox from 1.7" | |
addOnCheckedStateChangedListener { checkBox, state -> | |
when (state) { | |
STATE_INDETERMINATE -> { | |
stateValue.value = STATE_INDETERMINATE | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MaterialSwitch170(updateCheckStateError: () -> Unit, resetCheckErrorState: () -> Unit) { | |
AndroidView(factory = { context -> | |
MaterialSwitch(context).apply { | |
text = context.resources.getString(R.string.switch_from_1_7) | |
setThumbIconResource(R.drawable.baseline_check_circle_24) | |
setOnCheckedChangeListener { _, isChecked -> | |
when (isChecked) { | |
true -> updateCheckStateError() | |
false -> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
btnClearCheck.setOnClickListener { | |
// set the checkedChangeListener to null | |
rgChoices.setOnCheckedChangeListener(null) | |
rgChoices.clearCheck() | |
// re-set the checkedChangeListener | |
NewerOlder