use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RewardViewHolder method bindData.
@Override
@SuppressWarnings("unchecked")
public void bindData(@Nullable final Object data) throws Exception {
final Pair<Project, Reward> projectAndReward = requireNonNull((Pair<Project, Reward>) data);
final Project project = requireNonNull(projectAndReward.first, Project.class);
final Reward reward = requireNonNull(projectAndReward.second, Reward.class);
viewModel.inputs.projectAndReward(project, reward);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ActivitySampleProjectViewHolder method onBind.
public void onBind() {
final Context context = context();
final Project project = activity.project();
if (project != null) {
final Photo photo = project.photo();
if (photo != null) {
Picasso.with(context).load(photo.little()).into(activityImageView);
}
activityTitleTextView.setText(project.name());
switch(activity.category()) {
case Activity.CATEGORY_FAILURE:
activitySubtitleTextView.setText(categoryFailureString);
break;
case Activity.CATEGORY_CANCELLATION:
activitySubtitleTextView.setText(categoryCancellationString);
break;
case Activity.CATEGORY_LAUNCH:
final User user = activity.user();
if (user != null) {
activitySubtitleTextView.setText(ksString.format(categoryLaunchString, "user_name", user.name()));
}
break;
case Activity.CATEGORY_SUCCESS:
activitySubtitleTextView.setText(categorySuccessString);
break;
case Activity.CATEGORY_UPDATE:
final Update update = activity.update();
if (update != null) {
activitySubtitleTextView.setText(ksString.format(categoryUpdateString, "update_number", String.valueOf(update.sequence()), "update_title", update.title()));
}
break;
default:
break;
}
}
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class FriendBackingViewHolder method onBind.
@Override
public void onBind() {
final Context context = context();
final User activityUser = activity().user();
if (activityUser == null) {
return;
}
final Project activityProject = activity().project();
if (activityProject == null) {
return;
}
final User projectCreator = activityProject.creator();
if (projectCreator == null) {
return;
}
final Category projectCategory = activityProject.category();
if (projectCategory == null) {
return;
}
final Photo projectPhoto = activityProject.photo();
if (projectPhoto == null) {
return;
}
Picasso.with(context).load(activityUser.avatar().small()).transform(new CircleTransformation()).into(avatarImageView);
creatorNameTextView.setText(ksString.format(projectByCreatorString, "creator_name", projectCreator.name()));
projectNameTextView.setText(activityProject.name());
Picasso.with(context).load(projectPhoto.little()).into(projectPhotoImageView);
titleTextView.setText(SocialUtils.friendBackingActivityTitle(context, activityUser.name(), projectCategory.rootId(), ksString));
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProjectStateChangedPositiveViewHolder 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;
}
switch(activity().category()) {
case Activity.CATEGORY_LAUNCH:
final DateTime launchedAt = coalesce(project.launchedAt(), new DateTime());
cardView.setCardBackgroundColor(blueDarken10Color);
leftStatFirstTextView.setText(ksCurrency.format(project.goal(), project));
leftStatSecondTextView.setText(goalString);
rightStatFirstTextView.setText(launchedString);
rightStatSecondTextView.setText(DateTimeUtils.mediumDate(launchedAt));
titleTextView.setText(ksString.format(creatorLaunchedProjectString, "creator_name", user.name(), "project_name", project.name()));
break;
case Activity.CATEGORY_SUCCESS:
cardView.setCardBackgroundColor(greenDarken10Color);
leftStatFirstTextView.setText(ksCurrency.format(project.pledged(), project));
leftStatSecondTextView.setText(ksString.format(pledgedOfGoalString, "goal", ksCurrency.format(project.goal(), project, true)));
rightStatFirstTextView.setText(fundedString);
rightStatSecondTextView.setText(DateTimeUtils.mediumDate(activity().createdAt()));
titleTextView.setText(ksString.format(projectSuccessfullyFundedString, "project_name", project.name()));
break;
default:
cardView.setCardBackgroundColor(greenDarken10Color);
leftStatFirstTextView.setText("");
leftStatSecondTextView.setText("");
rightStatFirstTextView.setText("");
rightStatSecondTextView.setText("");
titleTextView.setText("");
}
// TODO: Switch to "You launched a project" if current user launched
//return context.getString(R.string.creator_launched_a_project, activity.user().name(), activity.project().name());
Picasso.with(context).load(photo.full()).into(projectPhotoImageView);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class KSCurrencyTest method testFormatCurrency_roundsDown.
public void testFormatCurrency_roundsDown() {
final KSCurrency currency = createKSCurrency("US");
final Project project = ProjectFactory.project();
assertEquals("$100", currency.format(100.4f, project));
assertEquals("$100", currency.format(100.5f, project));
assertEquals("$101", currency.format(101.5f, project));
assertEquals("$100", currency.format(100.9f, project));
}
Aggregations