Skip to content

Commit

Permalink
closes #122
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Frey committed Sep 14, 2013
1 parent 006381e commit 609e482
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/org/mythtv/client/ui/dvr/RecordingRulesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.mythtv.db.dvr.RecordingRuleDaoHelper;
import org.mythtv.db.dvr.model.RecRule;
import org.mythtv.db.http.EtagDaoHelper;
import org.mythtv.db.http.model.EtagInfoDelegate;
import org.mythtv.service.dvr.RecordingRuleService;
import org.mythtv.service.util.DateUtils;
import org.mythtv.service.util.RunningServiceHelper;
Expand Down Expand Up @@ -267,7 +268,7 @@ public void onCreateOptionsMenu( Menu menu, MenuInflater inflater ) {
Log.v( TAG, "onCreateOptionsMenu : enter" );
super.onCreateOptionsMenu( menu, inflater );

mMenuHelper.refreshMenuItem( getActivity(), menu, this.mMenuItemRefresh );
mMenuHelper.refreshMenuItem( getActivity(), menu, mMenuItemRefresh );

Log.v( TAG, "onCreateOptionsMenu : exit" );
}
Expand All @@ -289,8 +290,11 @@ public boolean onOptionsItemSelected( MenuItem item ) {

// adapter.refresh();
if( !mRunningServiceHelper.isServiceRunning( getActivity(), "org.mythtv.service.dvr.RecordingRuleService" ) ) {
EtagInfoDelegate etag = mEtagDaoHelper.findByEndpoint( getActivity(), mLocationProfile, "GetRecordScheduleList" );
mEtagDaoHelper.delete( getActivity(), mLocationProfile, etag );

getActivity().startService( new Intent( RecordingRuleService.ACTION_DOWNLOAD ) );
this.mMenuItemRefresh.startRefreshAnimation();
mMenuItemRefresh.startRefreshAnimation();
}

return true;
Expand Down
19 changes: 7 additions & 12 deletions src/org/mythtv/client/ui/dvr/RecordingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@
import org.mythtv.db.dvr.programGroup.ProgramGroup;
import org.mythtv.db.dvr.programGroup.ProgramGroupConstants;
import org.mythtv.db.dvr.programGroup.ProgramGroupDaoHelper;
import org.mythtv.db.http.EtagConstants;
import org.mythtv.db.http.EtagDaoHelper;
import org.mythtv.db.http.model.EtagInfoDelegate;
import org.mythtv.db.preferences.LocationProfileDaoHelper;
import org.mythtv.service.dvr.RecordedService;
import org.mythtv.service.util.DateUtils;
import org.mythtv.service.util.RunningServiceHelper;

import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
Expand Down Expand Up @@ -272,17 +270,14 @@ public boolean onOptionsItemSelected( MenuItem item ) {
case MenuHelper.REFRESH_ID:
Log.d( TAG, "onOptionsItemSelected : refresh selected" );

Cursor cursor = getActivity().getContentResolver().query( Uri.withAppendedPath( EtagConstants.CONTENT_URI, "endpoint" ), null, EtagConstants.FIELD_ENDPOINT + " = ?" ,new String[] { DvrEndpoint.GET_RECORDED_LIST.name() }, null );
if( cursor.moveToFirst() ) {
Long id = cursor.getLong( cursor.getColumnIndexOrThrow( EtagConstants._ID ) );

getActivity().getContentResolver().delete( ContentUris.withAppendedId( EtagConstants.CONTENT_URI, id ), null, null );
}
cursor.close();

if( !mRunningServiceHelper.isServiceRunning( getActivity(), "org.mythtv.service.dvr.RecordedDownloadService" ) ) {

EtagInfoDelegate etag = mEtagDaoHelper.findByEndpoint( getActivity(), mLocationProfile, "GetRecordedList" );
mEtagDaoHelper.delete( getActivity(), mLocationProfile, etag );

getActivity().startService( new Intent( RecordedService.ACTION_DOWNLOAD ) );
this.mMenuItemRefresh.startRefreshAnimation();
mMenuItemRefresh.startRefreshAnimation();

}

return true;
Expand Down
4 changes: 4 additions & 0 deletions src/org/mythtv/client/ui/dvr/UpcomingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.mythtv.db.dvr.DvrEndpoint;
import org.mythtv.db.dvr.UpcomingDaoHelper;
import org.mythtv.db.http.EtagDaoHelper;
import org.mythtv.db.http.model.EtagInfoDelegate;
import org.mythtv.service.dvr.UpcomingDownloadService;
import org.mythtv.service.util.DateUtils;
import org.mythtv.service.util.RunningServiceHelper;
Expand Down Expand Up @@ -176,6 +177,9 @@ public boolean onOptionsItemSelected( MenuItem item ) {
case MenuHelper.REFRESH_ID:
Log.d( TAG, "onOptionsItemSelected : refresh selected" );

EtagInfoDelegate etag = mEtagDaoHelper.findByEndpoint( this, mLocationProfile, "GetUpcomingList" );
mEtagDaoHelper.delete( this, mLocationProfile, etag );

loadData();

return true;
Expand Down
20 changes: 20 additions & 0 deletions src/org/mythtv/db/http/EtagDaoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@ public EtagInfoDelegate findByEndpointAndDataId( final Context context, final Lo
return etagInfo;
}

/**
* @param endpoint
* @return
*/
public EtagInfoDelegate findByEndpoint( final Context context, final LocationProfile locationProfile, final String endpoint ) {
// Log.d( TAG, "findByEndpoint : enter" );

if( null == context )
throw new RuntimeException( "EtagDaoHelper is not initialized" );

String selection = EtagConstants.FIELD_ENDPOINT + " = ?";

String[] selectionArgs = new String[] { endpoint };

EtagInfoDelegate etagInfo = findOne( context, locationProfile, null, null, selection, selectionArgs, null );

// Log.d( TAG, "findByEndpoint : exit" );
return etagInfo;
}

/**
* @param endpoint
* @param date
Expand Down

0 comments on commit 609e482

Please sign in to comment.