Skip to content

Instantly share code, notes, and snippets.

@tir38
tir38 / terminalTimer.sh
Last active October 20, 2024 04:43
in-terminal timer shell script
# script to create timer in terminal
# Jason Atwood
# 2013/6/22
#!/bin/sh
# start up
echo "starting timer script ..."
sleep 1 # seconds
# get input from user
@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;
<?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 / 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 / HandlerThreadSchedule.java
Last active February 8, 2018 09:58
Easily wrap Hander-creation code in an Observable
package com.example;
import android.os.Handler;
import android.os.HandlerThread;
import java.util.concurrent.TimeUnit;
import rx.Scheduler;
import rx.Subscription;
import rx.android.plugins.RxAndroidPlugins;
@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")
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 / 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'
@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 / IgnoreCaseTextMatcher.java
Last active March 25, 2021 06:37
Espresso (Hamcrest) matcher to match TextView text but ignoreCase
package com.example.app;
import android.support.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import static com.google.common.base.Preconditions.checkNotNull;