Skip to content

Instantly share code, notes, and snippets.

View MossoIsai's full-sized avatar
🏠
Working from home

AR2D2 MossoIsai

🏠
Working from home
  • Morelos, México
View GitHub Profile
@MossoIsai
MossoIsai / ExpiringLruCache.java
Created February 16, 2024 15:12 — forked from christopherperry/ExpiringLruCache.java
LruCache for Android with expiring keys. Instead of modifying LruCache directly I used delegation to get around final keyword usage and a dirty hack to override everything else.
import android.os.SystemClock;
import android.support.v4.util.LruCache;
import java.util.HashMap;
import java.util.Map;
/**
* An Lru Cache that allows entries to expire after
* a period of time. Items are evicted based on a combination
* of time, and usage. Adding items past the {@code maxSize}
@MossoIsai
MossoIsai / instalaciones.md
Created January 16, 2022 03:22 — forked from Klerith/instalaciones.md
Instalaciones necesarias para el curso de Git y GitHub
@MossoIsai
MossoIsai / MainActivity.kt
Created June 17, 2021 14:02 — forked from stevdza-san/MainActivity.kt
Proto DataStore | YouTube Tutorial - https://youtu.be/5_Jy8Alcp14
package com.example.protodatastoretest
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.ViewModelProvider
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
@MossoIsai
MossoIsai / ObserveOnceExtension.kt
Created May 19, 2021 02:33 — forked from kobeumut/ObserveOnceExtension.kt
Android Livedata Observe Once Only (Kotlin)
fun <T> LiveData<T>.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observer<T>) {
observe(lifecycleOwner, object : Observer<T> {
override fun onChanged(t: T?) {
observer.onChanged(t)
removeObserver(this)
}
})
}
//Using
liveData.observeOnce(this, Observer<Password> {