Skip to content

Instantly share code, notes, and snippets.

View tim4dev's full-sized avatar

Yuriy Tim tim4dev

View GitHub Profile
/*
* Copyright (c) 2024 Yuriy Timofeev <developer.tim4dev@gmail.com>
*
* Distributed under the Apache License 2.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
@tim4dev
tim4dev / UiState.kt
Created August 31, 2023 21:23
UiState
/*
* 2021 Yuriy Timofeev <intelligence.worker@gmail.com>.
*/
sealed class UiState<out T> where T : Any? {
object Loading : UiState<Nothing>()
data class Success<T>(val data: T) : UiState<T>()
@tim4dev
tim4dev / KeyboardObserver.kt
Last active April 29, 2022 04:39
Android keyboard state observer.
/**
* Android keyboard state observer.
* For portrait orientation only.
* https://bit.ly/3flvZar
* 2020 intelligence.worker@gmail.com.
*
* Example of usage:
* viewLifecycleOwner.lifecycleScope.launch {
* this@MyFragment.view?.run {
* KeyboardObserver().observe(your_root_view_here).distinctUntilChanged().collect { ... }