[Android] DirectoryAdapter: fix crash

Edward Wang git at videolan.org
Mon Feb 24 01:05:01 CET 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Feb 23 19:02:42 2014 -0500| [1c800f86e8d23f6c2810ee72e56687b5b62f5140] | committer: Edward Wang

DirectoryAdapter: fix crash

To access theme resources, the Activity context must be used, not the global context.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=1c800f86e8d23f6c2810ee72e56687b5b62f5140
---

 vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java     |    8 ++++----
 .../src/org/videolan/vlc/gui/DirectoryViewFragment.java        |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index ef11d49..0b1cee0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -237,15 +237,15 @@ public class DirectoryAdapter extends BaseAdapter {
     private String mCurrentDir;
     private String mCurrentRoot;
 
-    public DirectoryAdapter() {
-        DirectoryAdapter_Core(null);
+    public DirectoryAdapter(Context context) {
+        DirectoryAdapter_Core(context, null);
     }
 
-    private void DirectoryAdapter_Core(String rootDir) {
+    private void DirectoryAdapter_Core(Context activityContext, String rootDir) {
         if (rootDir != null)
             rootDir = Util.stripTrailingSlash(rootDir);
         Log.v(TAG, "rootMRL is " + rootDir);
-        mInflater = LayoutInflater.from(VLCApplication.getAppContext());
+        mInflater = LayoutInflater.from(activityContext);
         mRootNode = new DirectoryAdapter.Node(rootDir);
         mCurrentDir = rootDir;
         this.populateNode(mRootNode, rootDir);
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
index a01d539..d656f5a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -63,7 +63,7 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mDirectoryAdapter = new DirectoryAdapter();
+        mDirectoryAdapter = new DirectoryAdapter(getActivity());
 
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_MEDIA_MOUNTED);



More information about the Android mailing list