Skip to content

Instantly share code, notes, and snippets.

Avatar
👀
Contributing to open source

Victor Loveday Vicviral

👀
Contributing to open source
View GitHub Profile
@kobeumut
kobeumut / ObserveOnceExtension.kt
Created Apr 21, 2019
Android Livedata Observe Once Only (Kotlin)
View ObserveOnceExtension.kt
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> {
@Vicviral
Vicviral / AsyncTask.java
Created Sep 20, 2021 — forked from vadimTovstik/AsyncTask.java
How to download file to Internal Storage in Android
View AsyncTask.java
//in async task
//usage
// DownloadVideoAsyncTask async = new DownloadVideoAsyncTask(this);
// async.execute("www.site.com/idvideo.mp4");
public class DownloadVideoAsyncTask extends AsyncTask<String, Integer, String> {
private Context mContext;