This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PublishSubject<Long> animationTimer; | |
Subscription animationSubscription; | |
animationSubscription = Observable.interval(1, TimeUnit.SECONDS) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribeOn(Schedulers.newThread()) | |
.subscribe(animationTimer = PublishSubject.create()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override public void onDestroy() { | |
if (!animationSubscription.isUnsubscribed()) { | |
super.onDestroy(); | |
animationSubscription.unsubscribe(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CustomRendererBuilder rendererBuilder = new CustomRendererBuilder(animationTimer) | |
RVRendererAdapter adapter = new RVRendererAdapter<>(rendererBuilder); | |
list.setAdapter(adapter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override public void render() { | |
setupAnimation(); | |
animationTimer.subscribe(timerValue -> startAnimation()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onTrimMemory(int level) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW: | |
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun totalMemorySize(): Long { | |
val path: File = Environment.getDataDirectory() | |
val stat: StatFs = StatFs(path.getPath()) | |
return stat.getBlockCountLong() * stat.getBlockSizeLong() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun availableMemorySize(): Long { | |
val path: File = Environment.getDataDirectory() | |
val stat: StatFs = StatFs(path.getPath()) | |
return stat.getAvailableBlocksLong() * stat.getBlockSizeLong() | |
} |