Merge pull request #136 from poisdeux/issue#103

This implements feature request #103
This commit is contained in:
Synced Synapse 2015-11-13 18:39:15 +00:00
commit 939a5fc722
8 changed files with 63 additions and 11 deletions

View File

@ -23,6 +23,9 @@ import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
@ -111,6 +114,12 @@ abstract public class AbstractDetailsFragment extends Fragment
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onStart() {
super.onStart();
@ -136,9 +145,18 @@ abstract public class AbstractDetailsFragment extends Fragment
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// outState.putInt(ITEMID, itemId);
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.refresh_item, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
onRefresh();
}
return super.onOptionsItemSelected(item);
}
protected void startSync(boolean silentRefresh) {

View File

@ -28,6 +28,9 @@ import android.support.v4.content.Loader;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.SearchView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@ -133,6 +136,21 @@ public abstract class AbstractListFragment extends Fragment
SyncUtils.disconnectFromLibrarySyncService(getActivity(), serviceConnection);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.refresh_item, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_refresh:
onRefresh();
}
return super.onOptionsItemSelected(item);
}
/**
* Swipe refresh layout callback
*/

View File

@ -203,8 +203,6 @@ public class MovieDetailsFragment extends AbstractDetailsFragment
// Start the loaders
getLoaderManager().initLoader(LOADER_MOVIE, null, this);
getLoaderManager().initLoader(LOADER_CAST, null, this);
setHasOptionsMenu(false);
}
@Override

View File

@ -185,8 +185,6 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
// Start the loaders
getLoaderManager().initLoader(LOADER_MUSIC_VIDEO, null, this);
setHasOptionsMenu(false);
}
@Override

View File

@ -195,8 +195,6 @@ public class TVShowEpisodeDetailsFragment extends AbstractDetailsFragment
// Start the loaders
getLoaderManager().initLoader(LOADER_EPISODE, null, this);
// getLoaderManager().initLoader(LOADER_CAST, null, this);
setHasOptionsMenu(false);
}
@Override

View File

@ -166,8 +166,6 @@ public class TVShowOverviewFragment extends AbstractDetailsFragment
// Start the loaders
getLoaderManager().initLoader(LOADER_TVSHOW, null, this);
getLoaderManager().initLoader(LOADER_CAST, null, this);
setHasOptionsMenu(false);
}
@Override

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015 Synced Synapse. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_refresh"
android:title="@string/refresh"
app:showAsAction="never"/>
</menu>

View File

@ -342,6 +342,7 @@
<string name="might_not_have_pvr">An error occurred while getting channels info, probably because your media center doesn\'t have a tuner or it isn\'t configured.\n\nIf that\'s the case and you\'d like to remove this entry from the side menu, you can do it in the Settings.</string>
<string name="error_starting_channel">An error occurred starting channel playback: %1$s</string>
<string name="channel_switching">Switching to channel %1$s</string>
<string name="refresh">refresh</string>
<string name="tv">TV</string>
<string name="radio">Radio</string>