Skip to content

Instantly share code, notes, and snippets.

@johncarl81
johncarl81 / Enum Converter
Created September 8, 2014 14:48
Example of a Parcel Enum Converter
@Parcel
public class Tester {
@Parcel(converter = EnumExampleConverter.class)
public static enum EnumExample{
ONE,
TWO;
}
public static class EnumExampleConverter implements ParcelConverter<EnumExample>{
public class Tester extends SuperClass {
private SuperCaller superCaller = new SuperCaller();
private Delegate delegate = new Delegate(superCaller);
public static void main(String[] args){
Tester tester = new Tester();
tester.runMe();
}
package org.test;
import org.junit.Test;
import javax.tools.*;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.*;
String.format("0x%08X", Integer.decode("0x00020000")
public class CodeModelIfForExample {
private static final String CLASS_NAME = "TestClass";
public static void main(String args[]) throws Exception{
JCodeModel codeModel = new JCodeModel();
JDefinedClass c = codeModel._class(CLASS_NAME);
writeIfElse(codeModel, c);
@Generated(value = "org.androidtransfuse.TransfuseAnnotationProcessor", date = "01/02/2013 21:35:08 MST")
public class Transfuse$Parcels
implements ParcelRepository
{
private final Map<Class, ParcelableFactory> parcelWrappers = new HashMap<Class, ParcelableFactory>();
public Transfuse$Parcels() {
parcelWrappers.put(ParcelExample.class, new Transfuse$Parcels.ParcelExample_Parcelable_0Factory());
parcelWrappers.put(ParcelTwo.class, new Transfuse$Parcels.ParcelTwo_Parcelable_0Factory());
public class Parcels {
public static final String PARCELS_NAME = "Parcels";
public static final String PARCELS_REPOSITORY_NAME = "Transfuse$Parcels";
public static final String PARCELS_PACKAGE = "org.androidtransfuse";
private static ParcelRepository PARCELS;
public static void initialise(ClassLoader classLoader){
loadParcels(classLoader);
public class Parcels {
public static final String PARCELS_NAME = "Parcels";
public static final String PARCELS_REPOSITORY_NAME = "Transfuse$Parcels";
public static final String PARCELS_PACKAGE = "org.androidtransfuse";
private static final ParcelRepository PARCELS;
static{
ParcelRepository parcelsCreation;
@johncarl81
johncarl81 / gist:3923572
Last active October 11, 2015 21:38
Rotating Backups
#!/bin/bash
unset PATH;
# $1 = path to backup
# $2 = name of backup folder
# ------------- system commands used by this script --------------------
ID=/usr/bin/id;
ECHO=/bin/echo;
//static way (dont want to do this)
public class SlideshowActivity extends Activity{
public static void start(ArrayList<String> images, Song song, Uri videoUri, Context ctx){
Intent intent = new Intent(ctx, SlideshowActivity.class);
intent.putExtra(EXTRA_IMAGE_FILE_NAMES, images);
intent.putExtra(EXTRA_SELECTED_SONG, song);
intent.putExtra(EXTRA_VIDEO_URI, videoUri);
ctx.startActivity(intent);
}