From 62cd06997a908ca8b1eab67840fa1d6c373b7351 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sun, 5 Mar 2017 12:25:14 -0500 Subject: [PATCH] Remove unused --- .../nullsum/audinaut/adapter/MainAdapter.java | 16 +-- .../audinaut/fragments/MainFragment.java | 4 +- .../fragments/SelectDirectoryFragment.java | 4 +- .../audinaut/view/AlbumListCountView.java | 130 ------------------ app/src/main/res/layout/create_bookmark.xml | 27 ---- 5 files changed, 4 insertions(+), 177 deletions(-) delete mode 100644 app/src/main/java/net/nullsum/audinaut/view/AlbumListCountView.java delete mode 100644 app/src/main/res/layout/create_bookmark.xml diff --git a/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java b/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java index 965d874..f185971 100644 --- a/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java +++ b/app/src/main/java/net/nullsum/audinaut/adapter/MainAdapter.java @@ -25,14 +25,12 @@ import java.util.List; import net.nullsum.audinaut.R; import net.nullsum.audinaut.util.Util; -import net.nullsum.audinaut.view.AlbumListCountView; import net.nullsum.audinaut.view.BasicHeaderView; import net.nullsum.audinaut.view.BasicListView; import net.nullsum.audinaut.view.UpdateView; public class MainAdapter extends SectionAdapter { public static final int VIEW_TYPE_ALBUM_LIST = 1; - public static final int VIEW_TYPE_ALBUM_COUNT_LIST = 2; public MainAdapter(Context context, List headers, List> sections, OnItemClickedListener onItemClickedListener) { super(context, headers, sections); @@ -41,13 +39,7 @@ public class MainAdapter extends SectionAdapter { @Override public UpdateView.UpdateViewHolder onCreateSectionViewHolder(ViewGroup parent, int viewType) { - UpdateView updateView; - if(viewType == VIEW_TYPE_ALBUM_LIST) { - updateView = new BasicListView(context); - } else { - updateView = new AlbumListCountView(context); - } - + UpdateView updateView = new BasicListView(context); return new UpdateView.UpdateViewHolder(updateView); } @@ -64,11 +56,7 @@ public class MainAdapter extends SectionAdapter { @Override public int getItemViewType(Integer item) { - if(item == R.string.main_albums_newest) { - return VIEW_TYPE_ALBUM_COUNT_LIST; - } else { - return VIEW_TYPE_ALBUM_LIST; - } + return VIEW_TYPE_ALBUM_LIST; } @Override diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/MainFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/MainFragment.java index 5934225..f8110d7 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/MainFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/MainFragment.java @@ -322,9 +322,7 @@ public class MainFragment extends SelectRecyclerFragment { @Override public void onItemClicked(UpdateView updateView, Integer item) { - if (item == R.string.main_albums_newest) { - showAlbumList("newest"); - } else if (item == R.string.main_albums_random) { + if (item == R.string.main_albums_random) { showAlbumList("random"); } else if (item == R.string.main_albums_recent) { showAlbumList("recent"); diff --git a/app/src/main/java/net/nullsum/audinaut/fragments/SelectDirectoryFragment.java b/app/src/main/java/net/nullsum/audinaut/fragments/SelectDirectoryFragment.java index 0d35df0..aba54c6 100644 --- a/app/src/main/java/net/nullsum/audinaut/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/net/nullsum/audinaut/fragments/SelectDirectoryFragment.java @@ -403,9 +403,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section } private void getAlbumList(final String albumListType, final int size, final boolean refresh) { - if ("newest".equals(albumListType)) { - setTitle(R.string.main_albums_newest); - } else if ("random".equals(albumListType)) { + if ("random".equals(albumListType)) { setTitle(R.string.main_albums_random); } else if ("recent".equals(albumListType)) { setTitle(R.string.main_albums_recent); diff --git a/app/src/main/java/net/nullsum/audinaut/view/AlbumListCountView.java b/app/src/main/java/net/nullsum/audinaut/view/AlbumListCountView.java deleted file mode 100644 index 44cbce9..0000000 --- a/app/src/main/java/net/nullsum/audinaut/view/AlbumListCountView.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - 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 . - Copyright 2015 (C) Scott Jackson -*/ - -package net.nullsum.audinaut.view; - -import android.content.Context; -import android.content.SharedPreferences; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - -import java.util.ArrayList; - -import net.nullsum.audinaut.R; -import net.nullsum.audinaut.domain.MusicDirectory; -import net.nullsum.audinaut.service.MusicService; -import net.nullsum.audinaut.service.MusicServiceFactory; -import net.nullsum.audinaut.util.Constants; -import net.nullsum.audinaut.util.FileUtil; -import net.nullsum.audinaut.util.Util; - -public class AlbumListCountView extends UpdateView2 { - private final String TAG = AlbumListCountView.class.getSimpleName(); - - private TextView titleView; - private TextView countView; - private int startCount; - private int count = 0; - - public AlbumListCountView(Context context) { - super(context, false); - this.context = context; - LayoutInflater.from(context).inflate(R.layout.basic_count_item, this, true); - - titleView = (TextView) findViewById(R.id.basic_count_name); - countView = (TextView) findViewById(R.id.basic_count_count); - } - - protected void setObjectImpl(Integer albumListString, Void dummy) { - titleView.setText(albumListString); - - SharedPreferences prefs = Util.getPreferences(context); - startCount = prefs.getInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); - count = startCount; - update(); - } - - @Override - protected void updateBackground() { - try { - String recentAddedFile = Util.getCacheName(context, "recent_count"); - ArrayList recents = FileUtil.deserialize(context, recentAddedFile, ArrayList.class); - if (recents == null) { - recents = new ArrayList(); - } - - MusicService musicService = MusicServiceFactory.getMusicService(context); - MusicDirectory recentlyAdded = musicService.getAlbumList("newest", 20, 0, false, context, null); - - // If first run, just put everything in it and return 0 - boolean firstRun = recents.isEmpty(); - - // Count how many new albums are in the list - count = 0; - for (MusicDirectory.Entry album : recentlyAdded.getChildren()) { - if (!recents.contains(album.getId())) { - recents.add(album.getId()); - count++; - } - } - - // Keep recents list from growing infinitely - while (recents.size() > 40) { - recents.remove(0); - } - FileUtil.serialize(context, recents, recentAddedFile); - - if (!firstRun) { - // Add the old count which will get cleared out after viewing recents - count += startCount; - SharedPreferences.Editor editor = Util.getPreferences(context).edit(); - editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), count); - editor.commit(); - } - } catch(Exception e) { - Log.w(TAG, "Failed to refresh most recent count", e); - } - } - - @Override - protected void update() { - // Update count display with appropriate information - if(count <= 0) { - countView.setVisibility(View.GONE); - } else { - String displayName; - if(count < 10) { - displayName = "0" + count; - } else { - displayName = "" + count; - } - - countView.setText(displayName); - countView.setVisibility(View.VISIBLE); - } - } - - @Override - public void onClick() { - SharedPreferences.Editor editor = Util.getPreferences(context).edit(); - editor.putInt(Constants.PREFERENCES_KEY_RECENT_COUNT + Util.getActiveServer(context), 0); - editor.commit(); - - count = 0; - update(); - } -} diff --git a/app/src/main/res/layout/create_bookmark.xml b/app/src/main/res/layout/create_bookmark.xml deleted file mode 100644 index 22d9622..0000000 --- a/app/src/main/res/layout/create_bookmark.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - -