Skip to content

Instantly share code, notes, and snippets.

View josh-burton's full-sized avatar
👋

Josh Burton josh-burton

👋
View GitHub Profile
@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);
@davidwkeith
davidwkeith / index.html
Last active April 10, 2024 12:01
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom protocol handlers. Licensed under the WFTPL http://www.wtfpl.net/txt/copying/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!--
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom
protocol handlers.
@cblunt
cblunt / MaskedImageView.java
Created July 25, 2012 11:22
Android MaskedImageView - Uses the Background resource as a mask for the src bitmap. If set, foregroundBitmap is overlaid on top of the masked image.
package com.example;
import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
anonymous
anonymous / Timestampable.java
Created August 21, 2012 02:01
package models;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@ryanbateman
ryanbateman / gist:3899841
Created October 16, 2012 15:06
Round and frame an image
public static Bitmap round(Context context, Bitmap source) {
// Use the height and width of our source image as a basis
int width = source.getWidth();
int height = source.getHeight();
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(WHITE);
@emil2k
emil2k / Connectivity.java
Last active December 22, 2023 06:03
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@ficusk
ficusk / GsonRequest.java
Last active April 9, 2024 09:03
A Volley adapter for JSON requests that will be parsed into Java objects by Gson.
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
@pjdietz
pjdietz / Android Multiple Density Export.jsx
Created May 14, 2013 20:11
Photoshop JavaScript to automate exporting Android resources at multiple densities using the 3:4:6:8:12 scaling ratio.
/*global alert, app, prompt, ExportOptionsSaveForWeb, ExportType, File, Folder, ResampleMethod, SaveDocumentType, SaveOptions */
///////////////////////////////////////////////////////////////////////////////
// Android Multiple Density Export.jsx
//
// Photoshop JavaScript to automate exporting Android resources at multiple
// densities using the 3:4:6:8:12 scaling ratio.
//
//
// Installation:
@codebutler
codebutler / crashlytics_orgs.rb
Last active April 10, 2022 07:32
Crashlytics requires an IDE to "onboard" an Android app for no good reason. This prevents you from setting up a new app using a command line build tools such as Maven, Gradle or unsupported IDEs such as Android Studio. Turns out all you really need is your org's api key, which you can get using this script. Then just add this to your AndroidMani…
require 'httparty'
require 'json'
class Crashlytics
include HTTParty
base_uri 'https://api.crashlytics.com/api/v2'
def session(email, password)
self.class.post('/session.json',
body: {email: email, password:password}.to_json,
@pboos
pboos / annotation-processor-build.gradle
Last active August 7, 2020 06:38
Gradle stuff for Android
configurations {
apt
}
dependencies {
compile 'com.squareup.dagger:dagger:1.1.0'
apt 'com.squareup.dagger:dagger-compiler:1.1.0'
}
android.applicationVariants.all { variant ->