Clean ups
This commit is contained in:
parent
9d9fdff13f
commit
f458d146af
5 changed files with 47 additions and 68 deletions
|
|
@ -216,7 +216,7 @@ public class PlaylistAdapter extends AbsMultiSelectAdapter<PlaylistAdapter.ViewH
|
||||||
toggleChecked(getAdapterPosition());
|
toggleChecked(getAdapterPosition());
|
||||||
} else {
|
} else {
|
||||||
Playlist playlist = dataSet.get(getAdapterPosition());
|
Playlist playlist = dataSet.get(getAdapterPosition());
|
||||||
NavigationUtil.goToPlaylist(activity, playlist, null);
|
NavigationUtil.goToPlaylist(activity, playlist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,20 +189,16 @@ public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.ViewHolder
|
||||||
case ALBUM:
|
case ALBUM:
|
||||||
NavigationUtil.goToAlbum(activity,
|
NavigationUtil.goToAlbum(activity,
|
||||||
((Album) item).id,
|
((Album) item).id,
|
||||||
new Pair[]{
|
|
||||||
Pair.create(image,
|
Pair.create(image,
|
||||||
activity.getResources().getString(R.string.transition_album_art)
|
activity.getResources().getString(R.string.transition_album_art)
|
||||||
)
|
));
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case ARTIST:
|
case ARTIST:
|
||||||
NavigationUtil.goToArtist(activity,
|
NavigationUtil.goToArtist(activity,
|
||||||
((Artist) item).id,
|
((Artist) item).id,
|
||||||
new Pair[]{
|
|
||||||
Pair.create(image,
|
Pair.create(image,
|
||||||
activity.getResources().getString(R.string.transition_artist_image)
|
activity.getResources().getString(R.string.transition_artist_image)
|
||||||
)
|
));
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case SONG:
|
case SONG:
|
||||||
ArrayList<Song> playList = new ArrayList<>();
|
ArrayList<Song> playList = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,13 @@ public class SongMenuHelper {
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
Pair[] albumPairs = null;
|
Pair[] albumPairs = null;
|
||||||
if (activity instanceof AbsSlidingMusicPanelActivity)
|
if (activity instanceof AbsSlidingMusicPanelActivity)
|
||||||
albumPairs = ((AbsSlidingMusicPanelActivity) activity).addPlayPauseFabToSharedViews(null);
|
albumPairs = ((AbsSlidingMusicPanelActivity) activity).addPlayPauseFabToSharedViews();
|
||||||
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
|
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_artist:
|
case R.id.action_go_to_artist:
|
||||||
Pair[] artistPairs = null;
|
Pair[] artistPairs = null;
|
||||||
if (activity instanceof AbsSlidingMusicPanelActivity)
|
if (activity instanceof AbsSlidingMusicPanelActivity)
|
||||||
artistPairs = ((AbsSlidingMusicPanelActivity) activity).addPlayPauseFabToSharedViews(null);
|
artistPairs = ((AbsSlidingMusicPanelActivity) activity).addPlayPauseFabToSharedViews();
|
||||||
NavigationUtil.goToArtist(activity, song.artistId, artistPairs);
|
NavigationUtil.goToArtist(activity, song.artistId, artistPairs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -561,11 +561,11 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair[] addPlayPauseFabToSharedViews(@Nullable Pair[] sharedViews) {
|
public final Pair[] addPlayPauseFabToSharedViews(@Nullable final Pair... sharedElements) {
|
||||||
Pair[] sharedViewsWithFab;
|
Pair[] sharedViewsWithFab;
|
||||||
if (sharedViews != null) {
|
if (sharedElements != null) {
|
||||||
sharedViewsWithFab = new Pair[sharedViews.length + 1];
|
sharedViewsWithFab = new Pair[sharedElements.length + 1];
|
||||||
System.arraycopy(sharedViews, 0, sharedViewsWithFab, 0, sharedViews.length);
|
System.arraycopy(sharedElements, 0, sharedViewsWithFab, 0, sharedElements.length);
|
||||||
} else {
|
} else {
|
||||||
sharedViewsWithFab = new Pair[1];
|
sharedViewsWithFab = new Pair[1];
|
||||||
}
|
}
|
||||||
|
|
@ -1098,10 +1098,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
SongDetailDialog.create(song).show(getSupportFragmentManager(), "SONG_DETAIL");
|
SongDetailDialog.create(song).show(getSupportFragmentManager(), "SONG_DETAIL");
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_album:
|
case R.id.action_go_to_album:
|
||||||
NavigationUtil.goToAlbum(this, song.albumId, addPlayPauseFabToSharedViews(null));
|
NavigationUtil.goToAlbum(this, song.albumId, addPlayPauseFabToSharedViews());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_go_to_artist:
|
case R.id.action_go_to_artist:
|
||||||
NavigationUtil.goToArtist(this, song.artistId, addPlayPauseFabToSharedViews(null));
|
NavigationUtil.goToArtist(this, song.artistId, addPlayPauseFabToSharedViews());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import android.content.Intent;
|
||||||
import android.media.audiofx.AudioEffect;
|
import android.media.audiofx.AudioEffect;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
@ -26,62 +25,46 @@ import com.kabouzeid.gramophone.ui.activities.PlaylistDetailActivity;
|
||||||
*/
|
*/
|
||||||
public class NavigationUtil {
|
public class NavigationUtil {
|
||||||
|
|
||||||
public static void goToArtist(final Activity activity, final int artistId, @Nullable final Pair[] sharedViews) {
|
public static void goToArtist(@NonNull final Activity activity, final int artistId, @Nullable final Pair... sharedElements) {
|
||||||
if (activity instanceof ArtistDetailActivity)
|
if (activity instanceof ArtistDetailActivity) return;
|
||||||
return;
|
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
||||||
if ((activity instanceof KabViewsDisableAble && ((KabViewsDisableAble) activity).areViewsEnabled()) || !(activity instanceof KabViewsDisableAble)) {
|
|
||||||
if (activity instanceof KabViewsDisableAble)
|
|
||||||
((KabViewsDisableAble) activity).disableViews();
|
|
||||||
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
final Intent intent = new Intent(activity, ArtistDetailActivity.class);
|
||||||
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
|
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
|
||||||
if (sharedViews != null) {
|
|
||||||
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
//noinspection unchecked
|
||||||
sharedViews
|
activity.startActivity(intent, ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle());
|
||||||
);
|
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
|
||||||
} else {
|
|
||||||
activity.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void goToAlbum(final Activity activity, final int albumId, @Nullable final Pair[] sharedViews) {
|
public static void goToAlbum(@NonNull final Activity activity, final int albumId, @Nullable final Pair... sharedElements) {
|
||||||
if (activity instanceof AlbumDetailActivity)
|
if (activity instanceof AlbumDetailActivity) return;
|
||||||
return;
|
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
||||||
if ((activity instanceof KabViewsDisableAble && ((KabViewsDisableAble) activity).areViewsEnabled()) || !(activity instanceof KabViewsDisableAble)) {
|
|
||||||
if (activity instanceof KabViewsDisableAble)
|
|
||||||
((KabViewsDisableAble) activity).disableViews();
|
|
||||||
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
final Intent intent = new Intent(activity, AlbumDetailActivity.class);
|
||||||
intent.putExtra(AlbumDetailActivity.EXTRA_ALBUM_ID, albumId);
|
intent.putExtra(AlbumDetailActivity.EXTRA_ALBUM_ID, albumId);
|
||||||
if (sharedViews != null) {
|
|
||||||
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
//noinspection unchecked
|
||||||
sharedViews
|
activity.startActivity(intent, ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle());
|
||||||
);
|
|
||||||
ActivityCompat.startActivityForResult(activity, intent, 1001, optionsCompat.toBundle());
|
|
||||||
} else {
|
|
||||||
activity.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void goToPlaylist(final Activity activity, final Playlist playlist, @Nullable final Pair[] sharedViews) {
|
public static void goToPlaylist(@NonNull final Activity activity, final Playlist playlist, @Nullable final Pair... sharedElements) {
|
||||||
if ((activity instanceof KabViewsDisableAble && ((KabViewsDisableAble) activity).areViewsEnabled()) || !(activity instanceof KabViewsDisableAble)) {
|
if (!disableViewsAndCheckIsReadyForTransition(activity)) return;
|
||||||
if (activity instanceof KabViewsDisableAble)
|
|
||||||
((KabViewsDisableAble) activity).disableViews();
|
|
||||||
|
|
||||||
final Intent intent;
|
final Intent intent = new Intent(activity, PlaylistDetailActivity.class);
|
||||||
intent = new Intent(activity, PlaylistDetailActivity.class);
|
|
||||||
intent.putExtra(PlaylistDetailActivity.EXTRA_PLAYLIST, playlist);
|
intent.putExtra(PlaylistDetailActivity.EXTRA_PLAYLIST, playlist);
|
||||||
|
|
||||||
if (sharedViews != null) {
|
//noinspection unchecked
|
||||||
@SuppressWarnings("unchecked") ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
|
activity.startActivity(intent, ActivityOptionsCompat.makeSceneTransitionAnimation(activity, sharedElements).toBundle());
|
||||||
sharedViews
|
}
|
||||||
);
|
|
||||||
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
|
private static boolean disableViewsAndCheckIsReadyForTransition(@NonNull final Activity activity) {
|
||||||
} else {
|
if (activity instanceof KabViewsDisableAble) {
|
||||||
activity.startActivity(intent);
|
if (((KabViewsDisableAble) activity).areViewsEnabled()) {
|
||||||
|
((KabViewsDisableAble) activity).disableViews();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openPlayingQueueDialog(@NonNull final AppCompatActivity activity) {
|
public static void openPlayingQueueDialog(@NonNull final AppCompatActivity activity) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue