Search in sources :

Example 6 with Photo

use of com.kickstarter.models.Photo in project android-oss by kickstarter.

the class ProjectCardViewHolder method onBind.

public void onBind() {
    backersCountTextView.setText(NumberUtils.format(project.backersCount()));
    blurbTextView.setText(project.blurb());
    final Category category = project.category();
    if (category != null) {
        categoryTextView.setText(category.name());
    } else {
        categoryTextView.setText("");
    }
    deadlineCountdownTextView.setText(NumberUtils.format(ProjectUtils.deadlineCountdownValue(project)));
    deadlineCountdownUnitTextView.setText(ProjectUtils.deadlineCountdownDetail(project, context, ksString));
    nameTextView.setText(project.name());
    percentTextView.setText(NumberUtils.flooredPercentage(project.percentageFunded()));
    percentageFundedProgressBar.setProgress(ProgressBarUtils.progress(project.percentageFunded()));
    final Photo photo = project.photo();
    if (photo != null) {
        photoImageView.setVisibility(View.VISIBLE);
        final int targetImageWidth = (int) (getScreenWidthDp(context) * getScreenDensity(context) - grid4Dimen);
        final int targetImageHeight = ProjectUtils.photoHeightFromWidthRatio(targetImageWidth);
        photoImageView.setMaxHeight(targetImageHeight);
        Picasso.with(context).load(photo.full()).resize(targetImageWidth, // required to fit properly into apis < 18
        targetImageHeight).centerCrop().placeholder(grayGradientDrawable).into(photoImageView);
    } else {
        photoImageView.setVisibility(View.INVISIBLE);
    }
    setProjectMetadataView();
    setProjectStateView(context);
}
Also used : Category(com.kickstarter.models.Category) Photo(com.kickstarter.models.Photo)

Example 7 with Photo

use of com.kickstarter.models.Photo in project android-oss by kickstarter.

the class ProjectContextViewHolder method onBind.

public void onBind() {
    final Photo photo = project.photo();
    if (photo != null) {
        projectContextImageView.setVisibility(View.VISIBLE);
        Picasso.with(context).load(photo.full()).into(projectContextImageView);
    } else {
        projectContextImageView.setVisibility(View.INVISIBLE);
    }
    projectNameTextView.setText(project.name());
    creatorNameTextView.setText(ksString.format(projectCreatorByCreatorString, "creator_name", project.creator().name()));
}
Also used : Photo(com.kickstarter.models.Photo)

Example 8 with Photo

use of com.kickstarter.models.Photo in project android-oss by kickstarter.

the class ProjectSearchResultViewHolder method onBind.

public void onBind() {
    final Context context = context();
    creatorNameTextView.setText(ksString.format(byCreatorString, "creator_name", project.creator().name()));
    projectNameTextView.setText(project.name());
    final Photo photo = project.photo();
    if (photo != null) {
        projectImageView.setVisibility(View.VISIBLE);
        Picasso.with(context).load(photo.small()).into(projectImageView);
    } else {
        projectImageView.setVisibility(View.INVISIBLE);
    }
}
Also used : Context(android.content.Context) Photo(com.kickstarter.models.Photo)

Example 9 with Photo

use of com.kickstarter.models.Photo 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);
}
Also used : Context(android.content.Context) Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) Photo(com.kickstarter.models.Photo) DateTime(org.joda.time.DateTime)

Example 10 with Photo

use of com.kickstarter.models.Photo in project android-oss by kickstarter.

the class ThanksProjectViewHolder method onBind.

public void onBind() {
    nameTextView.setText(project.name());
    if (project.isLive()) {
        timeToGoTextView.setText(ksString.format(timeLeftToGoString, "time_left", ProjectUtils.deadlineCountdown(project, context)));
        timeToGoTextView.setVisibility(View.VISIBLE);
    } else {
        timeToGoTextView.setVisibility(View.GONE);
    }
    final Photo photo = project.photo();
    if (photo != null) {
        photoImageView.setVisibility(View.VISIBLE);
        Picasso.with(context).load(photo.med()).into(photoImageView);
    } else {
        photoImageView.setVisibility(View.INVISIBLE);
    }
}
Also used : Photo(com.kickstarter.models.Photo)

Aggregations

Photo (com.kickstarter.models.Photo)12 Context (android.content.Context)5 Project (com.kickstarter.models.Project)5 User (com.kickstarter.models.User)5 Category (com.kickstarter.models.Category)3 CircleTransformation (com.kickstarter.libs.transformations.CircleTransformation)2 Update (com.kickstarter.models.Update)2 DateTime (org.joda.time.DateTime)2 ShareLinkContent (com.facebook.share.model.ShareLinkContent)1 ShareOpenGraphAction (com.facebook.share.model.ShareOpenGraphAction)1 ShareOpenGraphContent (com.facebook.share.model.ShareOpenGraphContent)1 ShareOpenGraphObject (com.facebook.share.model.ShareOpenGraphObject)1 Location (com.kickstarter.models.Location)1