[Android] EmptyView for browser on TV

Geoffrey Métais git at videolan.org
Tue Apr 28 14:54:48 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr 28 14:38:31 2015 +0200| [835644e2846b1af3b5b2e4f8cba0fae8c1c08061] | committer: Geoffrey Métais

EmptyView for browser on TV

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=835644e2846b1af3b5b2e4f8cba0fae8c1c08061
---

 vlc-android/tv/res/layout/tv_vertical_grid.xml                |    7 +++++++
 .../org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java  |    2 ++
 .../tv/src/org/videolan/vlc/gui/tv/browser/GridFragment.java  |    4 +---
 .../org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java |    9 +++++++++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/vlc-android/tv/res/layout/tv_vertical_grid.xml b/vlc-android/tv/res/layout/tv_vertical_grid.xml
index 887a12c..fe38259 100644
--- a/vlc-android/tv/res/layout/tv_vertical_grid.xml
+++ b/vlc-android/tv/res/layout/tv_vertical_grid.xml
@@ -11,4 +11,11 @@
         android:layout_height="wrap_content"
         android:layout_gravity="center"
         android:visibility="gone"/>
+    <TextView
+        android:id="@+id/tv_fragment_empty"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:text="@string/directory_empty"
+        android:visibility="gone"/>
 </FrameLayout>
\ No newline at end of file
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index a2e1eef..8df7d68 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -79,6 +79,7 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
     public void onPause(){
         super.onPause();
         mMediaBrowser.release();
+        ((BrowserActivity)getActivity()).updateEmptyView(false);
     }
     @Override
     public void onMediaAdded(int index, Media media) {
@@ -100,6 +101,7 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
     @Override
     public void onBrowseEnd() {
         ((BrowserActivity)getActivity()).showProgress(false);
+        ((BrowserActivity)getActivity()).updateEmptyView(mMediaList.isEmpty());
         sortList();
     }
 
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/GridFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/GridFragment.java
index 7fed64b..5fb61cf 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/GridFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/GridFragment.java
@@ -37,6 +37,7 @@ public class GridFragment extends VerticalGridFragment {
 
     public interface BrowserActivity {
         public void showProgress(boolean show);
+        public void updateEmptyView(boolean empty);
     }
 
     protected static final String TAG = "VLC/GridFragment";
@@ -65,7 +66,4 @@ public class GridFragment extends VerticalGridFragment {
             TvUtil.openMedia(getActivity(), item, null);
         }
     };
-
-
-
 }
\ No newline at end of file
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
index cdba8e0..efbf939 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
@@ -25,6 +25,7 @@ import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.ProgressBar;
+import android.widget.TextView;
 
 import org.videolan.vlc.R;
 import org.videolan.vlc.gui.tv.MainTvActivity;
@@ -33,11 +34,14 @@ public class VerticalGridActivity extends Activity implements GridFragment.Brows
 
     GridFragment mFragment;
     ProgressBar mContentLoadingProgressBar;
+    TextView mEmptyView;
+
     @Override
     public void onCreate(Bundle savedInstanceState){
         super.onCreate(savedInstanceState);
         setContentView(R.layout.tv_vertical_grid);
         mContentLoadingProgressBar = (ProgressBar) findViewById(R.id.tv_fragment_progress);
+        mEmptyView = (TextView) findViewById(R.id.tv_fragment_empty);
         getWindow().setBackgroundDrawableResource(R.drawable.background);
         long type = getIntent().getLongExtra(MainTvActivity.BROWSER_TYPE, -1);
         if (type == MainTvActivity.HEADER_VIDEO)
@@ -66,4 +70,9 @@ public class VerticalGridActivity extends Activity implements GridFragment.Brows
     public void showProgress(boolean show){
         mContentLoadingProgressBar.setVisibility(show ? View.VISIBLE : View.GONE);
     }
+
+    @Override
+    public void updateEmptyView(boolean empty) {
+        mEmptyView.setVisibility(empty ? View.VISIBLE : View.GONE);
+    }
 }



More information about the Android mailing list