Commit fd3e8af8 authored by Edward Wang's avatar Edward Wang

Add icons to directory view

parent 5504cd9b
<?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
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment