Skip to content

Instantly share code, notes, and snippets.

View jgilfelt's full-sized avatar

Jeff Gilfelt jgilfelt

  • readyState Software Ltd
  • London, United Kingdom
View GitHub Profile
@jgilfelt
jgilfelt / main.xml
Created December 17, 2012 07:28
"fix" for black surface artefact left by MapFragment when transitioned in a ViewPager on old API versions
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
@jgilfelt
jgilfelt / CurlLoggingInterceptor.java
Created January 9, 2016 15:34
An OkHttp interceptor that logs requests as curl shell commands
/*
* Copyright (C) 2016 Jeff Gilfelt.
*
* 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
@jgilfelt
jgilfelt / AndroidMapsDirectionsIntent.java
Created July 27, 2010 07:56
Android Maps - Directions between two points Intent
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?f=d&saddr=53.447,-0.878&daddr=51.448,-0.972"));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);
@jgilfelt
jgilfelt / whartoff.sh
Created July 24, 2013 21:01
Whartoff - An ActionBarSherlock migration utility. For educational purposes only. Will not migrate project dependencies, static Sherlock attachments, List/ExpandableList/Preference Activities, compatibility MenuItem methods, Sherlock resource references and probably a dozen other use cases. This program will modify your code. Use it at your own …
# Whartoff - An ActionBarSherlock migration utility
#
# usage: whartoff.sh <option> <project directory>
#
# options:
# -c : ActionBarSherlock to compatibility ActionBar
# -n : ActionBarSherlock to native ActionBar
#!/bin/bash
@jgilfelt
jgilfelt / gist:1231694
Created September 21, 2011 09:50
Android - AsyncTask with inline callback boilerplate
private void asyncTaskWithInlineCallback() {
// display UI progress indicator
// ...
new MyAsyncTask() {
protected void onPostExecute(Boolean result) {
// dismiss UI progress indicator
// process the result
// ...
}
@jgilfelt
jgilfelt / README.md
Last active July 2, 2019 20:43 — forked from jagdeepsingh/README.md
ImageMagick 6.7.7-10 homebrew formula

Install ImageMagick 6.7.7-10

$ brew install https://gist.githubusercontent.com/jgilfelt/907d60ba5657e18daf9b4db1e442a6b0/raw/a56bc99ade0c86a60c954ec42cd2bc3bba8180ce/imagemagick.rb
@jgilfelt
jgilfelt / ShameActivity.java
Created October 3, 2013 16:28
A base Activity class that allows the compatibility menu button (AKA "the menu button of shame") to be displayed for applications whose targetSdkVersion >= 11. On devices with a hard menu key there is no effect. Useful if you want to launch some sort of in-app debug UI from an on-screen affordance without altering your application's user interfa…
package com.example.shame;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.view.KeyEvent;
import android.view.ViewConfiguration;
public abstract class ShameActivity extends Activity {
@jgilfelt
jgilfelt / MyApplication.java
Created March 11, 2013 09:42
Android - Set default preference values for a modern fragment-based PreferenceActivity
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// we cannot call setDefaultValues for multiple fragment based XML preference
// files with readAgain flag set to false, so always check KEY_HAS_SET_DEFAULT_VALUES
if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) {
@jgilfelt
jgilfelt / ScaleFadePageTransformer.java
Created December 3, 2012 20:05
An ICS+ app/widget drawer style PageTransformer for your ViewPager
/***
* Copyright (c) 2012 readyState Software Ltd
*
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@jgilfelt
jgilfelt / DoubleTapZoomMapView.java
Created February 8, 2012 14:17
Android - MapView implementing double tap to zoom
public class DoubleTapZoomMapView extends MapView {
private static final long TIME_INITIAL = -1;
private static final long TIME_DOUBLE_TAP = 250;
private long lastTouchTime = TIME_INITIAL;
public DoubleTapZoomMapView(Context context, AttributeSet attrs) {
super(context, attrs);
}