Skip to content

Instantly share code, notes, and snippets.

View alphater's full-sized avatar
:octocat:
I may be slow to respond.

alphater alphater

:octocat:
I may be slow to respond.
View GitHub Profile
@anastr
anastr / FilesDownloader.kt
Last active September 30, 2024 03:16
multi-file downloader with progress event
import android.content.Context
import android.util.Log
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers
import io.reactivex.rxjava3.subjects.PublishSubject
import okhttp3.MediaType
import okhttp3.OkHttpClient
@antonis
antonis / WebViewHeight.kt
Created May 22, 2019 11:31
Various ways to get the height of a Webview on Android. Nothing really works on all cases
import android.view.ViewTreeObserver
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
// Try 1
private fun getHeightFromDocumentBodyScrollHeight(webView: WebView, setHeight: (Int)->Unit) {
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
@JCarlosR
JCarlosR / PreferenceHelper.kt
Last active October 10, 2024 04:36 — forked from krupalshah/PreferenceHelper.kt
Helper for shared preferences management - Kotlin version
package com.programacionymas.helpers
import android.content.Context
import android.content.SharedPreferences
import android.preference.PreferenceManager
object PreferenceHelper {
fun defaultPrefs(context: Context): SharedPreferences
= PreferenceManager.getDefaultSharedPreferences(context)
@piruin
piruin / DrawableCompat.kt
Last active November 25, 2024 07:36
Kotlin Extension for set/get compound Drawable to TextView/EditText/Button as property
/*
* Copyright 2017 Piruin Panichphol
*
* 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