Hide separator dot if there are no icons

This commit is contained in:
ByteHamster 2020-02-05 10:18:06 +01:00
parent f3cbaee61b
commit 8b6a53fb88
10 changed files with 26 additions and 27 deletions

View File

@ -27,20 +27,18 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<EpisodeItemV
private final WeakReference<MainActivity> mainActivityRef;
private final ItemAccess itemAccess;
private final boolean showOnlyNewEpisodes;
private FeedItem selectedItem;
public AllEpisodesRecycleAdapter(MainActivity mainActivity, ItemAccess itemAccess, boolean showOnlyNewEpisodes) {
public AllEpisodesRecycleAdapter(MainActivity mainActivity, ItemAccess itemAccess) {
super();
this.mainActivityRef = new WeakReference<>(mainActivity);
this.itemAccess = itemAccess;
this.showOnlyNewEpisodes = showOnlyNewEpisodes;
}
@NonNull
@Override
public EpisodeItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
public EpisodeItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
EpisodeItemViewHolder viewHolder = new EpisodeItemViewHolder(mainActivityRef.get(), parent);
viewHolder.dragHandle.setVisibility(View.GONE);
return viewHolder;
@ -63,6 +61,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<EpisodeItemV
}
});
holder.itemView.setOnCreateContextMenuListener(this);
holder.hideSeparatorIfNecessary();
}
@Nullable

View File

@ -54,6 +54,7 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
FeedItem item1 = (FeedItem) v.getTag();
itemAccess.onFeedItemSecondaryAction(item1);
});
holder.hideSeparatorIfNecessary();
return holder.itemView;
}

View File

@ -63,6 +63,7 @@ public class FeedItemlistAdapter extends BaseAdapter {
if (item.getMedia() != null && item.getMedia().isCurrentlyPlaying()) {
currentlyPlayingItem = position;
}
holder.hideSeparatorIfNecessary();
return holder.itemView;
}

View File

@ -84,6 +84,8 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<EpisodeItemViewHo
}
});
holder.itemView.setOnCreateContextMenuListener(this);
holder.isInQueue.setVisibility(View.GONE);
holder.hideSeparatorIfNecessary();
}
@Nullable

View File

@ -38,11 +38,6 @@ public class AllEpisodesFragment extends EpisodesListFragment {
feedItemFilter = new FeedItemFilter(prefs.getString(PREF_FILTER, ""));
}
@Override
protected boolean showOnlyNewEpisodes() {
return false;
}
@Override
protected String getPrefName() {
return PREF_NAME;

View File

@ -93,10 +93,6 @@ public abstract class EpisodesListFragment extends Fragment {
private LinearLayoutManager layoutManager;
protected TextView txtvInformation;
boolean showOnlyNewEpisodes() {
return false;
}
String getPrefName() {
return DEFAULT_PREF_NAME;
}
@ -364,7 +360,7 @@ public abstract class EpisodesListFragment extends Fragment {
*/
private void createRecycleAdapter(RecyclerView recyclerView, EmptyViewHandler emptyViewHandler) {
MainActivity mainActivity = (MainActivity) getActivity();
listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess, showOnlyNewEpisodes());
listAdapter = new AllEpisodesRecycleAdapter(mainActivity, itemAccess);
listAdapter.setHasStableIds(true);
recyclerView.setAdapter(listAdapter);
emptyViewHandler.updateAdapter(listAdapter);

View File

@ -31,11 +31,6 @@ public class FavoriteEpisodesFragment extends EpisodesListFragment {
private static final String TAG = "FavoriteEpisodesFrag";
private static final String PREF_NAME = "PrefFavoriteEpisodesFragment";
@Override
protected boolean showOnlyNewEpisodes() {
return true;
}
@Override
protected String getPrefName() {
return PREF_NAME;

View File

@ -27,11 +27,6 @@ public class NewEpisodesFragment extends EpisodesListFragment {
public static final String TAG = "NewEpisodesFragment";
private static final String PREF_NAME = "PrefNewEpisodesFragment";
@Override
protected boolean showOnlyNewEpisodes() {
return true;
}
@Override
protected String getPrefName() {
return PREF_NAME;

View File

@ -49,13 +49,14 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
private final TextView position;
private final TextView duration;
private final TextView size;
private final TextView isNew;
private final ImageView isInQueue;
public final TextView isNew;
public final ImageView isInQueue;
private final ImageView isVideo;
private final ImageView isFavorite;
public final ImageView isFavorite;
private final ProgressBar progressBar;
public final ImageButton butSecondary;
private final MainActivity activity;
private final TextView separatorIcons;
private FeedItem item;
@ -80,6 +81,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
isNew = itemView.findViewById(R.id.statusUnread);
isFavorite = itemView.findViewById(R.id.isFavorite);
size = itemView.findViewById(R.id.size);
separatorIcons = itemView.findViewById(R.id.separatorIcons);
itemView.setTag(this);
}
@ -189,4 +191,16 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
position.setText(Converter.getDurationStringLong(event.getPosition()));
duration.setText(Converter.getDurationStringLong(event.getDuration()));
}
/**
* Hides the separator dot between icons and text if there are no icons.
*/
public void hideSeparatorIfNecessary() {
boolean hasIcons = isNew.getVisibility() == View.VISIBLE
|| isInQueue.getVisibility() == View.VISIBLE
|| isVideo.getVisibility() == View.VISIBLE
|| isFavorite.getVisibility() == View.VISIBLE
|| isNew.getVisibility() == View.VISIBLE;
separatorIcons.setVisibility(hasIcons ? View.VISIBLE : View.GONE);
}
}

View File

@ -103,6 +103,7 @@
android:id="@+id/ivInPlaylist"/>
<TextView
android:id="@+id/separatorIcons"
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"