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 TestUi() { | |
| val scrollState = rememberScrollState() | |
| val buttonTag = "buttons" | |
| val contentTag = "content" | |
| Layout( | |
| modifier = Modifier | |
| .fillMaxSize() | |
| .verticalScroll(scrollState), | |
| content = { |
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
| suspend fun LazyListState.animateScrollToItemCenter(index: Int) { | |
| var itemOffsetToCenter = layoutInfo.resolveItemOffsetToCenter(index) | |
| if (itemOffsetToCenter != null) { | |
| animateScrollToItem(index, itemOffsetToCenter) | |
| return | |
| } | |
| val containerSize = layoutInfo.viewportSize.height - layoutInfo.beforeContentPadding - layoutInfo.afterContentPadding | |
| // смещение чтобы сделать айтем видимым хотябы немного | |
| val offsetMagic = 50 | |
| // делает прыжок до айтема чтобы он был виден и могли узнать его размер |
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
| suspend fun <T> waitForCrt( | |
| frequencyMs: Long = 60, | |
| timeoutMs: Long = 5_000, | |
| allowedExceptions: Set<Class<out Any>> = setOf(), | |
| sleepAction: suspend (frequencyMs: Long) -> Unit = { delay(it) }, | |
| onWaiterRetry: (e: Throwable) -> Unit = {}, | |
| action: suspend () -> T | |
| ): T { | |
| var caughtAllowedException: Throwable | |
| val startTime = System.currentTimeMillis() |
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
| class View { | |
| fun show(s: String) { println(s) } | |
| } | |
| // Coroutines | |
| class Presenter1( | |
| private val context: CoroutineContext | |
| ) { | |
| private val scope = CoroutineScope(SupervisorJob() + context) |
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
| // RxJava | |
| val disposable = CompositeDisposable() | |
| disposable += Single.just("Hello world!") | |
| .delay(10, TimeUnit.SECONDS, Schedulers.io()) | |
| .subscribe { | |
| println(it) | |
| } | |
| disposable.clear() |
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
| suspend fun calculate(): Int { | |
| throw ArithmeticException() | |
| } | |
| // bad | |
| suspend fun test1() { | |
| try { | |
| calculate() | |
| } catch (e: Throwable) { | |
| println(e) |
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
| { | |
| "format": "pbf", | |
| "name": "OpenMapTiles", | |
| "attribution": "<a href=\"https://www.maptiler.com/copyright/\" target=\"_blank\">© MapTiler</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">© OpenStreetMap contributors</a>", | |
| "bounds": [ | |
| -180, | |
| -85.0511, | |
| 180, | |
| 85.0511 | |
| ], |