aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-04-01 20:20:41 -0700
committerScott Jackson <daneren2005@gmail.com>2015-04-01 20:20:41 -0700
commit4ca3d01d32065c8415d4d69141634d00ac0f65fa (patch)
tree0be479bb2c0b823a9c4ef673c327f57f107fe1db /src
parentb92cc3e2ac69ceb975f69a5183fb3741db6a2b1c (diff)
downloaddsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.tar.gz
dsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.tar.bz2
dsub-4ca3d01d32065c8415d4d69141634d00ac0f65fa.zip
Disable pull to refresh and add refresh button for TV layouts
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java6
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java42
2 files changed, 30 insertions, 18 deletions
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);