Skip to content

Instantly share code, notes, and snippets.

View imran0101's full-sized avatar

Imran imran0101

  • India
View GitHub Profile
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);
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 10:17
EventBus with complete and error.
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 06:02
EventBus using RxJava. Bunch of subjects and observers.
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 06:56
RxJava time bound operation. Debounce items without discarding, in the same sequence as the source observable. Raw
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 January 4, 2016 10:11
Observe Keyboard open or hidden
public class KeyboardObserver implements ViewTreeObserver.OnGlobalLayoutListener {
public interface Callback {
void onKeyboardVisible();
void onKeyboardHidden();
}
WeakReference<View> view;
@imran0101
imran0101 / EndlessRecyclerOnScrollListener.java
Last active February 22, 2022 12:50
RecyclerView position helper to get first and last visible positions
/**
* 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.