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