// Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
// 
//     public static final String TABLE_NAME = "usermemorylocations";
//     // columns
//     public static final String COL_ID = "_id";
//     public static final String COL_NAME = "name";
//     public static final String COL_LOCATION = "location";
//     public static final String COL_TYPE = "type";
//     public static final String COL_SORT_ORDER = "sortorder";
// 
//     public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
//             + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
//             + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
//             + COL_TYPE + " INTEGER DEFAULT 0, "
//             + COL_SORT_ORDER + " INTEGER);";
// 
//     private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
//             + TABLE_NAME;
// 
//     public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
// 
//     public static void onUpgrade (
//             SQLiteDatabase db,
//             int oldVersion,
//             int newVersion ) {
//         int curVer = oldVersion;
//         while (curVer < newVersion) {
//             curVer++;
//             if ( curVer == 15 ) {
//                 upgradeToVersion15(db);
//             }
//         }
//     }
// 
//     public static void upgradeToVersion15 (SQLiteDatabase db) {
//         onCreate(db);
//     }
// 
//     private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
// 
//     public static void onDowngrade (
//             SQLiteDatabase db,
//             int oldVersion,
//             int newVersion ) {
//         int curVer = oldVersion;
//         while ( curVer > newVersion ) {
//             curVer--;
//             if (curVer < 15) {
//                 // drop the table if downgrade is less than 15 (version table was added)
//                 dropTable(db);
//                 break;
//             }
//         }
//     }
// }
// 
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;


import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
        } else {
            // TODO change hardcoded create location title to use string resource
            builder.setTitle("Add Location");
            builder.setNegativeButton(R.string.buttonCancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });
        }
        return builder.create();
    }

    private boolean isUpdate() {
        return (id > -1);
    }

    private void findViews(View v) {
        name = (EditText) v.findViewById(R.id.nameText);
        location = (EditText) v.findViewById(R.id.locationText);
        intButton = (RadioButton) v.findViewById(R.id.radioButtonInt);
        byteButton = (RadioButton) v.findViewById(R.id.radioButtonByte);
        // default to BYTE being selected
        ((RadioButton)v.findViewById(R.id.radioButtonByte)).setChecked(true);
    }

    private void loadData(Bundle args) {
        id = args.getLong(UserMemoryLocationsTable.COL_ID);
        String sName = args.getString(UserMemoryLocationsTable.COL_NAME);
        int iLocation = args.getInt(UserMemoryLocationsTable.COL_LOCATION);
// Path: app/src/main/java/info/curtbinder/reefangel/db/UserMemoryLocationsTable.java
// public class UserMemoryLocationsTable {
// 
//     public static final String TABLE_NAME = "usermemorylocations";
//     // columns
//     public static final String COL_ID = "_id";
//     public static final String COL_NAME = "name";
//     public static final String COL_LOCATION = "location";
//     public static final String COL_TYPE = "type";
//     public static final String COL_SORT_ORDER = "sortorder";
// 
//     public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME
//             + " (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
//             + COL_NAME + " TEXT, " + COL_LOCATION + " INTEGER, "
//             + COL_TYPE + " INTEGER DEFAULT 0, "
//             + COL_SORT_ORDER + " INTEGER);";
// 
//     private static final String DROP_TABLE = "DROP TABLE IF EXISTS "
//             + TABLE_NAME;
// 
//     public static void onCreate (SQLiteDatabase db) { db.execSQL(CREATE_TABLE); }
// 
//     public static void onUpgrade (
//             SQLiteDatabase db,
//             int oldVersion,
//             int newVersion ) {
//         int curVer = oldVersion;
//         while (curVer < newVersion) {
//             curVer++;
//             if ( curVer == 15 ) {
//                 upgradeToVersion15(db);
//             }
//         }
//     }
// 
//     public static void upgradeToVersion15 (SQLiteDatabase db) {
//         onCreate(db);
//     }
// 
//     private static void dropTable (SQLiteDatabase db) { db.execSQL(DROP_TABLE); }
// 
//     public static void onDowngrade (
//             SQLiteDatabase db,
//             int oldVersion,
//             int newVersion ) {
//         int curVer = oldVersion;
//         while ( curVer > newVersion ) {
//             curVer--;
//             if (curVer < 15) {
//                 // drop the table if downgrade is less than 15 (version table was added)
//                 dropTable(db);
//                 break;
//             }
//         }
//     }
// }
// 
// Path: app/src/main/java/info/curtbinder/reefangel/phone/MemoryFragment.java
// public static final int CONFIRM_DELETE = 2;


// Path: app/src/main/java/info/curtbinder/reefangel/phone/DialogAddUserMemoryLocation.java
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import info.curtbinder.reefangel.db.UserMemoryLocationsTable;
import static info.curtbinder.reefangel.phone.MemoryFragment.TabUserFrag.CONFIRM_DELETE;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;

        } else {
            // TODO change hardcoded create location title to use string resource
            builder.setTitle("Add Location");
            builder.setNegativeButton(R.string.buttonCancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });
        }
        return builder.create();
    }

    private boolean isUpdate() {
        return (id > -1);
    }

    private void findViews(View v) {
        name = (EditText) v.findViewById(R.id.nameText);
        location = (EditText) v.findViewById(R.id.locationText);
        intButton = (RadioButton) v.findViewById(R.id.radioButtonInt);
        byteButton = (RadioButton) v.findViewById(R.id.radioButtonByte);
        // default to BYTE being selected
        ((RadioButton)v.findViewById(R.id.radioButtonByte)).setChecked(true);
    }

    private void loadData(Bundle args) {
        id = args.getLong(UserMemoryLocationsTable.COL_ID);
        String sName = args.getString(UserMemoryLocationsTable.COL_NAME);
        int iLocation = args.getInt(UserMemoryLocationsTable.COL_LOCATION);
        int type = args.getInt(UserMemoryLocationsTable.COL_TYPE);