Search in sources :

Example 1 with Category

use of com.kickstarter.models.Category 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 2 with Category

use of com.kickstarter.models.Category 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 3 with Category

use of com.kickstarter.models.Category 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 4 with Category

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

the class ChildFilterViewHolder method onBind.

@Override
public void onBind() {
    final Context context = context();
    final Category category = item.params().category();
    if (category != null && category.isRoot()) {
        filterTextView.setText(item.params().filterString(context, ksString));
    } else {
        filterTextView.setText(item.params().filterString(context, ksString));
    }
    if (item.selected()) {
        filterTextView.setTextAppearance(context, R.style.SubheadPrimaryMedium);
        filterTextView.setTextColor(blackColor);
    } else {
        filterTextView.setTextAppearance(context, R.style.SubheadPrimary);
        filterTextView.setTextColor(darkGrayColor);
    }
    filterView.setBackgroundColor(item.selected() ? filterSelectedColor : filterUnselectedColor);
}
Also used : Context(android.content.Context) Category(com.kickstarter.models.Category)

Example 5 with Category

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

the class ThanksCategoryHolderViewModelTest method testCategoryName.

@Test
public void testCategoryName() {
    final Category category = CategoryFactory.musicCategory();
    setUpEnvironment(environment());
    this.vm.getInputs().configureWith(category);
    this.categoryName.assertValues(category.name());
}
Also used : Category(com.kickstarter.models.Category) Test(org.junit.Test)

Aggregations

Category (com.kickstarter.models.Category)16 Test (org.junit.Test)9 Project (com.kickstarter.models.Project)6 DiscoveryParams (com.kickstarter.services.DiscoveryParams)5 User (com.kickstarter.models.User)4 Observable (rx.Observable)4 Context (android.content.Context)3 Intent (android.content.Intent)3 NonNull (android.support.annotation.NonNull)3 NonNull (androidx.annotation.NonNull)3 KSRobolectricTestCase (com.kickstarter.KSRobolectricTestCase)3 R (com.kickstarter.R)3 Environment (com.kickstarter.libs.Environment)3 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)3 EventName (com.kickstarter.libs.utils.EventName)3 CategoryFactory (com.kickstarter.mock.factories.CategoryFactory)3 UserFactory (com.kickstarter.mock.factories.UserFactory)3 MockApiClient (com.kickstarter.mock.services.MockApiClient)3 Photo (com.kickstarter.models.Photo)3 Arrays (java.util.Arrays)3