Cleaned up layout

This commit is contained in:
ByteHamster 2020-02-04 22:46:13 +01:00
parent 1313cde481
commit cb702a2de6
6 changed files with 180 additions and 160 deletions

View File

@ -51,7 +51,7 @@ public class FeedItemlistAdapter extends BaseAdapter {
public View getView(final int position, View convertView, ViewGroup parent) {
EpisodeItemViewHolder holder;
if (convertView == null) {
holder = new EpisodeItemViewHolder(activity);
holder = new EpisodeItemViewHolder(activity, parent);
} else {
holder = (EpisodeItemViewHolder) convertView.getTag();
}

View File

@ -55,7 +55,7 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<EpisodeItemViewHo
@NonNull
@Override
public EpisodeItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
EpisodeItemViewHolder viewHolder = new EpisodeItemViewHolder(mainActivity.get());
EpisodeItemViewHolder viewHolder = new EpisodeItemViewHolder(mainActivity.get(), parent);
viewHolder.dragHandle.setOnTouchListener((v1, event) -> {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
Log.d(TAG, "startDrag()");

View File

@ -5,12 +5,15 @@ import android.os.Build;
import android.text.Layout;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.view.LayoutInflaterCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.joanzapata.iconify.Iconify;
import de.danoeh.antennapod.R;
@ -37,7 +40,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
implements QueueRecyclerAdapter.ItemTouchHelperViewHolder {
private static final String TAG = "EpisodeItemViewHolder";
private final FrameLayout container;
private final View container;
public final ImageView dragHandle;
private final TextView placeholder;
private final ImageView cover;
@ -49,14 +52,15 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
private final TextView isNew;
private final ImageView isInQueue;
private final ImageView isVideo;
private final ImageView isFavorite;
private final ProgressBar progressBar;
private final ImageButton butSecondary;
private final MainActivity activity;
private FeedItem item;
public EpisodeItemViewHolder(MainActivity activity) {
super(View.inflate(activity, R.layout.feeditemlist_item, null));
public EpisodeItemViewHolder(MainActivity activity, ViewGroup parent) {
super(LayoutInflater.from(activity).inflate(R.layout.feeditemlist_item, parent, false));
this.activity = activity;
container = itemView.findViewById(R.id.container);
dragHandle = itemView.findViewById(R.id.drag_handle);
@ -67,13 +71,14 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
title.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
}
pubDate = itemView.findViewById(R.id.txtvPubDate);
position = itemView.findViewById(R.id.txtvProgressLeft);
duration = itemView.findViewById(R.id.txtvProgressRight);
position = itemView.findViewById(R.id.txtvPosition);
duration = itemView.findViewById(R.id.txtvDuration);
butSecondary = itemView.findViewById(R.id.butSecondaryAction);
progressBar = itemView.findViewById(R.id.progressBar);
isInQueue = itemView.findViewById(R.id.ivInPlaylist);
isVideo = itemView.findViewById(R.id.ivIsVideo);
isNew = itemView.findViewById(R.id.statusUnread);
isFavorite = itemView.findViewById(R.id.isFavorite);
size = itemView.findViewById(R.id.size);
itemView.setTag(this);
}
@ -94,8 +99,9 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
title.setText(item.getTitle());
title.setText(item.getTitle());
pubDate.setText(DateUtils.formatAbbrev(activity, item.getPubDate()));
isNew.setVisibility(item.isNew() ? View.VISIBLE : View.INVISIBLE);
isInQueue.setVisibility(item.isTagged(FeedItem.TAG_QUEUE) ? View.VISIBLE : View.INVISIBLE);
isNew.setVisibility(item.isNew() ? View.VISIBLE : View.GONE);
isFavorite.setVisibility(item.isTagged(FeedItem.TAG_FAVORITE) ? View.VISIBLE : View.GONE);
isInQueue.setVisibility(item.isTagged(FeedItem.TAG_QUEUE) ? View.VISIBLE : View.GONE);
itemView.setAlpha(item.isPlayed() /*&& makePlayedItemsTransparent*/ ? 0.5f : 1.0f);
if (item.getMedia() != null) {
@ -116,7 +122,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
}
private void bind(FeedMedia media) {
isVideo.setVisibility(media.getMediaType() == MediaType.VIDEO ? View.VISIBLE : View.INVISIBLE);
isVideo.setVisibility(media.getMediaType() == MediaType.VIDEO ? View.VISIBLE : View.GONE);
duration.setText(Converter.getDurationStringLong(media.getDuration()));
if (media.isCurrentlyPlaying()) {
@ -126,7 +132,8 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
}
final DownloadRequest downloadRequest = DownloadRequester.getInstance().getRequestFor(media);
progressBar.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.GONE);
position.setVisibility(View.GONE);
if (downloadRequest != null) {
position.setText(Converter.byteToString(downloadRequest.getSoFar()));
if (downloadRequest.getSize() > 0) {
@ -136,11 +143,13 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
}
progressBar.setProgress(downloadRequest.getProgressPercent());
progressBar.setVisibility(View.VISIBLE);
position.setVisibility(View.VISIBLE);
} else if (item.getState() == FeedItem.State.PLAYING || item.getState() == FeedItem.State.IN_PROGRESS) {
if (media.getDuration() > 0) {
int progress = (int) (100.0 * media.getPosition() / media.getDuration());
progressBar.setProgress(progress);
progressBar.setVisibility(View.VISIBLE);
position.setVisibility(View.VISIBLE);
position.setText(Converter.getDurationStringLong(media.getPosition()));
duration.setText(Converter.getDurationStringLong(media.getDuration()));
}

View File

@ -1,184 +1,197 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/container"
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_height="150dp">
android:orientation="horizontal"
tools:layout_height="150dp"
android:gravity="center_vertical"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" >
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="16dp">
<ImageView
android:id="@+id/drag_handle"
android:layout_width="104dp"
android:layout_height="64dp"
android:layout_marginLeft="-16dp"
android:layout_marginStart="-16dp"
android:layout_marginRight="-72dp"
android:layout_marginEnd="-72dp"
android:layout_width="36dp"
android:layout_height="match_parent"
android:contentDescription="@string/drag_handle_content_description"
android:scaleType="fitXY"
android:scaleType="center"
android:src="?attr/dragview_background"
tools:src="@drawable/ic_drag_vertical_grey600_48dp"
tools:background="@android:color/holo_green_dark" />
<RelativeLayout
android:layout_width="wrap_content"
</LinearLayout>
<RelativeLayout
android:layout_width="@dimen/thumbnail_length_queue_item"
android:layout_height="@dimen/thumbnail_length_queue_item"
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding">
<TextView
android:id="@+id/txtvPlaceholder"
android:layout_width="@dimen/thumbnail_length_queue_item"
android:layout_height="@dimen/thumbnail_length_queue_item"
android:layout_centerVertical="true"
android:gravity="center"
android:background="@color/light_gray"
android:maxLines="3"
android:ellipsize="end"/>
<ImageView
android:id="@+id/imgvCover"
android:layout_width="@dimen/thumbnail_length_queue_item"
android:layout_height="@dimen/thumbnail_length_queue_item"
android:layout_centerVertical="true"
android:contentDescription="@string/cover_label"
tools:src="@drawable/ic_antenna"
tools:background="@android:color/holo_green_dark"/>
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
android:layout_marginStart="@dimen/listitem_threeline_textleftpadding"
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding"
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
android:layout_weight="1"
tools:background="@android:color/holo_red_dark"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp">
android:id="@+id/status"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:id="@+id/txtvPlaceholder"
android:layout_width="@dimen/thumbnail_length_queue_item"
android:layout_height="@dimen/thumbnail_length_queue_item"
android:layout_centerVertical="true"
android:gravity="center"
android:background="@color/light_gray"
android:maxLines="3"
android:ellipsize="end"/>
android:text="@string/new_episodes_label"
style="@style/AntennaPod.TextView.UnreadIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/statusUnread"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"/>
<ImageView
android:id="@+id/imgvCover"
android:layout_width="@dimen/thumbnail_length_queue_item"
android:layout_height="@dimen/thumbnail_length_queue_item"
android:layout_centerVertical="true"
android:contentDescription="@string/cover_label"
tools:src="@drawable/ic_antenna"
tools:background="@android:color/holo_green_dark"/>
</RelativeLayout>
android:layout_width="16dp"
android:layout_height="16dp"
app:srcCompat="?attr/ic_unfav"
tools:srcCompat="@drawable/ic_star_grey600_24dp"
android:id="@+id/isFavorite"/>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
android:layout_marginStart="@dimen/listitem_threeline_textleftpadding"
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding"
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
android:layout_weight="1"
tools:background="@android:color/holo_red_dark">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
app:srcCompat="?attr/type_video"
tools:srcCompat="@drawable/ic_remove_red_eye_grey600_18dp"
android:id="@+id/ivIsVideo"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="?attr/stat_playlist"
tools:srcCompat="@drawable/ic_playlist_grey_24dp"
android:id="@+id/ivInPlaylist"/>
<TextView
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:text="·"
tools:background="@android:color/holo_blue_light"/>
<!-- order is important, pubDate first! -->
<TextView
android:id="@+id/txtvPubDate"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:lines="2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:gravity="end|top"
android:text="Feb\n12"
tools:background="@android:color/holo_blue_light" />
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
tools:text="Feb 12"/>
<TextView
android:id="@+id/txtvTitle"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/txtvPubDate"
android:layout_toStartOf="@id/txtvPubDate"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="Item title"
android:ellipsize="end"
tools:background="@android:color/holo_blue_light" />
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:text="·"
tools:background="@android:color/holo_blue_light"/>
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="0dp"
<TextView
android:id="@+id/size"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/txtvTitle"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
tools:text="10 MB"/>
<TextView
android:id="@+id/txtvProgressLeft"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="0dp"
android:text="00:42:23"
tools:background="@android:color/holo_blue_light"/>
</LinearLayout>
<TextView
android:id="@+id/txtvTitle"
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Item title"
android:ellipsize="end"
tools:background="@android:color/holo_blue_light"/>
<TextView
android:id="@+id/txtvProgressRight"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="0dp"
tools:text="Jan 23"
tools:background="@android:color/holo_green_dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/progress"
android:orientation="horizontal"
android:gravity="center_vertical">
<ProgressBar
android:id="@+id/progressBar"
style="?attr/progressBarTheme"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_below="@id/txtvProgressLeft"
android:layoutDirection="ltr"
android:max="100"
tools:background="@android:color/holo_blue_light" />
<TextView
android:id="@+id/txtvPosition"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
tools:text="00:42:23"
tools:background="@android:color/holo_blue_light"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_remove_red_eye_grey600_18dp"
android:id="@+id/ivIsVideo"
android:layout_below="@+id/progressBar"/>
<ProgressBar
android:id="@+id/progressBar"
style="?attr/progressBarTheme"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="4dp"
android:max="100"
android:layout_margin="4dp"
tools:background="@android:color/holo_blue_light"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_playlist_grey_24dp"
android:id="@+id/ivInPlaylist"
android:layout_below="@+id/progressBar"
android:layout_toEndOf="@+id/ivIsVideo"
android:layout_toRightOf="@+id/ivIsVideo"/>
<TextView
android:id="@+id/txtvDuration"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
tools:text="01:23:23"
tools:background="@android:color/holo_blue_light"/>
<TextView
android:text="@string/new_episodes_label"
style="@style/AntennaPod.TextView.UnreadIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/statusUnread"
android:layout_toEndOf="@+id/ivInPlaylist"
android:layout_toRightOf="@+id/ivInPlaylist"
android:layout_below="@+id/progressBar"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/size"
android:layout_toEndOf="@+id/statusUnread"
android:layout_toRightOf="@+id/statusUnread"
android:layout_below="@+id/progressBar"/>
</RelativeLayout>
</RelativeLayout>
<include layout="@layout/vertical_list_divider"/>
<include layout="@layout/secondary_action"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<include layout="@layout/vertical_list_divider"/>
<include layout="@layout/secondary_action"/>
</LinearLayout>

View File

@ -2,6 +2,4 @@
<resources>
<dimen name="thumbnail_length">170dp</dimen>
<dimen name="thumbnail_length_queue_item">64dp</dimen>
<dimen name="thumbnail_length_downloaded_item">64dp</dimen>
</resources>

View File

@ -10,8 +10,8 @@
<dimen name="text_size_navdrawer">16sp</dimen>
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">22sp</dimen>
<dimen name="thumbnail_length_itemlist">64dp</dimen>
<dimen name="thumbnail_length_queue_item">64dp</dimen>
<dimen name="thumbnail_length_itemlist">56dp</dimen>
<dimen name="thumbnail_length_queue_item">56dp</dimen>
<dimen name="thumbnail_length_downloaded_item">64dp</dimen>
<dimen name="thumbnail_length_onlinefeedview">100dp</dimen>
<dimen name="feeditemlist_header_height">132dp</dimen>