use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.
the class MovieSectionedListAdapter method bindView.
@Override
protected void bindView(int position, View view, ListItem<PhilmMovie> item) {
PhilmMovie movie = item.getListItem();
final TextView title = (TextView) view.findViewById(R.id.textview_title);
if (movie.getYear() > 0) {
title.setText(mActivity.getString(R.string.movie_title_year, movie.getTitle(), movie.getYear()));
} else {
title.setText(movie.getTitle());
}
final TextView ratingTextView = (TextView) view.findViewById(R.id.textview_subtitle_1);
ratingTextView.setText(mActivity.getString(R.string.movie_rating_votes, movie.getAverageRatingPercent(), movie.getAverageRatingVotes()));
final TextView release = (TextView) view.findViewById(R.id.textview_subtitle_2);
mDate.setTime(movie.getReleasedTime());
release.setText(mActivity.getString(R.string.movie_release_date, mMediumDateFormatter.format(mDate)));
final PhilmImageView imageView = (PhilmImageView) view.findViewById(R.id.imageview_poster);
imageView.loadPoster(movie);
}
use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.
the class MovieController method fetchDetailMovieIfNeeded.
private void fetchDetailMovieIfNeeded(final int callingId, String id) {
Preconditions.checkNotNull(id, "id cannot be null");
PhilmMovie cached = mMoviesState.getMovie(id);
if (cached == null) {
fetchDetailMovie(callingId, id);
} else {
fetchDetailMovieIfNeeded(callingId, cached, false);
}
}
use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.
the class PhilmSQLiteOpenHelper method delete.
@Override
public void delete(Collection<PhilmMovie> movies) {
assetNotClosed();
SQLiteDatabase db = null;
try {
db = getWritableDatabase();
db.beginTransaction();
final DatabaseCompartment dbc = cupboard().withDatabase(db);
for (PhilmMovie movie : movies) {
dbc.delete(movie);
}
db.setTransactionSuccessful();
} catch (Exception e) {
// Crashlytics.logException(e);
} finally {
if (db != null) {
db.endTransaction();
}
}
}
use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.
the class CheckinTraktRunnable method onSuccess.
@Override
public void onSuccess(CheckinResponse result) {
if (RESULT_TRAKT_SUCCESS.equals(result.status)) {
PhilmMovie movie = getTraktMovieEntityMapper().map(result.movie);
if (movie != null) {
long startTime = 0;
int duration = 0;
if (result.timestamps != null) {
startTime = result.timestamps.start.getTime();
duration = result.timestamps.active_for * 1000;
}
WatchingMovie watchingMovie = new WatchingMovie(movie, WatchingMovie.Type.CHECKIN, startTime, duration);
mMoviesState.setWatchingMovie(watchingMovie);
}
} else if (RESULT_TRAKT_FAILURE.equals(result.status)) {
// TODO Check time out, etc
}
}
use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.
the class FetchTmdbDetailMovieRunnable method onSuccess.
@Override
public void onSuccess(Movie result) {
PhilmMovie movie = getTmdbMovieEntityMapper().map(result);
movie.markFullFetchCompleted(PhilmModel.TYPE_TMDB);
// Need to manually update releases here due to country code
if (result.releases != null) {
movie.updateWithReleases(result.releases, getCountryProvider().getTwoLetterCountryCode());
}
// Need to manually update releases here due to entity mapper
if (result.similar_movies != null) {
movie.setRelated(getTmdbMovieEntityMapper().mapAll(result.similar_movies.results));
}
if (result.credits != null && !PhilmCollections.isEmpty(result.credits.cast)) {
movie.setCast(getTmdbCastEntityMapper().mapCredits(result.credits.cast));
}
if (result.credits != null && !PhilmCollections.isEmpty(result.credits.crew)) {
movie.setCrew(getTmdbCrewEntityMapper().mapCredits(result.credits.crew));
}
checkPhilmState(movie);
getDbHelper().put(movie);
getEventBus().post(new MoviesState.MovieInformationUpdatedEvent(getCallingId(), movie));
}
Aggregations