use of com.kickstarter.models.Update in project android-oss by kickstarter.
the class CommentsViewModelTest method testCommentsViewModel_EmptyState.
@Test
public void testCommentsViewModel_EmptyState() {
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<CommentsEnvelope> fetchComments(@NonNull final Update update) {
return Observable.empty();
}
};
final Environment env = environment().toBuilder().apiClient(apiClient).build();
final CommentsViewModel vm = new CommentsViewModel(env);
final TestSubscriber<CommentsData> commentsData = new TestSubscriber<>();
vm.outputs.commentsData().subscribe(commentsData);
// Start the view model with an update.
vm.intent(new Intent().putExtra(IntentKey.UPDATE, UpdateFactory.update()));
// Only Viewed Comments event should fire.
koalaTest.assertValues(KoalaEvent.VIEWED_COMMENTS);
commentsData.assertNoValues();
}
use of com.kickstarter.models.Update in project android-oss by kickstarter.
the class ProjectUpdateViewHolder method onBind.
@Override
public void onBind() {
final Context context = context();
final Project project = activity().project();
if (project == null) {
return;
}
final User user = activity().user();
if (user == null) {
return;
}
final Photo photo = project.photo();
if (photo == null) {
return;
}
final Update update = activity().update();
if (update == null) {
return;
}
final DateTime publishedAt = ObjectUtils.coalesce(update.publishedAt(), new DateTime());
projectNameTextView.setText(project.name());
Picasso.with(context).load(photo.little()).into(projectPhotoImageView);
timestampTextView.setText(DateTimeUtils.relative(context, ksString, publishedAt));
updateBodyTextView.setText(update.truncatedBody());
updateSequenceTextView.setText(ksString.format(projectUpdateCountString, "update_count", String.valueOf(update.sequence())));
updateTitleTextView.setText(update.title());
}
use of com.kickstarter.models.Update in project android-oss by kickstarter.
the class PushNotifications method fetchUpdateWithEnvelope.
@Nullable
private Observable<Pair<PushNotificationEnvelope, Update>> fetchUpdateWithEnvelope(@NonNull final PushNotificationEnvelope envelope) {
final Activity activity = envelope.activity();
if (activity == null) {
return null;
}
final Long updateId = activity.updateId();
if (updateId == null) {
return null;
}
final Long projectId = activity.projectId();
if (projectId == null) {
return null;
}
final String projectParam = ObjectUtils.toString(projectId);
final String updateParam = ObjectUtils.toString(updateId);
final Observable<Update> update = client.fetchUpdate(projectParam, updateParam).compose(Transformers.neverError());
return Observable.just(envelope).compose(Transformers.combineLatestPair(update));
}
use of com.kickstarter.models.Update in project android-oss by kickstarter.
the class KoalaUtils method activityProperties.
@NonNull
public static Map<String, Object> activityProperties(@NonNull final Activity activity, @NonNull final String prefix) {
Map<String, Object> properties = new HashMap<String, Object>() {
{
put("category", activity.category());
}
};
properties = MapUtils.prefixKeys(properties, prefix);
final Project project = activity.project();
if (project != null) {
properties.putAll(projectProperties(project));
final Update update = activity.update();
if (update != null) {
properties.putAll(updateProperties(project, update));
}
}
return properties;
}
use of com.kickstarter.models.Update in project android-oss by kickstarter.
the class UpdateViewModelTest method testUpdateViewModel_LoadsWebViewUrl.
@Test
public void testUpdateViewModel_LoadsWebViewUrl() {
final UpdateViewModel.ViewModel vm = new UpdateViewModel.ViewModel(environment());
final Update update = UpdateFactory.update();
final String anotherUpdateUrl = "https://kck.str/projects/param/param/posts/next-id";
final Request anotherUpdateRequest = new Request.Builder().url(anotherUpdateUrl).build();
final TestSubscriber<String> webViewUrl = new TestSubscriber<>();
vm.outputs.webViewUrl().subscribe(webViewUrl);
// Start the intent with a project and update.
vm.intent(defaultIntent);
// Initial update's url emits.
webViewUrl.assertValues(update.urls().web().update());
// Make a request for another update.
vm.inputs.goToUpdateRequest(anotherUpdateRequest);
// New update url emits.
webViewUrl.assertValues(update.urls().web().update(), anotherUpdateUrl);
}
Aggregations