more code refactoring

This commit is contained in:
dkanada 2020-04-26 13:14:21 +09:00
commit a0e8db7f75
31 changed files with 78 additions and 153 deletions

View file

@ -95,7 +95,6 @@ public class GenreAdapter extends RecyclerView.Adapter<GenreAdapter.ViewHolder>
} }
public class ViewHolder extends MediaEntryViewHolder { public class ViewHolder extends MediaEntryViewHolder {
public ViewHolder(@NonNull View itemView) { public ViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
} }

View file

@ -107,6 +107,7 @@ public class AlbumAdapter extends AbsMultiSelectAdapter<AlbumAdapter.ViewHolder,
if (holder.title != null) { if (holder.title != null) {
holder.title.setText(getAlbumTitle(album)); holder.title.setText(getAlbumTitle(album));
} }
if (holder.text != null) { if (holder.text != null) {
holder.text.setText(getAlbumText(album)); holder.text.setText(getAlbumText(album));
} }

View file

@ -45,6 +45,7 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
updateCab(); updateCab();
return true; return true;
} }
return false; return false;
} }
@ -57,6 +58,7 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
checked.add(identifier); checked.add(identifier);
} }
} }
notifyDataSetChanged(); notifyDataSetChanged();
updateCab(); updateCab();
} }
@ -67,6 +69,7 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
if (cab == null || !cab.isActive()) { if (cab == null || !cab.isActive()) {
cab = cabHolder.openCab(menuRes, this); cab = cabHolder.openCab(menuRes, this);
} }
final int size = checked.size(); final int size = checked.size();
if (size <= 0) cab.finish(); if (size <= 0) cab.finish();
else if (size == 1) cab.setTitle(getName(checked.get(0))); else if (size == 1) cab.setTitle(getName(checked.get(0)));
@ -101,6 +104,7 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
cab.finish(); cab.finish();
clearChecked(); clearChecked();
} }
return true; return true;
} }

View file

@ -13,12 +13,8 @@ import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.interfaces.CabHolder; import com.kabouzeid.gramophone.interfaces.CabHolder;
import com.kabouzeid.gramophone.model.Song; import com.kabouzeid.gramophone.model.Song;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Eugene Cheung (arkon)
*/
public abstract class AbsOffsetSongAdapter extends SongAdapter { public abstract class AbsOffsetSongAdapter extends SongAdapter {
protected static final int OFFSET_ITEM = 0; protected static final int OFFSET_ITEM = 0;
@ -80,6 +76,7 @@ public abstract class AbsOffsetSongAdapter extends SongAdapter {
@Override @Override
public String getSectionName(int position) { public String getSectionName(int position) {
position--; position--;
if (position < 0) return ""; if (position < 0) return "";
return super.getSectionName(position); return super.getSectionName(position);
} }
@ -91,8 +88,8 @@ public abstract class AbsOffsetSongAdapter extends SongAdapter {
@Override @Override
protected Song getSong() { protected Song getSong() {
if (getItemViewType() == OFFSET_ITEM) // return empty song just to be safe
return Song.EMPTY_SONG; // could also return null, just to be safe return empty song if (getItemViewType() == OFFSET_ITEM) return Song.EMPTY_SONG;
return dataSet.get(getAdapterPosition() - 1); return dataSet.get(getAdapterPosition() - 1);
} }

View file

@ -13,11 +13,7 @@ import com.kabouzeid.gramophone.util.MusicUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class AlbumSongAdapter extends SongAdapter { public class AlbumSongAdapter extends SongAdapter {
public AlbumSongAdapter(AppCompatActivity activity, List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { public AlbumSongAdapter(AppCompatActivity activity, List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) {
super(activity, dataSet, itemLayoutRes, usePalette, cabHolder); super(activity, dataSet, itemLayoutRes, usePalette, cabHolder);
} }
@ -61,6 +57,6 @@ public class AlbumSongAdapter extends SongAdapter {
@Override @Override
protected void loadAlbumCover(Song song, SongAdapter.ViewHolder holder) { protected void loadAlbumCover(Song song, SongAdapter.ViewHolder holder) {
// We don't want to load it in this adapter // don't want to load it in this adapter
} }
} }

View file

@ -104,9 +104,11 @@ public class ArtistSongAdapter extends ArrayAdapter<Song> implements MaterialCab
Pair[] albumPairs = new Pair[]{ Pair[] albumPairs = new Pair[]{
Pair.create(albumArt, activity.getResources().getString(R.string.transition_album_art)) Pair.create(albumArt, activity.getResources().getString(R.string.transition_album_art))
}; };
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs); NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
return true; return true;
} }
return super.onMenuItemClick(item); return super.onMenuItemClick(item);
} }
}); });
@ -119,6 +121,7 @@ public class ArtistSongAdapter extends ArrayAdapter<Song> implements MaterialCab
MusicPlayerRemote.openQueue(dataSet, position, true); MusicPlayerRemote.openQueue(dataSet, position, true);
} }
}); });
convertView.setOnLongClickListener(view -> { convertView.setOnLongClickListener(view -> {
toggleChecked(song); toggleChecked(song);
return true; return true;

View file

@ -120,6 +120,7 @@ public class OrderablePlaylistSongAdapter extends PlaylistSongAdapter implements
RemoveFromPlaylistDialog.create((PlaylistSong) getSong()).show(activity.getSupportFragmentManager(), "REMOVE_FROM_PLAYLIST"); RemoveFromPlaylistDialog.create((PlaylistSong) getSong()).show(activity.getSupportFragmentManager(), "REMOVE_FROM_PLAYLIST");
return true; return true;
} }
return super.onSongMenuItemClick(item); return super.onSongMenuItemClick(item);
} }

View file

@ -59,7 +59,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
@Override @Override
protected void loadAlbumCover(Song song, SongAdapter.ViewHolder holder) { protected void loadAlbumCover(Song song, SongAdapter.ViewHolder holder) {
// We don't want to load it in this adapter // don't want to load it in this adapter
} }
public void swapDataSet(List<Song> dataSet, int position) { public void swapDataSet(List<Song> dataSet, int position) {
@ -77,15 +77,19 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
if (holder.image != null) { if (holder.image != null) {
holder.image.setAlpha(alpha); holder.image.setAlpha(alpha);
} }
if (holder.title != null) { if (holder.title != null) {
holder.title.setAlpha(alpha); holder.title.setAlpha(alpha);
} }
if (holder.text != null) { if (holder.text != null) {
holder.text.setAlpha(alpha); holder.text.setAlpha(alpha);
} }
if (holder.imageText != null) { if (holder.imageText != null) {
holder.imageText.setAlpha(alpha); holder.imageText.setAlpha(alpha);
} }
if (holder.paletteColorContainer != null) { if (holder.paletteColorContainer != null) {
holder.paletteColorContainer.setAlpha(alpha); holder.paletteColorContainer.setAlpha(alpha);
} }
@ -130,6 +134,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
if (imageText != null) { if (imageText != null) {
imageText.setVisibility(View.VISIBLE); imageText.setVisibility(View.VISIBLE);
} }
if (image != null) { if (image != null) {
image.setVisibility(View.GONE); image.setVisibility(View.GONE);
} }
@ -147,6 +152,7 @@ public class PlayingQueueAdapter extends SongAdapter implements DraggableItemAda
MusicPlayerRemote.removeFromQueue(getAdapterPosition()); MusicPlayerRemote.removeFromQueue(getAdapterPosition());
return true; return true;
} }
return super.onSongMenuItemClick(item); return super.onSongMenuItemClick(item);
} }

View file

@ -37,24 +37,30 @@ public class PlaylistSongAdapter extends AbsOffsetSongAdapter {
holder.title.setText(MusicUtil.getPlaylistInfoString(activity, dataSet)); holder.title.setText(MusicUtil.getPlaylistInfoString(activity, dataSet));
holder.title.setTextColor(textColor); holder.title.setTextColor(textColor);
} }
if (holder.text != null) { if (holder.text != null) {
holder.text.setVisibility(View.GONE); holder.text.setVisibility(View.GONE);
} }
if (holder.menu != null) { if (holder.menu != null) {
holder.menu.setVisibility(View.GONE); holder.menu.setVisibility(View.GONE);
} }
if (holder.image != null) { if (holder.image != null) {
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2; final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2;
holder.image.setPadding(padding, padding, padding, padding); holder.image.setPadding(padding, padding, padding, padding);
holder.image.setColorFilter(textColor); holder.image.setColorFilter(textColor);
holder.image.setImageResource(R.drawable.ic_timer_white_24dp); holder.image.setImageResource(R.drawable.ic_timer_white_24dp);
} }
if (holder.dragView != null) { if (holder.dragView != null) {
holder.dragView.setVisibility(View.GONE); holder.dragView.setVisibility(View.GONE);
} }
if (holder.separator != null) { if (holder.separator != null) {
holder.separator.setVisibility(View.VISIBLE); holder.separator.setVisibility(View.VISIBLE);
} }
if (holder.shortSeparator != null) { if (holder.shortSeparator != null) {
holder.shortSeparator.setVisibility(View.GONE); holder.shortSeparator.setVisibility(View.GONE);
} }
@ -79,9 +85,11 @@ public class PlaylistSongAdapter extends AbsOffsetSongAdapter {
Pair[] albumPairs = new Pair[]{ Pair[] albumPairs = new Pair[]{
Pair.create(image, activity.getString(R.string.transition_album_art)) Pair.create(image, activity.getString(R.string.transition_album_art))
}; };
NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition() - 1).albumId, albumPairs); NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition() - 1).albumId, albumPairs);
return true; return true;
} }
return super.onSongMenuItemClick(item); return super.onSongMenuItemClick(item);
} }
} }

View file

@ -36,21 +36,26 @@ public class ShuffleButtonSongAdapter extends AbsOffsetSongAdapter {
holder.title.setTextColor(accentColor); holder.title.setTextColor(accentColor);
holder.title.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL)); holder.title.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
} }
if (holder.text != null) { if (holder.text != null) {
holder.text.setVisibility(View.GONE); holder.text.setVisibility(View.GONE);
} }
if (holder.menu != null) { if (holder.menu != null) {
holder.menu.setVisibility(View.GONE); holder.menu.setVisibility(View.GONE);
} }
if (holder.image != null) { if (holder.image != null) {
final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2; final int padding = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin) / 2;
holder.image.setPadding(padding, padding, padding, padding); holder.image.setPadding(padding, padding, padding, padding);
holder.image.setColorFilter(accentColor); holder.image.setColorFilter(accentColor);
holder.image.setImageResource(R.drawable.ic_shuffle_white_24dp); holder.image.setImageResource(R.drawable.ic_shuffle_white_24dp);
} }
if (holder.separator != null) { if (holder.separator != null) {
holder.separator.setVisibility(View.VISIBLE); holder.separator.setVisibility(View.VISIBLE);
} }
if (holder.shortSeparator != null) { if (holder.shortSeparator != null) {
holder.shortSeparator.setVisibility(View.GONE); holder.shortSeparator.setVisibility(View.GONE);
} }

View file

@ -49,6 +49,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
public SongAdapter(AppCompatActivity activity, List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder, boolean showSectionName) { public SongAdapter(AppCompatActivity activity, List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder, boolean showSectionName) {
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;
@ -107,6 +108,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
if (holder.title != null) { if (holder.title != null) {
holder.title.setText(getSongTitle(song)); holder.title.setText(getSongTitle(song));
} }
if (holder.text != null) { if (holder.text != null) {
holder.text.setText(getSongText(song)); holder.text.setText(getSongText(song));
} }
@ -245,9 +247,7 @@ public class SongAdapter extends AbsMultiSelectAdapter<SongAdapter.ViewHolder, S
if (image != null && image.getVisibility() == View.VISIBLE) { if (image != null && image.getVisibility() == View.VISIBLE) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_go_to_album: case R.id.action_go_to_album:
Pair[] albumPairs = new Pair[]{ Pair[] albumPairs = new Pair[]{Pair.create(image, activity.getResources().getString(R.string.transition_album_art))};
Pair.create(image, activity.getResources().getString(R.string.transition_album_art))
};
NavigationUtil.goToAlbum(activity, getSong().albumId, albumPairs); NavigationUtil.goToAlbum(activity, getSong().albumId, albumPairs);
return true; return true;
} }

View file

@ -15,9 +15,6 @@ import com.kabouzeid.gramophone.util.PlaylistsUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/
public class AddToPlaylistDialog extends DialogFragment { public class AddToPlaylistDialog extends DialogFragment {
@NonNull @NonNull
@ -50,9 +47,10 @@ public class AddToPlaylistDialog extends DialogFragment {
.title(R.string.action_add_to_playlist) .title(R.string.action_add_to_playlist)
.items(playlistNames) .items(playlistNames)
.itemsCallback((materialDialog, view, i, charSequence) -> { .itemsCallback((materialDialog, view, i, charSequence) -> {
//noinspection unchecked // noinspection unchecked
final List<Song> songs = getArguments().getParcelableArrayList("songs"); final List<Song> songs = getArguments().getParcelableArrayList("songs");
if (songs == null) return; if (songs == null) return;
if (i == 0) { if (i == 0) {
materialDialog.dismiss(); materialDialog.dismiss();
CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST"); CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");

View file

@ -10,9 +10,6 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.model.playlist.AbsSmartPlaylist; import com.kabouzeid.gramophone.model.playlist.AbsSmartPlaylist;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class ClearSmartPlaylistDialog extends DialogFragment { public class ClearSmartPlaylistDialog extends DialogFragment {
@NonNull @NonNull
@ -27,10 +24,10 @@ public class ClearSmartPlaylistDialog extends DialogFragment {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
//noinspection unchecked // noinspection unchecked
final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist"); final AbsSmartPlaylist playlist = getArguments().getParcelable("playlist");
int title = R.string.clear_playlist_title; int title = R.string.clear_playlist_title;
//noinspection ConstantConditions // noinspection ConstantConditions
CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name)); CharSequence content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist.name));
return new MaterialDialog.Builder(getActivity()) return new MaterialDialog.Builder(getActivity())

View file

@ -16,9 +16,6 @@ import com.kabouzeid.gramophone.util.PlaylistsUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/
public class CreatePlaylistDialog extends DialogFragment { public class CreatePlaylistDialog extends DialogFragment {
private static final String SONGS = "songs"; private static final String SONGS = "songs";
@ -63,7 +60,7 @@ public class CreatePlaylistDialog extends DialogFragment {
if (!PlaylistsUtil.doesPlaylistExist(getActivity(), name)) { if (!PlaylistsUtil.doesPlaylistExist(getActivity(), name)) {
final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), name); final int playlistId = PlaylistsUtil.createPlaylist(getActivity(), name);
if (getActivity() != null) { if (getActivity() != null) {
//noinspection unchecked // noinspection unchecked
List<Song> songs = getArguments().getParcelableArrayList(SONGS); List<Song> songs = getArguments().getParcelableArrayList(SONGS);
if (songs != null && !songs.isEmpty()) { if (songs != null && !songs.isEmpty()) {
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true); PlaylistsUtil.addToPlaylist(getActivity(), songs, playlistId, true);

View file

@ -14,9 +14,6 @@ import com.kabouzeid.gramophone.util.PlaylistsUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class DeletePlaylistDialog extends DialogFragment { public class DeletePlaylistDialog extends DialogFragment {
@NonNull @NonNull
@ -38,11 +35,10 @@ public class DeletePlaylistDialog extends DialogFragment {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
//noinspection unchecked
final List<Playlist> playlists = getArguments().getParcelableArrayList("playlists"); final List<Playlist> playlists = getArguments().getParcelableArrayList("playlists");
int title; int title;
CharSequence content; CharSequence content;
//noinspection ConstantConditions // noinspection ConstantConditions
if (playlists.size() > 1) { if (playlists.size() > 1) {
title = R.string.delete_playlists_title; title = R.string.delete_playlists_title;
content = Html.fromHtml(getString(R.string.delete_x_playlists, playlists.size())); content = Html.fromHtml(getString(R.string.delete_x_playlists, playlists.size()));
@ -50,14 +46,14 @@ public class DeletePlaylistDialog extends DialogFragment {
title = R.string.delete_playlist_title; title = R.string.delete_playlist_title;
content = Html.fromHtml(getString(R.string.delete_playlist_x, playlists.get(0).name)); content = Html.fromHtml(getString(R.string.delete_playlist_x, playlists.get(0).name));
} }
return new MaterialDialog.Builder(getActivity()) return new MaterialDialog.Builder(getActivity())
.title(title) .title(title)
.content(content) .content(content)
.positiveText(R.string.delete_action) .positiveText(R.string.delete_action)
.negativeText(android.R.string.cancel) .negativeText(android.R.string.cancel)
.onPositive((dialog, which) -> { .onPositive((dialog, which) -> {
if (getActivity() == null) if (getActivity() == null) return;
return;
PlaylistsUtil.deletePlaylists(getActivity(), playlists); PlaylistsUtil.deletePlaylists(getActivity(), playlists);
}) })
.build(); .build();

View file

@ -14,9 +14,6 @@ import com.kabouzeid.gramophone.util.MusicUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/
public class DeleteSongsDialog extends DialogFragment { public class DeleteSongsDialog extends DialogFragment {
@NonNull @NonNull
@ -38,7 +35,6 @@ public class DeleteSongsDialog extends DialogFragment {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
//noinspection unchecked
final List<Song> songs = getArguments().getParcelableArrayList("songs"); final List<Song> songs = getArguments().getParcelableArrayList("songs");
int title; int title;
CharSequence content; CharSequence content;
@ -49,14 +45,14 @@ public class DeleteSongsDialog extends DialogFragment {
title = R.string.delete_song_title; title = R.string.delete_song_title;
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title)); content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
} }
return new MaterialDialog.Builder(getActivity()) return new MaterialDialog.Builder(getActivity())
.title(title) .title(title)
.content(content) .content(content)
.positiveText(R.string.delete_action) .positiveText(R.string.delete_action)
.negativeText(android.R.string.cancel) .negativeText(android.R.string.cancel)
.onPositive((dialog, which) -> { .onPositive((dialog, which) -> {
if (getActivity() == null) if (getActivity() == null) return;
return;
MusicUtil.deleteTracks(getActivity(), songs); MusicUtil.deleteTracks(getActivity(), songs);
}) })
.build(); .build();

View file

@ -38,9 +38,6 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class DonationsDialog extends DialogFragment implements BillingProcessor.IBillingHandler { public class DonationsDialog extends DialogFragment implements BillingProcessor.IBillingHandler {
public static final String TAG = DonationsDialog.class.getSimpleName(); public static final String TAG = DonationsDialog.class.getSimpleName();
@ -111,6 +108,7 @@ public class DonationsDialog extends DialogFragment implements BillingProcessor.
if (skuDetailsLoadAsyncTask != null) { if (skuDetailsLoadAsyncTask != null) {
skuDetailsLoadAsyncTask.cancel(true); skuDetailsLoadAsyncTask.cancel(true);
} }
super.onDestroy(); super.onDestroy();
} }
@ -118,6 +116,7 @@ public class DonationsDialog extends DialogFragment implements BillingProcessor.
if (skuDetailsLoadAsyncTask != null) { if (skuDetailsLoadAsyncTask != null) {
skuDetailsLoadAsyncTask.cancel(false); skuDetailsLoadAsyncTask.cancel(false);
} }
skuDetailsLoadAsyncTask = new SkuDetailsLoadAsyncTask(this).execute(); skuDetailsLoadAsyncTask = new SkuDetailsLoadAsyncTask(this).execute();
} }
@ -147,6 +146,7 @@ public class DonationsDialog extends DialogFragment implements BillingProcessor.
final String[] ids = dialog.getResources().getStringArray(DONATION_PRODUCT_IDS); final String[] ids = dialog.getResources().getStringArray(DONATION_PRODUCT_IDS);
return dialog.billingProcessor.getPurchaseListingDetails(new ArrayList<>(Arrays.asList(ids))); return dialog.billingProcessor.getPurchaseListingDetails(new ArrayList<>(Arrays.asList(ids)));
} }
cancel(false); cancel(false);
return null; return null;
} }

View file

@ -14,9 +14,6 @@ import com.kabouzeid.gramophone.util.PlaylistsUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class RemoveFromPlaylistDialog extends DialogFragment { public class RemoveFromPlaylistDialog extends DialogFragment {
@NonNull @NonNull
@ -49,14 +46,14 @@ public class RemoveFromPlaylistDialog extends DialogFragment {
title = R.string.remove_song_from_playlist_title; title = R.string.remove_song_from_playlist_title;
content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs.get(0).title)); content = Html.fromHtml(getString(R.string.remove_song_x_from_playlist, songs.get(0).title));
} }
return new MaterialDialog.Builder(getActivity()) return new MaterialDialog.Builder(getActivity())
.title(title) .title(title)
.content(content) .content(content)
.positiveText(R.string.remove_action) .positiveText(R.string.remove_action)
.negativeText(android.R.string.cancel) .negativeText(android.R.string.cancel)
.onPositive((dialog, which) -> { .onPositive((dialog, which) -> {
if (getActivity() == null) if (getActivity() == null) return;
return;
PlaylistsUtil.removeFromPlaylist(getActivity(), songs); PlaylistsUtil.removeFromPlaylist(getActivity(), songs);
}) })
.build(); .build();

View file

@ -10,9 +10,6 @@ import com.afollestad.materialdialogs.MaterialDialog;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.util.PlaylistsUtil; import com.kabouzeid.gramophone.util.PlaylistsUtil;
/**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/
public class RenamePlaylistDialog extends DialogFragment { public class RenamePlaylistDialog extends DialogFragment {
private static final String PLAYLIST_ID = "playlist_id"; private static final String PLAYLIST_ID = "playlist_id";
@ -40,6 +37,7 @@ public class RenamePlaylistDialog extends DialogFragment {
.input(getString(R.string.playlist_name_empty), PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId), false, .input(getString(R.string.playlist_name_empty), PlaylistsUtil.getNameForPlaylist(getActivity(), playlistId), false,
(materialDialog, charSequence) -> { (materialDialog, charSequence) -> {
final String name = charSequence.toString().trim(); final String name = charSequence.toString().trim();
if (!name.isEmpty()) { if (!name.isEmpty()) {
long playlistId1 = getArguments().getLong(PLAYLIST_ID); long playlistId1 = getArguments().getLong(PLAYLIST_ID);
PlaylistsUtil.renamePlaylist(getActivity(), playlistId1, name); PlaylistsUtil.renamePlaylist(getActivity(), playlistId1, name);

View file

@ -29,9 +29,6 @@ import com.triggertrap.seekarc.SeekArc;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class SleepTimerDialog extends DialogFragment { public class SleepTimerDialog extends DialogFragment {
@BindView(R.id.seek_arc) @BindView(R.id.seek_arc)
SeekArc seekArc; SeekArc seekArc;
@ -79,6 +76,7 @@ public class SleepTimerDialog extends DialogFragment {
if (getActivity() == null) { if (getActivity() == null) {
return; return;
} }
final PendingIntent previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE); final PendingIntent previous = makeTimerPendingIntent(PendingIntent.FLAG_NO_CREATE);
if (previous != null) { if (previous != null) {
AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
@ -134,13 +132,13 @@ public class SleepTimerDialog extends DialogFragment {
seekArc.setProgress(1); seekArc.setProgress(1);
return; return;
} }
seekArcProgress = i; seekArcProgress = i;
updateTimeDisplayTime(); updateTimeDisplayTime();
} }
@Override @Override
public void onStartTrackingTouch(SeekArc seekArc) { public void onStartTrackingTouch(SeekArc seekArc) {
} }
@Override @Override
@ -165,6 +163,7 @@ public class SleepTimerDialog extends DialogFragment {
if (shouldFinishLastSong.isChecked()) { if (shouldFinishLastSong.isChecked()) {
return intent.setAction(MusicService.ACTION_PENDING_QUIT); return intent.setAction(MusicService.ACTION_PENDING_QUIT);
} }
return intent.setAction(MusicService.ACTION_QUIT); return intent.setAction(MusicService.ACTION_QUIT);
} }

View file

@ -28,9 +28,6 @@ import org.jaudiotagger.tag.TagException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
/**
* @author Karim Abou Zeid (kabouzeid), Aidan Follestad (afollestad)
*/
public class SongDetailDialog extends DialogFragment { public class SongDetailDialog extends DialogFragment {
public static final String TAG = SongDetailDialog.class.getSimpleName(); public static final String TAG = SongDetailDialog.class.getSimpleName();
@ -89,6 +86,7 @@ public class SongDetailDialog extends DialogFragment {
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName())); fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath())); filePath.setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length()))); fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
try { try {
AudioFile audioFile = AudioFileIO.read(songFile); AudioFile audioFile = AudioFileIO.read(songFile);
AudioHeader audioHeader = audioFile.getAudioHeader(); AudioHeader audioHeader = audioFile.getAudioHeader();
@ -99,11 +97,9 @@ public class SongDetailDialog extends DialogFragment {
samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz")); samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
} catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) { } catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
Log.e(TAG, "error while reading the song file", e); Log.e(TAG, "error while reading the song file", e);
// fallback
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))); trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
} }
} else { } else {
// fallback
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title)); fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration))); trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
} }

View file

@ -11,9 +11,6 @@ import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.model.Song; import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.util.MusicUtil; import com.kabouzeid.gramophone.util.MusicUtil;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class SongShareDialog extends DialogFragment { public class SongShareDialog extends DialogFragment {
@NonNull @NonNull
public static SongShareDialog create(final Song song) { public static SongShareDialog create(final Song song) {

View file

@ -36,6 +36,7 @@ public class LibraryPreferenceDialog extends DialogFragment {
} else { } else {
categoryInfos = PreferenceUtil.getInstance(getContext()).getLibraryCategories(); categoryInfos = PreferenceUtil.getInstance(getContext()).getLibraryCategories();
} }
adapter = new CategoryInfoAdapter(categoryInfos); adapter = new CategoryInfoAdapter(categoryInfos);
RecyclerView recyclerView = view.findViewById(R.id.recycler_view); RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
@ -78,6 +79,7 @@ public class LibraryPreferenceDialog extends DialogFragment {
if (categoryInfo.visible) if (categoryInfo.visible)
selected++; selected++;
} }
return selected; return selected;
} }
} }

View file

@ -5,9 +5,6 @@ import android.util.AttributeSet;
import com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEDialogPreference; import com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEDialogPreference;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class NowPlayingScreenPreference extends ATEDialogPreference { public class NowPlayingScreenPreference extends ATEDialogPreference {
public NowPlayingScreenPreference(Context context) { public NowPlayingScreenPreference(Context context) {
super(context); super(context);

View file

@ -23,9 +23,6 @@ import com.kabouzeid.gramophone.ui.fragments.player.NowPlayingScreen;
import com.kabouzeid.gramophone.util.PreferenceUtil; import com.kabouzeid.gramophone.util.PreferenceUtil;
import com.kabouzeid.gramophone.util.ViewUtil; import com.kabouzeid.gramophone.util.ViewUtil;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class NowPlayingScreenPreferenceDialog extends DialogFragment implements MaterialDialog.SingleButtonCallback, ViewPager.OnPageChangeListener { public class NowPlayingScreenPreferenceDialog extends DialogFragment implements MaterialDialog.SingleButtonCallback, ViewPager.OnPageChangeListener {
private DialogAction whichButtonClicked; private DialogAction whichButtonClicked;
@ -73,7 +70,6 @@ public class NowPlayingScreenPreferenceDialog extends DialogFragment implements
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
} }
@Override @Override
@ -83,11 +79,9 @@ public class NowPlayingScreenPreferenceDialog extends DialogFragment implements
@Override @Override
public void onPageScrollStateChanged(int state) { public void onPageScrollStateChanged(int state) {
} }
private static class NowPlayingScreenAdapter extends PagerAdapter { private static class NowPlayingScreenAdapter extends PagerAdapter {
private Context context; private Context context;
public NowPlayingScreenAdapter(Context context) { public NowPlayingScreenAdapter(Context context) {

View file

@ -47,7 +47,7 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
private static int mClickCounter = 0; private static int mClickCounter = 0;
private static long mLastClickTime = 0; private static long mLastClickTime = 0;
@SuppressLint("HandlerLeak") // false alarm, handler is already static @SuppressLint("HandlerLeak")
private static Handler mHandler = new Handler() { private static Handler mHandler = new Handler() {
@Override @Override
@ -101,9 +101,10 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
final int keycode = event.getKeyCode(); final int keycode = event.getKeyCode();
final int action = event.getAction(); final int action = event.getAction();
// fallback to system time if event time is not available
final long eventTime = event.getEventTime() != 0 ? final long eventTime = event.getEventTime() != 0 ?
event.getEventTime() : System.currentTimeMillis(); event.getEventTime() : System.currentTimeMillis();
// Fallback to system time if event time was not available.
String command = null; String command = null;
switch (keycode) { switch (keycode) {
@ -127,6 +128,7 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
command = MusicService.ACTION_PLAY; command = MusicService.ACTION_PLAY;
break; break;
} }
if (command != null) { if (command != null) {
if (action == KeyEvent.ACTION_DOWN) { if (action == KeyEvent.ACTION_DOWN) {
if (event.getRepeatCount() == 0) { if (event.getRepeatCount() == 0) {
@ -153,16 +155,19 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
if (mClickCounter >= 3) { if (mClickCounter >= 3) {
mClickCounter = 0; mClickCounter = 0;
} }
mLastClickTime = eventTime; mLastClickTime = eventTime;
acquireWakeLockAndSendMessage(context, msg, delay); acquireWakeLockAndSendMessage(context, msg, delay);
} else { } else {
startService(context, command); startService(context, command);
} }
return true; return true;
} }
} }
} }
} }
return false; return false;
} }
@ -189,6 +194,7 @@ public class MediaButtonIntentReceiver extends BroadcastReceiver {
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Phonograph headset button"); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Phonograph headset button");
mWakeLock.setReferenceCounted(false); mWakeLock.setReferenceCounted(false);
} }
if (DEBUG) Log.v(TAG, "Acquiring wake lock and sending " + msg.what); if (DEBUG) Log.v(TAG, "Acquiring wake lock and sending " + msg.what);
// Make sure we don't indefinitely hold the wake lock under any circumstances // Make sure we don't indefinitely hold the wake lock under any circumstances
mWakeLock.acquire(10000); mWakeLock.acquire(10000);

View file

@ -16,9 +16,6 @@ import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.service.playback.Playback; import com.kabouzeid.gramophone.service.playback.Playback;
import com.kabouzeid.gramophone.util.PreferenceUtil; import com.kabouzeid.gramophone.util.PreferenceUtil;
/**
* @author Andrew Neal, Karim Abou Zeid (kabouzeid)
*/
public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener { public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
public static final String TAG = MultiPlayer.class.getSimpleName(); public static final String TAG = MultiPlayer.class.getSimpleName();
@ -31,9 +28,6 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
private boolean mIsInitialized = false; private boolean mIsInitialized = false;
/**
* Constructor of <code>MultiPlayer</code>
*/
public MultiPlayer(final Context context) { public MultiPlayer(final Context context) {
this.context = context; this.context = context;
mCurrentMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mCurrentMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
@ -138,27 +132,16 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Sets the callbacks
*
* @param callbacks The callbacks to use
*/
@Override @Override
public void setCallbacks(@Nullable Playback.PlaybackCallbacks callbacks) { public void setCallbacks(@Nullable Playback.PlaybackCallbacks callbacks) {
this.callbacks = callbacks; this.callbacks = callbacks;
} }
/**
* @return True if the player is ready to go, false otherwise
*/
@Override @Override
public boolean isInitialized() { public boolean isInitialized() {
return mIsInitialized; return mIsInitialized;
} }
/**
* Starts or resumes playback.
*/
@Override @Override
public boolean start() { public boolean start() {
try { try {
@ -169,18 +152,12 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Resets the MediaPlayer to its uninitialized state.
*/
@Override @Override
public void stop() { public void stop() {
mCurrentMediaPlayer.reset(); mCurrentMediaPlayer.reset();
mIsInitialized = false; mIsInitialized = false;
} }
/**
* Releases resources associated with this MediaPlayer object.
*/
@Override @Override
public void release() { public void release() {
stop(); stop();
@ -190,9 +167,6 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Pauses playback. Call start() to resume.
*/
@Override @Override
public boolean pause() { public boolean pause() {
try { try {
@ -203,24 +177,17 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Checks whether the MultiPlayer is playing.
*/
@Override @Override
public boolean isPlaying() { public boolean isPlaying() {
return mIsInitialized && mCurrentMediaPlayer.isPlaying(); return mIsInitialized && mCurrentMediaPlayer.isPlaying();
} }
/**
* Gets the duration of the file.
*
* @return The duration in milliseconds
*/
@Override @Override
public int duration() { public int duration() {
if (!mIsInitialized) { if (!mIsInitialized) {
return -1; return -1;
} }
try { try {
return mCurrentMediaPlayer.getDuration(); return mCurrentMediaPlayer.getDuration();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
@ -228,16 +195,12 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Gets the current playback position.
*
* @return The current position in milliseconds
*/
@Override @Override
public int position() { public int position() {
if (!mIsInitialized) { if (!mIsInitialized) {
return -1; return -1;
} }
try { try {
return mCurrentMediaPlayer.getCurrentPosition(); return mCurrentMediaPlayer.getCurrentPosition();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
@ -245,12 +208,6 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Gets the current playback position.
*
* @param whereto The offset in milliseconds from the start to seek to
* @return The offset in milliseconds from the start to seek to
*/
@Override @Override
public int seek(final int whereto) { public int seek(final int whereto) {
try { try {
@ -271,11 +228,6 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Sets the audio session ID.
*
* @param sessionId The audio session ID
*/
@Override @Override
public boolean setAudioSessionId(final int sessionId) { public boolean setAudioSessionId(final int sessionId) {
try { try {
@ -286,19 +238,11 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
} }
} }
/**
* Returns the audio session ID.
*
* @return The current audio session ID.
*/
@Override @Override
public int getAudioSessionId() { public int getAudioSessionId() {
return mCurrentMediaPlayer.getAudioSessionId(); return mCurrentMediaPlayer.getAudioSessionId();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean onError(final MediaPlayer mp, final int what, final int extra) { public boolean onError(final MediaPlayer mp, final int what, final int extra) {
mIsInitialized = false; mIsInitialized = false;
@ -308,12 +252,10 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
if (context != null) { if (context != null) {
Toast.makeText(context, context.getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show(); Toast.makeText(context, context.getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
} }
return false; return false;
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void onCompletion(final MediaPlayer mp) { public void onCompletion(final MediaPlayer mp) {
if (mp == mCurrentMediaPlayer && mNextMediaPlayer != null) { if (mp == mCurrentMediaPlayer && mNextMediaPlayer != null) {

View file

@ -66,11 +66,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
/**
* @author Karim Abou Zeid (kabouzeid), Andrew Neal
*/
public class MusicService extends Service implements SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks { public class MusicService extends Service implements SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks {
public static final String PHONOGRAPH_PACKAGE_NAME = "com.kabouzeid.gramophone"; public static final String PHONOGRAPH_PACKAGE_NAME = "com.kabouzeid.gramophone";
public static final String MUSIC_PACKAGE_NAME = "com.android.music"; public static final String MUSIC_PACKAGE_NAME = "com.android.music";
@ -89,7 +85,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public static final String APP_WIDGET_UPDATE = PHONOGRAPH_PACKAGE_NAME + ".appwidgetupdate"; public static final String APP_WIDGET_UPDATE = PHONOGRAPH_PACKAGE_NAME + ".appwidgetupdate";
public static final String EXTRA_APP_WIDGET_NAME = PHONOGRAPH_PACKAGE_NAME + "app_widget_name"; public static final String EXTRA_APP_WIDGET_NAME = PHONOGRAPH_PACKAGE_NAME + "app_widget_name";
// do not change these three strings as it will break support with other apps (e.g. last.fm scrobbling) // do not change these three strings as it will break support with other apps like last.fm
public static final String META_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".metachanged"; public static final String META_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".metachanged";
public static final String QUEUE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".queuechanged"; public static final String QUEUE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".queuechanged";
public static final String PLAY_STATE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".playstatechanged"; public static final String PLAY_STATE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".playstatechanged";
@ -1013,7 +1009,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
sendChangeInternal(what); sendChangeInternal(what);
} }
// to let other apps know whats playing. i.E. last.fm (scrobbling) or musixmatch // to let other apps know whats playing like last.fm
private void sendPublicIntent(@NonNull final String what) { private void sendPublicIntent(@NonNull final String what) {
final Intent intent = new Intent(what.replace(PHONOGRAPH_PACKAGE_NAME, MUSIC_PACKAGE_NAME)); final Intent intent = new Intent(what.replace(PHONOGRAPH_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
@ -1350,7 +1346,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
@Override @Override
public void run() { public void run() {
savePositionInTrack(); savePositionInTrack();
sendPublicIntent(PLAY_STATE_CHANGED); // for musixmatch synced lyrics sendPublicIntent(PLAY_STATE_CHANGED);
} }
} }

View file

@ -117,8 +117,9 @@ public class PlayingNotificationImpl extends PlayingNotification {
setBackgroundColor(bgColor); setBackgroundColor(bgColor);
setNotificationContent(ColorUtil.isColorLight(bgColor)); setNotificationContent(ColorUtil.isColorLight(bgColor));
if (stopped) // notification has been stopped before loading was finished
return; // notification has been stopped before loading was finished if (stopped) return;
updateNotifyModeAndPostNotification(notification); updateNotifyModeAndPostNotification(notification);
} }
@ -179,5 +180,4 @@ public class PlayingNotificationImpl extends PlayingNotification {
intent.setComponent(serviceName); intent.setComponent(serviceName);
return PendingIntent.getService(context, 0, intent, 0); return PendingIntent.getService(context, 0, intent, 0);
} }
} }

View file

@ -97,8 +97,9 @@ public class PlayingNotificationImpl24 extends PlayingNotification {
builder.setColor(color); builder.setColor(color);
} }
if (stopped) // notification has been stopped before loading was finished
return; // notification has been stopped before loading was finished if (stopped) return;
updateNotifyModeAndPostNotification(builder.build()); updateNotifyModeAndPostNotification(builder.build());
} }
})); }));

View file

@ -2,11 +2,7 @@ package com.kabouzeid.gramophone.service.playback;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public interface Playback { public interface Playback {
boolean setDataSource(String path); boolean setDataSource(String path);
void setNextDataSource(@Nullable String path); void setNextDataSource(@Nullable String path);