[Android] Add icons to directory view
Edward Wang
git at videolan.org
Sat Jun 23 06:13:19 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Fri Jun 22 13:23:46 2012 -0400| [fd3e8af83574d772c159be7c7af2f620523fc776] | committer: Edward Wang
Add icons to directory view
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=fd3e8af83574d772c159be7c7af2f620523fc776
---
vlc-android/res/layout/directory_view_item.xml | 45 ++++++++++++++++++++
.../src/org/videolan/vlc/gui/DirectoryAdapter.java | 18 ++++----
2 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/vlc-android/res/layout/directory_view_item.xml b/vlc-android/res/layout/directory_view_item.xml
new file mode 100644
index 0000000..1b0b4df
--- /dev/null
+++ b/vlc-android/res/layout/directory_view_item.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/layout_item"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/dvi_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|left"
+ android:layout_marginRight="5dip"
+ android:src="@drawable/icon" />
+
+ <LinearLayout
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:layout_marginTop="5dip"
+ android:text="@string/title"
+ android:textColor="#ffffff"
+ android:textSize="20dip" />
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dip"
+ android:layout_marginLeft="5dip"
+ android:layout_marginRight="5dip"
+ android:text="@string/info"
+ android:textColor="#888888"
+ android:textSize="14dip" />
+ </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index 4a8cacd..c5da102 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -39,6 +39,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
+import android.widget.ImageView;
import android.widget.TextView;
public class DirectoryAdapter extends BaseAdapter {
@@ -132,7 +133,7 @@ public class DirectoryAdapter extends BaseAdapter {
View layout;
TextView title;
TextView text;
- Boolean isFile;
+ ImageView icon;
}
public void populateNode(DirectoryAdapter.Node n, String MRL) {
@@ -223,17 +224,14 @@ public class DirectoryAdapter extends BaseAdapter {
DirectoryAdapter.Node selectedNode = mCurrentNode.children.get(position);
DirectoryViewHolder holder;
View v = convertView;
- /* If view not created or type changed */
- if (v == null || ((DirectoryViewHolder)v.getTag()).isFile != selectedNode.isFile()) {
- if(selectedNode.isFile())
- v = mInflater.inflate(R.layout.audio_browser_playlist_child, parent, false);
- else
- v = mInflater.inflate(R.layout.audio_browser_playlist, parent, false);
+ /* If view not created */
+ if (v == null) {
+ v = mInflater.inflate(R.layout.directory_view_item, parent, false);
holder = new DirectoryViewHolder();
holder.layout = v.findViewById(R.id.layout_item);
holder.title = (TextView) v.findViewById(R.id.title);
holder.text = (TextView) v.findViewById(R.id.text);
- holder.isFile = selectedNode.isFile();
+ holder.icon = (ImageView) v.findViewById(R.id.dvi_icon);
v.setTag(holder);
} else
holder = (DirectoryViewHolder) v.getTag();
@@ -267,6 +265,10 @@ public class DirectoryAdapter extends BaseAdapter {
);
}
holder.text.setText(holderText);
+ if(selectedNode.isFile())
+ holder.icon.setImageResource(R.drawable.icon);
+ else
+ holder.icon.setImageResource(R.drawable.ic_folder);
return v;
}
More information about the Android
mailing list