// Path: app/src/main/java/info/curtbinder/reefangel/db/ErrorTable.java
// public class ErrorTable {
// 
// 	// private static final String TAG = ErrorTable.class.getSimpleName();
// 
// 	// Database constants
// 	public static final String TABLE_NAME = "errors";
// 	// columns
// 	public static final String COL_ID = "_id";
// 	public static final String COL_TIME = "time";
// 	public static final String COL_MESSAGE = "message";
// 	public static final String COL_READ = "read";
// 
// 	private static final String CREATE_TABLE =
// 			"CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// 					+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_TIME
// 					+ " INTEGER, " + COL_MESSAGE + " TEXT, " + COL_READ
// 					+ " 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++;
//             switch ( curVer ) {
//                 default:
//                     break;
//                 case 5:
//                     upgradeToVersion5(db);
//                     break;
//             }
//         }
// 	}
// 
//     private static void upgradeToVersion5 ( SQLiteDatabase db ) {
//         // table did not exist prior to version 5
//         dropTable(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--;
//             switch ( curVer ) {
//                 default:
//                     break;
//                 case 4:
//                 case 3:
//                 case 2:
//                 case 1:
//                     // drop the table if the downgraded version is less than 5
//                     dropTable(db);
//                     break;
//             }
//         }
// 	}
// }


import android.widget.TextView;
import info.curtbinder.reefangel.db.ErrorTable;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Curt Binder
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package info.curtbinder.reefangel.phone;



public class ErrorListCursorAdapter extends CursorAdapter {

	static class ViewHolder {
		TextView date;
		TextView msg;
	}

	public ErrorListCursorAdapter ( Context context, Cursor c, int flags ) {
		super( context, c, flags );
	}

	@Override
	public void bindView ( View view, Context context, Cursor cursor ) {
		final ViewHolder vh = (ViewHolder) view.getTag();
		setViews( vh, cursor );
	}

	@Override
	public View newView ( Context context, Cursor cursor, ViewGroup parent ) {
		final LayoutInflater inflater = LayoutInflater.from( context );
		View v = inflater.inflate( R.layout.frag_errors_item, parent, false );
		ViewHolder vh = new ViewHolder();
		vh.date = (TextView) v.findViewById( R.id.error_date );
		vh.msg = (TextView) v.findViewById( R.id.error_message );
		setViews( vh, cursor );
		v.setTag( vh );
		return v;
	}

	private void setViews ( ViewHolder v, Cursor c ) {
// Path: app/src/main/java/info/curtbinder/reefangel/db/ErrorTable.java
// public class ErrorTable {
// 
// 	// private static final String TAG = ErrorTable.class.getSimpleName();
// 
// 	// Database constants
// 	public static final String TABLE_NAME = "errors";
// 	// columns
// 	public static final String COL_ID = "_id";
// 	public static final String COL_TIME = "time";
// 	public static final String COL_MESSAGE = "message";
// 	public static final String COL_READ = "read";
// 
// 	private static final String CREATE_TABLE =
// 			"CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + COL_ID
// 					+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_TIME
// 					+ " INTEGER, " + COL_MESSAGE + " TEXT, " + COL_READ
// 					+ " 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++;
//             switch ( curVer ) {
//                 default:
//                     break;
//                 case 5:
//                     upgradeToVersion5(db);
//                     break;
//             }
//         }
// 	}
// 
//     private static void upgradeToVersion5 ( SQLiteDatabase db ) {
//         // table did not exist prior to version 5
//         dropTable(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--;
//             switch ( curVer ) {
//                 default:
//                     break;
//                 case 4:
//                 case 3:
//                 case 2:
//                 case 1:
//                     // drop the table if the downgraded version is less than 5
//                     dropTable(db);
//                     break;
//             }
//         }
// 	}
// }


// Path: app/src/main/java/info/curtbinder/reefangel/phone/ErrorListCursorAdapter.java
import android.widget.TextView;
import info.curtbinder.reefangel.db.ErrorTable;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Curt Binder
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package info.curtbinder.reefangel.phone;



public class ErrorListCursorAdapter extends CursorAdapter {

	static class ViewHolder {
		TextView date;
		TextView msg;
	}

	public ErrorListCursorAdapter ( Context context, Cursor c, int flags ) {
		super( context, c, flags );
	}

	@Override
	public void bindView ( View view, Context context, Cursor cursor ) {
		final ViewHolder vh = (ViewHolder) view.getTag();
		setViews( vh, cursor );
	}

	@Override
	public View newView ( Context context, Cursor cursor, ViewGroup parent ) {
		final LayoutInflater inflater = LayoutInflater.from( context );
		View v = inflater.inflate( R.layout.frag_errors_item, parent, false );
		ViewHolder vh = new ViewHolder();
		vh.date = (TextView) v.findViewById( R.id.error_date );
		vh.msg = (TextView) v.findViewById( R.id.error_message );
		setViews( vh, cursor );
		v.setTag( vh );
		return v;
	}

	private void setViews ( ViewHolder v, Cursor c ) {
		v.msg.setText( c.getString( c.getColumnIndex( ErrorTable.COL_MESSAGE ) ) );