Skip to content

Instantly share code, notes, and snippets.

Jay Newstrom JayNewstrom

View GitHub Profile
@JayNewstrom
JayNewstrom / Dockerfile
Last active Dec 27, 2018
Docker Android Gradle
View Dockerfile
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 Nov 9, 2018
Test and prototype for a more specific back pressure in rxjava 2
View RxBackPressure.kt
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 Nov 11, 2014
A helper class to allow animation based touch states.
View TouchEffectAnimator
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;
View CoundowTextBuilder.java
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 Feb 4, 2014
A base adapter that handles boilerplate and view reuse.
View ListAdapter.java
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 Aug 29, 2015
Resize image assests, starting with an image in your res/drawable-xxxhdpi folder.
View README.md

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 Jan 31, 2014
A very simple sticky list header helper.
View StickyListActivity.java
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 Jan 4, 2016
An adapter to use in a listview with separate views for header views and content views. with full reuse of cells
View HeaderAdapter.java
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;
You can’t perform that action at this time.