Skip to content

Instantly share code, notes, and snippets.

View moagrius's full-sized avatar

Mike Dunn moagrius

  • Austin, TX
View GitHub Profile
public class SomeClass {
}
new SomeClass(); // works
public class SomeClass {
public SomeClass(Strng name) {}
package com.qozix.crypto;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
package edu.gatech.seclass.tourneymanager;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import java.util.ArrayList;
import java.util.HashSet;

so a MediaCollection (or any ContentCollection) has a List.
The ContentElement interface will have a save method, that takes some reference to a database or database helper, and the implementation will take care of saving:

void Chapter.save(Database db) {
  Values values = new Values();
  // populate values with information
  db.insertOrUpdate(CHAPTERS_TABLE).values(values);
}
...
package com.qozix.messages;
/**
* Created by michaeldunn on 8/8/16.
*/
public abstract class Actor<T> {
public abstract void react(T t);
@SuppressWarnings("unchecked")
void translateAndReact(Object object) {
react((T) object);
package com.qozix.messages;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* Created by michaeldunn on 8/8/16.
*/
public class CompositeCallback<T> implements Callback<T> {
private List<Callback<T>> mCallbacks = new LinkedList<>();
public CompositeCallback(Callback<T> callback) {
add(callback);
}
public CompositeCallback<T> add(Callback<T> callback) {
if (callback != null) {
mCallbacks.add(callback);
package example.viewcontrollers;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@moagrius
moagrius / CenterContainViewGroup.java
Last active July 1, 2016 17:48
This is a re-usable widget that accepts one child. That child will always show as much of that child as possible, without clipping, and extending to the appropriate edge, then centered in the remaining space.
package com.michaeldunn.experiments.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import com.michaeldunn.experiments.R;