Skip to content

Instantly share code, notes, and snippets.

View drawers's full-sized avatar
🟩
In greenish twilight at the bottom of the Rhine

David Rawson drawers

🟩
In greenish twilight at the bottom of the Rhine
View GitHub Profile
@Tetr4
Tetr4 / ForceCacheOrNetwork.java
Last active February 1, 2020 05:17
How to force a cached or network response on Android with Retrofit + OkHttp
OkHttpClient okHttpClient = new OkHttpClient();
try {
int cacheSize = 10 * 1024 * 1024 // 10 MiB
Cache cache = new Cache(getCacheDir(), cacheSize);
okHttpClient.setCache(cache);
} catch (IOException e) {
Log.e(TAG, "Could not set cache", e);
}
// Forces cache. Used for cache connection
@webserveis
webserveis / material text sizes.md
Last active September 20, 2023 10:10 — forked from passsy/material text sizes.md
Material font sizes

Material text sizes XML for Android

Simple helper file for standard text sizes in material design. The sizes are provided by the material design documentation https://www.google.com/design/spec/style/typography.html#typography-roboto

material typography

Standard Styles

Too many type sizes and styles at once can wreck any layout. A typographic scale is a limited set of type sizes that work well together, along with the layout grid. The basic set of styles are based on a typographic scale of 12, 14, 16, 20, and 34.

@rnkoaa
rnkoaa / FlowableUtils.java
Created January 11, 2017 18:12
Convert a listenable future to an rxjava-2 flowable or single
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.reactivex.*;
/**
* Created on 1/11/2017.
*/
public class FlowableUtils {
@timrijckaert
timrijckaert / ImmediateSchedulersRule.java
Created March 5, 2017 22:35
RxJava2 Rule to change the Schedulers to immediate one. (https://www.infoq.com/articles/Testing-RxJava2)
private static class ImmediateSchedulersRule implements TestRule {
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
RxJavaPlugins.setIoSchedulerHandler(scheduler ->
Schedulers.trampoline());
RxJavaPlugins.setComputationSchedulerHandler(scheduler ->
Schedulers.trampoline());
@LordRaydenMK
LordRaydenMK / ValueClass.kt
Created February 2, 2020 22:09
Kotlin compiler plugin built with arrow-meta. Generates equals, hashCode and toString for classes annotated with @valueclass
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS)
annotation class ValueClass