Skip to content

Commit

Permalink
refactored all menus to the MenuHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Frey committed Nov 23, 2012
1 parent fb9d3a9 commit 2a5ce7c
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 393 deletions.
113 changes: 0 additions & 113 deletions res/layout/fragment_about.xml

This file was deleted.

23 changes: 9 additions & 14 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@

<string name="data_loading">Mythtv for Android is currently loading data from your backend. Please try again later.</string>

<!-- About -->
<!-- Menus -->
<string name="menu_about">About</string>
<string name="menu_about_ally">About</string>
<string name="about_title">About MythTV Android Frontend&#8230;</string>
<string name="about_url1"><u>https://github.com/MythTV-Clients/MythTV-Android-Frontend</u></string>
<string name="about_url2"><u>http://mythtv.org</u></string>
<string name="about_url3"><u>http://c9studio.com</u></string>

<!-- Help -->
<string name="menu_refresh">Refresh</string>
<string name="menu_edit">Edit</string>
<string name="menu_save">Save</string>
<string name="menu_reset">Reset</string>
<string name="menu_delete">Delete</string>
<string name="menu_watch">Watch</string>
<string name="menu_add">Add</string>
<string name="menu_prefs">Prefs</string>
<string name="menu_help">Help</string>
<string name="menu_help_faq">FAQ</string>
<string name="menu_help_troubleshoot">Troubleshoot</string>
Expand Down Expand Up @@ -129,12 +130,6 @@
<string name="btn_save">Save</string>
<string name="btn_cancel">Cancel</string>

<!-- Menu -->
<string name="menu_prefs">Prefs</string>
<string name="menu_refresh">Refresh</string>
<string name="menu_clear">Clear</string>
<string name="menu_setup">Setup</string>

<!-- Location dashboard -->
<string name="btn_home">Home</string>
<string name="btn_home_ally">Use selected home profile</string>
Expand Down
115 changes: 0 additions & 115 deletions src/org/mythtv/client/ui/AboutDialogFragment.java

This file was deleted.

41 changes: 10 additions & 31 deletions src/org/mythtv/client/ui/dvr/EpisodeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.joda.time.DateTime;
import org.mythtv.R;
import org.mythtv.client.ui.AbstractMythFragment;
import org.mythtv.client.ui.util.MenuHelper;
import org.mythtv.db.dvr.RecordedDaoHelper;
import org.mythtv.db.dvr.programGroup.ProgramGroup;
import org.mythtv.db.dvr.programGroup.ProgramGroupDaoHelper;
Expand All @@ -38,7 +39,6 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
Expand All @@ -55,12 +55,10 @@
public class EpisodeFragment extends AbstractMythFragment {

private static final String TAG = EpisodeFragment.class.getSimpleName();
private static final int DELETE_ID = Menu.FIRST + 300;
private static final int WATCH_ID = Menu.FIRST + 301;
private static final int ADD_ID = Menu.FIRST + 302;

private OnEpisodeActionListener listener = null;

private MenuHelper mMenuHelper;
private ProgramGroupDaoHelper mProgramGroupDaoHelper;
private RecordedDaoHelper mRecordedDaoHelper;
private ImageFetcher mImageFetcher;
Expand All @@ -87,6 +85,7 @@ public void onActivityCreated( Bundle savedInstanceState ) {
Log.v( TAG, "onActivityCreated : enter" );
super.onActivityCreated( savedInstanceState );

mMenuHelper = new MenuHelper( getActivity() );
mProgramGroupDaoHelper = new ProgramGroupDaoHelper( getActivity() );
mRecordedDaoHelper = new RecordedDaoHelper( getActivity() );

Expand All @@ -105,28 +104,10 @@ public void onCreateOptionsMenu( Menu menu, MenuInflater inflater ) {
Log.v( TAG, "onCreateOptionsMenu : enter" );
super.onCreateOptionsMenu( menu, inflater );

if( mNetworkHelper.isNetworkConnected() ) {

MenuItem watch = menu.add( Menu.NONE, WATCH_ID, Menu.NONE, "Watch" );
watch.setIcon( android.R.drawable.ic_menu_view );
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
watch.setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM );
}

MenuItem add = menu.add( Menu.NONE, ADD_ID, Menu.NONE, "ADD" );
add.setIcon( android.R.drawable.ic_menu_add );
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
add.setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM );
}

MenuItem delete = menu.add( Menu.NONE, DELETE_ID, Menu.NONE, "Delete" );
delete.setIcon( android.R.drawable.ic_menu_delete );
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
delete.setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM );
}

}

mMenuHelper.watchMenuItem( menu );
mMenuHelper.addMenuItem( menu );
mMenuHelper.deleteMenuItem( menu );

Log.v( TAG, "onCreateOptionsMenu : exit" );
}

Expand All @@ -138,7 +119,7 @@ public boolean onOptionsItemSelected( MenuItem item ) {
Log.v( TAG, "onOptionsItemSelected : enter" );

switch( item.getItemId() ) {
case WATCH_ID:
case MenuHelper.WATCH_ID:
Log.d( TAG, "onOptionsItemSelected : watch selected" );

if( mNetworkHelper.isNetworkConnected() ) {
Expand All @@ -153,7 +134,7 @@ public boolean onOptionsItemSelected( MenuItem item ) {
}

return true;
case ADD_ID:
case MenuHelper.ADD_ID:
Log.d( TAG, "onOptionsItemSelected : add selected" );

Toast.makeText( getActivity(), "Add HLS to Playlist - Coming Soon!", Toast.LENGTH_SHORT ).show();
Expand All @@ -166,7 +147,7 @@ public boolean onOptionsItemSelected( MenuItem item ) {
// }

return true;
case DELETE_ID:
case MenuHelper.DELETE_ID:
Log.d( TAG, "onOptionsItemSelected : delete selected" );

if( mNetworkHelper.isNetworkConnected() ) {
Expand Down Expand Up @@ -208,12 +189,10 @@ public void loadEpisode( Long channelId, DateTime startTime ) {

if( RecordingsActivity.class.isInstance( getActivity() ) ) {
mImageFetcher = ( (RecordingsActivity) getActivity() ).getImageFetcher();
// mRecordedDaoHelper = ( (RecordingsActivity) getActivity() ).getRecordedDaoHelper();
}

if( EpisodeActivity.class.isInstance( getActivity() ) ) {
mImageFetcher = ( (EpisodeActivity) getActivity() ).getImageFetcher();
// mRecordedDaoHelper = ( (EpisodeActivity) getActivity() ).getRecordedDaoHelper();
}

Log.v( TAG, "loadEpisode : channelId=" + channelId + ", startTime=" + DateUtils.dateTimeFormatterPretty.print( startTime ) );
Expand Down
Loading

0 comments on commit 2a5ce7c

Please sign in to comment.