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);
}
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()));
}
Aggregations