Skip to content

Instantly share code, notes, and snippets.

View FireZenk's full-sized avatar
🌍
Improving the world

Jorge Garrido FireZenk

🌍
Improving the world
View GitHub Profile
plop.addHelper('lowerCase', (text) => text.toLowerCase());
package {{lowerCase package}}.{{lowerCase feature}};
public class {{properCase feature}}PresenterImpl implements {{properCase feature}}Presenter, {{properCase feature}}Interactor.On{{properCase feature}}FinishedListener {
private {{properCase feature}}View {{lowerCase feature}}View;
private {{properCase feature}}Interactor {{lowerCase feature}}Interactor;
public {{properCase feature}}PresenterImpl({{properCase feature}}View {{lowerCase feature}}View) {
this.{{lowerCase feature}}View = {{lowerCase feature}}View;
this.{{lowerCase feature}}Interactor = new {{properCase feature}}InteractorImpl();
fun isLowMemory(): Boolean {
val memoryLimit: Long = (getTotalInternalMemorySize() * DEFAULT_THRESHOLD_PERCENTAGE) / 100;
return availableMemorySize() <= tenPercentLimit;
}
fun availableMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong()
}
fun totalMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getBlockCountLong() * stat.getBlockSizeLong()
}
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
onTrimMemory(int level)
@Override public void render() {
setupAnimation();
animationTimer.subscribe(timerValue -> startAnimation());
}
public CustomRendererBuilder(PublishSubject<Long> animationTimer) {
ListAdapteeCollection<Renderer<? extends Item>> prototypes = new
ListAdapteeCollection<>();
prototypes.add(new CustomRenderer(animationTimer));
setPrototypes(prototypes);
}
@Override protected Class getPrototypeClass(Item item) {
return CustomRenderer.class;
}