aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java70
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java18
3 files changed, 78 insertions, 14 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java
index 875a4800..d9290f49 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java
@@ -17,12 +17,14 @@ package github.daneren2005.dsub.adapter;
import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import github.daneren2005.dsub.R;
-import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PodcastChannel;
import github.daneren2005.dsub.domain.PodcastEpisode;
+import github.daneren2005.dsub.util.DrawableTint;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.BasicHeaderView;
@@ -35,13 +37,18 @@ import java.io.Serializable;
import java.util.List;
public class PodcastChannelAdapter extends SectionAdapter<Serializable> implements FastScroller.BubbleTextGetter {
- public static int VIEW_TYPE_PODCAST_LEGACY = 1;
- public static int VIEW_TYPE_PODCAST_LINE = 2;
- public static int VIEW_TYPE_PODCAST_CELL = 3;
- public static int VIEW_TYPE_PODCAST_EPISODE = 4;
+ public static final int VIEW_TYPE_PODCAST_LEGACY = 1;
+ public static final int VIEW_TYPE_PODCAST_LINE = 2;
+ public static final int VIEW_TYPE_PODCAST_CELL = 3;
+ public static final int VIEW_TYPE_PODCAST_EPISODE = 4;
+
+ public static final String EPISODE_HEADER = "episodes";
+ public static final String CHANNEL_HEADER = "channels";
private ImageLoader imageLoader;
private boolean largeCell;
+ private int selectToggleAttr = R.attr.select_server;
+ private List<Serializable> extraEpisodes;
public PodcastChannelAdapter(Context context, List<Serializable> podcasts, ImageLoader imageLoader, OnItemClickedListener listener, boolean largeCell) {
super(context, podcasts);
@@ -49,8 +56,9 @@ public class PodcastChannelAdapter extends SectionAdapter<Serializable> implemen
this.onItemClickedListener = listener;
this.largeCell = largeCell;
}
- public PodcastChannelAdapter(Context context, List<String> headers, List<List<Serializable>> sections, ImageLoader imageLoader, OnItemClickedListener listener, boolean largeCell) {
+ public PodcastChannelAdapter(Context context, List<String> headers, List<List<Serializable>> sections, List<Serializable> extraEpisodes, ImageLoader imageLoader, OnItemClickedListener listener, boolean largeCell) {
super(context, headers, sections);
+ this.extraEpisodes = extraEpisodes;
this.imageLoader = imageLoader;
this.onItemClickedListener = listener;
this.largeCell = largeCell;
@@ -118,4 +126,54 @@ public class PodcastChannelAdapter extends SectionAdapter<Serializable> implemen
menu.removeItem(R.id.menu_remove_playlist);
menu.removeItem(R.id.menu_unstar);
}
+
+ @Override
+ public UpdateView.UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) {
+ return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.newest_episode_header));
+ }
+
+ @Override
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header) {
+ UpdateView view = holder.getUpdateView();
+ ImageView toggleSelectionView = (ImageView) view.findViewById(R.id.item_select);
+
+ String display;
+ if(EPISODE_HEADER.equals(header)) {
+ display = context.getResources().getString(R.string.main_albums_newest);
+
+ if(extraEpisodes != null && !extraEpisodes.isEmpty()) {
+ toggleSelectionView.setVisibility(View.VISIBLE);
+ toggleSelectionView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // Update icon
+ if (selectToggleAttr == R.attr.select_server) {
+ selectToggleAttr = R.attr.select_tabs;
+
+ // Update how many are displayed
+ sections.get(0).addAll(extraEpisodes);
+ notifyItemRangeInserted(4, extraEpisodes.size());
+ } else {
+ selectToggleAttr = R.attr.select_server;
+
+ // Update how many are displayed
+ sections.get(0).removeAll(extraEpisodes);
+ notifyItemRangeRemoved(4, extraEpisodes.size());
+ }
+
+ ((ImageView) v).setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
+
+ }
+ });
+ toggleSelectionView.setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
+ }
+ } else {
+ display = context.getResources().getString(R.string.select_podcasts_channels);
+ toggleSelectionView.setVisibility(View.GONE);
+ }
+
+ if(view != null) {
+ view.setObject(display);
+ }
+ }
}
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 83e3e7e7..98467a2c 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -763,9 +763,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
}
recyclerView.setAdapter(entryGridAdapter);
- if(entryGridAdapter instanceof FastScroller.BubbleTextGetter) {
- fastScroller.attachRecyclerView(recyclerView);
- }
+ fastScroller.attachRecyclerView(recyclerView);
context.supportInvalidateOptionsMenu();
if(scrollToPosition != -1) {
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index b77d6746..d605cecd 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -141,17 +141,25 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable>
if(newestEpisodes == null || newestEpisodes.getChildrenSize() == 0) {
return new PodcastChannelAdapter(context, channels, hasCoverArt ? getImageLoader() : null, this, largeAlbums);
} else {
- Resources res = context.getResources();
- List<String> headers = Arrays.asList(res.getString(R.string.main_albums_newest), res.getString(R.string.select_podcasts_channels));
+ List<String> headers = Arrays.asList(PodcastChannelAdapter.EPISODE_HEADER, PodcastChannelAdapter.CHANNEL_HEADER);
+ List<MusicDirectory.Entry> episodes = newestEpisodes.getChildren();
List<Serializable> serializableEpisodes = new ArrayList<>();
- serializableEpisodes.addAll(newestEpisodes.getChildren());
+
+ // Put 3 in current list
+ while(serializableEpisodes.size() < 3) {
+ serializableEpisodes.add(episodes.remove(0));
+ }
+
+ // Put rest in extra set
+ List<Serializable> extraEpisodes = new ArrayList<>();
+ extraEpisodes.addAll(episodes);
List<List<Serializable>> sections = new ArrayList<>();
sections.add(serializableEpisodes);
sections.add(channels);
- return new PodcastChannelAdapter(context, headers, sections, ServerInfo.checkServerVersion(context, "1.13") ? getImageLoader() : null, this, largeAlbums);
+ return new PodcastChannelAdapter(context, headers, sections, extraEpisodes, ServerInfo.checkServerVersion(context, "1.13") ? getImageLoader() : null, this, largeAlbums);
}
}
@@ -161,7 +169,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable>
if(!Util.isOffline(context) && ServerInfo.hasNewestPodcastEpisodes(context)) {
try {
- newestEpisodes = musicService.getNewestPodcastEpisodes(3, context, listener);
+ newestEpisodes = musicService.getNewestPodcastEpisodes(10, context, listener);
} catch (Exception e) {
Log.e(TAG, "Failed to download newest episodes", e);
newestEpisodes = null;