Search in sources :

Example 51 with Project

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

the class ProjectStateChangedViewHolder method onBind.

@Override
public void onBind() {
    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;
    }
    Picasso.with(context()).load(photo.little()).into(projectPhotoImageView);
    switch(activity().category()) {
        case Activity.CATEGORY_FAILURE:
            titleTextView.setText(ksString.format(projectNotSuccessfullyFundedString, "project_name", project.name()));
            break;
        case Activity.CATEGORY_CANCELLATION:
            titleTextView.setText(ksString.format(projectCanceledByCreatorString, "project_name", project.name()));
            break;
        case Activity.CATEGORY_SUSPENSION:
            titleTextView.setText(ksString.format(projectSuspendedString, "project_name", project.name()));
            break;
        default:
            titleTextView.setText("");
    }
}
Also used : Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) Photo(com.kickstarter.models.Photo)

Example 52 with Project

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

the class ProjectUpdateViewHolder 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;
    }
    final Update update = activity().update();
    if (update == null) {
        return;
    }
    final DateTime publishedAt = ObjectUtils.coalesce(update.publishedAt(), new DateTime());
    projectNameTextView.setText(project.name());
    Picasso.with(context).load(photo.little()).into(projectPhotoImageView);
    timestampTextView.setText(DateTimeUtils.relative(context, ksString, publishedAt));
    updateBodyTextView.setText(update.truncatedBody());
    updateSequenceTextView.setText(ksString.format(projectUpdateCountString, "update_count", String.valueOf(update.sequence())));
    updateTitleTextView.setText(update.title());
}
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) DateTime(org.joda.time.DateTime)

Example 53 with Project

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

the class ProjectFactory method backedProjectWithRewardLimitReached.

@NonNull
public static Project backedProjectWithRewardLimitReached() {
    final Project project = project();
    final Reward reward = RewardFactory.limitReached();
    final Backing backing = Backing.builder().amount(10.0f).backerId(IdFactory.id()).id(IdFactory.id()).sequence(1).reward(reward).rewardId(reward.id()).pledgedAt(DateTime.now()).projectCountry(project.country()).projectId(project.id()).shippingAmount(0.0f).status(Backing.STATUS_PLEDGED).build();
    return project.toBuilder().backing(backing).isBacking(true).build();
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) NonNull(android.support.annotation.NonNull)

Example 54 with Project

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

the class ProjectIntentMapperTest method testProject_doesNotEmitFromHttpsProjectUri.

@Test
public void testProject_doesNotEmitFromHttpsProjectUri() {
    final Uri uri = Uri.parse("https://www.kickstarter.com/projects/1186238668/skull-graphic-tee");
    final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    final TestSubscriber<Project> resultTest = TestSubscriber.create();
    ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertNoValues();
}
Also used : Project(com.kickstarter.models.Project) MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) Uri(android.net.Uri) Test(org.junit.Test)

Example 55 with Project

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

the class ProjectIntentMapperTest method testProject_emitsTwiceFromProjectExtra.

@Test
public void testProject_emitsTwiceFromProjectExtra() {
    final Project project = ProjectFactory.project();
    final Intent intent = new Intent().putExtra(IntentKey.PROJECT, project);
    final TestSubscriber<Project> resultTest = TestSubscriber.create();
    ProjectIntentMapper.project(intent, new MockApiClient()).subscribe(resultTest);
    resultTest.assertValueCount(2);
}
Also used : Project(com.kickstarter.models.Project) MockApiClient(com.kickstarter.services.MockApiClient) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Project (com.kickstarter.models.Project)85 Test (org.junit.Test)68 Intent (android.content.Intent)36 TestSubscriber (rx.observers.TestSubscriber)33 Environment (com.kickstarter.libs.Environment)19 Reward (com.kickstarter.models.Reward)19 User (com.kickstarter.models.User)14 Pair (android.util.Pair)12 CurrentUserType (com.kickstarter.libs.CurrentUserType)12 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)12 NonNull (android.support.annotation.NonNull)9 MockBooleanPreference (com.kickstarter.libs.preferences.MockBooleanPreference)8 MockApiClient (com.kickstarter.services.MockApiClient)7 Context (android.content.Context)6 KSRobolectricTestCase (com.kickstarter.KSRobolectricTestCase)6 ProjectFactory (com.kickstarter.factories.ProjectFactory)6 UserFactory (com.kickstarter.factories.UserFactory)5 KoalaEvent (com.kickstarter.libs.KoalaEvent)5 Photo (com.kickstarter.models.Photo)5 Update (com.kickstarter.models.Update)5