This file contains 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
@BindingAdapter( | |
"multipleSpannedText" | |
) | |
fun setCommentItem( | |
textView: TextView, | |
multipleSpannedText: String | |
) { | |
val clickableSpanText = commentItem.comment.formattedComment | |
val clickableSpan = object : ClickableSpan() { |
This file contains 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 Any?.isNull(): Boolean { | |
return this == null | |
} | |
fun Any?.isNotNull(): Boolean { | |
return this != null | |
} |
This file contains 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 androidx.compose.ui.semantics.Role | |
import androidx.compose.ui.semantics.SemanticsProperties | |
import androidx.compose.ui.semantics.getOrNull | |
import androidx.compose.ui.test.SemanticsMatcher | |
// needs import below | |
// debugImplementation 'androidx.compose.ui:ui-test-manifest:1.0.0-beta05' | |
// from Yasin Kaçmaz : https://proandroiddev.com/test-jetpack-compose-layouts-easily-with-role-semanticproperty-dcf19f64130f | |
fun withRole(role: Role) = SemanticsMatcher("${SemanticsProperties.Role.name} contains '$role'") { |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<set xmlns:android="http://schemas.android.com/apk/res/android" | |
android:duration="@android:integer/config_longAnimTime" | |
android:fillAfter="true" | |
android:interpolator="@android:anim/overshoot_interpolator"> | |
<translate | |
android:fromYDelta="100%" | |
android:toYDelta="0%" /> |
This file contains 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
class CustomView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : ConstraintLayout(context, attrs, defStyleAttr) { | |
private var binding: CustomViewBinding | |
private var typedArray: TypedArray | |
init { |
This file contains 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 View.setDelayedJob(delayInMillis: Long, operation: () -> Unit): Job { | |
return CoroutineScope(Dispatchers.IO).launch { | |
delay(delayInMillis) | |
CoroutineScope(Dispatchers.Main).launch { | |
operation.invoke() | |
} | |
} | |
} |
This file contains 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
when (val result = queryList) { | |
is Result.Error -> {} | |
is Result.Loading -> {} | |
is Result.Success -> { | |
val mydata = result.data | |
// .. | |
} | |
} |
This file contains 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
/** | |
* Returns this List if it's not `null` and the empty list otherwise. | |
* @sample samples.collections.Collections.Lists.listOrEmpty | |
*/ | |
@kotlin.internal.InlineOnly | |
public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList() |
This file contains 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 Context.buildAlertDialog( | |
@StringRes title: Int? = null, | |
@StringRes message: Int? = null, | |
@StringRes setPositiveButton: Int? = null, | |
@StringRes setNegativeButton: Int? = null, | |
onPositiveSelected: (() -> Unit)? = null, | |
onNegativeSelected: (() -> Unit)? = null | |
): MaterialAlertDialogBuilder { |
This file contains 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
data class FragmentData(val pageId: String) | |
OlderNewer