Skip to content

Instantly share code, notes, and snippets.

View chemickypes's full-sized avatar
📱

Angelo Moroni chemickypes

📱
View GitHub Profile
...
View newf = findFirstVisibleItem();
if(!newf.equals(f) ) {
f = newf;
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
v.setAlpha(v.equals(f)?1f:0.5f);
}
}
@chemickypes
chemickypes / EndOffsetDecoration.java
Created June 27, 2017 14:04
Code for Medium article 2
...
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int dataSize = state.getItemCount();
int position = parent.getChildAdapterPosition(view);
if (dataSize > 0 && position == dataSize - 1) {
outRect.set(0, 0, mEndOffset, 0);
} else {
outRect.set(0, 0, 0, 0);
@chemickypes
chemickypes / HorizontalPicker.java
Last active June 27, 2017 14:04
Code for Article on Medium 1
...
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
try {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
int w = getWidth();
addItemDecoration(new EndOffsetDecoration(w - 50));
}catch (Exception e){
@chemickypes
chemickypes / CountDownTime.java
Created April 27, 2017 12:51
CountDownTimer suing RXJava 2
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Angelo Moroni on 27/04/17.
*/