From fdf8f9c9c59765b1498da5c90267df2bb3ad6c02 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 21 Nov 2013 18:39:07 +0100 Subject: [PATCH] Added ListView empty views (depending on current state). --- res/layout/renderer_fragment.xml | 20 ++++++++++++------ res/layout/server_fragment.xml | 21 +++++++++++++++++++ res/values/strings.xml | 5 ++++- .../controldlna/gui/RouteFragment.java | 8 +++++++ .../controldlna/gui/ServerFragment.java | 17 +++++++++++++++ 5 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 res/layout/server_fragment.xml diff --git a/res/layout/renderer_fragment.xml b/res/layout/renderer_fragment.xml index e47a882..20a7958 100644 --- a/res/layout/renderer_fragment.xml +++ b/res/layout/renderer_fragment.xml @@ -1,5 +1,5 @@ - @@ -7,17 +7,25 @@ + android:layout_height="wrap_content" > + + + android:visibility="visible" > - + diff --git a/res/layout/server_fragment.xml b/res/layout/server_fragment.xml new file mode 100644 index 0000000..e2f0622 --- /dev/null +++ b/res/layout/server_fragment.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index e0159ca..d1f5043 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -15,5 +15,8 @@ Wifi needs to be connected for playback Enable Wifi automatically on start "Do not show this dialog again" - + No UPNP devices found. \nNew devices will be added automatically when they are available. + Folder is empty + Playlist is empty + diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index a94ee14..e7405a1 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -59,6 +59,7 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ImageButton; import android.widget.ListView; import android.widget.SeekBar; +import android.widget.TextView; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.Toast; @@ -149,6 +150,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mListView.setAdapter(mRouteAdapter); mListView.setOnItemClickListener(this); mListView.setOnScrollListener(this); + mListView.setEmptyView(getView().findViewById(android.R.id.empty)); mControls = getView().findViewById(R.id.controls); mProgressBar = (SeekBar) getView().findViewById(R.id.progressBar); @@ -278,6 +280,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mMediaRouterPlayService.getService().play(mStartPlayingOnSelect); mStartPlayingOnSelect = -1; } + TextView emptyView = (TextView) mListView.getEmptyView(); + emptyView.setText(R.string.playlist_empty); } else mMediaRouterPlayService.getService().play(position); @@ -327,6 +331,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mListView.setAdapter(mRouteAdapter); disableTrackHighlight(); mSelectedRoute = null; + TextView emptyView = (TextView) mListView.getEmptyView(); + emptyView.setText(R.string.device_list_empty); } }) .setNegativeButton(android.R.string.no, null) @@ -337,6 +343,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mListView.setAdapter(mRouteAdapter); disableTrackHighlight(); mSelectedRoute = null; + TextView emptyView = (TextView) mListView.getEmptyView(); + emptyView.setText(R.string.device_list_empty); } return true; } diff --git a/src/com/github/nutomic/controldlna/gui/ServerFragment.java b/src/com/github/nutomic/controldlna/gui/ServerFragment.java index 59f044a..0ec4ff8 100644 --- a/src/com/github/nutomic/controldlna/gui/ServerFragment.java +++ b/src/com/github/nutomic/controldlna/gui/ServerFragment.java @@ -59,9 +59,13 @@ import android.os.IBinder; import android.os.Parcelable; import android.support.v4.app.ListFragment; import android.util.Log; +import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.ListView; +import android.widget.TextView; +import com.github.nutomic.controldlna.R; import com.github.nutomic.controldlna.gui.MainActivity.OnBackPressedListener; import com.github.nutomic.controldlna.utility.DeviceArrayAdapter; import com.github.nutomic.controldlna.utility.FileArrayAdapter; @@ -138,6 +142,13 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene } }; + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + + return inflater.inflate(R.layout.server_fragment, null); + }; + /** * Initializes ListView adapters, launches Cling UPNP service, registers * wifi state change listener and restores instance state if possible. @@ -207,6 +218,8 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene setListAdapter(mFileAdapter); mCurrentServer = mServerAdapter.getItem(position); getFiles(ROOT_DIRECTORY); + TextView emptyView = (TextView) getListView().getEmptyView(); + emptyView.setText(R.string.folder_list_etmpy); } else if (getListAdapter() == mFileAdapter) { if (mFileAdapter.getItem(position) instanceof Container) @@ -297,6 +310,8 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene setListAdapter(mServerAdapter); getListView().onRestoreInstanceState(mListState.peek()); mCurrentServer = null; + TextView emptyView = (TextView) getListView().getEmptyView(); + emptyView.setText(R.string.device_list_empty); } else getFiles(true); @@ -337,6 +352,8 @@ public class ServerFragment extends ListFragment implements OnBackPressedListene setListAdapter(mServerAdapter); getListView().onRestoreInstanceState(mListState.firstElement()); mCurrentServer = null; + TextView emptyView = (TextView) getListView().getEmptyView(); + emptyView.setText(R.string.device_list_empty); } i--; }