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));
}
}
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));
}
}
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));
}
}
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));
}
}
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;
}
Aggregations