Skip to content

Instantly share code, notes, and snippets.

@JayNewstrom
JayNewstrom / Dockerfile
Last active December 27, 2018 20:33
Docker Android Gradle
FROM openjdk:8-alpine AS base
ENV GRADLE_HOME /root/.gradle
RUN mkdir -p $GRADLE_HOME && \
echo "org.gradle.jvmargs=-Xmx4000M" >> $GRADLE_HOME/gradle.properties && \
echo "org.gradle.daemon=false" >> $GRADLE_HOME/gradle.properties && \
echo "org.gradle.parallel=true" >> $GRADLE_HOME/gradle.properties && \
echo "org.gradle.parallel.intra=true" >> $GRADLE_HOME/gradle.properties && \
echo "org.gradle.caching=true" >> $GRADLE_HOME/gradle.properties && \
echo "android.enableBuildCache=true" >> $GRADLE_HOME/gradle.properties && \
@JayNewstrom
JayNewstrom / RxBackPressure.kt
Last active November 9, 2018 01:10
Test and prototype for a more specific back pressure in rxjava 2
package com.jaynewstrom.rx
import io.reactivex.Flowable
import io.reactivex.Scheduler
import io.reactivex.schedulers.Schedulers
import org.junit.Test
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicLong
@JayNewstrom
JayNewstrom / TouchEffectAnimator
Created November 11, 2014 21:58
A helper class to allow animation based touch states.
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
@JayNewstrom
JayNewstrom / CoundowTextBuilder.java
Created April 9, 2014 19:19
Countdown Text Builder
StringBuilder sb = new StringBuilder();
if (secondsRemaining >= 3600) { // over and hour
long hours = secondsRemaining / 3600;
secondsRemaining %= 3600;
sb.append(hours);
sb.append(":");
if (secondsRemaining < 60) {
sb.append("00:"); // we will skip the minutes stuff, so add it here.
}
}
@JayNewstrom
JayNewstrom / ListAdapter.java
Created February 4, 2014 21:05
A base adapter that handles boilerplate and view reuse.
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
@JayNewstrom
JayNewstrom / README.md
Last active August 29, 2015 13:55
Resize image assests, starting with an image in your res/drawable-xxxhdpi folder.

Origionally based off: https://gist.github.com/ignasi/8420671

Setup

chmod +x resizer_xxxhdpi.sh

copy resizer_xxxhdpi.sh to res/drawable-xxxhdpi/resizer_xxxhdpi.sh

Usage

Start with the image you want to resize, we'll call it resize_me.png (remember, android resources can't have caps, or dashes)

@JayNewstrom
JayNewstrom / StickyListActivity.java
Created January 31, 2014 19:04
A very simple sticky list header helper.
public class StickyListActivity extends Activity {
@InjectView(R.id.fl_sticky_header_holder) FrameLayout stickyHeaderHolder;
@InjectView(R.id.list_view) ListView listView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_sticky_list);
Butterknife.inject(this);
@JayNewstrom
JayNewstrom / HeaderAdapter.java
Last active January 4, 2016 18:08
An adapter to use in a listview with separate views for header views and content views. with full reuse of cells
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;