Skip to content

Instantly share code, notes, and snippets.

View StuStirling's full-sized avatar

Stu Stirling StuStirling

View GitHub Profile
@iamriajul
iamriajul / GlideImageGetter.kt
Last active October 16, 2023 05:48
Custom Html.ImageGetter to load images in TextView HTML tags using Glide
/*
* Based on java code by Yaser Rajabi https://gist.github.com/yrajabi
*/
package org.dailyislam.android.utils.extenstions
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.text.Html.ImageGetter
@rharter
rharter / InjectableActivityScenario.kt
Created July 19, 2019 15:27
An ActivityScenario that allows you to use Dagger Android's automatic, lifecycle based injection without making your Application class `open`, or overriding it in tests.
package com.pixite.pigment.testing
import android.app.Activity
import android.app.Instrumentation
import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
@lopspower
lopspower / README.md
Last active May 10, 2024 17:08
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@alex-shpak
alex-shpak / Interceptor.java
Last active March 29, 2023 21:06
Refreshing OAuth token with okhttp interceptors. All requests will wait until token refresh finished, and then will continue with the new token.
private class HttpInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
//Build new request
Request.Builder builder = request.newBuilder();
builder.header("Accept", "application/json"); //if necessary, say to consume JSON