Skip to content

Instantly share code, notes, and snippets.

View markus2610's full-sized avatar

Markus markus2610

View GitHub Profile
@markus2610
markus2610 / gist:2149413
Created March 21, 2012 16:44 — forked from mosabua/gist:1316903
ExpandableListFragment
package android.support.v4.app;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnCreateContextMenuListener;
package se.fnord.android.layout;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
/**
* ViewGroup that arranges child views in a similar way to text, with them laid
* out one line at a time and "wrapping" to the next line as needed.
@markus2610
markus2610 / gist:2304781
Created April 4, 2012 19:02 — forked from esaounkine/gist:948236
Intent to start navigation activity - payload
final int defaultFlag = PackageManager.MATCH_DEFAULT_ONLY;
Intent[] explicitIntents;
//see an example here http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android
private Intent[] getExplicitIntents() {
if(explicitIntents == null) {
PackageManager currentPM = getPackageManager();
explicitIntents = new Intent[]{
new Intent("android.intent.action.navigon.START_PUBLIC"), //navigon with public intent
currentPM.getLaunchIntentForPackage("com.navigon.navigator"), //navigon without public intent
import java.io.InputStream;
import roboguice.inject.InjectExtra;
import android.app.Activity;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.DisplayMetrics;
@markus2610
markus2610 / ShakeDetector.java
Created April 6, 2012 13:22 — forked from alecplumb/ShakeDetector.java
Roboguice Android shake detector
import roboguice.activity.event.OnPauseEvent;
import roboguice.activity.event.OnResumeEvent;
import roboguice.event.EventManager;
import roboguice.event.Observes;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import com.google.inject.Inject;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.vvakame.polkodotter" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:name=".MyApplication" android:debuggable="true">
<activity android:name=".MainActivity" android:label="@string/app_name">
<intent-filter>
@markus2610
markus2610 / SimpleCursorLoader.java
Created April 12, 2012 11:32 — forked from casidiablo/SimpleCursorLoader.java
Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview
import android.content.Context;
import android.database.Cursor;
import android.support.v4.content.AsyncTaskLoader;
/**
* Used to write apps that run on platforms prior to Android 3.0. When running
* on Android 3.0 or above, this implementation is still used; it does not try
* to switch to the framework's implementation. See the framework SDK
* documentation for a class overview.
*
@markus2610
markus2610 / AspectRatioImageView.java
Created June 11, 2012 07:50 — 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 {
@markus2610
markus2610 / AsyncTaskExecutionHelper.java
Created June 19, 2012 19:14 — forked from greenrobot/AsyncTaskExecutionHelper.java
Helper bringing back parallel execution for AsyncTask (you are no serial execution and pseudo threading wimp, right?). Uses level 11 APIs when possible.
package de.greenrobot.util;
import java.util.concurrent.Executor;
import android.os.AsyncTask;
import android.os.Build;
/**
* Uses level 11 APIs when possible to use parallel/serial executors and falls back to standard execution if API level
* is below 11.
@markus2610
markus2610 / SquareViewAnimator.java
Created June 19, 2012 19:28 — forked from JakeWharton/SquareViewAnimator.java
ViewAnimator helper which allows setting the selected child by ID rather than index
package com.squareup.widgets;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ViewAnimator;
/** ViewAnimator helper which allows setting the selected child by ID rather than index. */
public class SquareViewAnimator extends ViewAnimator {
public SquareViewAnimator(Context context) {