Search in sources :

Example 1 with Photo

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

the class ThanksActivity method startShareOnFacebook.

private void startShareOnFacebook(@NonNull final Project project) {
    if (!ShareDialog.canShow(ShareLinkContent.class)) {
        return;
    }
    final Photo photo = project.photo();
    final ShareOpenGraphObject object = new ShareOpenGraphObject.Builder().putString("og:type", "kickstarter:project").putString("og:title", project.name()).putString("og:description", project.blurb()).putString("og:image", photo == null ? null : photo.small()).putString("og:url", project.webProjectUrl()).build();
    final ShareOpenGraphAction action = new ShareOpenGraphAction.Builder().setActionType("kickstarter:back").putObject("project", object).build();
    final ShareOpenGraphContent content = new ShareOpenGraphContent.Builder().setPreviewPropertyName("project").setAction(action).build();
    shareDialog.show(content);
}
Also used : ShareLinkContent(com.facebook.share.model.ShareLinkContent) ShareOpenGraphAction(com.facebook.share.model.ShareOpenGraphAction) Photo(com.kickstarter.models.Photo) ShareOpenGraphObject(com.facebook.share.model.ShareOpenGraphObject) ShareOpenGraphContent(com.facebook.share.model.ShareOpenGraphContent)

Example 2 with Photo

use of com.kickstarter.models.Photo 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();
}
Also used : CircleTransformation(com.kickstarter.libs.transformations.CircleTransformation) Category(com.kickstarter.models.Category) Photo(com.kickstarter.models.Photo) Location(com.kickstarter.models.Location)

Example 3 with Photo

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

Example 4 with Photo

use of com.kickstarter.models.Photo 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));
}
Also used : Context(android.content.Context) Project(com.kickstarter.models.Project) CircleTransformation(com.kickstarter.libs.transformations.CircleTransformation) User(com.kickstarter.models.User) Category(com.kickstarter.models.Category) Photo(com.kickstarter.models.Photo)

Example 5 with Photo

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

the class ProfileCardViewHolder method onBind.

@Override
public void onBind() {
    final Photo photo = project.photo();
    if (photo != null) {
        profileCardImageView.setVisibility(View.VISIBLE);
        Picasso.with(context()).load(photo.med()).placeholder(grayGradientDrawable).into(profileCardImageView);
    } else {
        profileCardImageView.setVisibility(View.INVISIBLE);
    }
    profileCardNameTextView.setText(project.name());
    percentageFundedProgressBar.setProgress(ProgressBarUtils.progress(project.percentageFunded()));
    setProjectStateView();
}
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