New artist details activity [biography missing yet]
This commit is contained in:
parent
346961a636
commit
ef48e9305b
26 changed files with 664 additions and 486 deletions
|
|
@ -42,11 +42,12 @@ android {
|
|||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:21.0.+'
|
||||
compile 'com.android.support:gridlayout-v7:21.0.+'
|
||||
compile 'com.android.support:recyclerview-v7:21.0.+'
|
||||
compile 'com.android.support:palette-v7:21.0.+'
|
||||
compile 'com.android.support:support-v13:21.0.+'
|
||||
compile 'com.android.support:appcompat-v7:21.0.0'
|
||||
compile 'com.android.support:gridlayout-v7:21.0.0'
|
||||
compile 'com.android.support:recyclerview-v7:21.0.0'
|
||||
compile 'com.android.support:palette-v7:21.0.0'
|
||||
compile 'com.android.support:support-v13:21.0.0'
|
||||
compile 'com.android.support:cardview-v7:21.0.0'
|
||||
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
|
||||
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
|
||||
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
image = (SquareImageView) itemView.findViewById(R.id.album_art);
|
||||
image = (ImageView) itemView.findViewById(R.id.album_art);
|
||||
title = (TextView) itemView.findViewById(R.id.album_title);
|
||||
artist = (TextView) itemView.findViewById(R.id.album_interpret);
|
||||
footer = itemView.findViewById(R.id.footer);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,98 @@
|
|||
package com.kabouzeid.gramophone.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistThumbnailUrlLoader;
|
||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 29.12.14.
|
||||
*/
|
||||
public class ArtistAdapter extends RecyclerView.Adapter<ArtistAdapter.ViewHolder> {
|
||||
protected Activity activity;
|
||||
protected List<Artist> dataSet;
|
||||
|
||||
public ArtistAdapter(Activity activity, List<Artist> objects) {
|
||||
this.activity = activity;
|
||||
dataSet = objects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_artist_view, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
final Artist artist = dataSet.get(position);
|
||||
|
||||
holder.artistName.setText(artist.name);
|
||||
holder.artistInfo.setText(artist.getSubTitle());
|
||||
holder.artistImage.setImageResource(R.drawable.default_artist_image);
|
||||
|
||||
LastFMArtistThumbnailUrlLoader.loadArtistThumbnailUrl(activity, artist.name, false, new LastFMArtistThumbnailUrlLoader.ArtistThumbnailUrlLoaderCallback() {
|
||||
@Override
|
||||
public void onArtistThumbnailUrlLoaded(String url) {
|
||||
Picasso.with(activity)
|
||||
.load(url)
|
||||
.placeholder(R.drawable.default_artist_image)
|
||||
.into(holder.artistImage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataSet.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
TextView artistName;
|
||||
TextView artistInfo;
|
||||
ImageView artistImage;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
artistName = (TextView) itemView.findViewById(R.id.artist_name);
|
||||
artistInfo = (TextView) itemView.findViewById(R.id.artist_info);
|
||||
artistImage = (ImageView) itemView.findViewById(R.id.artist_image);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Pair[] artistPairs = new Pair[]{
|
||||
Pair.create(artistImage,
|
||||
activity.getResources().getString(R.string.transition_artist_image)
|
||||
)};
|
||||
if (activity instanceof AbsFabActivity)
|
||||
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(artistPairs);
|
||||
NavigationUtil.goToArtist(activity, dataSet.get(getPosition()).id, artistPairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.kabouzeid.gramophone.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.view.SquareImageView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 24.11.14.
|
||||
*/
|
||||
public class ArtistAlbumAdapter extends RecyclerView.Adapter<ArtistAlbumAdapter.ViewHolder> {
|
||||
public static final String TAG = AlbumAdapter.class.getSimpleName();
|
||||
|
||||
private static final int TYPE_FIRST = 1;
|
||||
private static final int TYPE_MIDDLE = 2;
|
||||
private static final int TYPE_LAST = 3;
|
||||
|
||||
private Activity activity;
|
||||
private List<Album> dataSet;
|
||||
private int listMargin;
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_artist_album, parent, false);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
|
||||
if (viewType == TYPE_FIRST) {
|
||||
params.leftMargin = listMargin;
|
||||
} else if (viewType == TYPE_LAST) {
|
||||
params.rightMargin = listMargin;
|
||||
}
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
final Album album = dataSet.get(position);
|
||||
|
||||
Picasso.with(activity)
|
||||
.load(MusicUtil.getAlbumArtUri(album.id))
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(holder.image);
|
||||
|
||||
holder.title.setText(album.title);
|
||||
holder.year.setText(String.valueOf(album.year));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataSet.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return TYPE_FIRST;
|
||||
} else if (position == getItemCount() - 1) {
|
||||
return TYPE_LAST;
|
||||
} else return TYPE_MIDDLE;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
ImageView image;
|
||||
TextView title;
|
||||
TextView year;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
image = (ImageView) itemView.findViewById(R.id.album_art);
|
||||
title = (TextView) itemView.findViewById(R.id.album_title);
|
||||
year = (TextView) itemView.findViewById(R.id.album_year);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Pair[] albumPairs = new Pair[]{
|
||||
Pair.create(image,
|
||||
activity.getResources().getString(R.string.transition_album_cover)
|
||||
)};
|
||||
if (activity instanceof AbsFabActivity)
|
||||
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(albumPairs);
|
||||
NavigationUtil.goToAlbum(activity, dataSet.get(getPosition()).id, albumPairs);
|
||||
}
|
||||
}
|
||||
|
||||
public ArtistAlbumAdapter(Activity activity, List<Album> objects) {
|
||||
this.activity = activity;
|
||||
dataSet = objects;
|
||||
listMargin = activity.getResources().getDimensionPixelSize(R.dimen.default_item_margin);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
package com.kabouzeid.gramophone.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistThumbnailUrlLoader;
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 29.12.14.
|
||||
*/
|
||||
public class ArtistViewListAdapter extends ArrayAdapter<Artist> {
|
||||
private Context context;
|
||||
|
||||
|
||||
public ArtistViewListAdapter(Context context, List<Artist> objects) {
|
||||
super(context, R.layout.item_artist_view, objects);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Artist artist = getItem(position);
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(context).inflate(R.layout.item_artist_view, parent, false);
|
||||
}
|
||||
final TextView artistName = (TextView) convertView.findViewById(R.id.artist_name);
|
||||
final TextView artistInfo = (TextView) convertView.findViewById(R.id.artist_info);
|
||||
final ImageView artistArt = (ImageView) convertView.findViewById(R.id.artist_image);
|
||||
|
||||
artistName.setText(artist.name);
|
||||
artistInfo.setText(artist.getSubTitle());
|
||||
|
||||
artistArt.setImageResource(R.drawable.default_artist_image);
|
||||
|
||||
LastFMArtistThumbnailUrlLoader.loadArtistThumbnailUrl(context, artist.name, false, new LastFMArtistThumbnailUrlLoader.ArtistThumbnailUrlLoaderCallback() {
|
||||
@Override
|
||||
public void onArtistThumbnailUrlLoaded(String url) {
|
||||
Picasso.with(getContext())
|
||||
.load(url)
|
||||
.placeholder(R.drawable.default_artist_image)
|
||||
.into(artistArt);
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ public class AlbumSongAdapter extends RecyclerView.Adapter<AlbumSongAdapter.View
|
|||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_song, parent, false);
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_song_album, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,100 @@
|
|||
package com.kabouzeid.gramophone.adapter.songadapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.helper.SongDetailDialogHelper;
|
||||
import com.kabouzeid.gramophone.loader.SongFilePathLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by karim on 14.03.15.
|
||||
*/
|
||||
public class ArtistSongAdapter extends ArrayAdapter<Song> {
|
||||
private Activity activity;
|
||||
|
||||
public ArtistSongAdapter(Activity activity, List<Song> songs) {
|
||||
super(activity, R.layout.item_song, songs);
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
final Song song = getItem(position);
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_artist_song, parent, false);
|
||||
}
|
||||
|
||||
final TextView songTitle = (TextView) convertView.findViewById(R.id.song_title);
|
||||
final TextView songInfo = (TextView) convertView.findViewById(R.id.song_info);
|
||||
final ImageView albumArt = (ImageView) convertView.findViewById(R.id.album_art);
|
||||
|
||||
songTitle.setText(song.title);
|
||||
songInfo.setText(song.albumName);
|
||||
|
||||
Picasso.with(activity)
|
||||
.load(MusicUtil.getAlbumArtUri(song.albumId))
|
||||
.placeholder(R.drawable.default_album_art)
|
||||
.into(albumArt);
|
||||
|
||||
final ImageView overflowButton = (ImageView) convertView.findViewById(R.id.menu);
|
||||
overflowButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PopupMenu popupMenu = new PopupMenu(activity, v);
|
||||
popupMenu.inflate(R.menu.menu_song);
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_tag_editor:
|
||||
Intent intent = new Intent(activity, SongTagEditorActivity.class);
|
||||
intent.putExtra(AppKeys.E_ID, song.id);
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_details:
|
||||
String songFilePath = SongFilePathLoader.getSongFilePath(activity, song.id);
|
||||
File songFile = new File(songFilePath);
|
||||
SongDetailDialogHelper.getDialog(activity, songFile).show();
|
||||
return true;
|
||||
case R.id.action_go_to_album:
|
||||
Pair[] albumPairs = null;
|
||||
if (activity instanceof AbsFabActivity)
|
||||
albumPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(albumPairs);
|
||||
NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
|
||||
return true;
|
||||
case R.id.action_go_to_artist:
|
||||
Pair[] artistPairs = null;
|
||||
if (activity instanceof AbsFabActivity)
|
||||
artistPairs = ((AbsFabActivity) activity).getSharedViewsWithFab(artistPairs);
|
||||
NavigationUtil.goToArtist(activity, song.artistId, artistPairs);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popupMenu.show();
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class SongAdapter extends RecyclerView.Adapter<SongAdapter.ViewHolder> {
|
|||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_song_view, parent, false);
|
||||
View view = LayoutInflater.from(activity).inflate(R.layout.item_song, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import java.util.List;
|
|||
*
|
||||
* */
|
||||
|
||||
public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisableAble {
|
||||
public class AlbumDetailActivity extends AbsFabActivity {
|
||||
public static final String TAG = AlbumDetailActivity.class.getSimpleName();
|
||||
|
||||
private App app;
|
||||
|
|
@ -152,7 +152,12 @@ public class AlbumDetailActivity extends AbsFabActivity implements KabViewsDisab
|
|||
private void setUpViews() {
|
||||
albumTitleView.setText(album.title);
|
||||
|
||||
ViewUtil.addOnGlobalLayoutListener(albumArtImageView, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setUpAlbumArtAndApplyPalette();
|
||||
}
|
||||
});
|
||||
setUpListView();
|
||||
setUpSongsAdapter();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +1,47 @@
|
|||
package com.kabouzeid.gramophone.ui.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v13.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.graphics.Palette;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
|
||||
import com.github.ksoichiro.android.observablescrollview.ScrollState;
|
||||
import com.google.samples.apps.iosched.ui.widget.SlidingTabLayout;
|
||||
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.interfaces.KabViewsDisableAble;
|
||||
import com.kabouzeid.gramophone.adapter.AlbumAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.ArtistAlbumAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.songadapter.ArtistSongAdapter;
|
||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||
import com.kabouzeid.gramophone.lastfm.artist.LastFMArtistImageUrlLoader;
|
||||
import com.kabouzeid.gramophone.loader.ArtistAlbumLoader;
|
||||
import com.kabouzeid.gramophone.loader.ArtistLoader;
|
||||
import com.kabouzeid.gramophone.loader.ArtistSongLoader;
|
||||
import com.kabouzeid.gramophone.misc.AppKeys;
|
||||
import com.kabouzeid.gramophone.misc.SmallObservableScrollViewCallbacks;
|
||||
import com.kabouzeid.gramophone.model.Album;
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
|
||||
import com.kabouzeid.gramophone.ui.fragments.artistviewpager.AbsViewPagerTabArtistListFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.artistviewpager.ViewPagerTabArtistAlbumFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.artistviewpager.ViewPagerTabArtistBioFragment;
|
||||
import com.kabouzeid.gramophone.ui.fragments.artistviewpager.ViewPagerTabArtistSongListFragment;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.view.ViewHelper;
|
||||
import com.nineoldandroids.view.ViewPropertyAnimator;
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
*
|
||||
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
|
||||
|
|
@ -53,35 +50,59 @@ import com.squareup.picasso.Picasso;
|
|||
*
|
||||
* */
|
||||
|
||||
public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisableAble, ObservableScrollViewCallbacks {
|
||||
public class ArtistDetailActivity extends AbsFabActivity {
|
||||
public static final String TAG = ArtistDetailActivity.class.getSimpleName();
|
||||
|
||||
public static final String ARG_ARTIST_ID = "com.kabouzeid.gramophone.artist.id";
|
||||
public static final String ARG_ARTIST_NAME = "com.kabouzeid.gramophone.artist.name";
|
||||
|
||||
private static final boolean TOOLBAR_IS_STICKY = true;
|
||||
|
||||
private boolean isAnimating;
|
||||
|
||||
private Artist artist;
|
||||
|
||||
private SlidingTabLayout slidingTabs;
|
||||
private ObservableListView songListView;
|
||||
private View statusBar;
|
||||
private ImageView artistImageView;
|
||||
private View artistArtOverlayView;
|
||||
private View absAlbumListBackgroundView;
|
||||
private TextView artistTitleText;
|
||||
private ImageView artistIv;
|
||||
private View songsBackgroundView;
|
||||
private TextView artistNameTv;
|
||||
private Toolbar toolbar;
|
||||
private ViewPager viewPager;
|
||||
private NavigationAdapter navigationAdapter;
|
||||
private int toolbarHeight;
|
||||
private int headerOffset;
|
||||
private int titleViewHeight;
|
||||
private int artistImageViewHeight;
|
||||
private int toolbarColor;
|
||||
private int tabHeight;
|
||||
|
||||
private Fragment currentFragment;
|
||||
private View songListHeader;
|
||||
private RecyclerView albumRecyclerView;
|
||||
|
||||
private SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
scrollY += artistImageViewHeight + titleViewHeight;
|
||||
super.onScrollChanged(scrollY, b, b2);
|
||||
float flexibleRange = artistImageViewHeight - headerOffset;
|
||||
|
||||
// Translate album cover
|
||||
ViewHelper.setTranslationY(artistIv, Math.max(-artistImageViewHeight, -scrollY / 2));
|
||||
|
||||
// Translate list background
|
||||
ViewHelper.setTranslationY(songsBackgroundView, Math.max(0, -scrollY + artistImageViewHeight));
|
||||
|
||||
// Change alpha of overlay
|
||||
float alpha = Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
ViewUtil.setBackgroundAlpha(toolbar, alpha, toolbarColor);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, alpha, toolbarColor);
|
||||
|
||||
// Translate name text
|
||||
int maxTitleTranslationY = artistImageViewHeight;
|
||||
int titleTranslationY = maxTitleTranslationY - scrollY;
|
||||
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
||||
|
||||
ViewHelper.setTranslationY(artistNameTv, titleTranslationY);
|
||||
|
||||
// Translate FAB
|
||||
int fabTranslationY = titleTranslationY + titleViewHeight - (getFab().getHeight() / 2);
|
||||
ViewHelper.setTranslationY(getFab(), fabTranslationY);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
|
|
@ -102,19 +123,14 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
artistImageView = (ImageView) findViewById(R.id.artist_image);
|
||||
artistIv = (ImageView) findViewById(R.id.artist_image);
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
artistArtOverlayView = findViewById(R.id.overlay);
|
||||
artistTitleText = (TextView) findViewById(R.id.artist_name);
|
||||
absAlbumListBackgroundView = findViewById(R.id.list_background);
|
||||
songListView = (ObservableListView) findViewById(R.id.list);
|
||||
artistNameTv = (TextView) findViewById(R.id.artist_name);
|
||||
songsBackgroundView = findViewById(R.id.list_background);
|
||||
statusBar = findViewById(R.id.statusBar);
|
||||
slidingTabs = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
|
||||
songListHeader = LayoutInflater.from(this).inflate(R.layout.artist_detail_header, songListView, false);
|
||||
}
|
||||
|
||||
private void setUpObservableListViewParams() {
|
||||
|
|
@ -124,162 +140,71 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
titleViewHeight = getResources().getDimensionPixelSize(R.dimen.title_view_height);
|
||||
headerOffset = toolbarHeight;
|
||||
headerOffset += getResources().getDimensionPixelSize(R.dimen.statusMargin);
|
||||
tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
artistTitleText.setText(artist.name);
|
||||
ViewHelper.setAlpha(artistArtOverlayView, 0);
|
||||
artistNameTv.setText(artist.name);
|
||||
|
||||
ViewUtil.addOnGlobalLayoutListener(artistIv, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setUpArtistImageAndApplyPalette(false);
|
||||
setUpViewPatch();
|
||||
setUpSlidingTabs();
|
||||
}
|
||||
});
|
||||
setUpSongListView();
|
||||
setUpAlbumRecyclerView();
|
||||
}
|
||||
|
||||
private void setUpSlidingTabs() {
|
||||
navigationAdapter = new NavigationAdapter(this, artist);
|
||||
viewPager = (ViewPager) findViewById(R.id.pager);
|
||||
viewPager.setOffscreenPageLimit(2);
|
||||
viewPager.setAdapter(navigationAdapter);
|
||||
viewPager.setCurrentItem(1);
|
||||
private void setUpSongListView() {
|
||||
songListView.setScrollViewCallbacks(observableScrollViewCallbacks);
|
||||
|
||||
slidingTabs.setViewPager(viewPager);
|
||||
slidingTabs.setDistributeEvenly(true);
|
||||
slidingTabs.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
|
||||
slidingTabs.setSelectedIndicatorColors(Util.resolveColor(this, R.attr.colorAccent));
|
||||
slidingTabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
setListViewPadding();
|
||||
|
||||
songListView.addHeaderView(songListHeader);
|
||||
|
||||
final List<Song> songs = ArtistSongLoader.getArtistSongList(this, artist.id);
|
||||
ArtistSongAdapter songAdapter = new ArtistSongAdapter(this, songs);
|
||||
songListView.setAdapter(songAdapter);
|
||||
|
||||
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
contentView.post(new Runnable() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
public void run() {
|
||||
songsBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
observableScrollViewCallbacks.onScrollChanged(-(artistImageViewHeight + titleViewHeight), false, false);
|
||||
}
|
||||
});
|
||||
|
||||
songListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
currentFragment = navigationAdapter.getItemAt(position);
|
||||
if (currentFragment instanceof AbsViewPagerTabArtistListFragment) {
|
||||
restoreY(((AbsViewPagerTabArtistListFragment) currentFragment).getY());
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// header view has position 0
|
||||
if(position == 0){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
MusicPlayerRemote.openQueue(songs, position - 1, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void restoreY(final int scrollY) {
|
||||
translateToolBar(scrollY);
|
||||
int animationTime = 1000;
|
||||
DecelerateInterpolator interpolator = new DecelerateInterpolator(4);
|
||||
int titleTranslationY = getTitleTranslation(scrollY);
|
||||
ViewPropertyAnimator.animate(artistArtOverlayView).y(getOverlayTranslation(scrollY)).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(artistImageView).y(getImageViewTranslation(scrollY)).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(absAlbumListBackgroundView).y(getListBackgroundTranslation(scrollY)).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(artistArtOverlayView).alpha(getOverlayAlpha(scrollY)).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(slidingTabs).y(titleTranslationY + titleViewHeight).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(artistTitleText).y(titleTranslationY).setDuration(animationTime).setInterpolator(interpolator).start();
|
||||
ViewPropertyAnimator.animate(getFab()).y(getFabTranslation(scrollY)).setDuration(animationTime).setInterpolator(interpolator).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
isAnimating = true;
|
||||
private void setUpAlbumRecyclerView(){
|
||||
albumRecyclerView = (RecyclerView) songListHeader.findViewById(R.id.recycler_view);
|
||||
albumRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
List<Album> albums = ArtistAlbumLoader.getArtistAlbumList(this, artist.id);
|
||||
ArtistAlbumAdapter albumAdapter = new ArtistAlbumAdapter(this, albums);
|
||||
albumRecyclerView.setAdapter(albumAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
translateToolBar(scrollY);
|
||||
isAnimating = false;
|
||||
if (currentFragment instanceof AbsViewPagerTabArtistListFragment) {
|
||||
onScrollChanged((((AbsViewPagerTabArtistListFragment) currentFragment).getY()), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
isAnimating = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
isAnimating = true;
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollChanged(int scrollY, boolean b, boolean b2) {
|
||||
if (!isAnimating) {
|
||||
int titleTranslationY = getTitleTranslation(scrollY);
|
||||
ViewHelper.setTranslationY(artistArtOverlayView, getOverlayTranslation(scrollY));
|
||||
ViewHelper.setTranslationY(artistImageView, getImageViewTranslation(scrollY));
|
||||
ViewHelper.setTranslationY(absAlbumListBackgroundView, getListBackgroundTranslation(scrollY));
|
||||
ViewHelper.setAlpha(artistArtOverlayView, getOverlayAlpha(scrollY));
|
||||
ViewHelper.setTranslationY(artistTitleText, titleTranslationY);
|
||||
ViewHelper.setTranslationY(slidingTabs, titleTranslationY);
|
||||
ViewHelper.setTranslationY(getFab(), getFabTranslation(scrollY));
|
||||
translateToolBar(scrollY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownMotionEvent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
|
||||
}
|
||||
|
||||
private int getImageViewTranslation(int scrollY) {
|
||||
int minOverlayTransitionY = headerOffset - artistArtOverlayView.getHeight();
|
||||
return Math.max(minOverlayTransitionY, Math.min(0, -scrollY / 2));
|
||||
}
|
||||
|
||||
private int getOverlayTranslation(int scrollY) {
|
||||
int minOverlayTransitionY = headerOffset - artistArtOverlayView.getHeight();
|
||||
return Math.max(minOverlayTransitionY, Math.min(0, -scrollY));
|
||||
}
|
||||
|
||||
private int getListBackgroundTranslation(int scrollY) {
|
||||
return Math.max(0, -scrollY + artistImageViewHeight - 200);
|
||||
}
|
||||
|
||||
private int getTitleTranslation(int scrollY) {
|
||||
int maxTitleTranslationY = artistImageViewHeight;
|
||||
int titleTranslationY = maxTitleTranslationY - scrollY;
|
||||
if (TOOLBAR_IS_STICKY) {
|
||||
titleTranslationY = Math.max(headerOffset, titleTranslationY);
|
||||
}
|
||||
return titleTranslationY;
|
||||
}
|
||||
|
||||
private int getFabTranslation(int scrollY) {
|
||||
return getTitleTranslation(scrollY) + titleViewHeight + tabHeight - (getFab().getHeight() / 2);
|
||||
}
|
||||
|
||||
private float getOverlayAlpha(int scrollY) {
|
||||
float flexibleRange = artistImageViewHeight - headerOffset;
|
||||
return Math.max(0, Math.min(1, (float) scrollY / flexibleRange));
|
||||
}
|
||||
|
||||
private void translateToolBar(int scrollY) {
|
||||
if (TOOLBAR_IS_STICKY) {
|
||||
// Change alpha of toolbar background
|
||||
if (-scrollY + artistImageViewHeight <= headerOffset) {
|
||||
ViewUtil.setBackgroundAlpha(toolbar, 1, toolbarColor);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, 1, toolbarColor);
|
||||
|
||||
private void setListViewPadding() {
|
||||
if (Util.isInPortraitMode(this) || Util.isTablet(this)) {
|
||||
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, Util.getNavigationBarHeight(this));
|
||||
} else {
|
||||
ViewUtil.setBackgroundAlpha(toolbar, 0, toolbarColor);
|
||||
ViewUtil.setBackgroundAlpha(statusBar, 0, toolbarColor);
|
||||
}
|
||||
} else {
|
||||
// Translate Toolbar
|
||||
if (scrollY < artistImageViewHeight) {
|
||||
ViewHelper.setTranslationY(toolbar, 0);
|
||||
} else {
|
||||
ViewHelper.setTranslationY(toolbar, -scrollY);
|
||||
}
|
||||
songListView.setPadding(0, artistImageViewHeight + titleViewHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -290,15 +215,13 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
Picasso.with(ArtistDetailActivity.this)
|
||||
.load(url)
|
||||
.placeholder(R.drawable.default_artist_image)
|
||||
.into(artistImageView, new Callback.EmptyCallback() {
|
||||
.into(artistIv, new Callback.EmptyCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
super.onSuccess();
|
||||
final Bitmap bitmap = ((BitmapDrawable) artistImageView.getDrawable()).getBitmap();
|
||||
final Bitmap bitmap = ((BitmapDrawable) artistIv.getDrawable()).getBitmap();
|
||||
if (bitmap != null) applyPalette(bitmap);
|
||||
if (forceDownload) {
|
||||
Toast.makeText(ArtistDetailActivity.this, getResources().getString(R.string.updated_artist_image_for) + " " + artist.name, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -312,10 +235,8 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
Palette.Swatch swatch = palette.getVibrantSwatch();
|
||||
if (swatch != null) {
|
||||
toolbarColor = swatch.getRgb();
|
||||
artistArtOverlayView.setBackgroundColor(swatch.getRgb());
|
||||
artistTitleText.setBackgroundColor(swatch.getRgb());
|
||||
slidingTabs.setBackgroundColor(swatch.getRgb());
|
||||
artistTitleText.setTextColor(swatch.getTitleTextColor());
|
||||
artistNameTv.setBackgroundColor(swatch.getRgb());
|
||||
artistNameTv.setTextColor(swatch.getTitleTextColor());
|
||||
} else {
|
||||
setStandardColors();
|
||||
}
|
||||
|
|
@ -328,29 +249,14 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
int defaultBarColor = getResources().getColor(R.color.materialmusic_default_bar_color);
|
||||
|
||||
toolbarColor = defaultBarColor;
|
||||
artistArtOverlayView.setBackgroundColor(defaultBarColor);
|
||||
artistTitleText.setBackgroundColor(defaultBarColor);
|
||||
slidingTabs.setBackgroundColor(defaultBarColor);
|
||||
artistTitleText.setTextColor(titleTextColor);
|
||||
}
|
||||
|
||||
private void setUpViewPatch() {
|
||||
final View contentView = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||
contentView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
absAlbumListBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||
}
|
||||
});
|
||||
artistNameTv.setBackgroundColor(defaultBarColor);
|
||||
artistNameTv.setTextColor(titleTextColor);
|
||||
}
|
||||
|
||||
private void setUpToolBar() {
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setTitle(null);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (!TOOLBAR_IS_STICKY) {
|
||||
toolbar.setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
private void getIntentExtras() {
|
||||
|
|
@ -390,88 +296,14 @@ public class ArtistDetailActivity extends AbsFabActivity implements KabViewsDisa
|
|||
@Override
|
||||
public void enableViews() {
|
||||
super.enableViews();
|
||||
viewPager.setEnabled(true);
|
||||
songListView.setEnabled(true);
|
||||
toolbar.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableViews() {
|
||||
super.disableViews();
|
||||
viewPager.setEnabled(false);
|
||||
songListView.setEnabled(false);
|
||||
toolbar.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
private static class NavigationAdapter extends FragmentPagerAdapter {
|
||||
|
||||
private String[] titles;
|
||||
|
||||
private SparseArray<Fragment> pages;
|
||||
private Artist artist;
|
||||
private Context context;
|
||||
|
||||
public NavigationAdapter(Activity activity, Artist artist) {
|
||||
super(activity.getFragmentManager());
|
||||
this.artist = artist;
|
||||
pages = new SparseArray<>();
|
||||
context = activity;
|
||||
titles = new String[]{
|
||||
context.getResources().getString(R.string.tab_songs),
|
||||
context.getResources().getString(R.string.tab_albums),
|
||||
context.getResources().getString(R.string.tab_biography)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
final Bundle args = new Bundle();
|
||||
args.putInt(ARG_ARTIST_ID, artist.id);
|
||||
args.putString(ARG_ARTIST_NAME, artist.name);
|
||||
|
||||
Fragment f = getOrCreateFragmentAt(position);
|
||||
f.setArguments(args);
|
||||
|
||||
pages.put(position, f);
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
if (0 <= pages.indexOfKey(position)) {
|
||||
pages.remove(position);
|
||||
}
|
||||
super.destroyItem(container, position, object);
|
||||
}
|
||||
|
||||
private Fragment getOrCreateFragmentAt(int position) {
|
||||
switch (position) {
|
||||
case 1:
|
||||
return pages.get(position, new ViewPagerTabArtistAlbumFragment());
|
||||
case 0:
|
||||
return pages.get(position, new ViewPagerTabArtistSongListFragment());
|
||||
case 2:
|
||||
return pages.get(position, new ViewPagerTabArtistBioFragment());
|
||||
default:
|
||||
return pages.get(position, new MainActivity.PlaceholderFragmentAbs());
|
||||
}
|
||||
}
|
||||
|
||||
public Fragment getItemAt(int position) {
|
||||
return pages.get(position, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return titles.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return titles[position];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.kabouzeid.gramophone.App;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.AlbumAdapter;
|
||||
import com.kabouzeid.gramophone.loader.AlbumLoader;
|
||||
|
|
@ -25,13 +24,13 @@ public class AlbumViewFragment extends AbsMainActivityFragment {
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_albumview, container, false);
|
||||
return inflater.inflate(R.layout.fragment_album_view, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
|
||||
setUpRecyclerView();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,85 +1,55 @@
|
|||
package com.kabouzeid.gramophone.ui.fragments.mainactivityfragments;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.ArtistViewListAdapter;
|
||||
import com.kabouzeid.gramophone.adapter.ArtistAdapter;
|
||||
import com.kabouzeid.gramophone.loader.ArtistLoader;
|
||||
import com.kabouzeid.gramophone.model.Artist;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class ArtistViewFragment extends AbsMainActivityFragment {
|
||||
public static final String TAG = ArtistViewFragment.class.getSimpleName();
|
||||
|
||||
private AbsListView absListView;
|
||||
private View fragmentRootView;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_artist_view, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
fragmentRootView = view;
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initViews();
|
||||
setUpViews();
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
|
||||
setUpRecyclerView();
|
||||
}
|
||||
|
||||
private void setUpRecyclerView() {
|
||||
List<Artist> artists = ArtistLoader.getAllArtists(getActivity());
|
||||
ArtistAdapter artistAdapter = new ArtistAdapter(getActivity(), artists);
|
||||
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));
|
||||
recyclerView.setAdapter(artistAdapter);
|
||||
recyclerView.setPadding(0, getTopPadding(), 0, getBottomPadding());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableViews() {
|
||||
super.enableViews();
|
||||
absListView.setEnabled(true);
|
||||
recyclerView.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableViews() {
|
||||
super.disableViews();
|
||||
absListView.setEnabled(false);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
absListView = (AbsListView) fragmentRootView.findViewById(R.id.recyclerView);
|
||||
}
|
||||
|
||||
private void setUpViews() {
|
||||
setUpAbsListView();
|
||||
}
|
||||
|
||||
private void setUpAbsListView() {
|
||||
List<Artist> artists = ArtistLoader.getAllArtists(getActivity());
|
||||
fillAbsListView(artists);
|
||||
}
|
||||
|
||||
private void fillAbsListView(List<Artist> artists) {
|
||||
ArtistViewListAdapter artistAdapter = new ArtistViewListAdapter(getActivity(), artists);
|
||||
absListView.setAdapter(artistAdapter);
|
||||
absListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final Artist artist = (Artist) parent.getItemAtPosition(position);
|
||||
final View artistImageView = view.findViewById(R.id.artist_image);
|
||||
|
||||
Pair[] sharedElements = {Pair.create(artistImageView, getString(R.string.transition_artist_image))};
|
||||
NavigationUtil.goToArtist(getActivity(), artist.id, sharedElements);
|
||||
}
|
||||
});
|
||||
absListView.setPadding(0, getTopPadding(), 0, getBottomPadding());
|
||||
recyclerView.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SongViewFragment extends AbsMainActivityFragment {
|
|||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
|
||||
setUpRecyclerView();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
android:clipToPadding="false"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:scrollbarStyle="outsideOverlay"/>
|
||||
android:scrollbars="none"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -8,21 +8,6 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/list_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/colorBackground"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/artist_image"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -32,15 +17,21 @@
|
|||
android:transitionName="@string/transition_artist_image"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/overlay"
|
||||
android:id="@+id/list_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/header_image_height"
|
||||
android:background="@color/materialmusic_default_bar_color"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/colorBackground"/>
|
||||
|
||||
</FrameLayout>
|
||||
<com.github.ksoichiro.android.observablescrollview.ObservableListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:scrollbars="none"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
|
@ -60,22 +51,13 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textColor="?attr/title_text_color"/>
|
||||
|
||||
<com.google.samples.apps.iosched.ui.widget.SlidingTabLayout
|
||||
android:id="@+id/sliding_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/tab_height"
|
||||
android:background="@color/materialmusic_default_bar_color"
|
||||
android:elevation="@dimen/toolbar_elevation"
|
||||
android:paddingRight="88dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/transparent"/>
|
||||
android:background="@android:color/transparent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -91,8 +73,7 @@
|
|||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="@dimen/toolbar_elevation"/>
|
||||
android:background="@android:color/transparent"/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.melnykov.fab.FloatingActionButton
|
||||
|
|
@ -100,7 +81,7 @@
|
|||
style="@style/PlayPauseFab"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"/>
|
||||
|
||||
android:layout_marginRight="16dp"
|
||||
/>
|
||||
</FrameLayout>
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
android:elevation="3dp"
|
||||
android:foreground="?rect_selector">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:layout_margin="4dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="4dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.kabouzeid.gramophone.view.SquareImageView
|
||||
android:id="@+id/album_art"
|
||||
|
|
@ -53,10 +54,4 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_margin="4dp"
|
||||
android:background="?rect_selector"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
33
app/src/main/res/layout/artist_detail_header.xml
Normal file
33
app/src/main/res/layout/artist_detail_header.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginBottom="-8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:text="@string/albums"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"/>
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="164dp"
|
||||
android:paddingTop="8dp"
|
||||
android:scrollbars="none"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginTop="-8dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:text="@string/songs"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
android:padding="2dp">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/fragment_album_view"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:padding="2dp">
|
||||
|
||||
<ListView
|
||||
android:id="@+id/recyclerView"
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:dividerHeight="0px"
|
||||
android:divider="@null"
|
||||
android:listSelector="?rect_selector"
|
||||
android:padding="2dp"
|
||||
android:scrollbars="vertical"/>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:listSelector="?rect_selector"
|
||||
android:id="@+id/recyclerView"
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
|
|
|
|||
61
app/src/main/res/layout/item_artist_album.xml
Normal file
61
app/src/main/res/layout/item_artist_album.xml
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<android.support.v7.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="104dp"
|
||||
android:layout_height="148dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:elevation="3dp"
|
||||
android:foreground="?rect_selector">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="104dp"
|
||||
android:layout_height="104dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:transitionName="@string/transition_album_cover"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/materialmusic_default_bar_color">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:transitionName="@string/transition_album_text">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textColor="?attr/title_text_color"
|
||||
android:textSize="12sp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_year"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
|
||||
android:textColor="?attr/caption_text_color"
|
||||
android:textSize="10sp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:background="?rect_selector"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:background="?rect_selector"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
|
|
|
|||
|
|
@ -6,47 +6,49 @@
|
|||
android:background="?rect_selector"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_number"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<com.kabouzeid.gramophone.view.SquareImageView
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="sans-serif"
|
||||
android:background="@drawable/image_background"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
android:scaleType="centerCrop"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_title"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_duration"
|
||||
android:layout_width="40dp"
|
||||
android:id="@+id/song_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="2dp"/>
|
||||
</LinearLayout>
|
||||
52
app/src/main/res/layout/item_song_album.xml
Normal file
52
app/src/main/res/layout/item_song_album.xml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:background="?rect_selector"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/track_number"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="sans-serif"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_duration"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="sans-serif"
|
||||
android:gravity="center"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:id="@+id/menu"
|
||||
style="@style/OverFlowButton"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</LinearLayout>
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
<dimen name="default_item_margin">16dp</dimen>
|
||||
|
||||
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
|
||||
https://developer.android.com/design/patterns/navigation-drawer.html -->
|
||||
<dimen name="navigation_drawer_textsize">14sp</dimen>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue