Skip to content

Instantly share code, notes, and snippets.

View konmik's full-sized avatar

Konstantin Mikheev konmik

View GitHub Profile
@konmik
konmik / gist:6ac725fa7134402539c4
Last active September 8, 2020 21:36
Dagger 2 injection with inheritance
/**
* This class allows to inject into objects through a base class,
* so we don't have to repeat injection code everywhere.
*
* The performance drawback is about 0.013 ms per injection on a very slow device,
* which is negligible in most cases.
*
* Example:
* <pre>{@code
@konmik
konmik / gist:54c862feb512fc4fe01d
Created December 25, 2014 19:05
StringDiskLruCache based on Jake Warthon's DiskLruCache
public class StringDiskLruCache {
private static final int EXPIRATION = 1000 * 60 * 60 * 24;
private static final int DATA_INDEX = 0;
private static final int EXPIRATION_INDEX = 1;
private static final int INDEXES_COUNT = 2;
private Context context;
private DiskLruCache cache;