Skip to content

Instantly share code, notes, and snippets.

View IlyaGulya's full-sized avatar

Ilya Gulya IlyaGulya

View GitHub Profile
@IlyaGulya
IlyaGulya / HiddenAwareLifecycle.kt
Created April 2, 2024 14:55
Lifecycle implementation that handles fragment hidden state changes
class HiddenAwareLifecycle(
fragment: Fragment,
) : LifecycleRegistry(fragment) {
init {
fragment.lifecycle.addObserver(
object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
currentState = State.CREATED
}
@IlyaGulya
IlyaGulya / Example.kt
Last active December 10, 2021 12:25
Animated image example
@JvmInline
value class ImageId(val id: String)
@Preview
@Composable
fun Test() {
val images = emptyList<ImageId>()
var animatingImageId by remember {
mutableStateOf<ImageId?>(null)
@IlyaGulya
IlyaGulya / MviComponentTemplate.kt
Last active August 17, 2021 09:18
MVIKotlin Component Template
#set($capitalizedFilename = $NAME.substring(0,1).toUpperCase() + $NAME.substring(1))
#set($lowercaseFilename = $NAME.substring(0,1).toLowerCase() + $NAME.substring(1))
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import com.arkivanov.essenty.lifecycle.Lifecycle
import com.arkivanov.essenty.lifecycle.doOnDestroy
import com.arkivanov.mvikotlin.core.binder.BinderLifecycleMode
import com.arkivanov.mvikotlin.core.store.Reducer
import com.arkivanov.mvikotlin.core.store.SimpleBootstrapper
override fun onDestroy() {
super.onDestroy()
if (needCloseScope()) {
// Destroy this fragment with scope
Timber.d("Destroy UI scope: $fragmentScopeName")
Toothpick.closeScope(scope.name)
}
}
// This is android, baby!
/*
* Copyright 2019 Sergey Chelombitko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/articleImage"
android:layout_width="0dp"
android:layout_height="0dp"
[
{
"agency": null,
"amount": 18,
"balance": 24.61,
"correction": null,
"description": "One-time Payment-WIC - Concord",
"entryDate": "",
"entryTime": "",
"entryLane": null,
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 477G 0 disk
├─nvme0n1p1 259:1 0 2G 0 part /boot/efi
├─nvme0n1p2 259:2 0 4G 0 part /boot
└─nvme0n1p3 259:3 0 471G 0 part
└─luks-dc23720e-31b1-402c-982b-65b682e901e8 254:0 0 470.9G 0 crypt
├─main-swap 254:1 0 16G 0 lvm [SWAP]
└─main-root 254:2 0 454.9G 0 lvm /
package ru.campuz.base
import android.databinding.Observable
import android.databinding.ObservableField
fun <T, R> ObservableField<T>.map(mapper: (T?) -> R): ObservableField<R> {
return MappedObservableField(this, mapper)
}
class MappedObservableField<T, R>(
import * as React from "react";
import {inject, observer} from "mobx-react/native";
export class $ComponentName$Presenter extends Presenter {
constructor() {
super();
}
}
export type $ComponentName$PresenterProvider = () => $ComponentName$Presenter