Skip to content

Instantly share code, notes, and snippets.

Brendan brendanw

Block or report user

Report or block brendanw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brendanw
brendanw / RangeBar.kt
Created Apr 23, 2019
RangeBar with Two Thumbs Kotlin Implementation
View RangeBar.kt
/**
* RangeBar is a bar that allows a user to define a range of values by moving two thumbs.
*
* Normalized value refers to a number as it exists in a range from [min, max]
* Px value refers to a number as it exists in a range from [startX, endX]
*/
class RangeBar : View {
companion object {
// The diameter of the circle
View 2017-11-06T09_31_10_653Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/Users/brendanweinstein/.nvm/versions/node/v8.6.0/bin/node',
1 verbose cli '/Users/brendanweinstein/.nvm/versions/node/v8.6.0/bin/npm',
1 verbose cli 'install' ]
2 info using npm@5.3.0
3 info using node@v8.6.0
4 verbose npm-session 8d11a10848f2342f
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall BaseBeta@0.1.4
7 info lifecycle BaseBeta@0.1.4~preinstall: BaseBeta@0.1.4
View 2017-11-06T09_31_10_653Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/Users/brendanweinstein/.nvm/versions/node/v8.6.0/bin/node',
1 verbose cli '/Users/brendanweinstein/.nvm/versions/node/v8.6.0/bin/npm',
1 verbose cli 'install' ]
2 info using npm@5.3.0
3 info using node@v8.6.0
4 verbose npm-session 8d11a10848f2342f
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall BaseBeta@0.1.4
7 info lifecycle BaseBeta@0.1.4~preinstall: BaseBeta@0.1.4
View gist:be5e22bc2f9d54836e9ab309cd69c487
/**
* Need to return true here to continue hearing updates from the child
* for the duration of the scroll
*/
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
return true;
}
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
@brendanw
brendanw / gist:512f4befbb8cb664cf25285d87960720
Created Feb 3, 2017
Pared Down NestedScrollingParent and NestedScrollingChild
View gist:512f4befbb8cb664cf25285d87960720
public interface NestedScrollingParent {
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes);
public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes);
public void onStopNestedScroll(View target);
public void onNestedScroll(View target, int dxConsumed, int dyConsumed,
int dxUnconsumed, int dyUnconsumed);
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed);
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed);
public boolean onNestedPreFling(View target, float velocityX, float velocityY);
public int getNestedScrollAxes();
@brendanw
brendanw / gist:f71557a77d2a86d87a5286bd0465e8b4
Last active Feb 3, 2017
RecyclerView Scroll Tracking using a Sentinel View
View gist:f71557a77d2a86d87a5286bd0465e8b4
headerTrackScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
float sentinelYPos = adapter.getSentinelViewYPos();
if (sentinelYPos >= Utility.getScreenHeight(getContext()) || !areAuxiliaryTouchEventsEnabled) {
return;
}
float topOfListScrollY = sentinelYPos - headerHeight;
View ObservableQueue
import android.support.annotation.NonNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.Queue;
import rx.subjects.Subject;
public class ObservableQueue<E> implements Queue<E> {
@brendanw
brendanw / StickyRxBus.java
Created Aug 17, 2016
RxBus with Sticky Events
View StickyRxBus.java
/**
* An RxJava-backed EventBus class that can support sending and receiving multiple event types.
*
* Based on https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf
*/
public class EventBus<T> {
private static EventBus<Object> INSTANCE;
private List<T> events;
@brendanw
brendanw / gist:1f3c60a1e886a365c084
Created Feb 19, 2016
Detect when a ViewPager smoothScroll initialized by viewPager.setCurrentItem() has completed
View gist:1f3c60a1e886a365c084
import android.support.v4.view.ViewPager;
import android.view.ViewTreeObserver;
/**
* A class that can be added to a viewTreeObserver for ViewPager's in order to determine
* when a smoothScroll transition is completed by viewPager.setCurrentItem();
*/
public class PagerScrollListener implements ViewTreeObserver.OnScrollChangedListener {
private int scrollX;
private int totalChange = 0;
@brendanw
brendanw / gist:e79d0ad972fb715e96c5
Created Feb 19, 2016
Detect when a ViewPager smoothScroll initialized by viewPager.setCurrentItem() has completed
View gist:e79d0ad972fb715e96c5
import android.support.v4.view.ViewPager;
import android.view.ViewTreeObserver;
/**
* A class that can be added to a viewTreeObserver for ViewPager's in order to determine
* when a smoothScroll transition is completed by viewPager.setCurrentItem();
*/
public class PagerScrollListener implements ViewTreeObserver.OnScrollChangedListener {
private int scrollX;
private int totalChange = 0;
You can’t perform that action at this time.