Skip to content

Instantly share code, notes, and snippets.

View jenzz's full-sized avatar

Jens Driller jenzz

View GitHub Profile
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* An implementation of {@link BaseAdapter} which uses the new/bind pattern and
* view holder pattern for its views.
*
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_500_primary">#f44336</color>
<color name="red_50">#ffebee</color>
<color name="red_100">#ffcdd2</color>
<color name="red_200">#ef9a9a</color>
<color name="red_300">#e57373</color>
<color name="red_400">#ef5350</color>
<color name="red_600">#e53935</color>
<color name="red_700">#d32f2f</color>
@Takhion
Takhion / RetainedObservableActivity.java
Last active September 30, 2016 16:05
Simplest way to retain an active Observable during configuration changes
package me.eugeniomarletti.example;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Toast;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
@futtetennista
futtetennista / ThreadPoolIdlingResource.java
Last active October 12, 2016 23:53
Code taken from Espresso's AsyncTaskPoolMonitor and adapter to be used as an idling resource for any ThreadPoolExecutor
/*
* Copyright (C) 2013 Google, 2014 Stefano Dacchille
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.f2prateek.articuno.util;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.SparseArray;
import java.io.Serializable;
import java.util.ArrayList;
/**
@koral--
koral-- / build.gradle
Last active December 12, 2017 01:31
testApt to testAnnotationProcessor migration, workaround for issue: https://code.google.com/p/android/issues/detail?id=224272
android.applicationVariants.all {
def aptOutputDir = new File(buildDir, "generated/source/apt/${it.unitTestVariant.dirName}")
it.unitTestVariant.addJavaSourceFoldersToModel(aptOutputDir)
}
@JakeWharton
JakeWharton / build.gradle
Created July 19, 2014 00:17
Adding support-annotations jar to a Java module.
apply plugin: 'java'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger)
def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger)
for (File file : sdkHandler.sdkLoader.repositories) {
project.repositories.maven {
url = file.toURI()
@JakeWharton
JakeWharton / ViewHoldingAdapter.java
Created April 26, 2012 06:54
Template for a list adapter which uses a view holder to cache lookups.
public class TweetAdapter extends BaseAdapter {
// ...
public View getView(int position, View convertView, ViewGroup parent) {
TweetViewHolder vh = TweetViewHolder.get(convertView, parent);
Tweet item = getItem(position);
vh.user.setText(item.user);
vh.tweet.setText(item.tweet);
@alphazero
alphazero / eclispe:user.name OS X
Created September 25, 2011 03:38
set user.name (e.g. for @author tag) in eclipse | Mac OS X
# read $EHOME as the path to where eclipse is installed
# edit eclipse.ini
cd $EHOME/eclipse/Eclipse.app/Contents/MacOS/
vim eclipse.ini
# add the following key/value to end of the ini file
# value can be anything including embedded spaces.
-Duser.name=Your Name <your@email.tld>