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
PublishSubject<Long> animationTimer;
Subscription animationSubscription;
animationSubscription = Observable.interval(1, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.newThread())
.subscribe(animationTimer = PublishSubject.create());
@Override public void onDestroy() {
if (!animationSubscription.isUnsubscribed()) {
super.onDestroy();
animationSubscription.unsubscribe();
}
}
CustomRendererBuilder rendererBuilder = new CustomRendererBuilder(animationTimer)
RVRendererAdapter adapter = new RVRendererAdapter<>(rendererBuilder);
list.setAdapter(adapter);
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;
}
@Override public void render() {
setupAnimation();
animationTimer.subscribe(timerValue -> startAnimation());
}
onTrimMemory(int level)
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
fun totalMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getBlockCountLong() * stat.getBlockSizeLong()
}
fun availableMemorySize(): Long {
val path: File = Environment.getDataDirectory()
val stat: StatFs = StatFs(path.getPath())
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong()
}