Commit f69664c8 authored by Geoffrey Métais's avatar Geoffrey Métais

Remove redundant calls & instanciations

parent 4f0d0677
......@@ -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);
}
......
......@@ -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 {
......
......@@ -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")) {
......
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment