[Android] Code cleaning

Geoffrey Métais git at videolan.org
Wed Nov 21 16:43:13 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 21 14:26:42 2018 +0100| [ad6d32f40afa9227cd16303e403ca37b421da069] | committer: Geoffrey Métais

Code cleaning

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

 .../vlc/gui/tv/browser/BrowserGridFragment.java    | 30 +++++++++++-----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index 4d756a0c6..cff9dc36d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -24,18 +24,9 @@
 package org.videolan.vlc.gui.tv.browser;
 
 import android.annotation.TargetApi;
-import androidx.lifecycle.Observer;
-import androidx.lifecycle.ViewModelProviders;
 import android.content.Intent;
 import android.os.Build;
 import android.os.Bundle;
-import androidx.annotation.Nullable;
-import androidx.leanback.widget.OnItemViewClickedListener;
-import androidx.leanback.widget.OnItemViewSelectedListener;
-import androidx.leanback.widget.Presenter;
-import androidx.leanback.widget.Row;
-import androidx.leanback.widget.RowPresenter;
-import android.util.Log;
 
 import org.videolan.medialibrary.media.MediaLibraryItem;
 import org.videolan.medialibrary.media.MediaWrapper;
@@ -51,18 +42,27 @@ import org.videolan.vlc.viewmodels.browser.NetworkModel;
 
 import java.util.List;
 
+import androidx.annotation.Nullable;
+import androidx.leanback.widget.OnItemViewClickedListener;
+import androidx.leanback.widget.OnItemViewSelectedListener;
+import androidx.leanback.widget.Presenter;
+import androidx.leanback.widget.Row;
+import androidx.leanback.widget.RowPresenter;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 public class BrowserGridFragment extends GridFragment implements OnItemViewSelectedListener, OnItemViewClickedListener, DetailsFragment {
 
     private MediaWrapper mItemSelected;
     private NetworkModel provider;
-    protected boolean mShowHiddenFiles;
 
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setOnItemViewSelectedListener(this);
-        setOnItemViewClickedListener(this); mShowHiddenFiles = Settings.INSTANCE.getInstance(requireContext()).getBoolean("browser_show_hidden_files", false);
-        provider = ViewModelProviders.of(this, new NetworkModel.Factory(requireContext(), null, mShowHiddenFiles)).get(NetworkModel.class);
+        setOnItemViewClickedListener(this);
+        final boolean showHiddenFiles = Settings.INSTANCE.getInstance(requireContext()).getBoolean("browser_show_hidden_files", false);
+        provider = ViewModelProviders.of(this, new NetworkModel.Factory(requireContext(), null, showHiddenFiles)).get(NetworkModel.class);
         provider.getDataset().observe(this, new Observer<List<MediaLibraryItem>>() {
             @Override
             public void onChanged(@Nullable List<MediaLibraryItem> mediaLibraryItems) {
@@ -72,7 +72,7 @@ public class BrowserGridFragment extends GridFragment implements OnItemViewSelec
         ExternalMonitor.connected.observe(this, new Observer<Boolean>() {
             @Override
             public void onChanged(@Nullable Boolean connected) {
-                if (connected) provider.refresh();
+                if (connected != null && connected) provider.refresh();
                 //TODO empty/disconnected view
             }
         });
@@ -104,8 +104,8 @@ public class BrowserGridFragment extends GridFragment implements OnItemViewSelec
     public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) {
         MediaWrapper media = (MediaWrapper) item;
         if (media.getType() == MediaWrapper.TYPE_DIR)
-            TvUtil.INSTANCE.browseFolder(getActivity(), Constants.HEADER_NETWORK, ((MediaWrapper) item).getUri());
+            TvUtil.INSTANCE.browseFolder(requireActivity(), Constants.HEADER_NETWORK, ((MediaWrapper) item).getUri());
         else
-            TvUtil.INSTANCE.openMedia(getActivity(), item, null);
+            TvUtil.INSTANCE.openMedia(requireActivity(), item, null);
     }
 }



More information about the Android mailing list