[Android] Remove redundant calls & instanciations

Geoffrey Métais git at videolan.org
Fri Aug 25 10:33:49 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Aug 25 09:42:44 2017 +0200| [f69664c80f97f09ba11592615aff9e0963294005] | committer: Geoffrey Métais

Remove redundant calls & instanciations

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

 .../videolan/vlc/gui/browser/BaseBrowserFragment.java   |  6 +++++-
 .../videolan/vlc/gui/browser/FileBrowserFragment.java   | 13 +------------
 .../videolan/vlc/gui/browser/FilePickerFragment.java    |  4 ++--
 .../vlc/gui/browser/NetworkBrowserFragment.java         | 17 +----------------
 .../vlc/gui/browser/StorageBrowserFragment.java         |  5 -----
 5 files changed, 9 insertions(+), 36 deletions(-)

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 c9bcde10a..ae6af2c11 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -85,7 +85,6 @@ import java.util.LinkedList;
 public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAdapter> implements IRefreshable, MediaBrowser.EventListener, SwipeRefreshLayout.OnRefreshListener, View.OnClickListener, Filterable, IEventsHandler {
     protected static final String TAG = "VLC/BaseBrowserFragment";
 
-    public static String ROOT = "smb";
     public static final String KEY_MRL = "key_mrl";
     public static final String KEY_MEDIA = "key_media";
     public static final String KEY_MEDIA_LIST = "key_media_list";
@@ -150,6 +149,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
             mMrl = getActivity().getIntent().getDataString();
             getActivity().setIntent(null);
         }
+        mRoot = defineIsRoot();
         if (mFoldersContentLists == null)
             mFoldersContentLists = new SimpleArrayMap<>();
     }
@@ -164,6 +164,10 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
         return R.layout.directory_browser;
     }
 
+    protected boolean defineIsRoot() {
+        return mMrl == null;
+    }
+
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         return inflater.inflate(getLayoutId(), container, false);
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
index dab3172b2..185c09074 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
@@ -56,23 +56,12 @@ public class FileBrowserFragment extends BaseBrowserFragment {
 
     private AlertDialog mAlertDialog;
 
-    public FileBrowserFragment() {
-        super();
-        ROOT = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY;
-    }
-
-    @Override
-    public void onCreate(Bundle bundle) {
-        super.onCreate(bundle);
-        mRoot = mMrl == null;
-    }
-
     @Override
     protected Fragment createFragment() {
         return new FileBrowserFragment();
     }
 
-    public String getTitle(){
+    public String getTitle() {
         if (mRoot)
             return getCategoryTitle();
         else {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
index f7949eb73..65b31f5be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerFragment.java
@@ -105,7 +105,7 @@ public class FilePickerFragment extends FileBrowserFragment {
     public void browseUp() {
         if (mRoot)
             getActivity().finish();
-        else if (TextUtils.equals(Strings.removeFileProtocole(mMrl), ROOT)) {
+        else if (TextUtils.equals(Strings.removeFileProtocole(mMrl), AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)) {
             mMrl = null;
             mRoot = true;
             mAdapter.clear();
@@ -116,7 +116,7 @@ public class FilePickerFragment extends FileBrowserFragment {
         }
     }
 
-    public boolean defineIsRoot() {
+    protected boolean defineIsRoot() {
         if (mMrl == null)
             return true;
         if (mMrl.startsWith("file")) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 16c579b9f..69865b70e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -30,7 +30,6 @@ import android.content.IntentFilter;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.net.Uri;
-import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.content.LocalBroadcastManager;
@@ -54,20 +53,6 @@ import java.util.List;
 
 public class NetworkBrowserFragment extends BaseBrowserFragment {
 
-    public NetworkBrowserFragment() {
-        ROOT = "smb";
-        mHandler = new BrowserFragmentHandler(this);
-        mAdapter = new BaseBrowserAdapter(this);
-    }
-
-    @Override
-    public void onCreate(Bundle bundle) {
-        super.onCreate(bundle);
-        if (mMrl == null)
-            mMrl = ROOT;
-        mRoot = ROOT.equals(mMrl);
-    }
-
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         inflater.inflate(R.menu.fragment_option_network, menu);
@@ -80,7 +65,7 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
         MenuItem item = menu.findItem(R.id.ml_menu_save);
         item.setVisible(isSortEnabled());
 
-        boolean isFavorite = MediaDatabase.getInstance().networkFavExists(Uri.parse(mMrl));
+        boolean isFavorite = mMrl != null && MediaDatabase.getInstance().networkFavExists(Uri.parse(mMrl));
         item.setIcon(isFavorite ?
                 R.drawable.ic_menu_bookmark_w :
                 R.drawable.ic_menu_bookmark_outline_w);
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
index 5da9e95d5..03fbd5fd1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
@@ -57,11 +57,6 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
     boolean mScannedDirectory = false;
     SimpleArrayMap<String, CheckBox> mProcessingFolders = new SimpleArrayMap<>();
 
-    public StorageBrowserFragment(){
-        mHandler = new BrowserFragmentHandler(this);
-        ROOT = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY;
-    }
-
     public boolean isSortEnabled() {
         return false;
     }



More information about the Android mailing list