This implements feature request #103
Added refresh menu item in overflow menu to allow user to refresh the content in *ListFragments and *DetailsFragments.
This commit is contained in:
parent
f4715d70a2
commit
f0c32e5c18
|
@ -17,12 +17,14 @@
|
|||
package org.xbmc.kore.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
|
@ -36,8 +38,6 @@ import org.xbmc.kore.service.LibrarySyncService;
|
|||
import org.xbmc.kore.utils.LogUtils;
|
||||
import org.xbmc.kore.utils.UIUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
abstract public class AbstractDetailsFragment extends Fragment
|
||||
|
@ -109,6 +109,12 @@ abstract public class AbstractDetailsFragment extends Fragment
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
bus.register(this);
|
||||
|
@ -122,9 +128,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) {
|
||||
|
@ -138,7 +153,7 @@ abstract public class AbstractDetailsFragment extends Fragment
|
|||
if(syncType != null) {
|
||||
syncIntent.putExtra(syncType, true);
|
||||
}
|
||||
|
||||
|
||||
String syncID = getSyncID();
|
||||
int itemId = getSyncItemID();
|
||||
if( ( syncID != null ) && ( itemId != -1 ) ) {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -185,8 +185,6 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
|||
|
||||
// Start the loaders
|
||||
getLoaderManager().initLoader(LOADER_MUSIC_VIDEO, null, this);
|
||||
|
||||
setHasOptionsMenu(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
|
@ -342,5 +342,6 @@
|
|||
<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>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue