// 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;
        findViews(root);
        Bundle args = getArguments();
        if (args != null) {
            loadData(args);
        } else {
            id = -1;
        }
        builder.setView(root);
        builder.setPositiveButton(R.string.buttonSave, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if ( ! canSave() ) {
                    return;
                }
                Intent intent = saveUserMemoryLocation();
                getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, intent);
            }
        });
        if (isUpdate()) {
            // TODO change hardcoded update title to use a string resource
            builder.setTitle("Update Location");
            builder.setNegativeButton(R.string.buttonDelete, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {

                    Intent intent = new Intent();
                    Bundle extras = new Bundle();
                    extras.putLong(UserMemoryLocationsTable.COL_ID, id);
                    intent.putExtras(extras);
                    getTargetFragment().onActivityResult(getTargetRequestCode(),
// 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;

        findViews(root);
        Bundle args = getArguments();
        if (args != null) {
            loadData(args);
        } else {
            id = -1;
        }
        builder.setView(root);
        builder.setPositiveButton(R.string.buttonSave, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if ( ! canSave() ) {
                    return;
                }
                Intent intent = saveUserMemoryLocation();
                getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, intent);
            }
        });
        if (isUpdate()) {
            // TODO change hardcoded update title to use a string resource
            builder.setTitle("Update Location");
            builder.setNegativeButton(R.string.buttonDelete, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {

                    Intent intent = new Intent();
                    Bundle extras = new Bundle();
                    extras.putLong(UserMemoryLocationsTable.COL_ID, id);
                    intent.putExtras(extras);
                    getTargetFragment().onActivityResult(getTargetRequestCode(),
                            CONFIRM_DELETE, intent);