[Android] Code factorization

Geoffrey Métais git at videolan.org
Wed Nov 23 18:53:23 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 23 18:52:18 2016 +0100| [07dd026ba412a4ea51dccc1a3ec49f977e782c79] | committer: Geoffrey Métais

Code factorization

> https://code.videolan.org/videolan/vlc-android/commit/07dd026ba412a4ea51dccc1a3ec49f977e782c79
---

 vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java        | 8 ++------
 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 1 -
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java     | 1 -
 .../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java    | 1 -
 .../src/org/videolan/vlc/gui/browser/ExtensionBrowser.java       | 1 -
 .../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java   | 9 +++++++++
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java        | 1 -
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
index 543119b..9e0f1c1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
@@ -50,7 +50,6 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
 
     private HistoryAdapter mHistoryAdapter;
     private RecyclerView mRecyclerView;
-    private RecyclerView.LayoutManager mLayoutManager;
     private View mEmptyView;
 
     /* All subclasses of Fragment must include a public empty constructor. */
@@ -65,8 +64,7 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
         View v = inflater.inflate(R.layout.history_list, container, false);
         mRecyclerView = (RecyclerView)v.findViewById(android.R.id.list);
         mEmptyView = v.findViewById(android.R.id.empty);
-        mLayoutManager = new LinearLayoutManager(getActivity());
-        mRecyclerView.setLayoutManager(mLayoutManager);
+        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
         mRecyclerView.setAdapter(mHistoryAdapter);
         mRecyclerView.setNextFocusUpId(R.id.ml_menu_search);
         mRecyclerView.setNextFocusLeftId(android.R.id.list);
@@ -78,7 +76,6 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
 
-        mSwipeRefreshLayout.setColorSchemeColors(R.color.orange700/*, R.attr.colorPrimary, R.attr.colorPrimaryDark*/);
         mSwipeRefreshLayout.setOnRefreshListener(this);
         return v;
     }
@@ -127,8 +124,7 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
                         return;
                     mHistoryAdapter.setList((MediaWrapper[]) msg.obj);
                     updateEmptyView();
-                    if (mHistoryAdapter != null)
-                        mHistoryAdapter.notifyDataSetChanged();
+                    mHistoryAdapter.notifyDataSetChanged();
                     mSwipeRefreshLayout.setRefreshing(false);
                     getActivity().supportInvalidateOptionsMenu();
             }
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 c65ff15..0079cea 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -134,7 +134,6 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
         registerForContextMenu(songsList);
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
-        mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
         mSwipeRefreshLayout.setOnRefreshListener(this);
 
         return v;
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 4af160f..e56bc69 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -157,7 +157,6 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements DevicesDis
         setupTabLayout();
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
-        mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
         mSwipeRefreshLayout.setOnRefreshListener(this);
         mSearchButtonView = v.findViewById(R.id.searchButton);
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 81bb6cc..cb18ee3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -151,7 +151,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         registerForContextMenu(mRecyclerView);
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
-        mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
         mSwipeRefreshLayout.setOnRefreshListener(this);
         mSearchButtonView = v.findViewById(R.id.searchButton);
         return v;
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
index b21ae61..3cd7ce5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
@@ -88,7 +88,6 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
         registerForContextMenu(mRecyclerView);
 
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
-        mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
         mSwipeRefreshLayout.setOnRefreshListener(this);
 
         return v;
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index b72e199..f92db80 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.browser;
 import android.annotation.TargetApi;
 import android.os.Build;
 import android.os.Bundle;
+import android.support.annotation.Nullable;
 import android.support.design.widget.BottomSheetDialogFragment;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.view.ActionMode;
@@ -36,6 +37,7 @@ import android.view.View;
 import org.videolan.medialibrary.Medialibrary;
 import org.videolan.medialibrary.media.MediaLibraryItem;
 import org.videolan.medialibrary.media.MediaWrapper;
+import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MediaInfoDialog;
 import org.videolan.vlc.gui.PlaybackServiceFragment;
@@ -58,6 +60,13 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
         mMediaLibrary = VLCApplication.getMLInstance();
     }
 
+    @Override
+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        if (mSwipeRefreshLayout != null)
+            mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
+    }
+
     public void onStart(){
         super.onStart();
         final AppCompatActivity activity = (AppCompatActivity)getActivity();
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 d640bc8..8238195 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -117,7 +117,6 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
         mSwipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeLayout);
         mSearchButtonView = v.findViewById(R.id.searchButton);
 
-        mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
         mSwipeRefreshLayout.setOnRefreshListener(this);
 
         mDividerItemDecoration = new DividerItemDecoration(v.getContext(), DividerItemDecoration.VERTICAL_LIST);



More information about the Android mailing list