Implement drawer switches to have animations. Layout enough of artist fragment to demo this. Try out using dynamic colors based on album art for albums.
This commit is contained in:
@@ -3,7 +3,10 @@ package com.magnatune.eyecreate.companionformagnatune;
|
|||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.transition.Slide;
|
||||||
|
import android.view.Gravity;
|
||||||
|
|
||||||
import com.heinrichreimersoftware.materialdrawer.DrawerActivity;
|
import com.heinrichreimersoftware.materialdrawer.DrawerActivity;
|
||||||
import com.heinrichreimersoftware.materialdrawer.structure.DrawerItem;
|
import com.heinrichreimersoftware.materialdrawer.structure.DrawerItem;
|
||||||
@@ -30,6 +33,7 @@ public class BrowseActivity extends DrawerActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DrawerItem drawerItem, long l, int i) {
|
public void onClick(DrawerItem drawerItem, long l, int i) {
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit)
|
||||||
.replace(R.id.fragment_holder, new AlbumsFragment(), "albums")
|
.replace(R.id.fragment_holder, new AlbumsFragment(), "albums")
|
||||||
.commit();
|
.commit();
|
||||||
closeDrawer();
|
closeDrawer();
|
||||||
@@ -41,7 +45,9 @@ public class BrowseActivity extends DrawerActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DrawerItem drawerItem, long l, int i) {
|
public void onClick(DrawerItem drawerItem, long l, int i) {
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit)
|
||||||
.replace(R.id.fragment_holder, new ArtistFragment(), "artists")
|
.replace(R.id.fragment_holder, new ArtistFragment(), "artists")
|
||||||
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||||
.commit();
|
.commit();
|
||||||
closeDrawer();
|
closeDrawer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.adapters;
|
package com.magnatune.eyecreate.companionformagnatune.adapters;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.support.v7.graphics.Palette;
|
||||||
|
import android.support.v7.widget.CardView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.magnatune.eyecreate.companionformagnatune.R;
|
import com.magnatune.eyecreate.companionformagnatune.R;
|
||||||
import com.magnatune.eyecreate.companionformagnatune.model.Album;
|
import com.magnatune.eyecreate.companionformagnatune.model.Album;
|
||||||
import com.magnatune.eyecreate.companionformagnatune.viewholders.AlbumViewHolder;
|
import com.magnatune.eyecreate.companionformagnatune.viewholders.AlbumViewHolder;
|
||||||
|
import com.squareup.picasso.Callback;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
import io.realm.RealmBasedRecyclerViewAdapter;
|
import io.realm.RealmBasedRecyclerViewAdapter;
|
||||||
@@ -26,9 +30,32 @@ public class AlbumsAdapter extends RealmBasedRecyclerViewAdapter<Album,AlbumView
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindRealmViewHolder(AlbumViewHolder albumViewHolder, int i) {
|
public void onBindRealmViewHolder(final AlbumViewHolder albumViewHolder, int i) {
|
||||||
albumViewHolder.artistName.setText(realmResults.get(i).getArtist());
|
albumViewHolder.artistName.setText(realmResults.get(i).getArtist());
|
||||||
albumViewHolder.albumName.setText(realmResults.get(i).getAlbumname());
|
albumViewHolder.albumName.setText(realmResults.get(i).getAlbumname());
|
||||||
Picasso.with(albumViewHolder.itemView.getContext()).load(realmResults.get(i).getCover_small()).into(albumViewHolder.albumArt);
|
Picasso.with(albumViewHolder.itemView.getContext()).load(realmResults.get(i).getCover_small()).into(albumViewHolder.albumArt, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Palette colors = Palette.from(((BitmapDrawable)albumViewHolder.albumArt.getDrawable()).getBitmap()).generate();
|
||||||
|
Palette.Swatch swatch = null;
|
||||||
|
swatch = colors.getVibrantSwatch();
|
||||||
|
if(swatch == null) {
|
||||||
|
swatch = colors.getMutedSwatch();
|
||||||
|
}
|
||||||
|
if(swatch == null && colors.getSwatches().size()>0) {
|
||||||
|
swatch = colors.getSwatches().get(0);
|
||||||
|
}
|
||||||
|
if(swatch != null) {
|
||||||
|
((CardView)albumViewHolder.itemView).setCardBackgroundColor(swatch.getRgb());
|
||||||
|
albumViewHolder.albumName.setTextColor(swatch.getTitleTextColor());
|
||||||
|
albumViewHolder.artistName.setTextColor(swatch.getBodyTextColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class AlbumsFragment extends Fragment {
|
|||||||
triggerDBUpdate();
|
triggerDBUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recyclerView.setAdapter(new AlbumsAdapter(getActivity(), db.where(Album.class).findAll(), true, true, null));
|
recyclerView.setAdapter(new AlbumsAdapter(getActivity(), db.where(Album.class).findAllSorted("albumname"), true, true, null));
|
||||||
recyclerView.post(new Runnable() {
|
recyclerView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
package com.magnatune.eyecreate.companionformagnatune.fragments;
|
package com.magnatune.eyecreate.companionformagnatune.fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.magnatune.eyecreate.companionformagnatune.R;
|
||||||
|
|
||||||
public class ArtistFragment extends Fragment {
|
public class ArtistFragment extends Fragment {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View v = inflater.inflate(R.layout.fragment_artists,container,false);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
app/src/main/res/anim/fragment_enter.xml
Normal file
8
app/src/main/res/anim/fragment_enter.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set>
|
||||||
|
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromXDelta="100%"
|
||||||
|
android:toXDelta="0"
|
||||||
|
android:interpolator="@android:anim/decelerate_interpolator"
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||||
|
</set>
|
||||||
8
app/src/main/res/anim/fragment_exit.xml
Normal file
8
app/src/main/res/anim/fragment_exit.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<set>
|
||||||
|
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromXDelta="0"
|
||||||
|
android:toXDelta="-100%"
|
||||||
|
android:interpolator="@android:anim/accelerate_interpolator"
|
||||||
|
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||||
|
</set>
|
||||||
9
app/src/main/res/layout/fragment_artists.xml
Normal file
9
app/src/main/res/layout/fragment_artists.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<co.moonmonkeylabs.realmrecyclerview.RealmRecyclerView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/artist_list"
|
||||||
|
app:rrvLayoutType="LinearLayout"
|
||||||
|
app:rrvIsRefreshable="true"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android" />
|
||||||
Reference in New Issue
Block a user