[Android] Improve browsers display
Geoffrey Métais
git at videolan.org
Fri Dec 16 15:43:00 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec 16 15:35:05 2016 +0100| [10131281a3e5d1217758fafa3ffdcdf1e52cdc40] | committer: Geoffrey Métais
Improve browsers display
> https://code.videolan.org/videolan/vlc-android/commit/10131281a3e5d1217758fafa3ffdcdf1e52cdc40
---
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 7 +++----
.../org/videolan/vlc/gui/browser/StorageBrowserAdapter.java | 6 ------
.../org/videolan/vlc/gui/browser/StorageBrowserFragment.java | 10 +++++-----
3 files changed, 8 insertions(+), 15 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 43cd624..b671400 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -317,7 +317,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
protected void update(boolean force){
if (mReadyToDisplay) {
- updateEmptyView();
if (force || mAdapter.isEmpty()) {
refresh();
} else {
@@ -327,6 +326,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
}
protected void updateDisplay() {
+ updateEmptyView();
if (!mAdapter.isEmpty()) {
if (mSavedPosition > 0) {
mLayoutManager.scrollToPositionWithOffset(mSavedPosition, 0);
@@ -349,7 +349,8 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override
public void refresh() {
mHandler.sendEmptyMessageDelayed(BrowserFragmentHandler.MSG_SHOW_LOADING, 300);
- mAdapter.clear();
+ if (!mRoot)
+ mAdapter.clear();
mFoldersContentLists.clear();
if (mMediaBrowser == null)
mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
@@ -391,12 +392,10 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
switch (msg.what){
case MSG_SHOW_LOADING:
fragment.mSwipeRefreshLayout.setRefreshing(true);
- fragment.updateEmptyView();
break;
case MSG_HIDE_LOADING:
removeMessages(MSG_SHOW_LOADING);
fragment.mSwipeRefreshLayout.setRefreshing(false);
- fragment.updateEmptyView();
break;
case MSG_REFRESH:
if (getOwner() != null && !getOwner().isDetached())
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 fb85dc8..97d0f57 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -80,12 +80,6 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
vh.setContextMenuListener();
}
- @Override
- public void onViewRecycled(ViewHolder holder) {
- final MediaViewHolder vh = (MediaViewHolder) holder;
- vh.binding.setItem(null);
- }
-
public void addItem(MediaLibraryItem item, boolean notify, boolean top) {
if (item.getItemType() == MediaLibraryItem.TYPE_MEDIA)
item = new Storage(((MediaWrapper)item).getUri());
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 a9236ce..620725e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
@@ -45,7 +45,6 @@ import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.CustomDirectories;
import java.io.File;
-import java.util.ArrayList;
public class StorageBrowserFragment extends FileBrowserFragment {
@@ -114,14 +113,13 @@ public class StorageBrowserFragment extends FileBrowserFragment {
String[] storages = mMediaLibrary.getDevices();
String[] customDirectories = CustomDirectories.getCustomDirectories();
Storage storage;
- ArrayList 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));
- storagesList.add(storage);
+ mAdapter.addItem(storage, true, false);
}
customLoop:
for (String customDir : customDirectories) {
@@ -132,11 +130,11 @@ public class StorageBrowserFragment extends FileBrowserFragment {
continue customLoop;
}
storage = new Storage(Uri.parse(customDir));
- storagesList.add(storage);
+ mAdapter.addItem(storage, true, false);
}
+ updateEmptyView();
parseSubDirectories();
mHandler.sendEmptyMessage(BrowserFragmentHandler.MSG_HIDE_LOADING);
- mAdapter.dispatchUpdate(storagesList);
}
@Override
@@ -153,6 +151,8 @@ public class StorageBrowserFragment extends FileBrowserFragment {
}
protected void updateDisplay() {
+ updateEmptyView();
+ parseSubDirectories();
if (isRootDirectory())
((StorageBrowserAdapter)mAdapter).updateMediaDirs();
if (!mAdapter.isEmpty()) {
More information about the Android
mailing list