fix a large amount of deprecated and ide warnings
This commit is contained in:
parent
d301b34453
commit
beca66459b
26 changed files with 111 additions and 122 deletions
|
|
@ -43,7 +43,7 @@ public class MainActivity extends AbsMusicPanelActivity {
|
|||
private boolean onLogout;
|
||||
|
||||
@Nullable
|
||||
MainActivityFragmentCallbacks currentFragment;
|
||||
private MainActivityFragmentCallbacks currentFragment;
|
||||
|
||||
@Nullable
|
||||
private List<BaseItemDto> libraries;
|
||||
|
|
@ -59,7 +59,7 @@ public class MainActivity extends AbsMusicPanelActivity {
|
|||
|
||||
Menu menu = binding.navigationView.getMenu();
|
||||
QueryUtil.getLibraries(media -> {
|
||||
libraries = (List<BaseItemDto>) media;
|
||||
libraries = media;
|
||||
menu.clear();
|
||||
|
||||
for (BaseItemDto itemDto : libraries) {
|
||||
|
|
@ -164,11 +164,7 @@ public class MainActivity extends AbsMusicPanelActivity {
|
|||
|| menuItem.getItemId() == R.id.nav_logout) return true;
|
||||
|
||||
for (int i = 0; i < binding.navigationView.getMenu().size(); i++) {
|
||||
if (binding.navigationView.getMenu().getItem(i) == menuItem) {
|
||||
binding.navigationView.getMenu().getItem(i).setChecked(true);
|
||||
} else {
|
||||
binding.navigationView.getMenu().getItem(i).setChecked(false);
|
||||
}
|
||||
binding.navigationView.getMenu().getItem(i).setChecked(binding.navigationView.getMenu().getItem(i) == menuItem);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.dkanada.gramophone.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
|
|
@ -29,8 +30,9 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public class SearchActivity extends AbsMusicServiceActivity implements SearchView.OnQueryTextListener {
|
||||
public String QUERY = "query";
|
||||
private String QUERY = "query";
|
||||
|
||||
private ActivitySearchBinding binding;
|
||||
|
||||
|
|
@ -82,6 +84,7 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
|||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putString(QUERY, query);
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +119,7 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
|||
});
|
||||
|
||||
searchView.setQuery(query, false);
|
||||
searchView.post(() -> searchView.setOnQueryTextListener(SearchActivity.this));
|
||||
searchView.setOnQueryTextListener(SearchActivity.this);
|
||||
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
|
@ -136,34 +139,31 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
|||
ItemQuery itemQuery = new ItemQuery();
|
||||
itemQuery.setSearchTerm(query);
|
||||
|
||||
MediaCallback<Object> callback = new MediaCallback<Object>() {
|
||||
@Override
|
||||
public void onLoadMedia(List<Object> media) {
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
List<Album> albums = new ArrayList<>();
|
||||
List<Song> songs = new ArrayList<>();
|
||||
MediaCallback<Object> callback = media -> {
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
List<Album> albums = new ArrayList<>();
|
||||
List<Song> songs = new ArrayList<>();
|
||||
|
||||
for (Object result : media) {
|
||||
if (result instanceof Artist) {
|
||||
artists.add((Artist) result);
|
||||
} else if (result instanceof Album) {
|
||||
albums.add((Album) result);
|
||||
} else if (result instanceof Song) {
|
||||
songs.add((Song) result);
|
||||
}
|
||||
for (Object result : media) {
|
||||
if (result instanceof Artist) {
|
||||
artists.add((Artist) result);
|
||||
} else if (result instanceof Album) {
|
||||
albums.add((Album) result);
|
||||
} else if (result instanceof Song) {
|
||||
songs.add((Song) result);
|
||||
}
|
||||
|
||||
Collections.sort(artists, (one, two) -> one.name.compareTo(two.name));
|
||||
Collections.sort(albums, (one, two) -> one.title.compareTo(two.title));
|
||||
Collections.sort(songs, (one, two) -> one.title.compareTo(two.title));
|
||||
|
||||
List<Object> sortedData = new ArrayList<>();
|
||||
sortedData.addAll(artists);
|
||||
sortedData.addAll(albums);
|
||||
sortedData.addAll(songs);
|
||||
|
||||
adapter.swapDataSet(sortedData);
|
||||
}
|
||||
|
||||
Collections.sort(artists, (one, two) -> one.name.compareTo(two.name));
|
||||
Collections.sort(albums, (one, two) -> one.title.compareTo(two.title));
|
||||
Collections.sort(songs, (one, two) -> one.title.compareTo(two.title));
|
||||
|
||||
List<Object> sortedData = new ArrayList<>();
|
||||
sortedData.addAll(artists);
|
||||
sortedData.addAll(albums);
|
||||
sortedData.addAll(songs);
|
||||
|
||||
adapter.swapDataSet(sortedData);
|
||||
};
|
||||
|
||||
QueryUtil.getItems(itemQuery, callback);
|
||||
|
|
@ -178,12 +178,7 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
|||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
search(newText);
|
||||
}
|
||||
}, 1000);
|
||||
handler.postDelayed(() -> search(newText), 1000);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.dkanada.gramophone.glide.CustomGlideRequest;
|
|||
import com.dkanada.gramophone.glide.CustomPaletteTarget;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.interfaces.CabHolder;
|
||||
import com.dkanada.gramophone.interfaces.MediaCallback;
|
||||
import com.dkanada.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.dkanada.gramophone.model.Album;
|
||||
import com.dkanada.gramophone.model.Artist;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ import com.dkanada.gramophone.glide.CustomGlideRequest;
|
|||
import com.dkanada.gramophone.glide.CustomPaletteTarget;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.interfaces.CabHolder;
|
||||
import com.dkanada.gramophone.interfaces.MediaCallback;
|
||||
import com.dkanada.gramophone.interfaces.PaletteColorHolder;
|
||||
import com.dkanada.gramophone.model.Album;
|
||||
import com.dkanada.gramophone.model.Artist;
|
||||
import com.dkanada.gramophone.model.Song;
|
||||
import com.dkanada.gramophone.activities.base.AbsMusicPanelActivity;
|
||||
|
|
|
|||
|
|
@ -11,15 +11,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
import com.dkanada.gramophone.databinding.ActivityGenreDetailBinding;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||
import com.dkanada.gramophone.R;
|
||||
import com.dkanada.gramophone.adapter.song.SongAdapter;
|
||||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.interfaces.CabHolder;
|
||||
import com.dkanada.gramophone.interfaces.MediaCallback;
|
||||
import com.dkanada.gramophone.model.Genre;
|
||||
import com.dkanada.gramophone.model.Song;
|
||||
import com.dkanada.gramophone.activities.base.AbsMusicPanelActivity;
|
||||
import com.dkanada.gramophone.util.ThemeUtil;
|
||||
import com.dkanada.gramophone.util.QueryUtil;
|
||||
|
|
@ -29,7 +26,6 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
|||
import org.jellyfin.apiclient.model.querying.ItemQuery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GenreDetailActivity extends AbsMusicPanelActivity implements CabHolder {
|
||||
public static final String EXTRA_GENRE = "extra_genre";
|
||||
|
|
@ -41,8 +37,6 @@ public class GenreDetailActivity extends AbsMusicPanelActivity implements CabHol
|
|||
private MaterialCab cab;
|
||||
private SongAdapter adapter;
|
||||
|
||||
private RecyclerView.Adapter wrappedAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -148,11 +142,6 @@ public class GenreDetailActivity extends AbsMusicPanelActivity implements CabHol
|
|||
protected void onDestroy() {
|
||||
binding.recyclerView.setAdapter(null);
|
||||
|
||||
if (wrappedAdapter != null) {
|
||||
WrapperAdapterUtils.releaseAll(wrappedAdapter);
|
||||
wrappedAdapter = null;
|
||||
}
|
||||
|
||||
adapter = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.dkanada.gramophone.adapter.song.SongAdapter;
|
|||
import com.dkanada.gramophone.helper.MusicPlayerRemote;
|
||||
import com.dkanada.gramophone.helper.menu.PlaylistMenuHelper;
|
||||
import com.dkanada.gramophone.interfaces.CabHolder;
|
||||
import com.dkanada.gramophone.interfaces.MediaCallback;
|
||||
import com.dkanada.gramophone.model.Playlist;
|
||||
import com.dkanada.gramophone.model.PlaylistSong;
|
||||
import com.dkanada.gramophone.model.Song;
|
||||
|
|
@ -35,7 +34,6 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
|||
import org.jellyfin.apiclient.model.playlists.PlaylistItemQuery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaylistDetailActivity extends AbsMusicPanelActivity implements CabHolder {
|
||||
public static String EXTRA_PLAYLIST = "extra_playlist";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.dkanada.gramophone.helper.SwipeAndDragHelper;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHolder> implements SwipeAndDragHelper.ActionCompletionContract {
|
||||
private List<CategoryInfo> categories;
|
||||
private ItemTouchHelper touchHelper;
|
||||
|
|
@ -29,14 +30,14 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHo
|
|||
touchHelper = new ItemTouchHelper(swipeAndDragHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public CategoryAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.preference_dialog_category_item, parent, false);
|
||||
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CategoryAdapter.ViewHolder holder, int position) {
|
||||
CategoryInfo category = categories.get(position);
|
||||
|
|
@ -59,8 +60,7 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHo
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -99,13 +99,14 @@ public class CategoryAdapter extends RecyclerView.Adapter<CategoryAdapter.ViewHo
|
|||
return true;
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public CheckBox checkBox;
|
||||
public TextView title;
|
||||
public View dragView;
|
||||
|
||||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
checkBox = view.findViewById(R.id.checkbox);
|
||||
title = view.findViewById(R.id.title);
|
||||
dragView = view.findViewById(R.id.drag_view);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
this.directPlayCodecs = directPlayCodecs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public DirectPlayCodecAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.preference_dialog_direct_play_codecs_item, parent, false);
|
||||
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ public class DirectPlayCodecAdapter extends RecyclerView.Adapter<DirectPlayCodec
|
|||
return directPlayCodecs;
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public CheckBox checkbox;
|
||||
public TextView container;
|
||||
public TextView codec;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
|
|||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false);
|
||||
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +58,7 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
|
|||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
final Genre genre = dataSet.get(position);
|
||||
|
||||
if (holder.getAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.getBindingAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.shortSeparator != null) {
|
||||
holder.shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -115,7 +116,7 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Genre genre = dataSet.get(getAdapterPosition());
|
||||
Genre genre = dataSet.get(getBindingAdapterPosition());
|
||||
NavigationUtil.goToGenre(activity, genre);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
@NonNull
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false);
|
||||
|
||||
return createViewHolder(view, viewType);
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +77,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
holder.title.setText(playlist.name);
|
||||
}
|
||||
|
||||
if (holder.getAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.getBindingAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.shortSeparator != null) {
|
||||
holder.shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -149,7 +150,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
final PopupMenu popupMenu = new PopupMenu(activity, view);
|
||||
|
||||
popupMenu.inflate(R.menu.menu_item_playlist);
|
||||
popupMenu.setOnMenuItemClickListener(item -> PlaylistMenuHelper.handleMenuClick(activity, dataSet.get(getAdapterPosition()), item));
|
||||
popupMenu.setOnMenuItemClickListener(item -> PlaylistMenuHelper.handleMenuClick(activity, dataSet.get(getBindingAdapterPosition()), item));
|
||||
|
||||
popupMenu.show();
|
||||
});
|
||||
|
|
@ -159,16 +160,16 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (isInQuickSelectMode()) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
} else {
|
||||
Playlist playlist = dataSet.get(getAdapterPosition());
|
||||
Playlist playlist = dataSet.get(getBindingAdapterPosition());
|
||||
NavigationUtil.goToPlaylist(activity, playlist);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder> {
|
||||
|
||||
private static final int HEADER = 0;
|
||||
private static final int ALBUM = 1;
|
||||
private static final int ARTIST = 2;
|
||||
|
|
@ -53,8 +52,8 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
return HEADER;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == HEADER)
|
||||
return new ViewHolder(LayoutInflater.from(activity).inflate(R.layout.sub_header, parent, false), viewType);
|
||||
|
|
@ -100,6 +99,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
public class ViewHolder extends MediaEntryViewHolder {
|
||||
public ViewHolder(@NonNull View itemView, int itemViewType) {
|
||||
super(itemView);
|
||||
|
||||
itemView.setOnLongClickListener(null);
|
||||
|
||||
if (itemViewType != HEADER) {
|
||||
|
|
@ -119,7 +119,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
menu.setOnClickListener(new SongMenuHelper.OnClickSongMenu(activity) {
|
||||
@Override
|
||||
public Song getSong() {
|
||||
return (Song) dataSet.get(getAdapterPosition());
|
||||
return (Song) dataSet.get(getBindingAdapterPosition());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
@ -145,7 +145,7 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
|||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Object item = dataSet.get(getAdapterPosition());
|
||||
Object item = dataSet.get(getBindingAdapterPosition());
|
||||
switch (getItemViewType()) {
|
||||
case ALBUM:
|
||||
NavigationUtil.goToAlbum(activity,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
|
||||
public AlbumAdapter(@NonNull AppCompatActivity activity, List<Album> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) {
|
||||
super(activity, cabHolder, R.menu.menu_media_selection);
|
||||
|
||||
this.activity = activity;
|
||||
this.dataSet = dataSet;
|
||||
this.itemLayoutRes = itemLayoutRes;
|
||||
|
|
@ -64,10 +65,11 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
return dataSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false);
|
||||
|
||||
return createViewHolder(view, viewType);
|
||||
}
|
||||
|
||||
|
|
@ -86,11 +88,10 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
@Override
|
||||
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
|
||||
final Album album = dataSet.get(position);
|
||||
|
||||
final boolean isChecked = isChecked(album);
|
||||
holder.itemView.setActivated(isChecked);
|
||||
|
||||
if (holder.getAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.getBindingAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.shortSeparator != null) {
|
||||
holder.shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -206,8 +207,9 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
}
|
||||
|
||||
public class ViewHolder extends MediaEntryViewHolder {
|
||||
public ViewHolder(@NonNull final View itemView) {
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
setImageTransitionName(activity.getString(R.string.transition_album_image));
|
||||
if (menu != null) {
|
||||
menu.setVisibility(View.GONE);
|
||||
|
|
@ -217,16 +219,16 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isInQuickSelectMode()) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
} else {
|
||||
Pair[] albumPairs = new Pair[]{Pair.create(image, activity.getResources().getString(R.string.transition_album_image))};
|
||||
NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()), albumPairs);
|
||||
NavigationUtil.goToAlbum(activity, dataSet.get(getBindingAdapterPosition()), albumPairs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
|||
boolean isChecked = isChecked(artist);
|
||||
holder.itemView.setActivated(isChecked);
|
||||
|
||||
if (holder.getAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.getBindingAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.shortSeparator != null) {
|
||||
holder.shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -191,16 +191,16 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isInQuickSelectMode()) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
} else {
|
||||
Pair[] artistPairs = new Pair[]{Pair.create(image, activity.getResources().getString(R.string.transition_artist_image))};
|
||||
NavigationUtil.goToArtist(activity, dataSet.get(getAdapterPosition()), artistPairs);
|
||||
NavigationUtil.goToArtist(activity, dataSet.get(getBindingAdapterPosition()), artistPairs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,22 +91,22 @@ public abstract class AbsOffsetSongAdapter extends SongAdapter {
|
|||
protected Song getSong() {
|
||||
// return empty song just to be safe
|
||||
if (getItemViewType() == OFFSET_ITEM) return Song.EMPTY;
|
||||
return dataSet.get(getAdapterPosition() - 1);
|
||||
return dataSet.get(getBindingAdapterPosition() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isInQuickSelectMode() && getItemViewType() != OFFSET_ITEM) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(dataSet, getAdapterPosition() - 1, true);
|
||||
MusicPlayerRemote.openQueue(dataSet, getBindingAdapterPosition() - 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
if (getItemViewType() == OFFSET_ITEM) return false;
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ public class AlbumSongAdapter extends SongAdapter {
|
|||
}
|
||||
|
||||
public class ViewHolder extends SongAdapter.ViewHolder {
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ public class OrderablePlaylistSongAdapter extends PlaylistSongAdapter implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCheckCanStartDrag(ViewHolder holder, int position, int x, int y) {
|
||||
public boolean onCheckCanStartDrag(@NonNull ViewHolder holder, int position, int x, int y) {
|
||||
return onMoveItemListener != null && position > 0 &&
|
||||
(ViewUtil.hitTest(holder.dragView, x, y) || ViewUtil.hitTest(holder.image, x, y));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDraggableRange onGetItemDraggableRange(ViewHolder holder, int position) {
|
||||
public ItemDraggableRange onGetItemDraggableRange(@NonNull ViewHolder holder, int position) {
|
||||
return new ItemDraggableRange(1, dataSet.size());
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +98,7 @@ public class OrderablePlaylistSongAdapter extends PlaylistSongAdapter implements
|
|||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
if (dragView != null) {
|
||||
if (onMoveItemListener != null) {
|
||||
dragView.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAdapter<PlayingQueueAdapter.ViewHolder> {
|
||||
private static final int HISTORY = 0;
|
||||
private static final int CURRENT = 1;
|
||||
private static final int UP_NEXT = 2;
|
||||
private static final int NEXT = 2;
|
||||
|
||||
private int current;
|
||||
|
||||
|
|
@ -44,6 +44,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
|
|||
if (holder.imageText != null) {
|
||||
holder.imageText.setText(String.valueOf(position - current));
|
||||
}
|
||||
|
||||
if (holder.getItemViewType() == HISTORY || holder.getItemViewType() == CURRENT) {
|
||||
setAlpha(holder, 0.5f);
|
||||
}
|
||||
|
|
@ -54,8 +55,9 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
|
|||
if (position < current) {
|
||||
return HISTORY;
|
||||
} else if (position > current) {
|
||||
return UP_NEXT;
|
||||
return NEXT;
|
||||
}
|
||||
|
||||
return CURRENT;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +105,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemDraggableRange onGetItemDraggableRange(ViewHolder holder, int position) {
|
||||
public ItemDraggableRange onGetItemDraggableRange(@NonNull ViewHolder holder, int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +135,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
|
|||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
if (imageText != null) {
|
||||
imageText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
@ -151,7 +154,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
|
|||
protected boolean onSongMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_remove_from_queue:
|
||||
MusicPlayerRemote.removeFromQueue(getAdapterPosition());
|
||||
MusicPlayerRemote.removeFromQueue(getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class PlaylistSongAdapter extends AbsOffsetSongAdapter {
|
|||
protected boolean onSongMenuItemClick(MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_go_to_album) {
|
||||
Pair[] albumPairs = new Pair[]{Pair.create(image, activity.getString(R.string.transition_album_image))};
|
||||
NavigationUtil.goToAlbum(activity, new Album(dataSet.get(getAdapterPosition() - 1)), albumPairs);
|
||||
NavigationUtil.goToAlbum(activity, new Album(dataSet.get(getBindingAdapterPosition() - 1)), albumPairs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView;
|
|||
import java.util.List;
|
||||
|
||||
public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song> implements MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
protected final AppCompatActivity activity;
|
||||
protected List<Song> dataSet;
|
||||
|
||||
|
|
@ -56,6 +55,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
this.itemLayoutRes = itemLayoutRes;
|
||||
this.usePalette = usePalette;
|
||||
this.showSectionName = showSectionName;
|
||||
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
|
|
@ -78,10 +78,11 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
return dataSet.get(position).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(itemLayoutRes, parent, false);
|
||||
|
||||
return createViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
@ -92,11 +93,10 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
@Override
|
||||
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
|
||||
final Song song = dataSet.get(position);
|
||||
|
||||
boolean isChecked = isChecked(song);
|
||||
holder.itemView.setActivated(isChecked);
|
||||
|
||||
if (holder.getAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.getBindingAdapterPosition() == getItemCount() - 1) {
|
||||
if (holder.shortSeparator != null) {
|
||||
holder.shortSeparator.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -216,6 +216,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
|
||||
setImageTransitionName(activity.getString(R.string.transition_album_image));
|
||||
|
||||
if (menu == null) {
|
||||
|
|
@ -241,7 +242,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
}
|
||||
|
||||
protected Song getSong() {
|
||||
return dataSet.get(getAdapterPosition());
|
||||
return dataSet.get(getBindingAdapterPosition());
|
||||
}
|
||||
|
||||
protected int getSongMenuRes() {
|
||||
|
|
@ -264,15 +265,15 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isInQuickSelectMode()) {
|
||||
toggleChecked(getAdapterPosition());
|
||||
toggleChecked(getBindingAdapterPosition());
|
||||
} else {
|
||||
MusicPlayerRemote.openQueue(dataSet, getAdapterPosition(), true);
|
||||
MusicPlayerRemote.openQueue(dataSet, getBindingAdapterPosition(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
return toggleChecked(getAdapterPosition());
|
||||
return toggleChecked(getBindingAdapterPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class HorizontalAdapterHelper {
|
|||
|
||||
layoutParams.leftMargin = listMargin / 3;
|
||||
layoutParams.rightMargin = listMargin / 3;
|
||||
|
||||
if (viewType == TYPE_FIRST) {
|
||||
layoutParams.leftMargin = listMargin;
|
||||
} else if (viewType == TYPE_LAST) {
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ public class MusicProgressViewUpdateHelper extends Handler {
|
|||
private static final int UPDATE_INTERVAL_PLAYING = 1000;
|
||||
private static final int UPDATE_INTERVAL_PAUSED = 500;
|
||||
|
||||
private Callback callback;
|
||||
private int intervalPlaying;
|
||||
private int intervalPaused;
|
||||
private final Callback callback;
|
||||
private final int intervalPlaying;
|
||||
private final int intervalPaused;
|
||||
|
||||
public void start() {
|
||||
queueNextRefresh(1);
|
||||
|
|
@ -54,6 +54,7 @@ public class MusicProgressViewUpdateHelper extends Handler {
|
|||
|
||||
private void queueNextRefresh(final long delay) {
|
||||
final Message message = obtainMessage(CMD_REFRESH_PROGRESS_VIEWS);
|
||||
|
||||
removeMessages(CMD_REFRESH_PROGRESS_VIEWS);
|
||||
sendMessageDelayed(message, delay);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,33 @@
|
|||
package com.dkanada.gramophone.helper;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
|
||||
public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
||||
|
||||
private ActionCompletionContract contract;
|
||||
private final ActionCompletionContract contract;
|
||||
|
||||
public SwipeAndDragHelper(ActionCompletionContract contract) {
|
||||
this.contract = contract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
|
||||
return makeMovementFlags(dragFlags, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
contract.onViewMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
|
||||
contract.onViewMoved(viewHolder.getBindingAdapterPosition(), target.getBindingAdapterPosition());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -34,7 +36,7 @@ public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
|
||||
float alpha = 1 - (Math.abs(dX) / recyclerView.getWidth());
|
||||
viewHolder.itemView.setAlpha(alpha);
|
||||
|
|
@ -47,4 +49,3 @@ public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
|
|||
void onViewMoved(int oldPosition, int newPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class SongMenuHelper {
|
|||
}
|
||||
|
||||
public static abstract class OnClickSongMenu implements View.OnClickListener, PopupMenu.OnMenuItemClickListener {
|
||||
private AppCompatActivity activity;
|
||||
private final AppCompatActivity activity;
|
||||
|
||||
public OnClickSongMenu(@NonNull AppCompatActivity activity) {
|
||||
this.activity = activity;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import static android.content.Context.NOTIFICATION_SERVICE;
|
|||
public abstract class PlayingNotification {
|
||||
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
||||
protected static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
||||
|
||||
private static final int NOTIFY_MODE_FOREGROUND = 1;
|
||||
private static final int NOTIFY_MODE_BACKGROUND = 0;
|
||||
|
|
@ -24,7 +24,7 @@ public abstract class PlayingNotification {
|
|||
|
||||
private NotificationManager notificationManager;
|
||||
protected MusicService service;
|
||||
boolean stopped;
|
||||
protected boolean stopped;
|
||||
|
||||
public synchronized void init(MusicService service) {
|
||||
this.service = service;
|
||||
|
|
@ -63,9 +63,10 @@ public abstract class PlayingNotification {
|
|||
notifyMode = newNotifyMode;
|
||||
}
|
||||
|
||||
@RequiresApi(26)
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private void createNotificationChannel() {
|
||||
NotificationChannel notificationChannel = notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID);
|
||||
|
||||
if (notificationChannel == null) {
|
||||
notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, service.getString(R.string.playing_notification_name), NotificationManager.IMPORTANCE_LOW);
|
||||
notificationChannel.setDescription(service.getString(R.string.playing_notification_description));
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class ThemeUtil {
|
|||
private static class SwatchComparator implements Comparator<Palette.Swatch> {
|
||||
private static SwatchComparator sInstance;
|
||||
|
||||
static SwatchComparator getInstance() {
|
||||
private static SwatchComparator getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new SwatchComparator();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ import com.dkanada.gramophone.views.shortcuts.AppShortcutLauncherActivity;
|
|||
@TargetApi(Build.VERSION_CODES.O)
|
||||
public abstract class BaseShortcutType {
|
||||
|
||||
static final String PREFIX = BuildConfig.APPLICATION_ID + ".views.shortcut";
|
||||
protected static final String PREFIX = BuildConfig.APPLICATION_ID + ".views.shortcut";
|
||||
|
||||
Context context;
|
||||
protected final Context context;
|
||||
|
||||
public BaseShortcutType(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
static public String getId() {
|
||||
public static String getId() {
|
||||
return PREFIX + ".base";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue