Skip to content

Instantly share code, notes, and snippets.

View droidchief's full-sized avatar
🦾
Currently shipping on gitlab

Victor Loveday (Droid) droidchief

🦾
Currently shipping on gitlab
View GitHub Profile
@droidchief
droidchief / AsyncTask.java
Created September 20, 2021 14:57 — forked from dynoChris/AsyncTask.java
How to download file to Internal Storage in Android
//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;
@kobeumut
kobeumut / ObserveOnceExtension.kt
Created April 21, 2019 08:24
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> {