Skip to content

Instantly share code, notes, and snippets.

Avatar

Imran imran0101

  • India
View GitHub Profile
View TodoItemHolder.Remove.java
void remove(final TodoItem item, final TodoItemAdapterCallback callback,
final int adapterPosition) {
final ValueAnimator elevateAnimator = ValueAnimator.ofFloat(1f, 1.05f);
elevateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
float animatedValue = (float) animation.getAnimatedValue();
ViewCompat.setTranslationZ(cardTodo, animatedValue);
ViewCompat.setScaleX(cardTodo, animatedValue);
ViewCompat.setScaleY(cardTodo, animatedValue);
View TodoItemHolder.OnSelected.java
public void onSelected() {
int index = new Random().nextInt(rotationAngles.length);
ValueAnimator elevateAnimator = ValueAnimator.ofFloat(1f, 1.03f);
elevateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
float animatedValue = (float) animation.getAnimatedValue();
ViewCompat.setScaleX(cardTodo, animatedValue);
ViewCompat.setScaleY(cardTodo, animatedValue);
}
@imran0101
imran0101 / EventBus.java
Created May 22, 2016
EventBus with complete and error.
View EventBus.java
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action0;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
/**
* An object reference of EventBus
@imran0101
imran0101 / EventBus.java
Last active May 31, 2017
EventBus using RxJava. Bunch of subjects and observers.
View EventBus.java
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action0;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
/**
* An object reference of EventBus
@imran0101
imran0101 / TimeBoundOperator.java
Last active May 4, 2016
RxJava time bound operation. Debounce items without discarding, in the same sequence as the source observable. Raw
View TimeBoundOperator.java
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Scheduler;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
@imran0101
imran0101 / KeyboardObserver.java
Last active Jan 4, 2016
Observe Keyboard open or hidden
View KeyboardObserver.java
public class KeyboardObserver implements ViewTreeObserver.OnGlobalLayoutListener {
public interface Callback {
void onKeyboardVisible();
void onKeyboardHidden();
}
WeakReference<View> view;
@imran0101
imran0101 / EndlessRecyclerOnScrollListener.java
Last active Jan 30, 2021
RecyclerView position helper to get first and last visible positions
View EndlessRecyclerOnScrollListener.java
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.