[Android] ML folders: Fetch string resource from main thread
Geoffrey Métais
git at videolan.org
Wed Nov 15 09:49:38 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 15 09:48:46 2017 +0100| [662c4c613a9aafc9b43393e99015f3056c28c050] | committer: Geoffrey Métais
ML folders: Fetch string resource from main thread
> https://code.videolan.org/videolan/vlc-android/commit/662c4c613a9aafc9b43393e99015f3056c28c050
---
.../vlc/gui/browser/StorageBrowserAdapter.java | 4 ++--
.../vlc/gui/browser/StorageBrowserFragment.java | 28 ++++++++++++----------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
index 517b19e8c..ce9f54a5f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -58,7 +58,7 @@ class StorageBrowserAdapter extends BaseBrowserAdapter {
if (!storagePath.endsWith("/"))
storagePath += "/";
boolean hasContextMenu = mCustomDirsLocation.contains(storagePath);
- boolean checked = ((StorageBrowserFragment) fragment).mScannedDirectory || mMediaDirsLocation.contains(storagePath);
+ boolean checked = ((StorageBrowserFragment) fragment).scannedDirectory || mMediaDirsLocation.contains(storagePath);
vh.binding.setItem(storage);
vh.binding.setHasContextMenu(hasContextMenu);
if (checked)
@@ -67,7 +67,7 @@ class StorageBrowserAdapter extends BaseBrowserAdapter {
vh.binding.browserCheckbox.setState(ThreeStatesCheckbox.STATE_PARTIAL);
else
vh.binding.browserCheckbox.setState(ThreeStatesCheckbox.STATE_UNCHECKED);
- vh.binding.setCheckEnabled(!((StorageBrowserFragment) fragment).mScannedDirectory);
+ vh.binding.setCheckEnabled(!((StorageBrowserFragment) fragment).scannedDirectory);
if (hasContextMenu)
vh.setContextMenuListener();
}
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 2a0d659e4..f4a9872c8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
@@ -57,9 +57,10 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
public static final String KEY_IN_MEDIALIB = "key_in_medialib";
- boolean mScannedDirectory = false;
- SimpleArrayMap<String, CheckBox> mProcessingFolders = new SimpleArrayMap<>();
+ boolean scannedDirectory = false;
+ private final SimpleArrayMap<String, CheckBox> mProcessingFolders = new SimpleArrayMap<>();
private Snackbar mSnack;
+ private String mMainStorageTitle;
public boolean isSortEnabled() {
return false;
@@ -78,8 +79,9 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
if (bundle == null)
bundle = getArguments();
if (bundle != null){
- mScannedDirectory = bundle.getBoolean(KEY_IN_MEDIALIB);
+ scannedDirectory = bundle.getBoolean(KEY_IN_MEDIALIB);
}
+ mMainStorageTitle = getString(R.string.internal_memory);
}
@Override
@@ -120,21 +122,21 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putBoolean(KEY_IN_MEDIALIB, mScannedDirectory);
+ outState.putBoolean(KEY_IN_MEDIALIB, scannedDirectory);
}
@Override
protected void browseRoot() {
- String[] storages = AndroidDevices.getMediaDirectories();
- String[] customDirectories = CustomDirectories.getCustomDirectories();
+ final String[] storages = AndroidDevices.getMediaDirectories();
+ final String[] customDirectories = CustomDirectories.getCustomDirectories();
Storage storage;
- ArrayList<MediaLibraryItem> storagesList = new ArrayList<>();
+ final ArrayList<MediaLibraryItem> storagesList = new ArrayList<>();
for (String mediaDirLocation : storages) {
if (TextUtils.isEmpty(mediaDirLocation))
continue;
storage = new Storage(Uri.fromFile(new File(mediaDirLocation)));
if (TextUtils.equals(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY, mediaDirLocation))
- storage.setName(getString(R.string.internal_memory));
+ storage.setName(mMainStorageTitle);
storagesList.add(storage);
}
customLoop:
@@ -160,11 +162,11 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
}
public void browse (MediaWrapper media, int position, boolean scanned){
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- Fragment next = createFragment();
- Bundle args = new Bundle();
+ final FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
+ final Fragment next = createFragment();
+ final Bundle args = new Bundle();
args.putParcelable(KEY_MEDIA, media);
- args.putBoolean(KEY_IN_MEDIALIB, mScannedDirectory || scanned);
+ args.putBoolean(KEY_IN_MEDIALIB, scannedDirectory || scanned);
next.setArguments(args);
ft.replace(R.id.fragment_placeholder, next, media.getLocation());
ft.addToBackStack(mMrl);
@@ -183,7 +185,7 @@ public class StorageBrowserFragment extends FileBrowserFragment implements Entry
@Override
public void onClick(View v, int position, MediaLibraryItem item) {
- MediaWrapper mw = new MediaWrapper(((Storage) item).getUri());
+ final MediaWrapper mw = new MediaWrapper(((Storage) item).getUri());
mw.setType(MediaWrapper.TYPE_DIR);
browse(mw, position, ((BrowserItemBinding)DataBindingUtil.findBinding(v)).browserCheckbox.getState() == ThreeStatesCheckbox.STATE_CHECKED);
}
More information about the Android
mailing list