Search in sources :

Example 1 with PhilmMovie

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);
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) TextView(android.widget.TextView) PhilmImageView(app.philm.in.view.PhilmImageView)

Example 2 with PhilmMovie

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);
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie)

Example 3 with PhilmMovie

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();
        }
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) DatabaseCompartment(nl.qbusict.cupboard.DatabaseCompartment) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 4 with PhilmMovie

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
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) WatchingMovie(app.philm.in.model.WatchingMovie)

Example 5 with PhilmMovie

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));
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) MoviesState(app.philm.in.state.MoviesState)

Aggregations

PhilmMovie (app.philm.in.model.PhilmMovie)39 MoviesState (app.philm.in.state.MoviesState)17 ArrayList (java.util.ArrayList)4 TextView (android.widget.TextView)2 WatchingMovie (app.philm.in.model.WatchingMovie)2 PhilmImageView (app.philm.in.view.PhilmImageView)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 Bitmap (android.graphics.Bitmap)1 Bundle (android.os.Bundle)1 View (android.view.View)1 Display (app.philm.in.Display)1 ColorScheme (app.philm.in.model.ColorScheme)1 PhilmMovieCredit (app.philm.in.model.PhilmMovieCredit)1 PhilmMovieVideo (app.philm.in.model.PhilmMovieVideo)1 PhilmPerson (app.philm.in.model.PhilmPerson)1 PhilmPersonCredit (app.philm.in.model.PhilmPersonCredit)1 PhilmUserProfile (app.philm.in.model.PhilmUserProfile)1 FetchTmdbDetailMovieRunnable (app.philm.in.tasks.FetchTmdbDetailMovieRunnable)1 FetchTmdbMovieImagesRunnable (app.philm.in.tasks.FetchTmdbMovieImagesRunnable)1 FetchTraktDetailMovieRunnable (app.philm.in.tasks.FetchTraktDetailMovieRunnable)1