Back to project page Amphitheatre.
The source code is released under:
Apache License
If you think the Android project Amphitheatre listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2014 Jerrell Mardis//w w w. j a v a2 s. c om * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.jerrellmardis.amphitheatre.widget; import android.content.Context; import android.support.v17.leanback.widget.AbstractDetailsDescriptionPresenter; import com.jerrellmardis.amphitheatre.R; import com.jerrellmardis.amphitheatre.model.Video; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class DetailsDescriptionPresenter extends AbstractDetailsDescriptionPresenter { private Context mContext; public DetailsDescriptionPresenter(Context ctx) { super(); mContext = ctx; } @Override protected void onBindDescription(ViewHolder viewHolder, Object item) { Video video = (Video) item; if (video != null) { viewHolder.getTitle().setText(video.getName()); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); if (video.getMovie() != null) { viewHolder.getBody().setText(video.getOverview()); try { Date date = formatter.parse(video.getMovie().getReleaseDate()); DateFormat df = DateFormat.getDateInstance(); String subtitle = String.format(mContext.getString(R.string.released), df.format(date)); viewHolder.getSubtitle().setText(subtitle); } catch (Exception e) { e.printStackTrace(); } } else { viewHolder.getBody().setText(video.getTvShow().getEpisode().getOverview()); try { Date date = formatter.parse(video.getTvShow().getEpisode().getAirDate()); DateFormat df = DateFormat.getDateInstance(); String subtitle = String.format(mContext.getString(R.string.aired), df.format(date)); viewHolder.getSubtitle().setText(subtitle); } catch (Exception e) { e.printStackTrace(); } } } } }