Added status indicator to external feeditemlist

This commit is contained in:
daniel oeh 2013-02-21 16:47:19 +01:00
parent 64aaae3ea6
commit 51a06ef9e7
2 changed files with 91 additions and 2 deletions

View File

@ -80,4 +80,49 @@
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_toLeftOf="@id/butAction" /> android:layout_toLeftOf="@id/butAction" />
<TextView
android:id="@+id/statusUnread"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="8dp"
android:background="@color/status_unread"
android:gravity="center"
android:minWidth="@dimen/status_indicator_width"
android:text="@string/new_label"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/text_size_micro"
android:textStyle="bold" />
<ImageView
android:id="@+id/statusPlaying"
android:layout_width="@dimen/status_indicator_width"
android:layout_height="18dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="8dp"
android:background="@color/status_playing"
android:gravity="center"
android:padding="2dp"
android:src="@drawable/av_play_dark" />
<TextView
android:id="@+id/statusInProgress"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="8dp"
android:background="@color/status_progress"
android:gravity="center"
android:minWidth="@dimen/status_indicator_width"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="@dimen/text_size_micro"
android:textStyle="bold" />
</RelativeLayout> </RelativeLayout>

View File

@ -106,6 +106,12 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
.findViewById(R.id.imgvFeedimage); .findViewById(R.id.imgvFeedimage);
holder.butAction = (ImageButton) convertView holder.butAction = (ImageButton) convertView
.findViewById(R.id.butAction); .findViewById(R.id.butAction);
holder.statusPlaying = (View) convertView
.findViewById(R.id.statusPlaying);
holder.statusUnread = (View) convertView
.findViewById(R.id.statusUnread);
holder.statusInProgress = (TextView) convertView
.findViewById(R.id.statusInProgress);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
holder = (Holder) convertView.getTag(); holder = (Holder) convertView.getTag();
@ -113,6 +119,39 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
holder.title.setText(item.getTitle()); holder.title.setText(item.getTitle());
holder.feedTitle.setText(item.getFeed().getTitle()); holder.feedTitle.setText(item.getFeed().getTitle());
if (groupPosition == GROUP_POS_QUEUE) {
FeedItem.State state = item.getState();
switch (state) {
case PLAYING:
holder.statusPlaying.setVisibility(View.VISIBLE);
holder.statusUnread.setVisibility(View.GONE);
holder.statusInProgress.setVisibility(View.GONE);
break;
case IN_PROGRESS:
holder.statusPlaying.setVisibility(View.GONE);
holder.statusUnread.setVisibility(View.GONE);
holder.statusInProgress.setVisibility(View.VISIBLE);
holder.statusInProgress.setText(Converter
.getDurationStringLong(item.getMedia().getPosition()));
break;
case NEW:
holder.statusPlaying.setVisibility(View.GONE);
holder.statusUnread.setVisibility(View.VISIBLE);
holder.statusInProgress.setVisibility(View.GONE);
break;
default:
holder.statusPlaying.setVisibility(View.GONE);
holder.statusUnread.setVisibility(View.GONE);
holder.statusInProgress.setVisibility(View.GONE);
break;
}
} else {
holder.statusPlaying.setVisibility(View.GONE);
holder.statusUnread.setVisibility(View.GONE);
holder.statusInProgress.setVisibility(View.GONE);
}
FeedMedia media = item.getMedia(); FeedMedia media = item.getMedia();
if (media != null) { if (media != null) {
TypedArray drawables = context.obtainStyledAttributes(new int[] { TypedArray drawables = context.obtainStyledAttributes(new int[] {
@ -121,7 +160,8 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
if (!media.isDownloaded()) { if (!media.isDownloaded()) {
if (DownloadRequester.getInstance().isDownloadingFile(media)) { if (DownloadRequester.getInstance().isDownloadingFile(media)) {
holder.downloadStatus.setVisibility(View.VISIBLE); holder.downloadStatus.setVisibility(View.VISIBLE);
holder.downloadStatus.setImageDrawable(drawables.getDrawable(1)); holder.downloadStatus.setImageDrawable(drawables
.getDrawable(1));
} else { } else {
holder.downloadStatus.setVisibility(View.GONE); holder.downloadStatus.setVisibility(View.GONE);
} }
@ -129,7 +169,8 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
+ Converter.byteToString(media.getSize())); + Converter.byteToString(media.getSize()));
} else { } else {
holder.downloadStatus.setVisibility(View.VISIBLE); holder.downloadStatus.setVisibility(View.VISIBLE);
holder.downloadStatus.setImageDrawable(drawables.getDrawable(0)); holder.downloadStatus
.setImageDrawable(drawables.getDrawable(0));
holder.lenSize.setText(context holder.lenSize.setText(context
.getString(R.string.length_prefix) .getString(R.string.length_prefix)
+ Converter.getDurationStringLong(media.getDuration())); + Converter.getDurationStringLong(media.getDuration()));
@ -165,6 +206,9 @@ public class ExternalEpisodesListAdapter extends BaseExpandableListAdapter {
ImageView downloadStatus; ImageView downloadStatus;
ImageView feedImage; ImageView feedImage;
ImageButton butAction; ImageButton butAction;
View statusUnread;
View statusPlaying;
TextView statusInProgress;
} }
@Override @Override