aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java13
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectListFragment.java12
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java20
3 files changed, 32 insertions, 13 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 7703d5b2..bd1d98dc 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -54,7 +54,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
private GridView albumList;
private ListView entryList;
- private View emptyView;
private boolean hideButtons = false;
private Boolean licenseValid;
private boolean showHeader = true;
@@ -182,8 +181,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
});
- emptyView = rootView.findViewById(R.id.select_album_empty);
-
registerForContextMenu(entryList);
registerForContextMenu(albumList);
@@ -445,7 +442,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
entryList.setVisibility(View.INVISIBLE);
- emptyView.setVisibility(View.INVISIBLE);
if (playlistId != null) {
getPlaylist(playlistId, playlistName, refresh);
} else if(podcastId != null) {
@@ -658,7 +654,10 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
addAlbumHeader = false;
}
- emptyView.setVisibility((entries.isEmpty() && albums.isEmpty()) ? View.VISIBLE : View.GONE);
+ boolean validData = !entries.isEmpty() || !albums.isEmpty();
+ if(!validData) {
+ setEmpty(true);
+ }
// Always going to have entries in entryAdapter
entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null));
ListAdapter listAdapter = entryAdapter;
@@ -683,7 +682,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
}
entryList.setAdapter(listAdapter);
- entryList.setVisibility(View.VISIBLE);
+ if(validData) {
+ entryList.setVisibility(View.VISIBLE);
+ }
context.supportInvalidateOptionsMenu();
Bundle args = getArguments();
diff --git a/src/github/daneren2005/dsub/fragments/SelectListFragment.java b/src/github/daneren2005/dsub/fragments/SelectListFragment.java
index 1c77ad68..751b840f 100644
--- a/src/github/daneren2005/dsub/fragments/SelectListFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectListFragment.java
@@ -52,7 +52,6 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements
private static final String TAG = SelectListFragment.class.getSimpleName();
protected ListView listView;
protected ArrayAdapter adapter;
- protected View emptyView;
protected List<T> objects;
protected boolean serialize = true;
@@ -84,7 +83,6 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements
listView.setOnItemClickListener(this);
setupScrollList(listView);
registerForContextMenu(listView);
- emptyView = rootView.findViewById(R.id.fragment_list_empty);
if(objects == null) {
refresh(false);
@@ -115,8 +113,7 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements
if(titleRes != 0) {
setTitle(getTitleResource());
}
- listView.setVisibility(View.INVISIBLE);
- emptyView.setVisibility(View.GONE);
+ listView.setVisibility(View.GONE);
BackgroundTask<List<T>> task = new TabBackgroundTask<List<T>>(this) {
@Override
@@ -136,11 +133,12 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements
@Override
protected void done(List<T> result) {
- emptyView.setVisibility(result == null || result.isEmpty() ? View.VISIBLE : View.GONE);
-
- if (result != null) {
+ if (result != null && !result.isEmpty()) {
listView.setAdapter(adapter = getAdapter(result));
listView.setVisibility(View.VISIBLE);
+ } else {
+ setEmpty(true);
+ refreshLayout.setEnabled(true);
}
}
};
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index d799877b..a9d6d06d 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -434,6 +434,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
View view = rootView.findViewById(R.id.tab_progress);
if (view != null) {
view.setVisibility(visible ? View.VISIBLE : View.GONE);
+
+ if(visible) {
+ View progress = rootView.findViewById(R.id.tab_progress_spinner);
+ progress.setVisibility(View.VISIBLE);
+ }
}
}
@@ -444,6 +449,21 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}
+ public void setEmpty(boolean empty) {
+ View view = rootView.findViewById(R.id.tab_progress);
+ if(empty) {
+ view.setVisibility(View.VISIBLE);
+
+ View progress = view.findViewById(R.id.tab_progress_spinner);
+ progress.setVisibility(View.GONE);
+
+ TextView text = (TextView) view.findViewById(R.id.tab_progress_message);
+ text.setText(R.string.common_empty);
+ } else {
+ view.setVisibility(View.GONE);
+ }
+ }
+
protected synchronized ImageLoader getImageLoader() {
return context.getImageLoader();
}