Remove unused

This commit is contained in:
Andrew Rabert 2017-03-05 12:25:14 -05:00
parent c101be0bc9
commit 62cd06997a
5 changed files with 4 additions and 177 deletions

View File

@ -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<Integer> {
public static final int VIEW_TYPE_ALBUM_LIST = 1;
public static final int VIEW_TYPE_ALBUM_COUNT_LIST = 2;
public MainAdapter(Context context, List<String> headers, List<List<Integer>> sections, OnItemClickedListener onItemClickedListener) {
super(context, headers, sections);
@ -41,13 +39,7 @@ public class MainAdapter extends SectionAdapter<Integer> {
@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<Integer> {
@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

View File

@ -322,9 +322,7 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
@Override
public void onItemClicked(UpdateView<Integer> 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");

View File

@ -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);

View File

@ -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 <http://www.gnu.org/licenses/>.
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<Integer, Void> {
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<String> recents = FileUtil.deserialize(context, recentAddedFile, ArrayList.class);
if (recents == null) {
recents = new ArrayList<String>();
}
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();
}
}

View File

@ -1,27 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/comment_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:textSize="20dp"
android:text="@string/common.comment"
android:textColor="?android:textColorPrimary"/>
<EditText
android:id="@+id/comment_text"
android:inputType="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="4dp" />
</LinearLayout>
</LinearLayout>