/** * Fills the list with the available recordings. Only the recordings that are scheduled are added * to the list. */ private void populateList() { // Clear the list and add the recordings adapter.clear(); TVHClientApplication app = (TVHClientApplication) activity.getApplication(); for (SeriesRecording srec : app.getSeriesRecordings()) { adapter.add(srec); } // Show the newest scheduled recordings first adapter.sort(Constants.RECORDING_SORT_DESCENDING); adapter.notifyDataSetChanged(); if (toolbar != null) { onPrepareToolbarMenu(toolbar.getMenu()); toolbar.setTitle(getString(R.string.series_recordings)); if (adapter.getCount() > 0) { toolbar.setSubtitle(adapter.getCount() + " " + getString(R.string.items_available)); } else { toolbar.setSubtitle(R.string.no_recordings_scheduled); } } // Inform the listeners that the channel list is populated. // They could then define the preselected list item. if (fragmentStatusInterface != null) { fragmentStatusInterface.onListPopulated(TAG); } }
@Override public void onResume() { super.onResume(); TVHClientApplication app = (TVHClientApplication) activity.getApplication(); app.addListener(this); if (!app.isLoading()) { populateList(); } }
/** @param menu */ private void onPrepareToolbarMenu(Menu menu) { // Do not show the remove and play menu in single or dual pane mode. No // recording is preselected so the behavior is undefined. In dual pane // mode these menus are handled by the recording details details fragment. (menu.findItem(R.id.menu_record_remove)).setVisible(false); (menu.findItem(R.id.menu_play)).setVisible(false); (menu.findItem(R.id.menu_record_cancel)).setVisible(false); (menu.findItem(R.id.menu_record_remove_all)).setVisible(false); // Adding a manual series recording also requires the unlocked version TVHClientApplication app = (TVHClientApplication) activity.getApplication(); (menu.findItem(R.id.menu_add)).setVisible(app.isUnlocked()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); if (prefs.getBoolean("hideMenuCancelAllRecordingsPref", false) || adapter.getCount() == 0) { (menu.findItem(R.id.menu_record_cancel_all)).setVisible(false); } else { (menu.findItem(R.id.menu_record_cancel_all)).setVisible(true); } }
@Override public void onPause() { super.onPause(); TVHClientApplication app = (TVHClientApplication) activity.getApplication(); app.removeListener(this); }