Skip to content

Instantly share code, notes, and snippets.

Jorge Garrido FireZenk

View GitHub Profile
View MemoryTrimSnippet3.java
private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
View MemoryTrimSnippet2.java
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
View AnimationRendererSnippet.java
@Override public void render() {
setupAnimation();
animationTimer.subscribe(timerValue -> startAnimation());
}
View AnimationRendererAdapterSnippet.java
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;
}
View AnimationAdapterSnippet.java
CustomRendererBuilder rendererBuilder = new CustomRendererBuilder(animationTimer)
RVRendererAdapter adapter = new RVRendererAdapter<>(rendererBuilder);
list.setAdapter(adapter);
View AnimationUnsubscriptionSnippet.java
@Override public void onDestroy() {
if (!animationSubscription.isUnsubscribed()) {
super.onDestroy();
animationSubscription.unsubscribe();
}
}
View AnimationSubscriptionSnippet.java
PublishSubject<Long> animationTimer;
Subscription animationSubscription;
animationSubscription = Observable.interval(1, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.newThread())
.subscribe(animationTimer = PublishSubject.create());
@FireZenk
FireZenk / CustomActivity.java
Created May 2, 2017
Synchronizing animations in RecyclerView
View CustomActivity.java
@Bind(R.id.my_recyclerview) RecyclerView myList;
private PublishSubject<Long> animationTimer;
private Subscription animationSubscription;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
animationSubscription = Observable.interval(1, TimeUnit.SECONDS)
@FireZenk
FireZenk / SchedulerProvider.java
Created Jan 2, 2017
UseCase executor, that takes handle use cases, their possible errors and return the subscription
View SchedulerProvider.java
package com.sample.app.ui.schedulers;
import android.support.annotation.NonNull;
import rx.Scheduler;
/**
* Project: app
*
* Created by Jorge Garrido Oval on 01/12/2016.
You can’t perform that action at this time.