Skip to content

Instantly share code, notes, and snippets.

Avatar
📱

Angelo Moroni chemickypes

📱
View GitHub Profile
View LeftmostElementPickerLayoutManager.java
...
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);
}
}
View EndOffsetDecoration.java
...
@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 Jun 27, 2017
Code for Article on Medium 1
View HorizontalPicker.java
...
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 Apr 27, 2017
CountDownTimer suing RXJava 2
View CountDownTime.java
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.
*/
You can’t perform that action at this time.