1. Spencer Herzberg
  2. mythtv-for-android-mavenize

Commits

Spencer Herzberg  committed 060cdd6 Merge
  • Participants
  • Parent commits c1e3d44, 048309e
  • Branches master

Comments (0)

Files changed (35)

File AndroidManifest.xml

View file
  • Ignore whitespace
 		<activity 
 		    android:name=".client.ui.setup.capture.CaptureCardsActivity" />
 		
+		<!-- MythTV Android Services -->
+		<service android:name=".service.dvr.DvrService" />
+		
+		<!-- MythTV Android Providers -->
+		<provider
+            android:name=".provider.content.ArtworkProvider"
+            android:authorities="org.mythtv.content.artworks" />
+        		
+		<provider
+            android:name=".provider.dvr.ProgramGroupProvider"
+            android:authorities="org.mythtv.dvr.programGroups" />
+        		
+		<provider
+            android:name=".provider.dvr.ProgramProvider"
+            android:authorities="org.mythtv.dvr.programs" />
+        		
+		<provider
+            android:name=".provider.dvr.RecordingProvider"
+            android:authorities="org.mythtv.dvr.recordings" />
+        		
 	</application>
 
 </manifest>

File src/org/mythtv/client/db/DatabaseHelper.java

  • Ignore whitespace
-/**
- *  This file is part of MythTV for Android
- * 
- *  MythTV for Android is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  MythTV for Android is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with MythTV for Android.  If not, see <http://www.gnu.org/licenses/>.
- *   
- * @author Daniel Frey <dmfrey at gmail dot com>
- * @author John Baab <rhpot1991@ubuntu.com>
- * 
- * This software can be found at <https://github.com/dmfrey/mythtv-for-android/>
- *
- */
-
-package org.mythtv.client.db;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
-
-/**
- * @author Daniel Frey
- * @author John Baab
- *
- */
-public class DatabaseHelper extends SQLiteOpenHelper {
-
-	private static final String TAG = DatabaseHelper.class.getSimpleName();
-	
-	private static final String DATABASE_NAME = "mythtvdb";
-	private static final int DATABASE_VERSION = 5;
-
-	public static final String TABLE_LOCATION_PROFILE = "LOCATION_PROFILE";
-	public static final String TABLE_LOCATION_PROFILE_ID = "_ID";
-	public static final String TABLE_LOCATION_PROFILE_TYPE = "TYPE";
-	public static final String TABLE_LOCATION_PROFILE_NAME = "NAME";
-	public static final String TABLE_LOCATION_PROFILE_URL = "URL";
-	public static final String TABLE_LOCATION_PROFILE_SELECTED = "SELECTED";
-	public static final String SELECT_LOCATION_PROFILE =
-			"select " +
-				"lp._id, lp.type, lp.name, lp.url, lp.selected " +
-			"from " +
-				"location_profile lp";
-	
-	public static final String TABLE_PLAYBACK_PROFILE = "PLAYBACK_PROFILE";
-	public static final String TABLE_PLAYBACK_PROFILE_ID = "_ID";
-	public static final String TABLE_PLAYBACK_PROFILE_TYPE = "TYPE";
-	public static final String TABLE_PLAYBACK_PROFILE_NAME = "NAME";
-	public static final String TABLE_PLAYBACK_PROFILE_WIDTH = "WIDTH";
-	public static final String TABLE_PLAYBACK_PROFILE_HEIGHT = "HEIGHT";
-	public static final String TABLE_PLAYBACK_PROFILE_BITRATE = "BITRATE";
-	public static final String TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE = "AUDIO_BITRATE";
-	public static final String TABLE_PLAYBACK_PROFILE_SAMPLE_RATE = "SAMPLE_RATE";
-	public static final String TABLE_PLAYBACK_PROFILE_SELECTED = "SELECTED";
-	public static final String SELECT_PLAYBACK_PROFILE =
-			"select " +
-				"pp._id, pp.type, pp.name, pp.width, pp.height, pp.bitrate, pp.audio_bitrate, pp.sample_rate, lp.selected " +
-			"from " +
-				"playback_profile pp";
-
-	
-	public DatabaseHelper( Context context ) {
-		super( context, DATABASE_NAME, null, DATABASE_VERSION );
-	}
-	
-	/* (non-Javadoc)
-	 * @see android.database.sqlite.SQLiteOpenHelper#onCreate(android.database.sqlite.SQLiteDatabase)
-	 */
-	@Override
-	public void onCreate( SQLiteDatabase db ) {
-		Log.v( TAG, "onCreate : enter" );
-		
-		db.execSQL( "CREATE TABLE location_profile( _id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, name TEXT, url TEXT, selected INTEGER default 0 );" );
-
-		createPlaybackProfiles( db );
-		
-		Log.v( TAG, "onCreate : exit" );
-	}
-
-	/* (non-Javadoc)
-	 * @see android.database.sqlite.SQLiteOpenHelper#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)
-	 */
-	@Override
-	public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ) {
-		Log.v( TAG, "onUpgrade : enter" );
-
-	    db.execSQL( "DROP TABLE IF EXISTS playback_profile" );
-
-	    createPlaybackProfiles( db );
-	    
-		Log.v( TAG, "onUpgrade : exit" );
-	}
-
-	// internal helpers
-	
-	private void createPlaybackProfiles( SQLiteDatabase db ) {
-		Log.v( TAG, "createPlaybackProfiles : enter" );
-		
-		db.execSQL( "CREATE TABLE playback_profile( _id INTEGER PRIMARY KEY AUTOINCREMENT, type TEXT, name TEXT, url TEXT, width INTEGER, height INTEGER, bitrate INTEGER default 800000, audio_bitrate INTEGER default 64000, sample_rate INTEGER default 44100, selected INTEGER default 0 );" );
-
-		ContentValues values = new ContentValues();
-
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "720p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 1280 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 720 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 2000000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 192000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "720p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 1280 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 720 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 2000000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 192000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-		
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "630p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 1120 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 630 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 1500000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 192000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "630p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 1120 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 630 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 1500000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 192000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-		
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "540p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 960 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 540 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 1000000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 128000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 1 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "540p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 960 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 540 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 1000000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 128000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "480p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 854 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 480 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 800000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 128000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "480p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 854 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 480 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 800000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 128000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "360p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 640 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 360 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 500000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 96000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "360p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 640 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 360 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 500000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 96000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 1 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-		
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "HOME" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "270p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 480 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 270 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 300000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 96000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-
-		values = new ContentValues();
-		values.put( TABLE_PLAYBACK_PROFILE_TYPE, "AWAY" );
-		values.put( TABLE_PLAYBACK_PROFILE_NAME, "270p" );
-		values.put( TABLE_PLAYBACK_PROFILE_WIDTH, 480 );
-		values.put( TABLE_PLAYBACK_PROFILE_HEIGHT, 270 );
-		values.put( TABLE_PLAYBACK_PROFILE_BITRATE, 300000 );
-		values.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, 96000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, 48000 );
-		values.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-		db.insert( TABLE_PLAYBACK_PROFILE, null, values );
-		
-		Log.v( TAG, "createPlaybackProfiles : exit" );
-	}
-	
-}

File src/org/mythtv/client/db/MythtvDatabaseManager.java

  • Ignore whitespace
-/**
- *  This file is part of MythTV for Android
- * 
- *  MythTV for Android is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  MythTV for Android is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with MythTV for Android.  If not, see <http://www.gnu.org/licenses/>.
- *   
- * @author Daniel Frey <dmfrey at gmail dot com>
- * 
- * This software can be found at <https://github.com/dmfrey/mythtv-for-android/>
- *
- */
-
-package org.mythtv.client.db;
-
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE_ID;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE_NAME;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE_SELECTED;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE_TYPE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_LOCATION_PROFILE_URL;
-
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_ID;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_NAME;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_SELECTED;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_TYPE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_WIDTH;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_HEIGHT;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_BITRATE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE;
-import static org.mythtv.client.db.DatabaseHelper.TABLE_PLAYBACK_PROFILE_SAMPLE_RATE;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.mythtv.R;
-import org.mythtv.client.ui.preferences.LocationProfile;
-import org.mythtv.client.ui.preferences.LocationProfile.LocationType;
-import org.mythtv.client.ui.preferences.PlaybackProfile;
-
-import android.app.AlertDialog;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.database.Cursor;
-import android.database.SQLException;
-import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
-
-/**
- * @author Daniel Frey
- * 
- */
-public class MythtvDatabaseManager {
-
-	private static final String TAG = MythtvDatabaseManager.class.getSimpleName();
-
-	private final Context context;
-
-	private DatabaseHelper helper;
-	private SQLiteDatabase db;
-
-	/**
-	 * @param context
-	 */
-	public MythtvDatabaseManager( final Context context ) {
-		Log.v( TAG, "initialize : enter" );
-
-		this.context = context;
-		this.helper = new DatabaseHelper( context );
-
-		Log.v( TAG, "initialize : exit" );
-	}
-
-	/**
-	 * 
-	 */
-	private void open() {
-		Log.v( TAG, "open : enter" );
-
-		if( null != db ) {
-			close();
-		}
-
-		db = helper.getWritableDatabase();
-
-		Log.v( TAG, "open : exit" );
-	}
-
-	/**
-	 * 
-	 */
-	private void close() {
-		Log.v( TAG, "close : enter" );
-
-		helper.close();
-		db = null;
-
-		Log.v( TAG, "open : exit" );
-
-	}
-
-	/**
-	 * @return
-	 */
-	public List<LocationProfile> fetchHomeLocationProfiles() {
-		Log.v( TAG, "fetchHomeLocationProfiles : enter" );
-		Log.v( TAG, "fetchHomeLocationProfiles : exit" );
-		return fetchLocationProfilesByType( LocationType.HOME );
-	}
-
-	/**
-	 * @return
-	 */
-	public List<LocationProfile> fetchAwayLocationProfiles() {
-		Log.v( TAG, "fetchAwayLocationProfiles : enter" );
-		Log.v( TAG, "fetchAwayLocationProfiles : exit" );
-		return fetchLocationProfilesByType( LocationType.AWAY );
-	}
-
-	public LocationProfile fetchLocationProfile( long id ) {
-		Log.v( TAG, "fetchLocationProfile : enter" );
-		
-		open();
-		
-		LocationProfile profile = null;
-		
-		try {
-			Cursor cursor = db.query( 
-						TABLE_LOCATION_PROFILE, 
-						new String[] { TABLE_LOCATION_PROFILE_ID, TABLE_LOCATION_PROFILE_TYPE, TABLE_LOCATION_PROFILE_NAME, TABLE_LOCATION_PROFILE_URL, TABLE_LOCATION_PROFILE_SELECTED }, 
-						TABLE_LOCATION_PROFILE_ID + "=" + id, 
-						null, null, null, null 
-					  );
-			
-			if( cursor.getCount() == 1 && cursor.moveToFirst() ) {
-				Log.v( TAG, "fetchLocationProfile : location profile found" );
-
-				profile = convertCursorToLocationProfile( cursor );
-			}
-			
-			cursor.close();
-			
-		} catch( SQLException e ) {
-			Log.e( TAG, "fetchLocationProfile : error", e );
-			
-			AlertDialog.Builder builder = new AlertDialog.Builder( context );
-			builder.setTitle( "DataBase Error" );
-			builder.setMessage( "An error occurred locating profile" );
-			builder.setNeutralButton( R.string.close, new OnClickListener() {
-
-				public void onClick( DialogInterface dialog, int which ) { }
-			
-			});
-		} finally {
-			close();
-		}
-		
-		Log.v( TAG, "fetchLocationProfile : exit" );
-		return profile;
-	}
-
-	/**
-	 * @param profile
-	 * @return
-	 */
-	public long createHomeLocationProfile( LocationProfile profile ) {
-		Log.v( TAG, "createHomeLocationProfile : enter" );
-
-		profile.setType( LocationType.HOME );
-
-		long id = createLocationProfile( profile );
-		
-		if( fetchHomeLocationProfiles().size() == 1 ) {
-			Log.v( TAG, "createHomeLocationProfile : making default" );
-
-			setSelectedHomeLocationProfile( id );
-		}
-		
-		Log.v( TAG, "createHomeLocationProfile : exit" );
-		return id;
-	}
-
-	/**
-	 * @param profile
-	 * @return
-	 */
-	public long createAwayLocationProfile( LocationProfile profile ) {
-		Log.v( TAG, "createAwayLocationProfile : enter" );
-
-		profile.setType( LocationType.AWAY );
-
-		long id = createLocationProfile( profile );
-
-		if( fetchAwayLocationProfiles().size() == 1 ) {
-			Log.v( TAG, "createAwayLocationProfile : making default" );
-
-			setSelectedAwayLocationProfile( id );
-		}
-				
-		Log.v( TAG, "createAwayLocationProfile : enter" );
-		return id;
-	}
-
-	/**
-	 * @param profile
-	 * @return
-	 */
-	public boolean updateLocationProfile( LocationProfile profile ) {
-		Log.v( TAG, "updateLocationProfile : enter" );
-
-		open();
-
-		ContentValues args = new ContentValues();
-		args.put( TABLE_LOCATION_PROFILE_TYPE, profile.getType().name() );
-		args.put( TABLE_LOCATION_PROFILE_NAME, profile.getName() );
-		args.put( TABLE_LOCATION_PROFILE_URL, profile.getUrl() );
-		args.put( TABLE_LOCATION_PROFILE_SELECTED, profile.isSelected() ? 1 : 0 );
-
-		int rows = db.update( TABLE_LOCATION_PROFILE, args, TABLE_LOCATION_PROFILE_ID + "=" + profile.getId(), null );
-	
-		close();
-
-		Log.v( TAG, "updateLocationProfile : exit" );
-		return rows > 0;
-	}
-
-	/**
-	 * @param id
-	 * @return
-	 */
-	public boolean deleteLocationProfile( long id ) {
-		Log.v( TAG, "deleteLocationProfile : enter" );
-		
-		open();
-		
-		boolean result = db.delete( TABLE_LOCATION_PROFILE, TABLE_LOCATION_PROFILE_ID + "=" + id, null ) > 0;
-		
-		close();
-		
-		Log.v( TAG, "deleteLocationProfile : exit" );
-		return result;
-	}
-
-	/**
-	 * @param id
-	 * @return
-	 */
-	public boolean setSelectedHomeLocationProfile( long id ) {
-		Log.v( TAG, "setSelectedHomeLocationProfile : enter" );
-		Log.v( TAG, "setSelectedHomeLocationProfile : exit" );
-		return setSelectedLocationProfile( id, LocationType.HOME );
-	}
-
-	/**
-	 * @param id
-	 * @return
-	 */
-	public boolean setSelectedAwayLocationProfile( long id ) {
-		Log.v( TAG, "setSelectedAwayLocationProfile : enter" );
-		Log.v( TAG, "setSelectedAwayLocationProfile : exit" );
-		return setSelectedLocationProfile( id, LocationType.AWAY );
-	}
-
-	/**
-	 * @return
-	 */
-	public LocationProfile fetchSelectedHomeLocationProfile() {
-		Log.v( TAG, "fetchSelectedHomeLocationProfile : enter" );
-		Log.v( TAG, "fetchSelectedHomeLocationProfile : exit" );
-		return fetchSelectedLocationProfileByType( LocationType.HOME );
-	}
-
-	/**
-	 * @return
-	 */
-	public LocationProfile fetchSelectedAwayLocationProfile() {
-		Log.v( TAG, "fetchSelectedAwayLocationProfile : enter" );
-		Log.v( TAG, "fetchSelectedAwayLocationProfile : exit" );
-		return fetchSelectedLocationProfileByType( LocationType.AWAY );
-	}
-
-	/**
-	 * @return
-	 */
-	public List<PlaybackProfile> fetchHomePlaybackProfiles() {
-		Log.v( TAG, "fetchHomePlaybackProfiles : enter" );
-		Log.v( TAG, "fetchHomePlaybackProfiles : exit" );
-		return fetchPlaybackProfilesByType( LocationType.HOME );
-	}
-
-	/**
-	 * @return
-	 */
-	public List<PlaybackProfile> fetchAwayPlaybackProfiles() {
-		Log.v( TAG, "fetchAwayPlaybackProfiles : enter" );
-		Log.v( TAG, "fetchAwayPlaybackProfiles : exit" );
-		return fetchPlaybackProfilesByType( LocationType.AWAY );
-	}
-
-	public PlaybackProfile fetchPlaybackProfile( long id ) {
-		Log.v( TAG, "fetchPlaybackProfile : enter" );
-		
-		open();
-		
-		PlaybackProfile profile = null;
-		
-		try {
-			Cursor cursor = db.query( 
-						TABLE_PLAYBACK_PROFILE, 
-						new String[] { TABLE_PLAYBACK_PROFILE_ID, TABLE_PLAYBACK_PROFILE_TYPE, TABLE_PLAYBACK_PROFILE_NAME, TABLE_PLAYBACK_PROFILE_WIDTH, TABLE_PLAYBACK_PROFILE_HEIGHT, TABLE_PLAYBACK_PROFILE_BITRATE, TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, TABLE_PLAYBACK_PROFILE_SELECTED }, 
-						TABLE_PLAYBACK_PROFILE_ID + "=" + id, 
-						null, null, null, null 
-					  );
-			
-			if( cursor.getCount() == 1 && cursor.moveToFirst() ) {
-				Log.v( TAG, "fetchPlaybackProfile : playback profile found" );
-
-				profile = convertCursorToPlaybackProfile( cursor );
-			}
-			
-			cursor.close();
-			
-		} catch( SQLException e ) {
-			Log.e( TAG, "fetchPlaybackProfile : error", e );
-			
-			AlertDialog.Builder builder = new AlertDialog.Builder( context );
-			builder.setTitle( "DataBase Error" );
-			builder.setMessage( "An error occurred locating profile" );
-			builder.setNeutralButton( R.string.close, new OnClickListener() {
-
-				public void onClick( DialogInterface dialog, int which ) { }
-			
-			});
-		}
-		
-		close();
-		
-		Log.v( TAG, "fetchPlaybackProfile : exit" );
-		return profile;
-	}
-
-	/**
-	 * @param profile
-	 * @return
-	 */
-	public boolean updatePlaybackProfile( PlaybackProfile profile ) {
-		Log.v( TAG, "updatePlaybackProfile : enter" );
-
-		open();
-
-		ContentValues args = new ContentValues();
-		args.put( TABLE_PLAYBACK_PROFILE_TYPE, profile.getType().name() );
-		args.put( TABLE_PLAYBACK_PROFILE_NAME, profile.getName() );
-		args.put( TABLE_PLAYBACK_PROFILE_WIDTH, profile.getWidth() );
-		args.put( TABLE_PLAYBACK_PROFILE_HEIGHT, profile.getHeight() );
-		args.put( TABLE_PLAYBACK_PROFILE_BITRATE, profile.getVideoBitrate() );
-		args.put( TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, profile.getAudioBitrate() );
-		args.put( TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, profile.getAudioSampleRate() );
-		args.put( TABLE_PLAYBACK_PROFILE_SELECTED, profile.isSelected() ? 1 : 0 );
-
-		int rows = db.update( TABLE_PLAYBACK_PROFILE, args, TABLE_PLAYBACK_PROFILE_ID + "=" + profile.getId(), null );
-	
-		close();
-
-		Log.v( TAG, "updatePlaybackProfile : exit" );
-		return rows > 0;
-	}
-
-	/**
-	 * @param id
-	 * @return
-	 */
-	public boolean setSelectedHomePlaybackProfile( long id ) {
-		Log.v( TAG, "setSelectedHomePlaybackProfile : enter" );
-		Log.v( TAG, "setSelectedHomePlaybackProfile : exit" );
-		return setSelectedPlaybackProfile( id, LocationType.HOME );
-	}
-
-	/**
-	 * @param id
-	 * @return
-	 */
-	public boolean setSelectedAwayPlaybackProfile( long id ) {
-		Log.v( TAG, "setSelectedAwayPlaybackProfile : enter" );
-		Log.v( TAG, "setSelectedAwayPlaybackProfile : exit" );
-		return setSelectedPlaybackProfile( id, LocationType.AWAY );
-	}
-
-	/**
-	 * @return
-	 */
-	public PlaybackProfile fetchSelectedHomePlaybackProfile() {
-		Log.v( TAG, "fetchSelectedHomePlaybackProfile : enter" );
-		Log.v( TAG, "fetchSelectedHomePlaybackProfile : exit" );
-		return fetchSelectedPlaybackProfileByType( LocationType.HOME );
-	}
-
-	/**
-	 * @return
-	 */
-	public PlaybackProfile fetchSelectedAwayPlaybackProfile() {
-		Log.v( TAG, "fetchSelectedAwayPlaybackProfile : enter" );
-		Log.v( TAG, "fetchSelectedAwayPlaybackProfile : exit" );
-		return fetchSelectedPlaybackProfileByType( LocationType.AWAY );
-	}
-
-	// internal helpers
-
-	/**
-	 * @param cursor
-	 * @return
-	 */
-	private LocationProfile convertCursorToLocationProfile( Cursor cursor ) {
-		Log.v( TAG, "convertCursorToLocationProfile : enter" );
-		
-		LocationProfile profile = new LocationProfile();
-		profile.setId( cursor.getInt( 0 ) );
-		profile.setType( LocationType.valueOf( cursor.getString( 1 ) ) );
-		profile.setName( cursor.getString( 2 ) );
-		profile.setUrl( cursor.getString( 3 ) );
-		profile.setSelected( cursor.getInt( 4 ) != 0 );
-		
-		Log.v( TAG, "convertCursorToLocationProfile : exit" );
-		return profile;
-	}
-	
-	/**
-	 * @param cursor
-	 * @return
-	 */
-	private PlaybackProfile convertCursorToPlaybackProfile( Cursor cursor ) {
-		Log.v( TAG, "convertCursorToPlaybackProfile : enter" );
-		
-		PlaybackProfile profile = new PlaybackProfile();
-		profile.setId( cursor.getInt( 0 ) );
-		profile.setType( LocationType.valueOf( cursor.getString( 1 ) ) );
-		profile.setName( cursor.getString( 2 ) );
-		profile.setWidth( cursor.getInt( 3 ) );
-		profile.setHeight( cursor.getInt( 4 ) );
-		profile.setVideoBitrate( cursor.getInt( 5 ) );
-		profile.setAudioBitrate( cursor.getInt( 6 ) );
-		profile.setAudioSampleRate( cursor.getInt( 7 ) );
-		profile.setSelected( cursor.getInt( 8 ) != 0 );
-		
-		Log.v( TAG, "convertCursorToPlaybackProfile : exit" );
-		return profile;
-	}
-
-	/**
-	 * @param type
-	 * @return
-	 */
-	private List<LocationProfile> fetchLocationProfilesByType( LocationType type ) {
-		Log.v( TAG, "fetchLocationProfilesByType : enter" );
-		
-		open();
-		
-		List<LocationProfile> profiles = new ArrayList<LocationProfile>();
-
-		Cursor cursor = db.query( TABLE_LOCATION_PROFILE, new String[] { TABLE_LOCATION_PROFILE_ID, TABLE_LOCATION_PROFILE_TYPE, TABLE_LOCATION_PROFILE_NAME, TABLE_LOCATION_PROFILE_URL, TABLE_LOCATION_PROFILE_SELECTED }, "type=?",	new String[] { type.name() }, null, null, null );
-		
-		int count = cursor.getCount();
-		if( count > 0 && cursor.moveToFirst() ) {
-			Log.v( TAG, "fetchLocationProfilesByType : location profiles found" );
-		
-			for( int i = 0; i < count; i++ ) {
-				Log.v( TAG, "fetchLocationProfilesByType : location profile cursor iteration" );
-				
-				profiles.add( convertCursorToLocationProfile( cursor ) );
-				cursor.moveToNext();
-			}
-		}
-		
-		cursor.close();
-		close();
-		
-		Log.v( TAG, "fetchLocationProfilesByType : exit" );
-		return profiles;
-	}
-
-	/**
-	 * @param type
-	 * @return
-	 */
-	private List<PlaybackProfile> fetchPlaybackProfilesByType( LocationType type ) {
-		Log.v( TAG, "fetchPlaybackProfilesByType : enter" );
-		
-		open();
-		
-		List<PlaybackProfile> profiles = new ArrayList<PlaybackProfile>();
-
-		Cursor cursor = db.query( TABLE_PLAYBACK_PROFILE, new String[] { TABLE_PLAYBACK_PROFILE_ID, TABLE_PLAYBACK_PROFILE_TYPE, TABLE_PLAYBACK_PROFILE_NAME, TABLE_PLAYBACK_PROFILE_WIDTH, TABLE_PLAYBACK_PROFILE_HEIGHT, TABLE_PLAYBACK_PROFILE_BITRATE, TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, TABLE_PLAYBACK_PROFILE_SELECTED }, "type=?",	new String[] { type.name() }, null, null, null );
-		
-		int count = cursor.getCount();
-		if( count > 0 && cursor.moveToFirst() ) {
-			Log.v( TAG, "fetchPlaybackProfilesByType : playback profiles found" );
-		
-			for( int i = 0; i < count; i++ ) {
-				Log.v( TAG, "fetchPlaybackProfilesByType : playback profile cursor iteration" );
-				
-				profiles.add( convertCursorToPlaybackProfile( cursor ) );
-				cursor.moveToNext();
-			}
-		}
-		
-		cursor.close();
-		close();
-		
-		Log.v( TAG, "fetchPlaybackProfilesByType : exit" );
-		return profiles;
-	}
-
-	/**
-	 * @param profile
-	 * @return
-	 */
-	private long createLocationProfile( LocationProfile profile ) {
-		Log.v( TAG, "createLocationProfile : enter" );
-
-		Log.v( TAG, "createLocationProfile : profile=" + profile.toString() );
-		
-		open();
-		
-		ContentValues initialValues = new ContentValues();
-		initialValues.put( TABLE_LOCATION_PROFILE_TYPE, profile.getType().name() );
-		initialValues.put( TABLE_LOCATION_PROFILE_NAME, profile.getName() );
-		initialValues.put( TABLE_LOCATION_PROFILE_URL, profile.getUrl() );
-		initialValues.put( TABLE_LOCATION_PROFILE_SELECTED, 0 );
-
-		long id = db.insert( TABLE_LOCATION_PROFILE, null, initialValues );
-		
-		close();
-		
-		Log.v( TAG, "createLocationProfile : enter" );
-		return id;
-	}
-
-	private boolean setSelectedLocationProfile( long id, LocationType type ) {
-		Log.v( TAG, "setSelectedLocationProfile : enter" );
-
-		open();
-		
-		ContentValues args = new ContentValues();
-		args.put( TABLE_LOCATION_PROFILE_SELECTED, 0 );
-
-		db.update( TABLE_LOCATION_PROFILE, args, TABLE_LOCATION_PROFILE_TYPE + "=?", new String[] { type.name() } );
-
-		args = new ContentValues();
-		args.put( TABLE_LOCATION_PROFILE_SELECTED, 1 );
-
-		int rows = db.update( TABLE_LOCATION_PROFILE, args, TABLE_LOCATION_PROFILE_ID + "=?", new String[] { "" + id } );
-	
-		close();
-
-		Log.v( TAG, "setSelectedLocationProfile : exit" );
-		return rows > 0;
-	}
-
-	private boolean setSelectedPlaybackProfile( long id, LocationType type ) {
-		Log.v( TAG, "setSelectedPlaybackProfile : enter" );
-
-		open();
-		
-		ContentValues args = new ContentValues();
-		args.put( TABLE_PLAYBACK_PROFILE_SELECTED, 0 );
-
-		db.update( TABLE_PLAYBACK_PROFILE, args, TABLE_PLAYBACK_PROFILE_TYPE + "=?", new String[] { type.name() } );
-
-		args = new ContentValues();
-		args.put( TABLE_PLAYBACK_PROFILE_SELECTED, 1 );
-
-		int rows = db.update( TABLE_PLAYBACK_PROFILE, args, TABLE_PLAYBACK_PROFILE_ID + "=?", new String[] { "" + id } );
-	
-		close();
-
-		Log.v( TAG, "setSelectedPlaybackProfile : exit" );
-		return rows > 0;
-	}
-
-	private LocationProfile fetchSelectedLocationProfileByType( LocationType type ) {
-		Log.v( TAG, "fetchSelectedLocationProfileByType : enter" );
-		
-		open();
-		
-		LocationProfile profile = null;
-
-		try {
-			Cursor cursor = db.query( 
-						TABLE_LOCATION_PROFILE, 
-						new String[] { TABLE_LOCATION_PROFILE_ID, TABLE_LOCATION_PROFILE_TYPE, TABLE_LOCATION_PROFILE_NAME, TABLE_LOCATION_PROFILE_URL, TABLE_LOCATION_PROFILE_SELECTED }, 
-						TABLE_LOCATION_PROFILE_TYPE + "=? and " + TABLE_LOCATION_PROFILE_SELECTED + "=?", 
-						new String[] { type.name(), "1" }, 
-						null, null, null 
-					  );
-			
-			if( cursor.getCount() == 1 && cursor.moveToFirst() ) {
-				Log.v( TAG, "fetchSelectedLocationProfileByType : location profile found" );
-
-				profile = convertCursorToLocationProfile( cursor );
-			}
-			
-			cursor.close();
-			
-		} catch( SQLException e ) {
-			Log.e( TAG, "fetchSelectedLocationProfileByType : error", e );
-			
-			AlertDialog.Builder builder = new AlertDialog.Builder( context );
-			builder.setTitle( "DataBase Error" );
-			builder.setMessage( "An error occurred locating profile" );
-			builder.setNeutralButton( R.string.close, new OnClickListener() {
-
-				public void onClick( DialogInterface dialog, int which ) { }
-			
-			});
-		} finally {
-			close();
-		}
-		
-		Log.v( TAG, "fetchSelectedLocationProfileByType : exit" );
-		return profile;
-	}
-
-	private PlaybackProfile fetchSelectedPlaybackProfileByType( LocationType type ) {
-		Log.v( TAG, "fetchSelectedPlaybackProfileByType : enter" );
-		
-		open();
-		
-		PlaybackProfile profile = null;
-
-		try {
-			Cursor cursor = db.query( 
-						TABLE_PLAYBACK_PROFILE, 
-						new String[] { TABLE_PLAYBACK_PROFILE_ID, TABLE_PLAYBACK_PROFILE_TYPE, TABLE_PLAYBACK_PROFILE_NAME, TABLE_PLAYBACK_PROFILE_WIDTH, TABLE_PLAYBACK_PROFILE_HEIGHT, TABLE_PLAYBACK_PROFILE_BITRATE, TABLE_PLAYBACK_PROFILE_AUDIO_BITRATE, TABLE_PLAYBACK_PROFILE_SAMPLE_RATE, TABLE_PLAYBACK_PROFILE_SELECTED }, 
-						TABLE_PLAYBACK_PROFILE_TYPE + "=? and " + TABLE_PLAYBACK_PROFILE_SELECTED + "=?", 
-						new String[] { type.name(), "1" }, 
-						null, null, null 
-					  );
-			
-			if( cursor.getCount() == 1 && cursor.moveToFirst() ) {
-				Log.v( TAG, "fetchSelectedPlaybackProfileByType : playback profile found" );
-
-				profile = convertCursorToPlaybackProfile( cursor );
-			}
-			
-			cursor.close();
-			
-		} catch( SQLException e ) {
-			Log.e( TAG, "fetchSelectedPlaybackProfileByType : error", e );
-			
-			AlertDialog.Builder builder = new AlertDialog.Builder( context );
-			builder.setTitle( "DataBase Error" );
-			builder.setMessage( "An error occurred locating profile" );
-			builder.setNeutralButton( R.string.close, new OnClickListener() {
-
-				public void onClick( DialogInterface dialog, int which ) { }
-			
-			});
-		} finally {
-			close();
-		}
-		
-		Log.v( TAG, "fetchSelectedPlaybackProfileByType : exit" );
-		return profile;
-	}
-
-}

File src/org/mythtv/client/ui/AbstractLocationAwareFragmentActivity.java

View file
  • Ignore whitespace
  */
 package org.mythtv.client.ui;
 
+import org.mythtv.service.dvr.DvrServiceHelper;
+
 import android.app.ActionBar;
+import android.content.BroadcastReceiver;
+import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
 
 	protected static final String TAG = AbstractLocationAwareFragmentActivity.class.getSimpleName();
 
+	private Long requestId;
+	private BroadcastReceiver requestReceiver;
+
+	private DvrServiceHelper mDvrServiceHelper;
+
 	// ***************************************
 	// FragmentActivity methods
 	// ***************************************
 		Log.v( TAG, "onCreate : enter" );
 
 		super.onCreate( savedInstanceState );
-
+		
 		resources = getResources();
 
 		setupActionBar();
 		Log.v( TAG, "onCreate : exit" );
 	}
 
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.FragmentActivity#onResume()
+	 */
+	@Override
+	protected void onResume() {
+		Log.v( TAG, "onResume : enter" );
+		super.onResume();
+
+		IntentFilter filter = new IntentFilter( DvrServiceHelper.ACTION_REQUEST_RESULT );
+		requestReceiver = new BroadcastReceiver() {
+
+			@Override
+			public void onReceive( Context context, Intent intent ) {
+
+				long resultRequestId = intent.getLongExtra( DvrServiceHelper.EXTRA_REQUEST_ID, 0 );
+
+				Log.d( TAG, "Received intent " + intent.getAction() + ", request ID " + resultRequestId );
+
+				if( resultRequestId == requestId ) {
+
+					Log.d( TAG, "Result is for our request ID" );
+					
+					int resultCode = intent.getIntExtra( DvrServiceHelper.EXTRA_RESULT_CODE, 0 );
+
+					Log.d( TAG, "Result code = " + resultCode );
+
+					if( resultCode == 200 ) {
+						Log.d( TAG, "Updating UI with new data" );
+					} else {
+						Log.d( TAG, "error occurred" );
+					}
+				} else {
+					Log.d( TAG, "Result is NOT for our request ID" );
+				}
+
+			}
+		};
+
+		mDvrServiceHelper = DvrServiceHelper.getInstance( this );
+		this.registerReceiver( requestReceiver, filter );
+
+		if( requestId == null ) {
+			Log.i( TAG, "onResume : loading recordedList" );
+
+			requestId = mDvrServiceHelper.getRecordingedList();
+		} else if( mDvrServiceHelper.isRequestPending( requestId ) ) {
+			Log.i( TAG, "onResume : recordedList waiting" );
+		} else {
+			Log.i( TAG, "onResume : recordedList loaded" );
+		}
+
+		Log.v( TAG, "onResume : exit" );
+	}
+
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.FragmentActivity#onPause()
+	 */
+	@Override
+	protected void onPause() {
+		Log.v( TAG, "onPause : enter" );
+		super.onPause();
+
+		// Unregister for broadcast
+		if( null != requestReceiver ) {
+			try {
+				unregisterReceiver( requestReceiver );
+			} catch( IllegalArgumentException e ) {
+				Log.e( TAG, e.getLocalizedMessage(), e );
+			}
+		}
+		
+		Log.v( TAG, "onPause : exit" );
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 

File src/org/mythtv/client/ui/AwayActivity.java

View file
  • Ignore whitespace
 
 	private final static String TAG = AwayActivity.class.getSimpleName();
 	
+	/* (non-Javadoc)
+	 * @see org.mythtv.client.ui.AbstractLocationAwareFragmentActivity#onCreate(android.os.Bundle)
+	 */
 	@Override
 	protected void onCreate( Bundle savedInstanceState ) {
 		Log.d( TAG, "onCreate : enter" );

File src/org/mythtv/client/ui/LocationActivity.java

View file
  • Ignore whitespace
 package org.mythtv.client.ui;
 
 import org.mythtv.R;
-import org.mythtv.client.db.MythtvDatabaseManager;
 import org.mythtv.client.ui.preferences.LocationProfile;
 import org.mythtv.client.ui.preferences.MythtvPreferenceActivity;
 import org.mythtv.client.ui.preferences.MythtvPreferenceActivityHC;
 import org.mythtv.client.ui.preferences.PlaybackProfile;
+import org.mythtv.db.MythtvDatabaseManager;
 
 import android.content.Context;
 import android.content.Intent;

File src/org/mythtv/client/ui/dvr/ProgramGroupActivity.java

View file
  • Ignore whitespace
 	@Override
 	protected void onCreate( Bundle savedInstanceState ) {
 		Log.v( TAG, "onCreate : enter" );
-
 		super.onCreate( savedInstanceState );
 
+		Bundle extras = getIntent().getExtras(); 
+		String name = extras.getString( EXTRA_PROGRAM_GROUP_KEY );
+		
 		setContentView( R.layout.fragment_dvr_program_group );
 
 		programGroupFragment = (ProgramGroupFragment) getSupportFragmentManager().findFragmentById( R.id.fragment_dvr_program_group );
-		programGroupFragment.setActivity( this );
-		programGroupFragment.loadPrograms();
+		programGroupFragment.loadPrograms( name );
 		
 		Log.v( TAG, "onCreate : exit" );
 	}

File src/org/mythtv/client/ui/dvr/ProgramGroupFragment.java

View file
  • Ignore whitespace
  */
 package org.mythtv.client.ui.dvr;
 
-import java.util.List;
-
 import org.mythtv.R;
-import org.mythtv.client.MainApplication;
 import org.mythtv.client.ui.util.MythtvListFragment;
-import org.mythtv.services.api.dvr.Program;
+import org.mythtv.db.dvr.ProgramConstants;
 
-import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
+import android.database.Cursor;
 import android.os.Bundle;
+import android.provider.BaseColumns;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v4.widget.CursorAdapter;
+import android.support.v4.widget.SimpleCursorAdapter;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.BaseAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
 
  * @author John Baab
  * 
  */
-public class ProgramGroupFragment extends MythtvListFragment {
+public class ProgramGroupFragment extends MythtvListFragment implements LoaderManager.LoaderCallbacks<Cursor> {
 
 	private static final String TAG = ProgramGroupFragment.class.getSimpleName();
 
-	private ProgramAdapter adapter = null;
+	private ProgramCursorAdapter adapter;
 	
-	private Activity activity;
+	public ProgramGroupFragment() { }
 	
-	public ProgramGroupFragment() {
-		this( null );
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onCreateLoader(int, android.os.Bundle)
+	 */
+	@Override
+	public Loader<Cursor> onCreateLoader( int id, Bundle args ) {
+		Log.v( TAG, "onCreateLoader : enter" );
+		
+		String name = args.getString( ProgramGroupActivity.EXTRA_PROGRAM_GROUP_KEY );
+		Log.v( TAG, "onCreateLoader : name=" + name );
+		
+		String[] projection = { BaseColumns._ID, ProgramConstants.FIELD_TITLE, ProgramConstants.FIELD_SUB_TITLE };
+		String[] selectionArgs = { name };
+		 
+	    CursorLoader cursorLoader = new CursorLoader( getActivity(), ProgramConstants.CONTENT_URI, projection, ProgramConstants.FIELD_TITLE + "=?", selectionArgs, ProgramConstants.FIELD_SUB_TITLE );
+	    Log.v( TAG, "onCreateLoader : cursorLoader=" + cursorLoader.toString() );
+	    
+	    Log.v( TAG, "onCreateLoader : exit" );
+		return cursorLoader;
+	}
+
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader, java.lang.Object)
+	 */
+	@Override
+	public void onLoadFinished( Loader<Cursor> loader, Cursor cursor ) {
+		Log.v( TAG, "onLoadFinished : enter" );
+		
+		adapter.swapCursor( cursor );
+		
+		Log.v( TAG, "onLoadFinished : exit" );
 	}
-	
-	public ProgramGroupFragment( Activity activity ) {
-		super();
-		Log.i( TAG, "initialize : enter" );
 
-		this.activity = activity;
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoaderReset(android.support.v4.content.Loader)
+	 */
+	@Override
+	public void onLoaderReset( Loader<Cursor> loader ) {
+		Log.v( TAG, "onLoaderReset : enter" );
 		
-		Log.i( TAG, "initialize : exit" );
+		adapter.swapCursor( null );
+				
+		Log.v( TAG, "onLoaderReset : exit" );
+	}
+
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.Fragment#onCreate(android.os.Bundle)
+	 */
+	@Override
+	public void onCreate( Bundle savedInstanceState ) {
+		Log.i( TAG, "onCreate : enter" );
+		super.onCreate( savedInstanceState );
+
+		Log.i( TAG, "onCreate : exit" );
 	}
 
 	@Override
 	public void onActivityCreated( Bundle savedInstanceState ) {
 		Log.i( TAG, "onActivityCreated : enter" );
-
 		super.onActivityCreated( savedInstanceState );
 	    
-   		loadPrograms();
-
 	    Log.i( TAG, "onActivityCreated : exit" );
 	}
 
-	public void setActivity( Activity activity ) {
-		this.activity = activity;
-	}
-	
-	public void loadPrograms() {
+	public void loadPrograms( String name ) {
 		Log.i( TAG, "loadPrograms : enter" );
 
-		if( null != activity ) {
-			adapter = new ProgramAdapter( ( (MainApplication) activity.getApplicationContext() ).getCurrentRecordingsInProgramGroup() );
-			setListAdapter( adapter );
-		}
+		Log.i( TAG, "loadPrograms : name=" + name );
+
+		Bundle args = new Bundle();
+		args.putString( ProgramGroupActivity.EXTRA_PROGRAM_GROUP_KEY, name );
 		
-		Log.i( TAG, "loadPrograms : exit" );
+		getLoaderManager().initLoader( 0, args, this );
+
+	    adapter = new ProgramCursorAdapter(
+	            getActivity().getApplicationContext(), R.layout.program_row,
+	            null, new String[] { ProgramConstants.FIELD_SUB_TITLE }, new int[] { R.id.program_sub_title },
+	            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
+
+	    setListAdapter( adapter );
+	    
+	    Log.i( TAG, "loadPrograms : exit" );
 	}
 	
 	@Override
 
 		super.onListItemClick( l, v, position, id );
 		
-		Log.v (TAG, "position : " + position);
+		Log.v (TAG, "onListItemClick : position=" + position + ", id=" + id );
 	    
-		Program program = adapter.getItem( position );
-		getApplicationContext().setCurrentProgram( program );
-		
 		Intent i = new Intent( getActivity(), VideoActivity.class );
+		i.putExtra( VideoActivity.EXTRA_PROGRAM_KEY, id );
 		startActivity( i );
 
 		Log.v( TAG, "onListItemClick : exit" );
 	}
 	
-	private class ProgramAdapter extends BaseAdapter {
-		List<Program> programs = null;
-
-		ProgramAdapter( List<Program> programs ) {
-			super();
+	private class ProgramCursorAdapter extends SimpleCursorAdapter {
 
-			this.programs = programs;
-		}
-
-		@Override
-		public int getCount() {
-			return programs.size();
-		}
-
-		@Override
-		public Program getItem( int position ) {
-			return programs.get( position );
-		}
-
-		@Override
-		public long getItemId( int position ) {
-			return position;
+		public ProgramCursorAdapter( Context context, int layout, Cursor c, String[] from, int[] to, int flags ) {
+			super( context, layout, c, from, to, flags );
 		}
 
 		@Override
 		public View getView( int position, View convertView, ViewGroup parent ) {
-			View row = convertView;
-
-			if( row == null ) {
-				LayoutInflater inflater = getActivity().getLayoutInflater();
-
-				row = inflater.inflate( R.layout.program_row, parent, false );
-			}
-
-			Program program = getItem( position );
-
-			TextView title = (TextView) row.findViewById( R.id.program_sub_title );
-			title.setText( !"".equals( program.getSubTitle().trim() ) ? program.getSubTitle() : program.getTitle() );
-
-			//TextView description = (TextView) row.findViewById( R.id.program_description );
-			//description.setText( program.getDescription() );
-
+			Log.v( TAG, "getView : enter" );
+
+			View row =  super.getView( position, convertView, parent );
+			
+			getCursor().moveToPosition( position );
+		    try {
+		        int idIndex = getCursor().getColumnIndexOrThrow( BaseColumns._ID );
+		        int titleIndex = getCursor().getColumnIndexOrThrow( ProgramConstants.FIELD_TITLE );
+				int subTitleIndex = getCursor().getColumnIndexOrThrow( ProgramConstants.FIELD_SUB_TITLE );
+
+		        int id = getCursor().getInt( idIndex );
+		        String title = getCursor().getString( titleIndex );
+		        String subTitle = getCursor().getString( subTitleIndex );
+
+		        Log.v( TAG, "getView : id=" + id + ", title=" + title + ", subTitle=" + subTitle );
+		        
+				if( row == null ) {
+					LayoutInflater inflater = getActivity().getLayoutInflater();
+
+					row = inflater.inflate( R.layout.program_row, parent, false );
+				}
+
+				TextView t = (TextView) row.findViewById( R.id.program_sub_title );
+				t.setText( !"".equals( subTitle ) ? subTitle : title );
+
+		    } catch( Exception e ) {
+				Log.e( TAG, "getView : error", e );
+		    }
+		    
 			return row;
 		}
+
 	}
 
 }

File src/org/mythtv/client/ui/dvr/RecordingsActivity.java

View file
  • Ignore whitespace
 		Log.i( TAG, "onCreate : exit" );
 	}
 
-	public void addProgramGroupFragment( ProgramGroup programGroup ) {
+	public void addProgramGroupFragment( String programGroup ) {
 		Log.d( TAG, "addProgramGroupFragment : enter" );
 
 		FragmentManager fragMgr = getSupportFragmentManager();
+		
 		ProgramGroupFragment programGroupFragment = (ProgramGroupFragment) fragMgr.findFragmentById( R.id.fragment_dvr_program_group );
+		
 		FragmentTransaction xaction = fragMgr.beginTransaction();
 
 		if( null == programGroupFragment ) {
 			Log.v( TAG, "addProgramGroupFragment : creating new program group fragment" );
 
-			programGroupFragment = new ProgramGroupFragment( this );
+			programGroupFragment = new ProgramGroupFragment();
 
 			xaction
 				.add( R.id.fragment_dvr_program_group, programGroupFragment )
 				.commit();
 		}
 
-		programGroupFragment.loadPrograms();
+		programGroupFragment.loadPrograms( programGroup );
 		
 		Log.d( TAG, "addProgramGroupFragment : exit" );
 	}
 
-	public void onProgramGroupSelected( ProgramGroup programGroup ) {
+	public void onProgramGroupSelected( String programGroup ) {
 		Log.d( TAG, "onProgramGroupSelected : enter" );
 
-		getApplicationContext().setCurrentRecordingsInProgramGroup( programGroup.getRecordings() );
-
+		
 		if( isTwoPane ) {
 			Log.v( TAG, "onProgramGroupSelected : adding program group to pane" );
 
 			Log.v( TAG, "onProgramGroupSelected : starting program group activity" );
 
 			Intent i = new Intent( this, ProgramGroupActivity.class );
+			i.putExtra( ProgramGroupActivity.EXTRA_PROGRAM_GROUP_KEY, programGroup );
 			startActivity( i );
 		}
 

File src/org/mythtv/client/ui/dvr/RecordingsFragment.java

View file
  • Ignore whitespace
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
 
 import org.mythtv.R;
 import org.mythtv.client.ui.util.MythtvListFragment;
-import org.mythtv.services.api.content.ArtworkInfo;
-import org.mythtv.services.api.dvr.Program;
+import org.mythtv.db.dvr.ProgramGroupConstants;
 
-import android.app.AlertDialog;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.BitmapDrawable;
 import android.os.AsyncTask;
 import android.os.Bundle;
+import android.provider.BaseColumns;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v4.widget.CursorAdapter;
+import android.support.v4.widget.SimpleCursorAdapter;
 import android.util.Log;
-import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.BaseAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
 
  * @author Daniel Frey
  * 
  */
-public class RecordingsFragment extends MythtvListFragment {
+public class RecordingsFragment extends MythtvListFragment implements LoaderManager.LoaderCallbacks<Cursor> {
 
 	private static final String TAG = RecordingsFragment.class.getSimpleName();
 
 	private OnProgramGroupListener listener = null;
-	private ProgramGroupAdapter adapter = null;
+	private ProgramGroupCursorAdapter adapter;
+	
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onCreateLoader(int, android.os.Bundle)
+	 */
+	@Override
+	public Loader<Cursor> onCreateLoader( int id, Bundle args ) {
+		Log.v( TAG, "onCreateLoader : enter" );
+		
+		String[] projection = { BaseColumns._ID, ProgramGroupConstants.FIELD_PROGRAM_GROUP, ProgramGroupConstants.FIELD_INETREF, ProgramGroupConstants.FIELD_BANNER_URL };
+		 
+	    CursorLoader cursorLoader = new CursorLoader( getActivity(), ProgramGroupConstants.CONTENT_URI, projection, null, null, ProgramGroupConstants.FIELD_PROGRAM_GROUP );
+		
+	    Log.v( TAG, "onCreateLoader : exit" );
+		return cursorLoader;
+	}
+
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoadFinished(android.support.v4.content.Loader, java.lang.Object)
+	 */
+	@Override
+	public void onLoadFinished( Loader<Cursor> loader, Cursor cursor ) {
+		Log.v( TAG, "onLoadFinished : enter" );
+		
+		adapter.swapCursor( cursor );
+		
+		Log.v( TAG, "onLoadFinished : exit" );
+	}
+
+	/* (non-Javadoc)
+	 * @see android.support.v4.app.LoaderManager.LoaderCallbacks#onLoaderReset(android.support.v4.content.Loader)
+	 */
+	@Override
+	public void onLoaderReset( Loader<Cursor> loader ) {
+		Log.v( TAG, "onLoaderReset : enter" );
+		
+		adapter.swapCursor( null );
+				
+		Log.v( TAG, "onLoaderReset : exit" );
+	}
 
 	@Override
 	public void onCreate( Bundle savedInstanceState ) {
 
 		setRetainInstance( true );
 
+		getLoaderManager().initLoader( 0, null, this );
+		 
+	    adapter = new ProgramGroupCursorAdapter(
+	            getActivity().getApplicationContext(), R.layout.program_group_row,
+	            null, new String[] { ProgramGroupConstants.FIELD_PROGRAM_GROUP }, new int[] { R.id.program_group_row },
+	            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER );
+	    
+	    setListAdapter( adapter );
+		
 		Log.v( TAG, "onCreate : exit" );
 	}
 
 
 		super.onResume();
 	    
-		if( null != getApplicationContext().getRecordingsLoaded() ) {
-			Log.v( TAG, "onResume : recordings previously loaded" );
-			
-			Calendar now = Calendar.getInstance();
-			long nowTimeInMillis = now.getTimeInMillis();
-			long loadedTimeInMillis = getApplicationContext().getRecordingsLoaded().getTimeInMillis();
-			
-			long diff = loadedTimeInMillis - nowTimeInMillis;
-			if( diff / (60 * 1000) > 30 ) {
-				Log.v( TAG, "onResume : its been more than 30 minutes, refresh recordings" );
-				
-				getApplicationContext().getProgramGroups().clear();
-			}
-		}
-		
-		if( null == getApplicationContext().getProgramGroups() || getApplicationContext().getProgramGroups().isEmpty() ) {
-			Log.v( TAG, "onResume : load recordings" );
-
-			loadRecordings();
-		} else {
-			Log.v( TAG, "onResume : restore recordings" );
-
-			setProgramGroupAdapter();
-		}
-
 		Log.v( TAG, "onResume : exit" );
 	}
 	
 		Log.v( TAG, "onListItemClick : enter" );
 
 		super.onListItemClick( l, v, position, id );
-	    
-		if( null != listener ) {
-			Log.v( TAG, "onListItemClick : selecting programGroup at position " + position );
-			
-			listener.onProgramGroupSelected( adapter.getItem( position ) );
-		}
+		Log.v( TAG, "onListItemClick : position=" + position + ", id=" + id );
 
+		Cursor cursor = getActivity().getApplicationContext().getContentResolver().query( ContentUris.withAppendedId( ProgramGroupConstants.CONTENT_URI, id ), new String[] { ProgramGroupConstants.FIELD_PROGRAM_GROUP }, null, null, null );
+		if( cursor.moveToFirst() ) {
+			int nameIndex = cursor.getColumnIndexOrThrow( ProgramGroupConstants.FIELD_PROGRAM_GROUP );
+			String name = cursor.getString( nameIndex );
+		
+			listener.onProgramGroupSelected( name );
+		}
+		cursor.close();
+		
 		Log.v( TAG, "onListItemClick : exit" );
 	}
 	  
-	public void loadRecordings() {
-		Log.v( TAG, "loadRecordings : enter" );
-
-		new DownloadRecordedTask().execute();
-
-		Log.v( TAG, "loadRecordings : exit" );
-	}
-
 	public void setOnProgramGroupListener( OnProgramGroupListener listener ) {
 		Log.v( TAG, "setOnProgramGroupListener : enter" );
 
 	}
 
 	public interface OnProgramGroupListener {
-		void onProgramGroupSelected( ProgramGroup programGroup );
+		void onProgramGroupSelected( String programGroup );
 	}
 
-	private void setRecordingsInProgramGroups( List<Program> programs ) {
-		Log.v( TAG, "setRecordingsInProgramGroups : enter" );
-		
-		List<ProgramGroup> programGroups = new ArrayList<ProgramGroup>();
-		ProgramGroup all = new ProgramGroup();
-		all.setName( "All" );
-		all.setRecordings( programs );
-		programGroups.add( all );
-		
-		Map<String, List<Program>>recordingsInProgramGroups = new TreeMap<String, List<Program>>();
-		
-		String title;
-		for( Program program : programs ) {
-			Log.v( TAG, "setRecordingsInProgramGroups : program iteration" );
-			
-			title = program.getTitle();
+//	private void exceptionDialolg( Throwable t ) {
+//		AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() );
+//
+//		builder
+//			.setTitle( R.string.exception )
+//			.setMessage( t.toString() )
+//			.setPositiveButton( R.string.close, null )
+//				.show();
+//	}
 
-			if( !recordingsInProgramGroups.containsKey( title ) ) {
-				List<Program> recordingsInThisProgramGroup = new ArrayList<Program>();
-				recordingsInThisProgramGroup.add( program );
-				
-				Log.v( TAG, "setRecordingsInProgramGroups : adding new program group, title=" + title );
-				recordingsInProgramGroups.put( title, recordingsInThisProgramGroup );
-			} else {
-				Log.v( TAG, "setRecordingsInProgramGroups : updating program group, title=" + title );
+	private class ProgramGroupCursorAdapter extends SimpleCursorAdapter {
 
-				recordingsInProgramGroups.get( title ).add( program );
-			}
+		public ProgramGroupCursorAdapter( Context context, int layout, Cursor c, String[] from, int[] to, int flags ) {
+			super( context, layout, c, from, to, flags );
 		}
 
-		for( String key : recordingsInProgramGroups.keySet() ) {
-			ProgramGroup programGroup = new ProgramGroup();
-			programGroup.setName( key );
-			programGroup.setRecordings( recordingsInProgramGroups.get( key ) );
+		/* (non-Javadoc)
+		 * @see android.support.v4.widget.CursorAdapter#getView(int, android.view.View, android.view.ViewGroup)
+		 */
+		@SuppressWarnings( "deprecation" )
+		@Override
+		public View getView( int position, View convertView, ViewGroup parent ) {
 			
-			programGroups.add( programGroup );
+			View row =  super.getView( position, convertView, parent );
 			
-			for( Program program : programGroup.getRecordings() ) {
-				Log.v( TAG, "getView : programsInProgramGroup iteration" );
-
-				if( null == programGroup.getBanner() && ( null != program.getArtwork() && null != program.getArtwork().getArtworkInfos() && !program.getArtwork().getArtworkInfos().isEmpty() ) ) {
-					Log.v( TAG, "getView : programsInProgramGroup contains artwork" );
+			getCursor().moveToPosition( position );
+		    try {
+		        int idIndex = getCursor().getColumnIndexOrThrow( BaseColumns._ID );
+		        int nameIndex = getCursor().getColumnIndexOrThrow( ProgramGroupConstants.FIELD_PROGRAM_GROUP );
+				int inetrefIndex = getCursor().getColumnIndexOrThrow( ProgramGroupConstants.FIELD_INETREF );
+		        int bannerIndex = getCursor().getColumnIndexOrThrow( ProgramGroupConstants.FIELD_BANNER_URL );
+
+		        int id = getCursor().getInt( idIndex );
+		        String name = getCursor().getString( nameIndex );
+		        String inetref = getCursor().getString( inetrefIndex );
+		        String banner = getCursor().getString( bannerIndex );
+		        Log.v( TAG, "getView : id=" + id + ", name=" + name + ", inetref=" + inetref + ", banner=" + banner );
+		        
+				TextView textView = (TextView) row.findViewById( R.id.program_group_row );
+				if( null == banner || "".equals( banner ) ) {
+					Log.v( TAG, "getView : program group contains no artwork" );
+
+					row.setBackgroundDrawable( null );
+					textView.setText( name );
+
+					if( !"N/A".equals( banner ) && ( null != inetref && !"".equals( inetref ) ) ) {
+						new DownloadBannerImageTask().execute( id, name, inetref );
+					}
+				} else {
+					Log.v( TAG, "getView : program group contains artwork" );
 
 					File root = getActivity().getExternalCacheDir();
 
 					File pictureDir = new File( root, DownloadBannerImageTask.BANNERS_DIR );
 					pictureDir.mkdirs();
 
-		            String filename = programGroup.getName();
-		            filename = filename.replace( ':', '_' );
-		            filename = filename.replace( '/', '_' );
-
-		            File f = new File( pictureDir, filename + ".png" );
+		            File f = new File( pictureDir, inetref + ".png" );
 					if( f.exists() ) {
 						Log.v( TAG, "getView : loading banner from cache" );
 						
 						try {
 							InputStream is = new FileInputStream( f );
 							Bitmap bitmap = BitmapFactory.decodeStream( is );
-							programGroup.setBanner( new BitmapDrawable( bitmap ) );
-						} catch( Exception e ) {
-							Log.e( TAG, "getView : error reading file", e );
-						}
-						
-						break;
-					} else {
-						for( ArtworkInfo info : program.getArtwork().getArtworkInfos() ) {
-							Log.v( TAG, "getView : programsInProgramGroup artwork iteration" );
-
-							if( info.getStorageGroup().equals( DownloadBannerImageTask.BANNERS_DIR ) ) {
-								Log.v( TAG, "getView : programsInProgramGroup contains banner artwork" );
 
-								new DownloadBannerImageTask().execute( programGroup, program.getInetref() );
+							row.setBackgroundDrawable( new BitmapDrawable( bitmap ) );
+							textView.setText( "" );
+						} catch( Exception e ) {
+							Log.e( TAG, "getView : error reading file" );
 
-								break;
-							}
+							row.setBackgroundDrawable( null );
+							textView.setText( name );
 						}
+					} else {
+				        row.setBackgroundDrawable( null );
+						textView.setText( name );
 					}
 				}
-			}
-
+		    } catch( Exception e ) {
+				Log.e( TAG, "getView : error", e );
+		    }
+		    
+			return row;
 		}
-
-		getApplicationContext().setProgramGroups( programGroups );
-		getApplicationContext().setRecordingsLoaded( Calendar.getInstance() );
-		
-		setProgramGroupAdapter();
 		
-		Log.v( TAG, "setRecordingsInProgramGroups : exit" );
 	}
 	
-	private void setProgramGroupAdapter() {
-		Log.v( TAG, "setProgramGroupAdapter : enter" );
-		
-		adapter = new ProgramGroupAdapter( getApplicationContext().getProgramGroups() );
-		setListAdapter( adapter );
-
-		Log.v( TAG, "setProgramGroupAdapter : exit" );
-	}
-	
-	private void exceptionDialolg( Throwable t ) {
-		AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() );
-
-		builder
-			.setTitle( R.string.exception )
-			.setMessage( t.toString() )
-			.setPositiveButton( R.string.close, null )
-				.show();
-	}
-
-	private class DownloadRecordedTask extends AsyncTask<Void, Void, List<Program>> {
-
-		private Exception e = null;
-
-		@Override
-		protected List<Program> doInBackground( Void... params ) {
-			Log.v( TAG, "doInBackground : enter" );
-
-			List<Program> lookup = null;
-
-			try {
-				Log.v( TAG, "doInBackground : lookup" );
-
-				lookup = getApplicationContext().getMythServicesApi().dvrOperations().getRecordedList( 0, 0, true );
-			} catch( Exception e ) {
-				Log.v( TAG, "doInBackground : error" );
-
-				this.e = e;
-			}
-
-			Log.v( TAG, "doInBackground : exit" );
-			return lookup;
-		}
-
-		@Override
-		protected void onPostExecute( List<Program> result ) {
-			Log.v( TAG, "onPostExecute : enter" );
-
-			if( null == e ) {
-
-				Log.v( TAG, "onPostExecute : filter livetv" );
-				List<Program> filteredResults = new ArrayList<Program>();
-				for( Program program : result ) {
-					if( !"livetv".equalsIgnoreCase( program.getRecording().getRecordingGroup() ) ) {
-						filteredResults.add( program );
-					}
-				}
-
-				setRecordingsInProgramGroups( filteredResults );
-			} else {
-				Log.e( TAG, "error getting programs", e );
-				exceptionDialolg( e );
-			}
-
-			Log.v( TAG, "onPostExecute : exit" );
-		}
-
-	}
-
-	private class ProgramGroupAdapter extends BaseAdapter {
-		
-		List<ProgramGroup> programGroups = null;
-
-		ProgramGroupAdapter( List<