Merge pull request #154 from poisdeux/sharedelementtransition_musicvideos
Implemented shared element transitions for music videos
This commit is contained in:
commit
05906fe081
|
@ -19,6 +19,7 @@ import android.annotation.TargetApi;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.app.SharedElementCallback;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
@ -66,6 +67,8 @@ public class MusicActivity extends BaseActivity
|
||||||
|
|
||||||
private NavigationDrawerFragment navigationDrawerFragment;
|
private NavigationDrawerFragment navigationDrawerFragment;
|
||||||
|
|
||||||
|
private MusicListFragment musicListFragment;
|
||||||
|
|
||||||
private boolean clearSharedElements;
|
private boolean clearSharedElements;
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
|
@ -80,7 +83,7 @@ public class MusicActivity extends BaseActivity
|
||||||
navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
|
navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
MusicListFragment musicListFragment = new MusicListFragment();
|
musicListFragment = new MusicListFragment();
|
||||||
|
|
||||||
// Setup animations
|
// Setup animations
|
||||||
if (Utils.isLollipopOrLater()) {
|
if (Utils.isLollipopOrLater()) {
|
||||||
|
@ -88,6 +91,16 @@ public class MusicActivity extends BaseActivity
|
||||||
musicListFragment.setReenterTransition(TransitionInflater
|
musicListFragment.setReenterTransition(TransitionInflater
|
||||||
.from(this)
|
.from(this)
|
||||||
.inflateTransition(android.R.transition.fade));
|
.inflateTransition(android.R.transition.fade));
|
||||||
|
musicListFragment.setExitSharedElementCallback(new SharedElementCallback() {
|
||||||
|
@Override
|
||||||
|
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
|
||||||
|
if (clearSharedElements) {
|
||||||
|
names.clear();
|
||||||
|
sharedElements.clear();
|
||||||
|
clearSharedElements = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
|
@ -360,20 +373,46 @@ public class MusicActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(21)
|
@TargetApi(21)
|
||||||
public void onMusicVideoSelected(int musicVideoId, String musicVideoTitle) {
|
public void onMusicVideoSelected(MusicVideoListFragment.ViewHolder vh) {
|
||||||
selectedMusicVideoId = musicVideoId;
|
selectedMusicVideoId = vh.musicVideoId;
|
||||||
selectedMusicVideoTitle = musicVideoTitle;
|
selectedMusicVideoTitle = vh.musicVideoTitle;
|
||||||
|
|
||||||
// Replace list fragment
|
// Replace list fragment
|
||||||
MusicVideoDetailsFragment detailsFragment = MusicVideoDetailsFragment.newInstance(musicVideoId);
|
final MusicVideoDetailsFragment detailsFragment = MusicVideoDetailsFragment.newInstance(vh);
|
||||||
FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
// Set up transitions
|
// Set up transitions
|
||||||
if (Utils.isLollipopOrLater()) {
|
if (Utils.isLollipopOrLater()) {
|
||||||
|
android.support.v4.app.SharedElementCallback seCallback = new android.support.v4.app.SharedElementCallback() {
|
||||||
|
@Override
|
||||||
|
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
|
||||||
|
//On returning onMapSharedElements for the exiting fragment is called before the onMapSharedElements
|
||||||
|
// for the reentering fragment. We use this to determine if we are returning and if
|
||||||
|
// we should clear the shared element lists. Note that, clearing must be done in the reentering fragment
|
||||||
|
// as this is called last. Otherwise it the app will crash during transition setup. Not sure, but might
|
||||||
|
// be a v4 support package bug.
|
||||||
|
if (detailsFragment.isVisible()) {
|
||||||
|
View sharedView = detailsFragment.getSharedElement();
|
||||||
|
if (sharedView == null) { // shared element not visible
|
||||||
|
LogUtils.LOGD(TAG, "onMusicVideoSelected: setting clearedSharedElements to true");
|
||||||
|
clearSharedElements = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
detailsFragment.setEnterSharedElementCallback(seCallback);
|
||||||
|
|
||||||
detailsFragment.setEnterTransition(TransitionInflater
|
detailsFragment.setEnterTransition(TransitionInflater
|
||||||
.from(this)
|
.from(this)
|
||||||
.inflateTransition(R.transition.media_details));
|
.inflateTransition(R.transition.media_details));
|
||||||
detailsFragment.setReturnTransition(null);
|
detailsFragment.setReturnTransition(null);
|
||||||
|
|
||||||
|
Transition changeImageTransition = TransitionInflater.from(
|
||||||
|
this).inflateTransition(R.transition.change_image);
|
||||||
|
detailsFragment.setSharedElementReturnTransition(changeImageTransition);
|
||||||
|
detailsFragment.setSharedElementEnterTransition(changeImageTransition);
|
||||||
|
|
||||||
|
fragTrans.addSharedElement(vh.artView, vh.artView.getTransitionName());
|
||||||
} else {
|
} else {
|
||||||
fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0,
|
fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0,
|
||||||
R.anim.fragment_list_popenter, 0);
|
R.anim.fragment_list_popenter, 0);
|
||||||
|
@ -382,6 +421,6 @@ public class MusicActivity extends BaseActivity
|
||||||
fragTrans.replace(R.id.fragment_container, detailsFragment)
|
fragTrans.replace(R.id.fragment_container, detailsFragment)
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit();
|
.commit();
|
||||||
setupActionBar(null, null, null, musicVideoTitle);
|
setupActionBar(null, null, null, selectedMusicVideoTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.xbmc.kore.ui;
|
package org.xbmc.kore.ui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -55,6 +56,7 @@ import org.xbmc.kore.service.LibrarySyncService;
|
||||||
import org.xbmc.kore.utils.FileDownloadHelper;
|
import org.xbmc.kore.utils.FileDownloadHelper;
|
||||||
import org.xbmc.kore.utils.LogUtils;
|
import org.xbmc.kore.utils.LogUtils;
|
||||||
import org.xbmc.kore.utils.UIUtils;
|
import org.xbmc.kore.utils.UIUtils;
|
||||||
|
import org.xbmc.kore.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -70,7 +72,15 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
private static final String TAG = LogUtils.makeLogTag(MusicVideoDetailsFragment.class);
|
private static final String TAG = LogUtils.makeLogTag(MusicVideoDetailsFragment.class);
|
||||||
|
|
||||||
public static final String MUSICVIDEOID = "music_video_id";
|
public static final String BUNDLE_KEY_ID = "music_video_id";
|
||||||
|
public static final String BUNDLE_KEY_ALBUM = "album";
|
||||||
|
public static final String POSTER_TRANS_NAME = "POSTER_TRANS_NAME";
|
||||||
|
public static final String BUNDLE_KEY_ARTIST = "artist";
|
||||||
|
public static final String BUNDLE_KEY_TITLE = "title";
|
||||||
|
public static final String BUNDLE_KEY_GENRES = "genre";
|
||||||
|
public static final String BUNDLE_KEY_YEAR = "year";
|
||||||
|
public static final String BUNDLE_KEY_PLOT = "plot";
|
||||||
|
public static final String BUNDLE_KEY_RUNTIME = "runtime";
|
||||||
|
|
||||||
// Loader IDs
|
// Loader IDs
|
||||||
private static final int LOADER_MUSIC_VIDEO = 0;
|
private static final int LOADER_MUSIC_VIDEO = 0;
|
||||||
|
@ -114,18 +124,32 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
/**
|
/**
|
||||||
* Create a new instance of this, initialized to show the video musicVideoId
|
* Create a new instance of this, initialized to show the video musicVideoId
|
||||||
*/
|
*/
|
||||||
public static MusicVideoDetailsFragment newInstance(int musicVideoId) {
|
@TargetApi(21)
|
||||||
|
public static MusicVideoDetailsFragment newInstance(MusicVideoListFragment.ViewHolder vh) {
|
||||||
MusicVideoDetailsFragment fragment = new MusicVideoDetailsFragment();
|
MusicVideoDetailsFragment fragment = new MusicVideoDetailsFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt(MUSICVIDEOID, musicVideoId);
|
args.putInt(BUNDLE_KEY_ID, vh.musicVideoId);
|
||||||
|
args.putString(BUNDLE_KEY_TITLE, vh.musicVideoTitle);
|
||||||
|
args.putString(BUNDLE_KEY_ALBUM, vh.album);
|
||||||
|
args.putString(BUNDLE_KEY_ARTIST, vh.artist);
|
||||||
|
args.putString(BUNDLE_KEY_GENRES, vh.genres);
|
||||||
|
args.putString(BUNDLE_KEY_PLOT, vh.plot);
|
||||||
|
args.putInt(BUNDLE_KEY_RUNTIME, vh.runtime);
|
||||||
|
args.putInt(BUNDLE_KEY_YEAR, vh.year);
|
||||||
|
|
||||||
|
if( Utils.isLollipopOrLater()) {
|
||||||
|
args.putString(POSTER_TRANS_NAME, vh.artView.getTransitionName());
|
||||||
|
}
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(21)
|
||||||
@Override
|
@Override
|
||||||
protected View createView(LayoutInflater inflater, ViewGroup container) {
|
protected View createView(LayoutInflater inflater, ViewGroup container) {
|
||||||
musicVideoId = getArguments().getInt(MUSICVIDEOID, -1);
|
Bundle bundle = getArguments();
|
||||||
|
musicVideoId = bundle.getInt(BUNDLE_KEY_ID, -1);
|
||||||
|
|
||||||
if (musicVideoId == -1) {
|
if (musicVideoId == -1) {
|
||||||
// There's nothing to show
|
// There's nothing to show
|
||||||
|
@ -152,6 +176,16 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
FloatingActionButton fab = (FloatingActionButton)fabButton;
|
FloatingActionButton fab = (FloatingActionButton)fabButton;
|
||||||
fab.attachToScrollView((ObservableScrollView) mediaPanel);
|
fab.attachToScrollView((ObservableScrollView) mediaPanel);
|
||||||
|
|
||||||
|
mediaTitle.setText(bundle.getString(BUNDLE_KEY_TITLE));
|
||||||
|
setMediaUndertitle(bundle.getString(BUNDLE_KEY_ARTIST), bundle.getString(BUNDLE_KEY_ALBUM));
|
||||||
|
setMediaYear(bundle.getInt(BUNDLE_KEY_RUNTIME), bundle.getInt(BUNDLE_KEY_YEAR));
|
||||||
|
mediaGenres.setText(bundle.getString(BUNDLE_KEY_GENRES));
|
||||||
|
mediaDescription.setText(bundle.getString(BUNDLE_KEY_PLOT));
|
||||||
|
|
||||||
|
if(Utils.isLollipopOrLater()) {
|
||||||
|
mediaPoster.setTransitionName(bundle.getString(POSTER_TRANS_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
// Pad main content view to overlap with bottom system bar
|
// Pad main content view to overlap with bottom system bar
|
||||||
// UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true);
|
// UIUtils.setPaddingForSystemBars(getActivity(), mediaPanel, false, false, true);
|
||||||
// mediaPanel.setClipToPadding(false);
|
// mediaPanel.setClipToPadding(false);
|
||||||
|
@ -380,16 +414,11 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
String musicVideoTitle = cursor.getString(MusicVideoDetailsQuery.TITLE);
|
String musicVideoTitle = cursor.getString(MusicVideoDetailsQuery.TITLE);
|
||||||
mediaTitle.setText(musicVideoTitle);
|
mediaTitle.setText(musicVideoTitle);
|
||||||
String artistAlbum = cursor.getString(MusicVideoDetailsQuery.ARTIST) + " | " +
|
|
||||||
cursor.getString(MusicVideoDetailsQuery.ALBUM);
|
|
||||||
mediaUndertitle.setText(artistAlbum);
|
|
||||||
|
|
||||||
int runtime = cursor.getInt(MusicVideoDetailsQuery.RUNTIME);
|
setMediaUndertitle(cursor.getString(MusicVideoDetailsQuery.ARTIST), cursor.getString(MusicVideoDetailsQuery.ALBUM));
|
||||||
String durationYear = runtime > 0 ?
|
|
||||||
UIUtils.formatTime(runtime) + " | " +
|
setMediaYear(cursor.getInt(MusicVideoDetailsQuery.RUNTIME), cursor.getInt(MusicVideoDetailsQuery.YEAR));
|
||||||
String.valueOf(cursor.getInt(MusicVideoDetailsQuery.YEAR)) :
|
|
||||||
String.valueOf(cursor.getInt(MusicVideoDetailsQuery.YEAR));
|
|
||||||
mediaYear.setText(durationYear);
|
|
||||||
mediaGenres.setText(cursor.getString(MusicVideoDetailsQuery.GENRES));
|
mediaGenres.setText(cursor.getString(MusicVideoDetailsQuery.GENRES));
|
||||||
|
|
||||||
mediaDescription.setText(cursor.getString(MusicVideoDetailsQuery.PLOT));
|
mediaDescription.setText(cursor.getString(MusicVideoDetailsQuery.PLOT));
|
||||||
|
@ -404,41 +433,20 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
|
|
||||||
int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
|
int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
|
||||||
artWidth = displayMetrics.widthPixels;
|
artWidth = displayMetrics.widthPixels;
|
||||||
if (!TextUtils.isEmpty(fanart)) {
|
int posterWidth = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
|
||||||
int posterWidth = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
|
int posterHeight = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
|
||||||
int posterHeight = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_heigth);
|
UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(),
|
||||||
mediaPoster.setVisibility(View.VISIBLE);
|
poster, musicVideoTitle,
|
||||||
UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(),
|
mediaPoster, posterWidth, posterHeight);
|
||||||
poster, musicVideoTitle,
|
UIUtils.loadImageIntoImageview(getHostManager(),
|
||||||
mediaPoster, posterWidth, posterHeight);
|
TextUtils.isEmpty(fanart)? poster : fanart,
|
||||||
UIUtils.loadImageIntoImageview(getHostManager(),
|
mediaArt, artWidth, artHeight);
|
||||||
fanart,
|
|
||||||
mediaArt, artWidth, artHeight);
|
|
||||||
} else {
|
|
||||||
// No fanart, just present the poster
|
|
||||||
mediaPoster.setVisibility(View.GONE);
|
|
||||||
UIUtils.loadImageIntoImageview(getHostManager(),
|
|
||||||
poster,
|
|
||||||
mediaArt, artWidth, artHeight);
|
|
||||||
// Reset padding
|
|
||||||
int paddingLeft = mediaTitle.getPaddingRight(),
|
|
||||||
paddingRight = mediaTitle.getPaddingRight(),
|
|
||||||
paddingTop = mediaTitle.getPaddingTop(),
|
|
||||||
paddingBottom = mediaTitle.getPaddingBottom();
|
|
||||||
mediaTitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
|
||||||
mediaUndertitle.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Setup download info
|
// Setup download info
|
||||||
musicVideoDownloadInfo = new FileDownloadHelper.MusicVideoInfo(
|
musicVideoDownloadInfo = new FileDownloadHelper.MusicVideoInfo(
|
||||||
musicVideoTitle, cursor.getString(MusicVideoDetailsQuery.FILE));
|
musicVideoTitle, cursor.getString(MusicVideoDetailsQuery.FILE));
|
||||||
|
|
||||||
// Check if downloaded file exists
|
// Check if downloaded file exists
|
||||||
downloadButton.setVisibility(View.VISIBLE);
|
|
||||||
if (musicVideoDownloadInfo.downloadFileExists()) {
|
if (musicVideoDownloadInfo.downloadFileExists()) {
|
||||||
Resources.Theme theme = getActivity().getTheme();
|
Resources.Theme theme = getActivity().getTheme();
|
||||||
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[]{
|
TypedArray styledAttributes = theme.obtainStyledAttributes(new int[]{
|
||||||
|
@ -452,6 +460,30 @@ public class MusicVideoDetailsFragment extends AbstractDetailsFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setMediaUndertitle(String artist, String album) {
|
||||||
|
mediaUndertitle.setText(artist + " | " + album);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMediaYear(int runtime, int year) {
|
||||||
|
String durationYear = runtime > 0 ?
|
||||||
|
UIUtils.formatTime(runtime) + " | " +
|
||||||
|
String.valueOf(year) :
|
||||||
|
String.valueOf(year);
|
||||||
|
mediaYear.setText(durationYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shared element if visible
|
||||||
|
* @return View if visible, null otherwise
|
||||||
|
*/
|
||||||
|
public View getSharedElement() {
|
||||||
|
if (UIUtils.isViewInBounds(mediaPanel, mediaPoster)) {
|
||||||
|
return mediaPoster;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video details query parameters.
|
* Video details query parameters.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.xbmc.kore.ui;
|
package org.xbmc.kore.ui;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -44,6 +45,7 @@ import org.xbmc.kore.provider.MediaDatabase;
|
||||||
import org.xbmc.kore.service.LibrarySyncService;
|
import org.xbmc.kore.service.LibrarySyncService;
|
||||||
import org.xbmc.kore.utils.LogUtils;
|
import org.xbmc.kore.utils.LogUtils;
|
||||||
import org.xbmc.kore.utils.UIUtils;
|
import org.xbmc.kore.utils.UIUtils;
|
||||||
|
import org.xbmc.kore.utils.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment that presents the artists list
|
* Fragment that presents the artists list
|
||||||
|
@ -52,7 +54,7 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
private static final String TAG = LogUtils.makeLogTag(MusicVideoListFragment.class);
|
private static final String TAG = LogUtils.makeLogTag(MusicVideoListFragment.class);
|
||||||
|
|
||||||
public interface OnMusicVideoSelectedListener {
|
public interface OnMusicVideoSelectedListener {
|
||||||
public void onMusicVideoSelected(int musicVideoId, String musicVideoTitle);
|
public void onMusicVideoSelected(ViewHolder vh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activity listener
|
// Activity listener
|
||||||
|
@ -69,7 +71,7 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
// Get the movie id from the tag
|
// Get the movie id from the tag
|
||||||
ViewHolder tag = (ViewHolder)view.getTag();
|
ViewHolder tag = (ViewHolder)view.getTag();
|
||||||
// Notify the activity
|
// Notify the activity
|
||||||
listenerActivity.onMusicVideoSelected(tag.musicVideoId, tag.musicVideoTitle);
|
listenerActivity.onMusicVideoSelected(tag);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -141,6 +143,8 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
MediaContract.MusicVideos.THUMBNAIL,
|
MediaContract.MusicVideos.THUMBNAIL,
|
||||||
MediaContract.MusicVideos.RUNTIME,
|
MediaContract.MusicVideos.RUNTIME,
|
||||||
MediaContract.MusicVideos.GENRES,
|
MediaContract.MusicVideos.GENRES,
|
||||||
|
MediaContract.MusicVideos.YEAR,
|
||||||
|
MediaContract.MusicVideos.PLOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
String SORT = MediaDatabase.sortCommonTokens(MediaContract.MusicVideos.TITLE) + " ASC";
|
String SORT = MediaDatabase.sortCommonTokens(MediaContract.MusicVideos.TITLE) + " ASC";
|
||||||
|
@ -153,6 +157,8 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
final int THUMBNAIL = 5;
|
final int THUMBNAIL = 5;
|
||||||
final int RUNTIME = 6;
|
final int RUNTIME = 6;
|
||||||
final int GENRES = 7;
|
final int GENRES = 7;
|
||||||
|
final int YEAR = 8;
|
||||||
|
final int PLOT = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MusicVideosAdapter extends CursorAdapter {
|
private static class MusicVideosAdapter extends CursorAdapter {
|
||||||
|
@ -166,10 +172,8 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
|
|
||||||
// Get the art dimensions
|
// Get the art dimensions
|
||||||
Resources resources = context.getResources();
|
Resources resources = context.getResources();
|
||||||
artWidth = (int)(resources.getDimension(R.dimen.musicvideolist_art_width) /
|
artHeight = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_heigth);
|
||||||
UIUtils.IMAGE_RESIZE_FACTOR);
|
artWidth = resources.getDimensionPixelOffset(R.dimen.musicvideodetail_poster_width);
|
||||||
artHeight = (int)(resources.getDimension(R.dimen.musicvideolist_art_heigth) /
|
|
||||||
UIUtils.IMAGE_RESIZE_FACTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -190,6 +194,7 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@TargetApi(21)
|
||||||
@Override
|
@Override
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
final ViewHolder viewHolder = (ViewHolder)view.getTag();
|
final ViewHolder viewHolder = (ViewHolder)view.getTag();
|
||||||
|
@ -197,28 +202,37 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
// Save the movie id
|
// Save the movie id
|
||||||
viewHolder.musicVideoId = cursor.getInt(MusicVideosListQuery.MUSICVIDEOID);
|
viewHolder.musicVideoId = cursor.getInt(MusicVideosListQuery.MUSICVIDEOID);
|
||||||
viewHolder.musicVideoTitle = cursor.getString(MusicVideosListQuery.TITLE);
|
viewHolder.musicVideoTitle = cursor.getString(MusicVideosListQuery.TITLE);
|
||||||
|
viewHolder.album = cursor.getString(MusicVideosListQuery.ALBUM);
|
||||||
|
viewHolder.artist = cursor.getString(MusicVideosListQuery.ARTIST);
|
||||||
|
viewHolder.genres = cursor.getString(MusicVideosListQuery.GENRES);
|
||||||
|
viewHolder.plot = cursor.getString(MusicVideosListQuery.PLOT);
|
||||||
|
viewHolder.runtime = cursor.getInt(MusicVideosListQuery.RUNTIME);
|
||||||
|
viewHolder.year = cursor.getInt(MusicVideosListQuery.YEAR);
|
||||||
|
|
||||||
viewHolder.titleView.setText(viewHolder.musicVideoTitle);
|
viewHolder.titleView.setText(viewHolder.musicVideoTitle);
|
||||||
String artistAlbum = cursor.getString(MusicVideosListQuery.ARTIST) + " | " +
|
String artistAlbum = viewHolder.artist + " | " +
|
||||||
cursor.getString(MusicVideosListQuery.ALBUM);
|
viewHolder.album;
|
||||||
viewHolder.artistAlbumView.setText(artistAlbum);
|
viewHolder.artistAlbumView.setText(artistAlbum);
|
||||||
|
|
||||||
int runtime = cursor.getInt(MusicVideosListQuery.RUNTIME);
|
|
||||||
String durationGenres =
|
String durationGenres =
|
||||||
runtime > 0 ?
|
viewHolder.runtime > 0 ?
|
||||||
UIUtils.formatTime(runtime) + " | " + cursor.getString(MusicVideosListQuery.GENRES) :
|
UIUtils.formatTime(viewHolder.runtime) + " | " + viewHolder.genres :
|
||||||
cursor.getString(MusicVideosListQuery.GENRES);
|
viewHolder.genres;
|
||||||
viewHolder.durationGenresView.setText(durationGenres);
|
viewHolder.durationGenresView.setText(durationGenres);
|
||||||
UIUtils.loadImageWithCharacterAvatar(context, hostManager,
|
UIUtils.loadImageWithCharacterAvatar(context, hostManager,
|
||||||
cursor.getString(MusicVideosListQuery.THUMBNAIL), viewHolder.musicVideoTitle,
|
cursor.getString(MusicVideosListQuery.THUMBNAIL), viewHolder.musicVideoTitle,
|
||||||
viewHolder.artView, artWidth, artHeight);
|
viewHolder.artView, artWidth, artHeight);
|
||||||
|
|
||||||
|
if(Utils.isLollipopOrLater()) {
|
||||||
|
viewHolder.artView.setTransitionName("a"+viewHolder.musicVideoId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View holder pattern
|
* View holder pattern
|
||||||
*/
|
*/
|
||||||
private static class ViewHolder {
|
public static class ViewHolder {
|
||||||
TextView titleView;
|
TextView titleView;
|
||||||
TextView artistAlbumView;
|
TextView artistAlbumView;
|
||||||
TextView durationGenresView;
|
TextView durationGenresView;
|
||||||
|
@ -226,5 +240,11 @@ public class MusicVideoListFragment extends AbstractListFragment {
|
||||||
|
|
||||||
int musicVideoId;
|
int musicVideoId;
|
||||||
String musicVideoTitle;
|
String musicVideoTitle;
|
||||||
|
String artist;
|
||||||
|
String album;
|
||||||
|
int runtime;
|
||||||
|
String genres;
|
||||||
|
int year;
|
||||||
|
String plot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
style="@style/Widget.Button.Borderless"
|
style="@style/Widget.Button.Borderless"
|
||||||
android:src="?attr/iconDownload"
|
android:src="?attr/iconDownload"
|
||||||
android:contentDescription="@string/download"
|
android:contentDescription="@string/download"/>
|
||||||
android:visibility="gone"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
Loading…
Reference in New Issue