diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-04-01 20:20:41 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-04-01 20:20:41 -0700 |
commit | 4ca3d01d32065c8415d4d69141634d00ac0f65fa (patch) | |
tree | 0be479bb2c0b823a9c4ef673c327f57f107fe1db | |
parent | b92cc3e2ac69ceb975f69a5183fb3741db6a2b1c (diff) | |
download | dsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.tar.gz dsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.tar.bz2 dsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.zip |
Disable pull to refresh and add refresh button for TV layouts
-rw-r--r-- | res/menu/abstract_top_menu.xml | 8 | ||||
-rw-r--r-- | res/menu/empty.xml | 8 | ||||
-rw-r--r-- | res/menu/select_album.xml | 8 | ||||
-rw-r--r-- | res/menu/select_album_list.xml | 8 | ||||
-rw-r--r-- | res/menu/select_artist.xml | 8 | ||||
-rw-r--r-- | res/menu/select_podcast_episode.xml | 9 | ||||
-rw-r--r-- | res/menu/select_podcasts.xml | 8 | ||||
-rw-r--r-- | res/menu/select_song.xml | 8 | ||||
-rw-r--r-- | res/menu/user.xml | 8 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/SubsonicActivity.java | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SubsonicFragment.java | 42 |
11 files changed, 103 insertions, 18 deletions
diff --git a/res/menu/abstract_top_menu.xml b/res/menu/abstract_top_menu.xml index 67d18390..c2575794 100644 --- a/res/menu/abstract_top_menu.xml +++ b/res/menu/abstract_top_menu.xml @@ -7,6 +7,14 @@ android:title="@string/menu.search"
compat:showAsAction="always|withText"/>
+ <group android:id="@+id/tv">
+ <item
+ android:id="@+id/menu_refresh"
+ android:icon="?attr/refresh"
+ android:title="@string/menu.refresh"
+ compat:showAsAction="ifRoom|withText"/>
+ </group>
+
<item
android:id="@+id/menu_exit"
android:title="@string/menu.exit"/>
diff --git a/res/menu/empty.xml b/res/menu/empty.xml index 7abe954b..20a71d9b 100644 --- a/res/menu/empty.xml +++ b/res/menu/empty.xml @@ -2,6 +2,14 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_exit" android:title="@string/menu.exit"/> diff --git a/res/menu/select_album.xml b/res/menu/select_album.xml index a9741d84..627b213c 100644 --- a/res/menu/select_album.xml +++ b/res/menu/select_album.xml @@ -19,6 +19,14 @@ android:title="@string/menu.shuffle" compat:showAsAction="ifRoom|withText"/> + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_top_tracks" android:title="@string/menu.top_tracks"/> diff --git a/res/menu/select_album_list.xml b/res/menu/select_album_list.xml index 3b86fbcd..68e2847e 100644 --- a/res/menu/select_album_list.xml +++ b/res/menu/select_album_list.xml @@ -13,6 +13,14 @@ android:title="@string/menu.shuffle" compat:showAsAction="ifRoom|withText"/> + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_exit" android:title="@string/menu.exit"/> diff --git a/res/menu/select_artist.xml b/res/menu/select_artist.xml index 8e1cdba3..dbbc781d 100644 --- a/res/menu/select_artist.xml +++ b/res/menu/select_artist.xml @@ -13,6 +13,14 @@ android:title="@string/menu.search" compat:showAsAction="ifRoom|withText"/> + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_first_level_artist" android:title="@string/menu.first_level_artist" diff --git a/res/menu/select_podcast_episode.xml b/res/menu/select_podcast_episode.xml index dbb369e9..63259af3 100644 --- a/res/menu/select_podcast_episode.xml +++ b/res/menu/select_podcast_episode.xml @@ -1,6 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> + + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_download_all" android:title="@string/select_podcasts.server_download"/> diff --git a/res/menu/select_podcasts.xml b/res/menu/select_podcasts.xml index cd351a19..3fad1f84 100644 --- a/res/menu/select_podcasts.xml +++ b/res/menu/select_podcasts.xml @@ -13,6 +13,14 @@ android:title="@string/menu.add_podcast" compat:showAsAction="always|withText"/> + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> + <item android:id="@+id/menu_check" android:title="@string/menu.check_podcasts"/> diff --git a/res/menu/select_song.xml b/res/menu/select_song.xml index 07fd57a7..4e3ae00d 100644 --- a/res/menu/select_song.xml +++ b/res/menu/select_song.xml @@ -12,6 +12,14 @@ android:icon="?attr/shuffle" android:title="@string/menu.shuffle" compat:showAsAction="ifRoom|withText"/> + + <group android:id="@+id/tv"> + <item + android:id="@+id/menu_refresh" + android:icon="?attr/refresh" + android:title="@string/menu.refresh" + compat:showAsAction="ifRoom|withText"/> + </group> <item android:id="@+id/menu_download" diff --git a/res/menu/user.xml b/res/menu/user.xml index aea881fc..6e406b77 100644 --- a/res/menu/user.xml +++ b/res/menu/user.xml @@ -14,6 +14,14 @@ android:icon="?attr/password"
compat:showAsAction="always|withText"/>
+ <group android:id="@+id/tv">
+ <item
+ android:id="@+id/menu_refresh"
+ android:icon="?attr/refresh"
+ android:title="@string/menu.refresh"
+ compat:showAsAction="ifRoom|withText"/>
+ </group>
+
<item
android:id="@+id/menu_change_email"
android:title="@string/admin.change_email"/>
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 8d0e9c20..de0809db 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -88,7 +88,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte protected SubsonicFragment currentFragment;
protected View primaryContainer;
protected View secondaryContainer;
- protected boolean tv = true;
+ protected boolean tv = false;
Spinner actionBarSpinner;
ArrayAdapter<CharSequence> spinnerAdapter;
ViewGroup rootView;
@@ -369,6 +369,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte try {
currentFragment.setContext(this);
currentFragment.onCreateOptionsMenu(menu, menuInflater);
+
+ if(!isTv()) {
+ menu.setGroupVisible(R.id.tv, false);
+ }
} catch(Exception e) {
Log.w(TAG, "Error on creating options menu", e);
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 1e2d2ad8..8bd01cd6 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -180,6 +180,9 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR case R.id.menu_exit:
exit();
return true;
+ case R.id.menu_refresh:
+ refresh();
+ return true;
}
return false;
@@ -606,22 +609,27 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
protected void setupScrollList(final AbsListView listView) {
- listView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
+ if(context.isTv()) {
+ refreshLayout.setEnabled(false);
+ } else {
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ }
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0 && listView.getFirstVisiblePosition() == 0);
- }
- });
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0 && listView.getFirstVisiblePosition() == 0);
+ }
+ });
- refreshLayout.setColorScheme(
- R.color.holo_blue_light,
- R.color.holo_orange_light,
- R.color.holo_green_light,
- R.color.holo_red_light);
+ refreshLayout.setColorScheme(
+ R.color.holo_blue_light,
+ R.color.holo_orange_light,
+ R.color.holo_green_light,
+ R.color.holo_red_light);
+ }
}
protected void warnIfStorageUnavailable() {
@@ -1598,13 +1606,13 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void onClick(DialogInterface dialog, int which) {
final Bookmark oldBookmark = entry.getBookmark();
entry.setBookmark(null);
-
+
new LoadingTask<Void>(context, false) {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.deleteBookmark(entry, context, null);
-
+
new EntryInstanceUpdater(entry) {
@Override
public void update(Entry found) {
@@ -1627,7 +1635,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override
protected void error(Throwable error) {
entry.setBookmark(oldBookmark);
-
+
String msg;
if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
|