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 / attrs.xml
Created July 1, 2016 17:37
Use this to gather custom XML attributes for CenterContainViewGroup
<resources>
<declare-styleable name="CenterContainViewGroup">
<attr name="natural_width" format="integer" />
<attr name="natural_height" format="integer" />
</declare-styleable>
</resources>