Search in sources :

Example 6 with KSString

use of com.kickstarter.libs.KSString in project android-oss by kickstarter.

the class SocialUtils method projectCardFriendNamepile.

/**
   * Returns a namepile for a list of friends.
   */
@NonNull
public static String projectCardFriendNamepile(@NonNull final List<User> friends, @NonNull final KSString ksString) {
    final String friendName = friends.size() >= 1 ? friends.get(0).name() : "";
    final String secondFriendName = friends.size() >= 2 ? friends.get(1).name() : "";
    final String remainingCount = NumberUtils.format(Math.max(0, friends.size() - 2));
    return ksString.format("discovery_baseball_card_social_friends_are_backers", friends.size(), "friend_name", friendName, "second_friend_name", secondFriendName, "remaining_count", remainingCount);
}
Also used : KSString(com.kickstarter.libs.KSString) NonNull(android.support.annotation.NonNull)

Example 7 with KSString

use of com.kickstarter.libs.KSString in project android-oss by kickstarter.

the class DateTimeUtilsTest method testRelative.

@Test
public void testRelative() {
    final Context context = context();
    final KSString ksString = ksString();
    final DateTime dateTime = DateTime.parse("2015-12-17T18:35:05Z");
    final RelativeDateTimeOptions.Builder builder = RelativeDateTimeOptions.builder();
    assertEquals("just now", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:35:10Z")).build()));
    assertEquals("right now", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:35:00Z")).build()));
    assertEquals("2 minutes ago", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:37:05Z")).build()));
    assertEquals("in 2 minutes", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:33:05Z")).build()));
    assertEquals("1 hour ago", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T19:35:05Z")).build()));
    assertEquals("in 1 hour", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T17:35:05Z")).build()));
    assertEquals("4 hours ago", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T22:35:05Z")).build()));
    assertEquals("in 4 hours", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T14:35:05Z")).build()));
    assertEquals("23 hours ago", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-18T17:35:05Z")).build()));
    assertEquals("in 23 hours", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-16T19:35:05Z")).build()));
    assertEquals("yesterday", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-18T18:35:05Z")).build()));
    assertEquals("in 1 day", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-16T18:35:05Z")).build()));
    assertEquals("10 days ago", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-27T18:35:05Z")).build()));
    assertEquals("in 10 days", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-07T18:35:05Z")).build()));
    assertEquals("Dec 17, 2015", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2016-01-27T18:35:05Z")).build()));
    assertEquals("Dec 17, 2015", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-10-17T18:35:05Z")).build()));
}
Also used : Context(android.content.Context) RelativeDateTimeOptions(com.kickstarter.libs.RelativeDateTimeOptions) KSString(com.kickstarter.libs.KSString) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

KSString (com.kickstarter.libs.KSString)7 DateTime (org.joda.time.DateTime)6 Context (android.content.Context)5 RelativeDateTimeOptions (com.kickstarter.libs.RelativeDateTimeOptions)5 Test (org.junit.Test)5 NonNull (android.support.annotation.NonNull)2 Seconds (org.joda.time.Seconds)1 Config (org.robolectric.annotation.Config)1