Search in sources :

Example 21 with PhilmMovie

use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.

the class MovieController method populateMovieListUi.

private void populateMovieListUi(MovieListUi ui) {
    final MovieQueryType queryType = ui.getMovieQueryType();
    Set<MovieFilter> filters = null;
    if (isLoggedIn()) {
        if (queryType.supportFiltering()) {
            ui.setFiltersVisibility(true);
            filters = mMoviesState.getFilters();
            ui.showActiveFilters(filters);
        }
    } else {
        ui.setFiltersVisibility(false);
    }
    List<PhilmMovie> items = null;
    List<MovieFilter> sections = queryType.getSections();
    List<MovieFilter> sectionProcessingOrder = queryType.getSectionsProcessingOrder();
    switch(queryType) {
        case TRENDING:
            items = mMoviesState.getTrending();
            break;
        case POPULAR:
            MoviesState.MoviePaginatedResult popular = mMoviesState.getPopular();
            if (popular != null) {
                items = popular.items;
            }
            break;
        case LIBRARY:
            items = mMoviesState.getLibrary();
            break;
        case WATCHLIST:
            items = mMoviesState.getWatchlist();
            break;
        case SEARCH_MOVIES:
            MoviesState.SearchResult searchResult = mMoviesState.getSearchResult();
            if (searchResult != null && searchResult.movies != null) {
                items = searchResult.movies.items;
            }
            break;
        case NOW_PLAYING:
            MoviesState.MoviePaginatedResult nowPlaying = mMoviesState.getNowPlaying();
            if (nowPlaying != null) {
                items = nowPlaying.items;
            }
            break;
        case UPCOMING:
            MoviesState.MoviePaginatedResult upcoming = mMoviesState.getUpcoming();
            if (upcoming != null) {
                items = upcoming.items;
            }
            break;
        case RECOMMENDED:
            items = mMoviesState.getRecommended();
            break;
        case MOVIE_RELATED:
            PhilmMovie movie = mMoviesState.getMovie(ui.getRequestParameter());
            if (movie != null) {
                items = movie.getRelated();
            }
            break;
    }
    if (!PhilmCollections.isEmpty(items)) {
        // Always filter movies (for adult)
        items = filterMovies(items, filters);
    }
    if (items == null) {
        ui.setItems(null);
    } else if (PhilmCollections.isEmpty(sections)) {
        ui.setItems(createListItemList(items));
        if (isLoggedIn()) {
            ui.allowedBatchOperations(MovieOperation.MARK_SEEN, MovieOperation.ADD_TO_COLLECTION, MovieOperation.ADD_TO_WATCHLIST);
        } else {
            ui.disableBatchOperations();
        }
    } else {
        ui.setItems(createSectionedListItemList(items, sections, sectionProcessingOrder));
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) MoviesState(app.philm.in.state.MoviesState)

Example 22 with PhilmMovie

use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.

the class BaseTraktActionRunnable method onActionCompleted.

private void onActionCompleted(final boolean successful) {
    if (successful) {
        ArrayList<PhilmMovie> result = new ArrayList<>(mIds.length);
        for (int i = 0; i < mIds.length; i++) {
            PhilmMovie movie = onSuccessfulAction(mIds[i]);
            if (movie != null) {
                result.add(movie);
            }
        }
        getEventBus().post(new MoviesState.MovieFlagsUpdatedEvent(getCallingId(), result));
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) ArrayList(java.util.ArrayList) MoviesState(app.philm.in.state.MoviesState)

Example 23 with PhilmMovie

use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.

the class FetchTmdbMovieCreditsRunnable method onError.

@Override
public void onError(RetrofitError re) {
    super.onError(re);
    PhilmMovie movie = mMoviesState.getMovie(mId);
    if (movie != null) {
        getEventBus().post(new MoviesState.MovieCastItemsUpdatedEvent(getCallingId(), movie));
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) MoviesState(app.philm.in.state.MoviesState)

Example 24 with PhilmMovie

use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.

the class FetchTmdbMovieTrailersRunnable method onError.

@Override
public void onError(RetrofitError re) {
    super.onError(re);
    PhilmMovie movie = mMoviesState.getMovie(mId);
    if (movie != null) {
        getEventBus().post(new MoviesState.MovieVideosItemsUpdatedEvent(getCallingId(), movie));
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) MoviesState(app.philm.in.state.MoviesState)

Example 25 with PhilmMovie

use of app.philm.in.model.PhilmMovie in project philm by chrisbanes.

the class TmdbMovieEntityMapper method map.

@Override
public PhilmMovie map(Movie entity) {
    PhilmMovie movie = getEntity(String.valueOf(entity.id));
    if (movie == null && entity.imdb_id != null) {
        movie = getEntity(entity.imdb_id);
    }
    if (movie == null) {
        // No movie, so create one
        movie = new PhilmMovie();
    }
    // We already have a movie, so just update it wrapped value
    movie.setFromMovie(entity);
    putEntity(movie);
    return movie;
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie)

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