Skip to content

Instantly share code, notes, and snippets.

View dragoncodes's full-sized avatar

Petar Marinov dragoncodes

View GitHub Profile
View WaitForBroadcasts.kt
suspend fun String.waitForBroadcast(
context: Context,
trigger: (() -> Unit)? = null) =
suspendCoroutine<Boolean> { continuation ->
var broadcastReceiver: BroadcastReceiver? = null
try
{
View ScrollAndWait.kt
suspend fun RecyclerView.awaitScrollToPositionWithOffset(position: Int, offset: Int) = suspendCoroutine<Unit> {
val layoutManager = layoutManager as? LinearLayoutManager ?: return@suspendCoroutine it.resume(Unit)
addOnScrollListener(object : RecyclerView.OnScrollListener()
{
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int)
{
super.onScrollStateChanged(recyclerView, newState)
View MenuDefinitions.kt
@DslMarker annotation class MenuConfigurationPart
@Suppress("unused")
fun menuConfig(builder: MenuConfiguration.() -> Unit) = MenuConfiguration(builder)
@MenuConfigurationPart
class MenuConfiguration(
inline val builder: MenuConfiguration.() -> Unit
)
{
View Menu_Header&Content.kt
@MenuConfigurationPart
class MenuHeader
{
lateinit var userEmail: () -> String
val viewControllers: MutableList<AViewController> = mutableListOf()
/**
* [SEPARATOR_SETTING_INVISIBLE] - no separator
* [SEPARATOR_SETTING_FULL_WIDTH] - full width separator
View MenuConfiguration.kt
@DslMarker annotation class MenuConfigurationPart
@Suppress("unused")
fun menuConfig(builder: MenuConfiguration.() -> Unit) = MenuConfiguration(builder)
@MenuConfigurationPart
class MenuConfiguration(
inline val builder: MenuConfiguration.() -> Unit
)
{