it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.video.AndroidMovieNodeRenderer Maven / Gradle / Ivy
/***********************************************************************************************************************
* To change this template, choose Tools | Templates
* and open the template in the editor.
**********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.video;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import it.tidalwave.bluebill.mobile.android.R;
import it.tidalwave.bluebill.mobile.android.taxonomy.factsheet.AndroidMediaNodeRenderer;
import it.tidalwave.bluebill.mobile.taxonomy.factsheet.VideoNode;
import it.tidalwave.mobile.media.Movie;
import javax.annotation.Nonnull;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: $
*
**********************************************************************************************************************/
public class AndroidMovieNodeRenderer extends AndroidMediaNodeRenderer
{
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public AndroidMovieNodeRenderer (final @Nonnull Context context)
{
super(context, R.layout.movie_browser_row);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override @Nonnull
public View getView (final @Nonnull VideoNode node, final @Nonnull ViewGroup viewGroup)
throws Exception
{
final View view = super.getView(node, viewGroup);
final TextView tvLabel = (TextView)view.findViewById(R.id.tvLabel);
final TextView tvLocationAndDate = (TextView)view.findViewById(R.id.tvLocationAndDate);
final TextView tvAuthor = (TextView)view.findViewById(R.id.tvAuthor);
final TextView tvRights = (TextView)view.findViewById(R.id.tvRights);
final TextView tvDuration = (TextView)view.findViewById(R.id.tvDuration);
final Movie movie = node.getMovie();
if (movie.containsKey(Movie.DC_TITLE))
{
try
{
tvLabel.setText(movie.get(Movie.DC_TITLE));
}
catch (ClassCastException e) // FIXME: use ad hoc CardinalityException
{
tvLabel.setText(movie.get(Movie.DC_TITLES).toString());
}
String movieId = "";
movieId = movie.getId().stringValue();
movieId = movieId.replaceAll(".*/", "").replaceAll("#.*$", "");
if (movie.containsKey(Movie.DC_ABSTRACT))
{
tvLocationAndDate.setText(movie.get(Movie.DC_ABSTRACT));
}
// tvLocationAndDate.setText(location.as(Displayable).getDisplayName() + " " + df.format(date));
// tvAuthor.setText(author.as(Displayable).getDisplayName() + ", " + source.as(Displayable).getDisplayName() + " " + movieId);
tvAuthor.setText("BBC" + " " + movieId);
renderLicense(tvRights, movie);
// tvDuration.setText(formatDuration(media.get(Media.DURATION)));
tvDuration.setText(formatDuration(0));
}
return view;
}
}