use of com.kickstarter.models.Location in project android-oss by kickstarter.
the class ViewPledgeViewModelTest method testShipping_withShippingLocation.
@Test
public void testShipping_withShippingLocation() {
final Location location = LocationFactory.sydney();
final Reward reward = RewardFactory.rewardWithShipping();
final Backing backing = BackingFactory.backing().toBuilder().location(location).reward(reward).rewardId(reward.id()).shippingAmount(5.0f).build();
final ViewPledgeViewModel vm = vm(backing);
final TestSubscriber<String> shippingLocationTextViewTextTest = TestSubscriber.create();
vm.outputs.shippingLocationTextViewText().subscribe(shippingLocationTextViewTextTest);
final TestSubscriber<String> shippingAmountTextViewTextTest = TestSubscriber.create();
vm.outputs.shippingAmountTextViewText().subscribe(shippingAmountTextViewTextTest);
final TestSubscriber<Boolean> shippingSectionIsHiddenTest = TestSubscriber.create();
vm.outputs.shippingSectionIsHidden().subscribe(shippingSectionIsHiddenTest);
vm.intent(intent(backing));
shippingLocationTextViewTextTest.assertValues("Sydney, AU");
shippingAmountTextViewTextTest.assertValues("$5");
shippingSectionIsHiddenTest.assertValues(false);
}
use of com.kickstarter.models.Location in project android-oss by kickstarter.
the class ProjectViewHolder method onBind.
public void onBind() {
final Photo photo = project.photo();
if (photo != null) {
final int targetImageWidth = (int) (getScreenWidthDp(context) * getScreenDensity(context));
final int targetImageHeight = ProjectUtils.photoHeightFromWidthRatio(targetImageWidth);
photoImageView.setMaxHeight(targetImageHeight);
Picasso.with(context).load(photo.full()).resize(targetImageWidth, targetImageHeight).centerCrop().placeholder(grayGradientDrawable).into(photoImageView);
}
if (project.hasVideo()) {
playButton.setVisibility(View.VISIBLE);
} else {
playButton.setVisibility(View.GONE);
}
/* Project */
blurbTextView.setText(Html.fromHtml(ksString.format(blurbReadMoreString, "blurb", TextUtils.htmlEncode(project.blurb()), "space", " ")));
creatorNameTextView.setText(Html.fromHtml(ksString.format(byCreatorString, "creator_name", TextUtils.htmlEncode(project.creator().name()))));
if (project.isBacking()) {
backerLabelLinearLayout.setVisibility(View.VISIBLE);
} else {
backerLabelLinearLayout.setVisibility(View.GONE);
}
projectNameTextView.setText(project.name());
final Category category = project.category();
if (category != null) {
categoryTextView.setText(category.name());
}
final Location location = project.location();
if (location != null) {
locationTextView.setText(location.displayableName());
}
percentageFundedProgressBar.setProgress(ProgressBarUtils.progress(project.percentageFunded()));
deadlineCountdownTextView.setText(NumberUtils.format(ProjectUtils.deadlineCountdownValue(project)));
deadlineCountdownUnitTextView.setText(ProjectUtils.deadlineCountdownDetail(project, context, ksString));
backersCountTextView.setText(NumberUtils.format(project.backersCount()));
/* Creator */
Picasso.with(context).load(project.creator().avatar().medium()).transform(new CircleTransformation()).into(avatarImageView);
avatarNameTextView.setText(project.creator().name());
final Integer updatesCount = project.updatesCount();
updatesCountTextView.setText(updatesCount != null ? NumberUtils.format(updatesCount) : null);
final Integer commentsCount = project.commentsCount();
commentsCountTextView.setText(commentsCount != null ? NumberUtils.format(commentsCount) : null);
setConvertedUsdView();
setLandscapeActionButton();
setLandscapeOverlayText();
setPledgedOfGoalView();
setProjectDisclaimerView();
setProjectSocialClick();
setProjectStateView();
setSocialView();
setStatsContentDescription();
}
use of com.kickstarter.models.Location in project android-oss by kickstarter.
the class KoalaUtils method projectProperties.
@NonNull
public static Map<String, Object> projectProperties(@NonNull final Project project, @Nullable final User loggedInUser, @NonNull final String prefix) {
final Map<String, Object> properties = new HashMap<String, Object>() {
{
put("backers_count", project.backersCount());
put("country", project.country());
put("currency", project.currency());
put("goal", project.goal());
put("pid", project.id());
put("name", project.name());
put("state", project.state());
put("update_count", project.updatesCount());
put("comments_count", project.commentsCount());
put("pledged", project.pledged());
put("percent_raised", project.percentageFunded() / 100.0f);
put("has_video", project.video() != null);
put("hours_remaining", ProjectUtils.timeInSecondsUntilDeadline(project) / 60.0f / 60.0f);
// TODO: Implement `duration`
// put("duration", project.duration());
final Category category = project.category();
if (category != null) {
put("category", category.name());
final Category parent = category.parent();
if (parent != null) {
put("parent_category", parent.name());
}
}
final Location location = project.location();
if (location != null) {
put("location", location.name());
}
putAll(userProperties(project.creator(), "creator_"));
if (loggedInUser != null) {
put("user_is_project_creator", ProjectUtils.userIsCreator(project, loggedInUser));
put("user_is_backer", project.isBacking());
put("user_has_starred", project.isStarred());
}
}
};
return MapUtils.prefixKeys(properties, prefix);
}
Aggregations