Search in sources :

Example 1 with ObjectUtils

use of com.kickstarter.libs.utils.ObjectUtils in project android-oss by kickstarter.

the class ProjectIntentMapper method project.

/**
   * Returns an observable of projects retrieved from intent data. May hit the API if the intent only contains a project
   * param rather than a parceled project.
   */
@NonNull
public static Observable<Project> project(@NonNull final Intent intent, @NonNull final ApiClientType client) {
    final Project intentProject = projectFromIntent(intent);
    final Observable<Project> projectFromParceledProject = intentProject == null ? Observable.empty() : Observable.just(intentProject).flatMap(client::fetchProject).startWith(intentProject).retry(3);
    final Observable<Project> projectFromParceledParam = Observable.just(paramFromIntent(intent)).filter(ObjectUtils::isNotNull).flatMap(client::fetchProject).retry(3);
    return projectFromParceledProject.mergeWith(projectFromParceledParam).compose(Transformers.neverError());
}
Also used : Project(com.kickstarter.models.Project) ObjectUtils(com.kickstarter.libs.utils.ObjectUtils) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)1 ObjectUtils (com.kickstarter.libs.utils.ObjectUtils)1 Project (com.kickstarter.models.Project)1