[Android] move swipe layout reference in BrowserFragment

Geoffrey Métais git at videolan.org
Mon Feb 9 11:30:46 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 20 16:24:25 2015 +0100| [cdd01d4037c1f17a76073246291640c4f971a0d5] | committer: Geoffrey Métais

move swipe layout reference in BrowserFragment

+ fixes History fragment

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

 .../src/org/videolan/vlc/gui/BrowserFragment.java  |    2 ++
 .../videolan/vlc/gui/DirectoryViewFragment.java    |    8 +++---
 .../src/org/videolan/vlc/gui/HistoryFragment.java  |   28 +++++++++-----------
 .../vlc/gui/audio/AudioAlbumsSongsFragment.java    |    4 +--
 .../vlc/gui/audio/AudioBrowserFragment.java        |    1 -
 .../videolan/vlc/gui/video/VideoGridFragment.java  |    1 -
 6 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/BrowserFragment.java
index 4b3cba7..bbf7a70 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserFragment.java
@@ -23,9 +23,11 @@
 package org.videolan.vlc.gui;
 
 import android.support.v4.app.Fragment;
+import android.support.v4.widget.SwipeRefreshLayout;
 
 public class BrowserFragment extends Fragment {
 
+    protected SwipeRefreshLayout mSwipeRefreshLayout;
     protected volatile boolean mReadyToDisplay = true;
 
     protected void setReadyToDisplay(boolean ready){}
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
index 88e4e4c..df91a65 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -63,8 +63,6 @@ public class DirectoryViewFragment extends BrowserFragment implements IRefreshab
 
     private DirectoryAdapter mDirectoryAdapter;
     private ListView mListView;
-    private SwipeRefreshLayout mSwipeRefreshLayout;
-    private boolean mReady = true;
 
     /* All subclasses of Fragment must include a public empty constructor. */
     public DirectoryViewFragment() { }
@@ -300,15 +298,15 @@ public class DirectoryViewFragment extends BrowserFragment implements IRefreshab
 
     @Override
     public void setReadyToDisplay(boolean ready) {
-        if (ready && !mReady)
+        if (ready && !mReadyToDisplay)
             display();
         else
-            mReady = ready;
+            mReadyToDisplay = ready;
     }
 
     @Override
     public void display() {
-        mReady = true;
+        mReadyToDisplay = true;
         refresh();
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
index 5448ead..1b07657 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
@@ -28,7 +28,6 @@ import org.videolan.vlc.interfaces.IRefreshable;
 import android.annotation.TargetApi;
 import android.os.Build;
 import android.os.Bundle;
-import android.support.v4.app.ListFragment;
 import android.support.v4.widget.SwipeRefreshLayout;
 import android.support.v7.app.ActionBarActivity;
 import android.view.ContextMenu;
@@ -48,8 +47,6 @@ public class HistoryFragment extends BrowserFragment implements IRefreshable, Sw
 
     private HistoryAdapter mHistoryAdapter;
     private ListView mListView;
-    private SwipeRefreshLayout mSwipeRefreshLayout;
-    private boolean mReady = true;
 
     /* All subclasses of Fragment must include a public empty constructor. */
     public HistoryFragment() { }
@@ -64,8 +61,6 @@ public class HistoryFragment extends BrowserFragment implements IRefreshable, Sw
     private void focusHelper(boolean idIsEmpty) {
         View parent = View.inflate(getActivity(), R.layout.history_list,
             null);
-        mListView = (ListView) parent.findViewById(android.R.id.list);
-        mListView.setOnItemClickListener(this);
         MainActivity main = (MainActivity)getActivity();
         main.setMenuFocusDown(idIsEmpty, android.R.id.list);
         main.setSearchAsFocusDown(idIsEmpty, parent,
@@ -79,23 +74,24 @@ public class HistoryFragment extends BrowserFragment implements IRefreshable, Sw
         ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(R.string.history);
 
         View v = inflater.inflate(R.layout.history_list, container, false);
+        mListView = (ListView)v.findViewById(android.R.id.list);
+        mListView.setOnItemClickListener(this);
         mListView.setAdapter(mHistoryAdapter);
-        final ListView listView = (ListView)v.findViewById(android.R.id.list);
-        listView.setNextFocusUpId(R.id.ml_menu_search);
-        listView.setNextFocusLeftId(android.R.id.list);
-        listView.setNextFocusRightId(android.R.id.list);
+        mListView.setNextFocusUpId(R.id.ml_menu_search);
+        mListView.setNextFocusLeftId(android.R.id.list);
+        mListView.setNextFocusRightId(android.R.id.list);
         if (LibVlcUtil.isHoneycombOrLater())
-            listView.setNextFocusForwardId(android.R.id.list);
+            mListView.setNextFocusForwardId(android.R.id.list);
         focusHelper(mHistoryAdapter.getCount() == 0);
-        listView.requestFocus();
-        registerForContextMenu(listView);
+        mListView.requestFocus();
+        registerForContextMenu(mListView);
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
 
         mSwipeRefreshLayout.setColorSchemeColors(R.color.darkerorange/*, R.attr.colorPrimary, R.attr.colorPrimaryDark*/);
         mSwipeRefreshLayout.setOnRefreshListener(this);
 
-        listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+        mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
             @Override
             public void onScrollStateChanged(AbsListView view, int scrollState) {}
             @Override
@@ -165,15 +161,15 @@ public class HistoryFragment extends BrowserFragment implements IRefreshable, Sw
 
     @Override
     public void setReadyToDisplay(boolean ready) {
-        if (ready && !mReady)
+        if (ready && !mReadyToDisplay)
             display();
         else
-            mReady = ready;
+            mReadyToDisplay = ready;
     }
 
     @Override
     public void display() {
-        mReady = true;
+        mReadyToDisplay = true;
         refresh();
     }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index e6fdaac..9ed787b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -29,6 +29,7 @@ import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.MediaLibrary;
 import org.videolan.vlc.R;
 import org.videolan.vlc.audio.AudioServiceController;
+import org.videolan.vlc.gui.BrowserFragment;
 import org.videolan.vlc.gui.CommonDialogs;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.util.AndroidDevices;
@@ -66,7 +67,7 @@ import android.widget.TabHost;
 import android.widget.TabHost.TabSpec;
 import android.widget.TextView;
 
-public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
+public class AudioAlbumsSongsFragment extends BrowserFragment implements SwipeRefreshLayout.OnRefreshListener {
 
     public final static String TAG = "VLC/AudioAlbumsSongsFragment";
 
@@ -75,7 +76,6 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
 
     private AudioBrowserListAdapter mSongsAdapter;
     private AudioBrowserListAdapter mAlbumsAdapter;
-    private SwipeRefreshLayout mSwipeRefreshLayout;
 
     public final static String EXTRA_NAME = "name";
     public final static String EXTRA_NAME2 = "name2";
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 6e6615c..6890bc4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -75,7 +75,6 @@ public class AudioBrowserFragment extends BrowserFragment implements SwipeRefres
     public final static String TAG = "VLC/AudioBrowserFragment";
 
     private FlingViewGroup mFlingViewGroup;
-    private SwipeRefreshLayout mSwipeRefreshLayout;
     private int mFlingViewPosition = 0;
 
     private HeaderScrollView mHeader;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index bc233cb..ff4b4cd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -105,7 +105,6 @@ public class VideoGridFragment extends BrowserFragment implements ISortable, IVi
     private LibVLC mLibVlc;
     private Thumbnailer mThumbnailer;
     private VideoGridAnimator mAnimator;
-    private SwipeRefreshLayout mSwipeRefreshLayout;
 
     private AudioServiceController mAudioController;
     private boolean mReady = true;



More information about the Android mailing list