Skip to content

Instantly share code, notes, and snippets.

@rpgobjects
rpgobjects / AspectRatioImageView.java
Created October 18, 2016 18:10 — forked from JakeWharton/AspectRatioImageView.java
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
@rpgobjects
rpgobjects / EndlessRecyclerOnScrollListener.java
Created November 30, 2015 02:46 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@rpgobjects
rpgobjects / gist:d256dd18178f5227d85a
Created February 20, 2015 15:33
IPv6 calculator. I didn't create this, I pulled it from http://silmor.de/ipaddrcalc.html.
<!-- saved from url=(0032)http://silmor.de/ipaddrcalc.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>IPv6 Address Calculator</title>
</head>
<body>
<h1>Address Calculator</h1>
@rpgobjects
rpgobjects / gist:3407fbb0a61263f00016
Created July 23, 2014 17:34
release key command
keytool -genkey -v -keystore {name}.keystore -alias {name} -keyalg RSA -keysize 2048 -validity 10000
@rpgobjects
rpgobjects / IonIdlingResource
Last active April 6, 2018 03:54
Espresso IdlingResource for Ion
/**
* Espresso IdlingResource for Ion
* https://github.com/koush/ion
* https://code.google.com/p/android-test-kit/
* Because you can't deregister an IdlingResource, you have to create a new one per test.
* You need to use a unique resourceName each test.
*/
public final class IonIdlingResource implements IdlingResource {
private static final String TAG = "IonIdlingResource";
static public String image2encodedString(String plate_read_key) {
File d = CitySyncController.getPhotoDir();
File f = new File(d,plate_read_key);
InputStream inputStream = null;
try {
inputStream = new FileInputStream(f);
} catch (FileNotFoundException e) {
return "";
}
byte[] bytes;