aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java144
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java35
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java2
-rw-r--r--app/src/main/res/layout/expandable_header.xml (renamed from app/src/main/res/layout/newest_episode_header.xml)0
11 files changed, 177 insertions, 28 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java
index 5feaa482..207dc0b2 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java
@@ -92,7 +92,7 @@ public class ArtistAdapter extends SectionAdapter<Artist> implements FastScrolle
return new UpdateView.UpdateViewHolder(header, false);
}
@Override
- public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header) {
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header, int sectionIndex) {
TextView folderName = (TextView) holder.getView().findViewById(R.id.select_artist_folder_2);
String musicFolderId = Util.getSelectedMusicFolderId(context);
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
index 71e78e4b..b07d4731 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java
@@ -16,14 +16,12 @@
package github.daneren2005.dsub.adapter;
import android.content.Context;
-import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import java.util.ArrayList;
import java.util.List;
import github.daneren2005.dsub.R;
@@ -96,7 +94,7 @@ public class EntryGridAdapter extends SectionAdapter<Entry> {
public UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) {
return new UpdateViewHolder(header, false);
}
- public void onBindHeaderHolder(UpdateViewHolder holder, String header) {
+ public void onBindHeaderHolder(UpdateViewHolder holder, String header, int sectionIndex) {
}
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java
new file mode 100644
index 00000000..822c83f3
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java
@@ -0,0 +1,144 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2015 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.adapter;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.util.DrawableTint;
+import github.daneren2005.dsub.view.BasicHeaderView;
+import github.daneren2005.dsub.view.UpdateView;
+
+public abstract class ExpandableSectionAdapter<T> extends SectionAdapter<T> {
+ private static final String TAG = ExpandableSectionAdapter.class.getSimpleName();
+ private static final int DEFAULT_VISIBLE = 4;
+ private static final int EXPAND_TOGGLE = R.attr.select_server;
+ private static final int COLLAPSE_TOGGLE = R.attr.select_tabs;
+
+ protected List<Integer> sectionsDefaultVisible;
+ protected List<List<T>> sectionsExtras;
+ protected int expandToggleRes;
+ protected int collapseToggleRes;
+
+ protected ExpandableSectionAdapter() {}
+ public ExpandableSectionAdapter(Context context, List<String> headers, List<List<T>> sections) {
+ init(context, headers, sections, null);
+ }
+ public ExpandableSectionAdapter(Context context, List<String> headers, List<List<T>> sections, List<Integer> sectionsDefaultVisible) {
+ init(context, headers, sections, sectionsDefaultVisible);
+ }
+ protected void init(Context context, List<String> headers, List<List<T>> fullSections, List<Integer> sectionsDefaultVisible) {
+ this.context = context;
+ this.headers = headers;
+ this.sectionsDefaultVisible = sectionsDefaultVisible;
+ if(sectionsDefaultVisible == null) {
+ sectionsDefaultVisible = new ArrayList<>(fullSections.size());
+ for(int i = 0; i < fullSections.size(); i++) {
+ sectionsDefaultVisible.add(DEFAULT_VISIBLE);
+ }
+ }
+
+ this.sections = new ArrayList<>();
+ this.sectionsExtras = new ArrayList<>();
+ int i = 0;
+ for(List<T> fullSection: fullSections) {
+ List<T> visibleSection = new ArrayList<>();
+
+ Integer defaultVisible = sectionsDefaultVisible.get(i);
+ if(defaultVisible == null || defaultVisible >= fullSection.size()) {
+ visibleSection.addAll(fullSection);
+ this.sectionsExtras.add(null);
+ } else {
+ visibleSection.addAll(fullSection.subList(0, defaultVisible));
+ this.sectionsExtras.add(fullSection.subList(defaultVisible, fullSection.size()));
+ Log.d(TAG, visibleSection.size() + " + " + this.sectionsExtras.get(i).size());
+ }
+ this.sections.add(visibleSection);
+
+ i++;
+ }
+
+ expandToggleRes = DrawableTint.getDrawableRes(context, EXPAND_TOGGLE);
+ collapseToggleRes = DrawableTint.getDrawableRes(context, COLLAPSE_TOGGLE);
+ }
+
+ @Override
+ public UpdateView.UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) {
+ return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.expandable_header));
+ }
+
+ @Override
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header, final int sectionIndex) {
+ UpdateView view = holder.getUpdateView();
+ ImageView toggleSelectionView = (ImageView) view.findViewById(R.id.item_select);
+
+ List<T> visibleSelection = sections.get(sectionIndex);
+ List<T> sectionExtras = sectionsExtras.get(sectionIndex);
+
+ if(sectionExtras != null && !sectionExtras.isEmpty()) {
+ toggleSelectionView.setVisibility(View.VISIBLE);
+ toggleSelectionView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ List<T> visibleSelection = sections.get(sectionIndex);
+ List<T> sectionExtras = sectionsExtras.get(sectionIndex);
+
+ // Update icon
+ int selectToggleAttr;
+ if (!visibleSelection.contains(sectionExtras.get(0))) {
+ selectToggleAttr = COLLAPSE_TOGGLE;
+
+ // Update how many are displayed
+ int lastIndex = getItemPosition(visibleSelection.get(visibleSelection.size() - 1));
+ visibleSelection.addAll(sectionExtras);
+ notifyItemRangeInserted(lastIndex, sectionExtras.size());
+ } else {
+ selectToggleAttr = EXPAND_TOGGLE;
+
+ // Update how many are displayed
+ visibleSelection.removeAll(sectionExtras);
+ int lastIndex = getItemPosition(visibleSelection.get(visibleSelection.size() - 1));
+ notifyItemRangeRemoved(lastIndex, sectionExtras.size());
+ }
+
+ ((ImageView) v).setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
+ }
+ });
+
+ int selectToggleAttr;
+ if (!visibleSelection.contains(sectionExtras.get(0))) {
+ selectToggleAttr = EXPAND_TOGGLE;
+ } else {
+ selectToggleAttr = COLLAPSE_TOGGLE;
+ }
+
+ toggleSelectionView.setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
+ } else {
+ toggleSelectionView.setVisibility(View.GONE);
+ }
+
+ if(view != null) {
+ view.setObject(header);
+ }
+ }
+}
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java
index 473366fe..dd70aa99 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/MainAdapter.java
@@ -77,7 +77,7 @@ public class MainAdapter extends SectionAdapter<Integer> {
return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.album_list_header));
}
@Override
- public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header) {
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header, int sectionIndex) {
UpdateView view = holder.getUpdateView();
CheckBox checkBox = (CheckBox) view.findViewById(R.id.item_checkbox);
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 aeb98a6b..97d29407 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/PodcastChannelAdapter.java
@@ -131,11 +131,11 @@ public class PodcastChannelAdapter extends SectionAdapter<Serializable> implemen
@Override
public UpdateView.UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) {
- return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.newest_episode_header));
+ return new UpdateView.UpdateViewHolder(new BasicHeaderView(context, R.layout.expandable_header));
}
@Override
- public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header) {
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String header, int sectionIndex) {
UpdateView view = holder.getUpdateView();
ImageView toggleSelectionView = (ImageView) view.findViewById(R.id.item_select);
@@ -164,7 +164,6 @@ public class PodcastChannelAdapter extends SectionAdapter<Serializable> implemen
}
((ImageView) v).setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
-
}
});
toggleSelectionView.setImageResource(DrawableTint.getDrawableRes(context, selectToggleAttr));
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java
index 66f2db21..69e5d56d 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java
@@ -19,7 +19,9 @@ import android.content.Context;
import android.content.res.Resources;
import android.view.Menu;
import android.view.MenuInflater;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import java.io.Serializable;
import java.util.ArrayList;
@@ -28,10 +30,12 @@ import java.util.List;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory.Entry;
import github.daneren2005.dsub.domain.SearchResult;
+import github.daneren2005.dsub.util.DrawableTint;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.AlbumView;
import github.daneren2005.dsub.view.ArtistView;
+import github.daneren2005.dsub.view.BasicHeaderView;
import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
@@ -40,32 +44,39 @@ import static github.daneren2005.dsub.adapter.EntryGridAdapter.VIEW_TYPE_ALBUM_C
import static github.daneren2005.dsub.adapter.EntryGridAdapter.VIEW_TYPE_ALBUM_LINE;
import static github.daneren2005.dsub.adapter.EntryGridAdapter.VIEW_TYPE_SONG;
-public class SearchAdapter extends SectionAdapter<Serializable> {
- private SearchResult searchResult;
+public class SearchAdapter extends ExpandableSectionAdapter<Serializable> {
private ImageLoader imageLoader;
private boolean largeAlbums;
+ private static final int MAX_ARTISTS = 10;
+ private static final int MAX_ALBUMS = 4;
+ private static final int MAX_SONGS = 10;
+
public SearchAdapter(Context context, SearchResult searchResult, ImageLoader imageLoader, boolean largeAlbums, OnItemClickedListener listener) {
- this.context = context;
- this.searchResult = searchResult;
this.imageLoader = imageLoader;
this.largeAlbums = largeAlbums;
- this.sections = new ArrayList<>();
- this.headers = new ArrayList<>();
+ List<List<Serializable>> sections = new ArrayList<>();
+ List<String> headers = new ArrayList<>();
+ List<Integer> defaultVisible = new ArrayList<>();
Resources res = context.getResources();
if(!searchResult.getArtists().isEmpty()) {
- this.sections.add((List<Serializable>) (List<?>) searchResult.getArtists());
- this.headers.add(res.getString(R.string.search_artists));
+ sections.add((List<Serializable>) (List<?>) searchResult.getArtists());
+ headers.add(res.getString(R.string.search_artists));
+ defaultVisible.add(MAX_ARTISTS);
}
if(!searchResult.getAlbums().isEmpty()) {
- this.sections.add((List<Serializable>) (List<?>) searchResult.getAlbums());
- this.headers.add(res.getString(R.string.search_albums));
+ sections.add((List<Serializable>) (List<?>) searchResult.getAlbums());
+ headers.add(res.getString(R.string.search_albums));
+ defaultVisible.add(MAX_ALBUMS);
}
if(!searchResult.getSongs().isEmpty()) {
- this.sections.add((List<Serializable>) (List<?>) searchResult.getSongs());
- this.headers.add(res.getString(R.string.search_songs));
+ sections.add((List<Serializable>) (List<?>) searchResult.getSongs());
+ headers.add(res.getString(R.string.search_songs));
+ defaultVisible.add(MAX_SONGS);
}
+ init(context, headers, sections, defaultVisible);
+
this.onItemClickedListener = listener;
checkable = true;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
index fbed4d7a..33bbb384 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
@@ -194,7 +194,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
for(List<T> section: sections) {
boolean validHeader = headers.get(subHeader) != null;
if(position == subPosition && validHeader) {
- onBindHeaderHolder(holder, headers.get(subHeader));
+ onBindHeaderHolder(holder, headers.get(subHeader), subHeader);
return;
}
@@ -289,7 +289,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
public UpdateViewHolder onCreateHeaderHolder(ViewGroup parent) {
return new UpdateViewHolder(new BasicHeaderView(context));
}
- public void onBindHeaderHolder(UpdateViewHolder holder, String header) {
+ public void onBindHeaderHolder(UpdateViewHolder holder, String header, int sectionIndex) {
UpdateView view = holder.getUpdateView();
if(view != null) {
view.setObject(header);
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java
index 51d08a99..4e75a2f7 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java
@@ -16,15 +16,12 @@
package github.daneren2005.dsub.adapter;
import android.content.Context;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import github.daneren2005.dsub.R;
@@ -82,7 +79,7 @@ public class SettingsAdapter extends SectionAdapter<Setting> {
View header = LayoutInflater.from(context).inflate(R.layout.user_header, parent, false);
return new UpdateView.UpdateViewHolder(header, false);
}
- public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String description) {
+ public void onBindHeaderHolder(UpdateView.UpdateViewHolder holder, String description, int sectionIndex) {
View header = holder.getView();
RecyclingImageView coverArtView = (RecyclingImageView) header.findViewById(R.id.user_avatar);
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
index 1aef5982..6f7ac86e 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -39,7 +39,7 @@ import github.daneren2005.dsub.view.UpdateView;
public class SearchFragment extends SubsonicFragment implements SectionAdapter.OnItemClickedListener<Serializable> {
private static final String TAG = SearchFragment.class.getSimpleName();
- private static final int MAX_ARTISTS = 10;
+ private static final int MAX_ARTISTS = 20;
private static final int MAX_ALBUMS = 10;
private static final int MAX_SONGS = 25;
private static final int MIN_CLOSENESS = 1;
diff --git a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
index 3048a0db..e1929bf8 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -95,7 +95,7 @@ public class OfflineMusicService implements MusicService {
artist.setIndex(file.getName().substring(0, 1));
artist.setName(file.getName());
artists.add(artist);
- } else {
+ } else if(!file.getName().equals("albumart.jpg") && !file.getName().equals(".nomedia")) {
entries.add(createEntry(context, file));
}
}
diff --git a/app/src/main/res/layout/newest_episode_header.xml b/app/src/main/res/layout/expandable_header.xml
index bd78275e..bd78275e 100644
--- a/app/src/main/res/layout/newest_episode_header.xml
+++ b/app/src/main/res/layout/expandable_header.xml