Search in sources :

Example 1 with PhilmPerson

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

the class FetchTmdbPersonRunnable method onSuccess.

@Override
public void onSuccess(Person result) {
    PhilmPerson person = getTmdbPersonEntityMapper().map(result);
    if (person != null && result.movie_credits != null) {
        if (!PhilmCollections.isEmpty(result.movie_credits.cast)) {
            List<PhilmPersonCredit> credits = new ArrayList<>();
            for (PersonCastCredit credit : result.movie_credits.cast) {
                credits.add(new PhilmPersonCredit(credit));
            }
            Collections.sort(credits, PhilmPersonCredit.COMPARATOR_SORT_DATE);
            person.setCastCredits(credits);
        }
        if (!PhilmCollections.isEmpty(result.movie_credits.crew)) {
            List<PhilmPersonCredit> credits = new ArrayList<>();
            for (PersonCrewCredit credit : result.movie_credits.crew) {
                credits.add(new PhilmPersonCredit(credit));
            }
            Collections.sort(credits, PhilmPersonCredit.COMPARATOR_SORT_DATE);
            person.setCrewCredits(credits);
        }
        person.setFetchedCredits(true);
        getEventBus().post(new MoviesState.PersonChangedEvent(getCallingId(), person));
    }
}
Also used : PersonCastCredit(com.uwetrottmann.tmdb.entities.PersonCastCredit) PersonCrewCredit(com.uwetrottmann.tmdb.entities.PersonCrewCredit) ArrayList(java.util.ArrayList) PhilmPerson(app.philm.in.model.PhilmPerson) PhilmPersonCredit(app.philm.in.model.PhilmPersonCredit) MoviesState(app.philm.in.state.MoviesState)

Example 2 with PhilmPerson

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

the class FetchTmdbPersonRunnable method onError.

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

Example 3 with PhilmPerson

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

the class MovieController method fetchPersonIfNeeded.

private void fetchPersonIfNeeded(final int callingId, String id) {
    Preconditions.checkNotNull(id, "id cannot be null");
    PhilmPerson person = mMoviesState.getPerson(id);
    if (person == null || !person.hasFetchedCredits()) {
        fetchPerson(callingId, Integer.parseInt(id));
    }
}
Also used : PhilmPerson(app.philm.in.model.PhilmPerson)

Example 4 with PhilmPerson

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

the class FetchTmdbPersonCreditsRunnable method onError.

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

Example 5 with PhilmPerson

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

the class TmdbCrewEntityMapper method map.

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

Aggregations

PhilmPerson (app.philm.in.model.PhilmPerson)11 MoviesState (app.philm.in.state.MoviesState)5 PhilmPersonCredit (app.philm.in.model.PhilmPersonCredit)3 ArrayList (java.util.ArrayList)3 PersonCastCredit (com.uwetrottmann.tmdb.entities.PersonCastCredit)2 PersonCrewCredit (com.uwetrottmann.tmdb.entities.PersonCrewCredit)2 Bundle (android.os.Bundle)1 TextView (android.widget.TextView)1 Display (app.philm.in.Display)1 ColorScheme (app.philm.in.model.ColorScheme)1 PhilmMovie (app.philm.in.model.PhilmMovie)1 PhilmMovieVideo (app.philm.in.model.PhilmMovieVideo)1 PhilmImageView (app.philm.in.view.PhilmImageView)1 Rating (com.jakewharton.trakt.enumerations.Rating)1 List (java.util.List)1