Improvements to layouts

This commit is contained in:
daniel oeh 2012-06-23 12:36:04 +02:00
parent 119f718bcf
commit 5c308c7f1e
5 changed files with 149 additions and 48 deletions

BIN
res/drawable/type_audio.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
res/drawable/type_video.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,36 +1,86 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" > android:layout_height="fill_parent"
<TextView android:layout_marginBottom="4dp"
android:id="@+id/txtvItemname" android:layout_marginLeft="1dp"
android:layout_width="fill_parent" android:layout_marginTop="4dp" >
android:layout_height="wrap_content"
/> <ImageButton
<TextView android:id="@+id/butAction"
android:id="@+id/txtvItemsize" android:layout_width="wrap_content"
android:layout_width="fill_parent" android:layout_height="match_parent"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:layout_below="@id/txtvItemname" android:layout_centerVertical="true"
/> android:background="@drawable/borderless_button"
<ImageButton android:clickable="false"
android:id="@+id/butAction" android:focusable="false"
android:layout_width="wrap_content" android:focusableInTouchMode="false"
android:layout_height="match_parent" android:padding="8dp"
android:padding="8dp" android:scaleType="fitXY"
android:src="@drawable/navigation_expand" android:src="@drawable/navigation_expand" />
android:background="@drawable/borderless_button"
android:layout_alignParentRight="true" <ImageView
android:focusable="false" android:id="@+id/divider"
android:focusableInTouchMode="false" android:layout_width="wrap_content"
android:clickable="false" android:layout_height="match_parent"
/> android:layout_centerVertical="true"
<ImageView android:layout_toLeftOf="@id/butAction"
android:layout_height="match_parent" android:focusable="false"
android:layout_width="wrap_content" android:scaleType="fitXY"
android:src="@drawable/vertical_divider" android:src="@drawable/vertical_divider" />
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/butAction" <LinearLayout
android:focusable="false"/> android:layout_width="wrap_content"
android:layout_height="match_parent"
</RelativeLayout> android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/divider"
android:orientation="vertical" >
<TextView
android:id="@+id/txtvItemname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16dp" />
<TextView
android:id="@+id/txtvPublished"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray" />
<RelativeLayout
android:id="@+id/enc_info"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/txtvLenSize"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/txtvLenSize"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/txtvLenSize"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imgvType"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/imgvDownloaded"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/av_download"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
<ImageView <ImageView
@ -44,13 +43,14 @@
<SeekBar <SeekBar
android:id="@+id/sbPosition" android:id="@+id/sbPosition"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content"
android:max="500" />
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:scaleType="fitXY"
android:padding="5dp" android:padding="5dp"
android:scaleType="fitXY"
android:src="@drawable/horizontal_divider" /> android:src="@drawable/horizontal_divider" />
<LinearLayout <LinearLayout
@ -96,4 +96,11 @@
android:src="@android:drawable/ic_media_ff" /> android:src="@android:drawable/ic_media_ff" />
</LinearLayout> </LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:scaleType="fitXY"
android:src="@drawable/horizontal_divider" />
</LinearLayout> </LinearLayout>

View File

@ -1,5 +1,6 @@
package de.podfetcher.adapter; package de.podfetcher.adapter;
import java.text.DateFormat;
import java.util.List; import java.util.List;
import de.podfetcher.feed.FeedItem; import de.podfetcher.feed.FeedItem;
@ -8,7 +9,10 @@ import de.podfetcher.R;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -19,8 +23,8 @@ import android.graphics.Typeface;
public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
private OnClickListener onButActionClicked; private OnClickListener onButActionClicked;
public FeedItemlistAdapter(Context context, public FeedItemlistAdapter(Context context, int textViewResourceId,
int textViewResourceId, List<FeedItem> objects, OnClickListener onButActionClicked) { List<FeedItem> objects, OnClickListener onButActionClicked) {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
this.onButActionClicked = onButActionClicked; this.onButActionClicked = onButActionClicked;
} }
@ -30,17 +34,28 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
Holder holder; Holder holder;
FeedItem item = getItem(position); FeedItem item = getItem(position);
if(convertView == null) { if (convertView == null) {
holder = new Holder(); holder = new Holder();
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.feeditemlist_item, null); convertView = inflater.inflate(R.layout.feeditemlist_item, null);
holder.title = (TextView) convertView.findViewById(R.id.txtvItemname); holder.title = (TextView) convertView
holder.size = (TextView) convertView.findViewById(R.id.txtvItemsize); .findViewById(R.id.txtvItemname);
holder.butAction = (ImageButton) convertView.findViewById(R.id.butAction); holder.lenSize = (TextView) convertView
.findViewById(R.id.txtvLenSize);
holder.butAction = (ImageButton) convertView
.findViewById(R.id.butAction);
holder.published = (TextView) convertView
.findViewById(R.id.txtvPublished);
holder.downloaded = (ImageView) convertView
.findViewById(R.id.imgvDownloaded);
holder.type = (ImageView) convertView.findViewById(R.id.imgvType);
holder.encInfo = (RelativeLayout) convertView
.findViewById(R.id.enc_info);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
holder = (Holder) convertView.getTag(); holder = (Holder) convertView.getTag();
} }
holder.title.setText(item.getTitle()); holder.title.setText(item.getTitle());
@ -49,16 +64,45 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> {
} else { } else {
holder.title.setTypeface(Typeface.DEFAULT); holder.title.setTypeface(Typeface.DEFAULT);
} }
holder.size.setText(Converter.byteToString(item.getMedia().getSize()));
holder.published.setText("Published: "
+ DateUtils.formatSameDayTime(item.getPubDate().getTime(),
System.currentTimeMillis(), DateFormat.SHORT,
DateFormat.SHORT));
if (item.getMedia() == null) {
holder.encInfo.setVisibility(View.GONE);
} else {
if (item.getMedia().isDownloaded()) {
holder.lenSize.setText(Converter.getDurationStringShort(item
.getMedia().getDuration()));
holder.downloaded.setVisibility(View.VISIBLE);
} else {
holder.lenSize.setText(Converter.byteToString(item.getMedia()
.getSize()));
}
String type = item.getMedia().getMime_type()
.substring(0, item.getMedia().getMime_type().indexOf('/'));
if (type.equals("audio")) {
holder.type.setImageResource(R.drawable.type_audio);
} else if (type.equals("video")) {
holder.type.setImageResource(R.drawable.type_video);
}
}
holder.butAction.setFocusable(false); holder.butAction.setFocusable(false);
holder.butAction.setOnClickListener(onButActionClicked); holder.butAction.setOnClickListener(onButActionClicked);
return convertView; return convertView;
} }
static class Holder { static class Holder {
TextView title; TextView title;
TextView size; TextView published;
TextView lenSize;
ImageView downloaded;
ImageView type;
ImageButton butAction; ImageButton butAction;
RelativeLayout encInfo;
} }
} }