Skip to content

Instantly share code, notes, and snippets.

@tir38
tir38 / gist:3d03f5b94c30595fdeeb
Last active December 25, 2015 06:13
Extends Daniel Olshansky's DevByte example "ListView Expanding Cells Animation" to allow for custom collapsable height http://www.youtube.com/watch?v=mwE61B56pVQ http://developer.android.com/shareables/devbytes/ListViewExpandingCells.zip

In Daniel's example, all rows contain the same view, so their collapsed heights are all the same. However if you have different size collapsed rows, the animation will be jumpy. To fix this

  1. pull the cell height out of the constructor for ExpandableListItem:
public class ExpandableListItem implements OnSizeChangedListener {

    private String mTitle;
    private String mText;
 private boolean mIsExpanded;
@tir38
tir38 / LifecycleLoggingActivity.java
Last active January 27, 2016 20:47
AppCompatActivity for logging all the "onXYZ" methods
package com.your.package.here
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
public class LifecycleLoggingActivity extends AppCompatActivity {
@tir38
tir38 / init.java
Created July 14, 2016 16:47
Use Crashlytics to track Crashlytics initialization
long start = System.currentTimeMillis();
boolean isDebugApplication = ...
Fabric.with(context, new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(isDebugApplication).build())
.build());
long initDuration = System.currentTimeMillis() - start;
Answers.getInstance().logContentView(new ContentViewEvent()
.putContentName("Fabric initialization time in milliseconds")
@tir38
tir38 / build.gradle
Last active October 7, 2016 06:00
How to document your dependency list
dependencies {
compile project(':core')
// Parser for scanRecord byte array returned from
// android.bluetooth.BluetoothAdapter.LeScanCallback.onLeScan()
// This is only needed for pre-Lollipop devices.
// https://github.com/TakahikoKawasaki/nv-bluetooth
// Apache 2.0
compile 'com.neovisionaries:nv-bluetooth:1.7'
<?xml version="1.0" encoding="utf-8"?>
<!-- Add this as a debug manifest so the permissions won't be required by your production app -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
</manifest>
@tir38
tir38 / build.gradle
Created November 8, 2016 21:57
rando signing config setup
android {
...
signingConfigs {
release {
storeFile file("../keystore/production.jks")
keyAlias ...
keyPassword ...
storePassword ...
}
@tir38
tir38 / build.gradle
Last active February 10, 2017 21:56
When running connectedCustomerDebugAndroidTest
apply plugin: 'com.android.application'
def supportLibVer = "25.0.1"
def googleServicesLibVer = "9.8.0"
def daggerLibVersion = "2.2"
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
import android.app.Activity;
import android.support.annotation.Nullable;
import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry;
import java.util.Collection;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.runner.lifecycle.Stage.RESUMED;
public final class CurrentActivityUtil {
@tir38
tir38 / temp.java
Last active August 11, 2017 22:16
Questions about events and observables
package com.onbeep.obiwan.frameworks;
import io.reactivex.Observable;
public class Temp {
/**
* Question 1: should an event be a class or enum?
* <p>
* I don't have a good answer. Discussion going on here:
@tir38
tir38 / example.java
Last active September 14, 2017 16:17
How do you prefer to use Dagger2?
// Given this module:
@Module
class DripCoffeeModule {
@Provides static Heater provideHeater() {
return new ElectricHeater();
}
}
// Which of these options do you prefer?