Merge pull request #6208 from ByteHamster/hide-progressbar
Hide progress bar when there is no progress
This commit is contained in:
commit
94b2a4288b
@ -1,6 +1,7 @@
|
|||||||
package de.danoeh.antennapod.view.viewholder;
|
package de.danoeh.antennapod.view.viewholder;
|
||||||
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
@ -31,6 +32,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
private final TextView date;
|
private final TextView date;
|
||||||
private final ProgressBar progressBar;
|
private final ProgressBar progressBar;
|
||||||
private final CircularProgressBar circularProgressBar;
|
private final CircularProgressBar circularProgressBar;
|
||||||
|
private final View progressBarReplacementSpacer;
|
||||||
|
|
||||||
private final MainActivity activity;
|
private final MainActivity activity;
|
||||||
private FeedItem item;
|
private FeedItem item;
|
||||||
@ -46,6 +48,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
secondaryActionIcon = itemView.findViewById(R.id.secondaryActionIcon);
|
secondaryActionIcon = itemView.findViewById(R.id.secondaryActionIcon);
|
||||||
circularProgressBar = itemView.findViewById(R.id.circularProgressBar);
|
circularProgressBar = itemView.findViewById(R.id.circularProgressBar);
|
||||||
progressBar = itemView.findViewById(R.id.progressBar);
|
progressBar = itemView.findViewById(R.id.progressBar);
|
||||||
|
progressBarReplacementSpacer = itemView.findViewById(R.id.progressBarReplacementSpacer);
|
||||||
itemView.setTag(this);
|
itemView.setTag(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +70,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
FeedMedia media = item.getMedia();
|
FeedMedia media = item.getMedia();
|
||||||
if (media == null) {
|
if (media == null) {
|
||||||
circularProgressBar.setPercentage(0, item);
|
circularProgressBar.setPercentage(0, item);
|
||||||
|
setProgressBar(false, 0);
|
||||||
} else {
|
} else {
|
||||||
if (PlaybackStatus.isCurrentlyPlaying(media)) {
|
if (PlaybackStatus.isCurrentlyPlaying(media)) {
|
||||||
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background_playing));
|
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background_playing));
|
||||||
@ -74,9 +78,12 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background));
|
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getMedia().getDuration() > 0) {
|
if (item.getMedia().getDuration() > 0 && item.getMedia().getPosition() > 0) {
|
||||||
progressBar.setProgress(100 * item.getMedia().getPosition() / item.getMedia().getDuration());
|
setProgressBar(true, 100.0f * item.getMedia().getPosition() / item.getMedia().getDuration());
|
||||||
|
} else {
|
||||||
|
setProgressBar(false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DownloadService.isDownloadingFile(media.getDownload_url())) {
|
if (DownloadService.isDownloadingFile(media.getDownload_url())) {
|
||||||
final DownloadRequest downloadRequest = DownloadService.findRequest(media.getDownload_url());
|
final DownloadRequest downloadRequest = DownloadService.findRequest(media.getDownload_url());
|
||||||
float percent = 0.01f * downloadRequest.getProgressPercent();
|
float percent = 0.01f * downloadRequest.getProgressPercent();
|
||||||
@ -99,7 +106,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
date.setText("███");
|
date.setText("███");
|
||||||
secondaryActionIcon.setImageDrawable(null);
|
secondaryActionIcon.setImageDrawable(null);
|
||||||
circularProgressBar.setPercentage(0, null);
|
circularProgressBar.setPercentage(0, null);
|
||||||
progressBar.setProgress(50);
|
setProgressBar(true, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCurrentlyPlayingItem() {
|
public boolean isCurrentlyPlayingItem() {
|
||||||
@ -107,6 +114,12 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void notifyPlaybackPositionUpdated(PlaybackPositionEvent event) {
|
public void notifyPlaybackPositionUpdated(PlaybackPositionEvent event) {
|
||||||
progressBar.setProgress((int) (100.0 * event.getPosition() / event.getDuration()));
|
setProgressBar(true, 100.0f * event.getPosition() / event.getDuration());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setProgressBar(boolean visible, float progress) {
|
||||||
|
progressBar.setVisibility(visible ? ViewGroup.VISIBLE : ViewGroup.GONE);
|
||||||
|
progressBarReplacementSpacer.setVisibility(visible ? View.GONE : ViewGroup.VISIBLE);
|
||||||
|
progressBar.setProgress(Math.max(5, (int) progress)); // otherwise invisible below the edge radius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,12 @@
|
|||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/progressBarReplacementSpacer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/titleLabel"
|
android:id="@+id/titleLabel"
|
||||||
android:layout_width="128dp"
|
android:layout_width="128dp"
|
||||||
@ -103,7 +109,8 @@
|
|||||||
android:paddingHorizontal="4dp"
|
android:paddingHorizontal="4dp"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp"
|
||||||
|
tools:text="@sample/episodes.json/data/title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dateLabel"
|
android:id="@+id/dateLabel"
|
||||||
@ -114,6 +121,7 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAlignment="textStart"
|
android:textAlignment="textStart"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
|
tools:text="@sample/episodes.json/data/published_at"
|
||||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle" />
|
style="@style/AntennaPod.TextView.ListItemSecondaryTitle" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user