Skip to content

Instantly share code, notes, and snippets.

@alexjlockwood
alexjlockwood / SampleActivity.java
Created May 31, 2012 00:00
Simple Debugging #1
public class SampleActivity extends Activity {
/**
* A string constant to use in calls to the "log" methods. Its
* value is often given by the name of the class, as this will
* allow you to easily determine where log methods are coming
* from when you analyze your logcat output.
*/
private static final String TAG = "SampleActivity";
@alexjlockwood
alexjlockwood / CompatabilityManager.java
Created June 1, 2012 23:08
Compatability Manager
public class CompatibilityUtil {
/**
* Get the current Android API level.
*/
public static int getSdkVersion() {
return Build.VERSION.SDK_INT;
}
/**
public abstract class AlbumStorageDirFactory {
/**
* Returns a File object that points to the folder that will store
* the album's pictures.
*/
public abstract File getAlbumStorageDir(String albumName);
/**
* A static factory method that returns a new AlbumStorageDirFactory
public class BaseAlbumDirFactory extends AlbumStorageDirFactory {
/**
* For pre-Froyo devices, we must provide the name of the photo directory
* ourselves. We choose "/dcim/" as it is the widely considered to be the
* standard storage location for digital camera files.
*/
private static final String CAMERA_DIR = "/dcim/";
@Override
public class FroyoAlbumDirFactory extends AlbumStorageDirFactory {
@Override
public File getAlbumStorageDir(String albumName) {
return new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
),
albumName
);
public class SampleActivity extends Activity {
private AlbumStorageDirFactory mAlbumFactory;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Implementation not shown */
import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.preference.PreferenceManager;
import com.google.android.gms.auth.GoogleAuthUtil;
public class SampleActivity extends Activity {
private final Handler mLeakyHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// ...
}
}
@Override
@alexjlockwood
alexjlockwood / gulpfile.js
Last active November 20, 2016 16:08
Example of working around gulpfile.js error in this blog post: https://codegaze.github.io/2016/01/09/a-jekyll-workflow-with-gulp/
// Require all the things
var gulp = require('gulp'),
sass = require('gulp-sass'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
minifyCSS = require('gulp-clean-css'),
prefixer = require('gulp-autoprefixer'),
connect = require('gulp-connect');
cp = require('child_process');
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.