[Android] src: Allow refreshing in the directory view
Edward Wang
git at videolan.org
Sat Jun 23 14:42:59 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Jun 23 08:42:49 2012 -0400| [f4d064a2484d440af21c19ca44b5bbf949f1ca3a] | committer: Edward Wang
src: Allow refreshing in the directory view
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=f4d064a2484d440af21c19ca44b5bbf949f1ca3a
---
vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java | 12 +++++++-----
.../src/org/videolan/vlc/gui/DirectoryViewFragment.java | 4 ++++
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 5 ++++-
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index 887a393..3778b6d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -301,10 +301,12 @@ public class DirectoryAdapter extends BaseAdapter {
}
public void clear() {
- this.mRootNode.children.clear();
- this.mRootNode = new DirectoryAdapter.Node(mRootDir);
- this.populateNode(mRootNode, mRootDir);
- this.mCurrentDir = mRootDir;
- this.mCurrentNode = mRootNode;
+ for(DirectoryAdapter.Node n : this.mCurrentNode.children)
+ n.children.clear();
+ this.mCurrentNode.children.clear();
+ this.mCurrentNode = new DirectoryAdapter.Node(mCurrentDir);
+ this.populateNode(mCurrentNode, mCurrentDir);
+
+ this.notifyDataSetChanged();
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
index 2e87397..93183be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -100,4 +100,8 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
Util.toaster(getActivity(), R.string.notavailable);
}
+ public void refresh() {
+ mDirectoryAdapter.clear();
+ }
+
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 72b1f9c..bdb43e0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -264,7 +264,10 @@ public class MainActivity extends SherlockFragmentActivity {
break;
// Refresh
case R.id.ml_menu_refresh:
- MediaLibrary.getInstance(this).loadMediaItems(this);
+ if(mMediaLibraryActive)
+ MediaLibrary.getInstance(this).loadMediaItems(this);
+ else
+ mDirectoryView.refresh();
break;
// Browse Folders
case R.id.ml_menu_browse:
More information about the Android
mailing list