[Android] Add DirectoryViewFragment and related missing files

Edward Wang git at videolan.org
Fri Jun 22 04:25:35 CEST 2012


android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Jun 21 22:24:22 2012 -0400| [fedc8720b7690cb1dfb9895c4e9da5273893a3e6] | committer: Edward Wang

Add DirectoryViewFragment and related missing files

Folder clipart from http://openclipart.org/detail/74023/folder-by-vorre-74023, public domain.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=fedc8720b7690cb1dfb9895c4e9da5273893a3e6
---

 vlc-android/res/drawable-hdpi/ic_folder.png        |  Bin 0 -> 3499 bytes
 vlc-android/res/drawable/ic_folder.png             |  Bin 0 -> 1234 bytes
 vlc-android/res/layout/directory_view.xml          |    9 ++
 .../videolan/vlc/gui/DirectoryViewFragment.java    |   86 ++++++++++++++++++++
 4 files changed, 95 insertions(+)

diff --git a/vlc-android/res/drawable-hdpi/ic_folder.png b/vlc-android/res/drawable-hdpi/ic_folder.png
new file mode 100644
index 0000000..906f305
Binary files /dev/null and b/vlc-android/res/drawable-hdpi/ic_folder.png differ
diff --git a/vlc-android/res/drawable/ic_folder.png b/vlc-android/res/drawable/ic_folder.png
new file mode 100644
index 0000000..da2ca10
Binary files /dev/null and b/vlc-android/res/drawable/ic_folder.png differ
diff --git a/vlc-android/res/layout/directory_view.xml b/vlc-android/res/layout/directory_view.xml
new file mode 100644
index 0000000..98f75a1
--- /dev/null
+++ b/vlc-android/res/layout/directory_view.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/list"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:divider="@color/item_common"
+    android:dividerHeight="1dp">
+
+</ListView>
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
new file mode 100644
index 0000000..2dcd9e5
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -0,0 +1,86 @@
+package org.videolan.vlc.gui;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.videolan.vlc.AudioServiceController;
+import org.videolan.vlc.LibVLC;
+import org.videolan.vlc.R;
+import org.videolan.vlc.Util;
+import org.videolan.vlc.gui.audio.AudioDirectoryAdapter;
+import org.videolan.vlc.gui.audio.AudioPlayerActivity;
+import org.videolan.vlc.gui.video.VideoPlayerActivity;
+import org.videolan.vlc.interfaces.ISortable;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import android.widget.AdapterView.OnItemClickListener;
+
+import com.actionbarsherlock.app.SherlockListFragment;
+
+public class DirectoryViewFragment extends SherlockListFragment implements ISortable {
+    public final static String TAG = "VLC/DirectoryViewFragment";
+
+    private AudioDirectoryAdapter mDirectoryAdapter;
+    private Context mContext;
+
+    public DirectoryViewFragment(Context context) {
+        mContext = context;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mDirectoryAdapter = new AudioDirectoryAdapter(mContext);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+    {
+        View v = inflater.inflate(R.layout.directory_view, container, false);
+        setListAdapter(mDirectoryAdapter);
+
+        return v;
+    }
+
+    @Override
+    public void onListItemClick(ListView l, View v, int p, long id) {
+        Boolean success = mDirectoryAdapter.browse(p);
+        if(!success) { /* Clicked on a media file */
+            AudioServiceController audioController = AudioServiceController.getInstance();
+            String mediaFile = mDirectoryAdapter.getMediaLocation(p);
+
+            try {
+                if(!LibVLC.getExistingInstance().hasVideoTrack(mediaFile)) {
+                    ArrayList<String> arrayList = new ArrayList<String>();
+                    arrayList.add(mDirectoryAdapter.getMediaLocation(p));
+                    audioController.load(arrayList, 0);
+                    Intent intent = new Intent(getActivity(), AudioPlayerActivity.class);
+                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+                    startActivity(intent);
+                } else {
+                    audioController.stop();
+                    Intent intent = new Intent(getActivity(), VideoPlayerActivity.class);
+                    intent.putExtra("itemLocation", mediaFile);
+                    startActivity(intent);
+                }
+            } catch (IOException e) {
+                /* disk error maybe? */
+            }
+        }
+    }
+
+    @Override
+    public void sortBy(int sortby) {
+        // TODO
+        Util.toaster(getActivity(), R.string.notavailable);
+    }
+
+}



More information about the Android mailing list