Skip to content

Instantly share code, notes, and snippets.

boolean isSingleTap = Math.abs(mStartingY - y) < Etils.dpToPx(5)
&& Math.abs(mStartingX - x) < Etils.dpToPx(5);
if (isSingleTap) {
shouldClose = isOpen;
}
@eddieberklee
eddieberklee / Threshold for closing opening a drag
Created April 25, 2016 23:11
Code for opening/closing based on a threshold of how far the container was dragged
boolean shouldClose;
float translationY = mEventsSliderContainer.getTranslationY();
if (isOpen) {
shouldClose = (translationY > mScrollViewHeight / 2)
|| (translationY > OPEN_CLOSE_THRESHOLD);
} else { // already closed, when should it remain closed
shouldClose = (translationY > mScrollViewHeight / 2)
&& (translationY > mScrollViewHeight - OPEN_CLOSE_THRESHOLD);
}
Paint redStrokePaint, blueStrokePaint;
redStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
redStrokePaint.setStyle(Paint.Style.STROKE);
redStrokePaint.setStrokeWidth(Etils.dpToPx(1));
redStrokePaint.setColor(context.getResources().getColor(R.color.flatui_red_1_transp_50));
blueStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
blueStrokePaint.setStyle(Paint.Style.STROKE);
blueStrokePaint.setStrokeWidth(Etils.dpToPx(1));
blueStrokePaint.setColor(context.getResources().getColor(R.color.flatui_blue_1_transp_50));
Paint greenStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
04-06 19:21:12.782 E/RunLoop: Uncaught exception in Firebase runloop (2.5.0). Please report to [email protected]
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.firebase.client.core.SnapshotHolder.update(com.firebase.client.core.Path, com.firebase.client.snapshot.Node)' on a null object reference
at com.firebase.client.core.Repo.updateInfo(Repo.java:497)
at com.firebase.client.core.Repo.onServerInfoUpdate(Repo.java:456)
at com.firebase.client.core.PersistentConnection.handleTimestamp(PersistentConnection.java:811)
at com.firebase.client.core.PersistentConnection.onReady(PersistentConnection.java:309)
at com.firebase.client.realtime.Connection.onConnectionReady(Connection.java:197)
at com.firebase.client.realtime.Connection.onHandshake(Connection.java
drawingPath.moveTo(startHalfHourPointInner[0], startHalfHourPointInner[1]);
drawingPath.lineTo(startHalfHourPoint[0], startHalfHourPoint[1]);
drawingPath.arcTo(clockFaceRect, startAngle, sweepAngle);
drawingPath.lineTo(endHalfHourPointInner[0], endHalfHourPointInner[1]);
// drawingPath.lineTo(startHalfHourPointInner[0], startHalfHourPointInner[1]);
drawingPath.addArc(constrainedCircleRect, startAngle, sweepAngle);
drawingPath.moveTo(startHalfHourPointInner[0], startHalfHourPointInner[1]);
drawingPath.lineTo(startHalfHourPoint[0], startHalfHourPoint[1]);
@eddieberklee
eddieberklee / colored_arcs.java
Created December 22, 2015 23:54
Android Colored Half Hour Arcs around a Circle
int[] colors = new int[]{
getResources().getColor(R.color.flatui_red_1),
getResources().getColor(R.color.flatui_red_2),
getResources().getColor(R.color.flatui_orange_1),
getResources().getColor(R.color.flatui_orange_2),
getResources().getColor(R.color.flatui_yellow_1),
getResources().getColor(R.color.flatui_yellow_2),
getResources().getColor(R.color.flatui_green_1),
getResources().getColor(R.color.flatui_green_2),
getResources().getColor(R.color.flatui_blue_1),
@eddieberklee
eddieberklee / intersection.java
Created December 22, 2015 23:51
Android Detecting Intersection of a Touch Point with a Path
float padding = Util.dpToPx(1);
RectF touchPoint = new RectF(x, y, x + padding, y + padding);
Path touchPointPath = new Path();
touchPointPath.addRect(touchPoint, Path.Direction.CW);
for (int i = 0; i < mHourPaths.length; i++) {
hourPath = mHourPaths[i];
touchPointPath.addCircle(x, y, padding, Path.Direction.CW);
touchPointPath.close();
Path hourPathCopy = new Path(hourPath);
import java.util.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.experimental.theories.DataPoint;
  • Complete this TODO.
import os
import monitor
monitor.start(interval=1.0)
monitor.track(os.path.join(os.path.dirname(__file__), 'site.cf'))
# ...
# The rest of your wsgi.py file