-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
facepile ( •_•) ( •_•)>⌐■-■ (⌐■_■) #181
Changes from 7 commits
5f73b49
e561da8
ff54278
647ecc7
e6077ce
fb361f8
c55fa5a
a4a9da4
50e60ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ | |
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.text.TextUtils; | ||
|
||
import com.kickstarter.R; | ||
import com.kickstarter.libs.KSString; | ||
import com.kickstarter.models.User; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public final class SocialUtils { | ||
|
@@ -131,12 +133,25 @@ public static String friendBackingActivityTitle(final @NonNull Context context, | |
/** | ||
* Returns a namepile for a list of friends. | ||
*/ | ||
public static @NonNull String projectCardFriendNamepile(final @NonNull List<User> friends, final @NonNull 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)); | ||
public static @NonNull String projectCardFriendNamepile(final Context context, final @NonNull List<User> friends, final @NonNull KSString ksString) { | ||
final String friendName; | ||
if (friends.size() < 3) { | ||
friendName = friends.size() >= 1 ? friends.get(0).name() : ""; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this logic makes sense, but is a little hard to read through. maybe it'd be helpful to leave a lil comment here with an example of what |
||
final String delimiter = context.getString(R.string.project_social_friends_separator).trim() + " "; | ||
final String joinedFriends = TextUtils.join(delimiter, Arrays.asList(friends.get(0).name(), friends.get(1).name())); | ||
friendName = friends.size() == 3 ? joinedFriends.concat(delimiter.trim()) : joinedFriends; | ||
} | ||
|
||
final String secondFriendName; | ||
if (friends.size() >= 2) { | ||
secondFriendName = friends.size() == 2 ? friends.get(1).name() : friends.get(2).name(); | ||
} else { | ||
secondFriendName = ""; | ||
} | ||
final String remainingCount = NumberUtils.format(Math.max(0, friends.size() - 3)); | ||
|
||
return ksString.format("discovery_baseball_card_social_friends_are_backers", friends.size(), | ||
return ksString.format("discovery_baseball_card_social_friends_are_backers", friends.size() == 3 ? friends.size() - 1 : friends.size(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah this is all a bit gnarly but it makes sense! If I have any refactoring ideas I'll chime in. |
||
"friend_name", friendName, | ||
"second_friend_name", secondFriendName, | ||
"remaining_count", remainingCount | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,9 @@ public final class ProjectCardViewHolder extends KSViewHolder { | |
protected @Bind(R.id.deadline_countdown_unit) TextView deadlineCountdownUnitTextView; | ||
protected @Bind(R.id.featured) TextView featuredTextView; | ||
protected @Bind(R.id.featured_group) ViewGroup featuredViewGroup; | ||
protected @Bind(R.id.friend_backing_avatar) ImageView friendBackingAvatarImageView; | ||
protected @Bind(R.id.friend_backing_avatar1) ImageView friendBackingAvatarImageView1; | ||
protected @Bind(R.id.friend_backing_avatar2) ImageView friendBackingAvatarImageView2; | ||
protected @Bind(R.id.friend_backing_avatar3) ImageView friendBackingAvatarImageView3; | ||
protected @Bind(R.id.friend_backing_message) TextView friendBackingMessageTextView; | ||
protected @Bind(R.id.friend_backing_group) ViewGroup friendBackingViewGroup; | ||
protected @Bind(R.id.funding_successful_date_text_view) TextView fundingSuccessfulTextViewDate; | ||
|
@@ -118,10 +120,30 @@ public ProjectCardViewHolder(final @NonNull View view, final @NonNull Delegate d | |
.compose(observeForUI()) | ||
.subscribe(ViewUtils.setGone(this.featuredViewGroup)); | ||
|
||
this.viewModel.outputs.friendAvatarUrl() | ||
this.viewModel.outputs.friendAvatar2IsHidden() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can rename these outputs from |
||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(this::setFriendAvatarUrl); | ||
.subscribe(hidden -> ViewUtils.setGone(this.friendBackingAvatarImageView2, hidden)); | ||
|
||
this.viewModel.outputs.friendAvatar3IsHidden() | ||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(hidden -> ViewUtils.setGone(this.friendBackingAvatarImageView3, hidden)); | ||
|
||
this.viewModel.outputs.friendAvatarUrl1() | ||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(url -> setFriendAvatarUrl(url, this.friendBackingAvatarImageView1)); | ||
|
||
this.viewModel.outputs.friendAvatarUrl2() | ||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(url -> setFriendAvatarUrl(url, this.friendBackingAvatarImageView2)); | ||
|
||
this.viewModel.outputs.friendAvatarUrl3() | ||
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(url -> setFriendAvatarUrl(url, this.friendBackingAvatarImageView3)); | ||
|
||
this.viewModel.outputs.friendBackingViewIsHidden() | ||
.compose(bindToLifecycle()) | ||
|
@@ -132,7 +154,7 @@ public ProjectCardViewHolder(final @NonNull View view, final @NonNull Delegate d | |
.compose(bindToLifecycle()) | ||
.compose(observeForUI()) | ||
.subscribe(friends -> | ||
this.friendBackingMessageTextView.setText(SocialUtils.projectCardFriendNamepile(friends, this.ksString)) | ||
this.friendBackingMessageTextView.setText(SocialUtils.projectCardFriendNamepile(context(), friends, this.ksString)) | ||
); | ||
|
||
this.viewModel.outputs.fundingUnsuccessfulViewGroupIsGone() | ||
|
@@ -282,10 +304,10 @@ private void setDeadlineCountdownText(final @NonNull Project project) { | |
this.deadlineCountdownUnitTextView.setText(ProjectUtils.deadlineCountdownDetail(project, context(), this.ksString)); | ||
} | ||
|
||
private void setFriendAvatarUrl(final @NonNull String avatarUrl) { | ||
private void setFriendAvatarUrl(final @NonNull String avatarUrl, final @NonNull ImageView imageView) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice nice |
||
Picasso.with(context()).load(avatarUrl) | ||
.transform(new CircleTransformation()) | ||
.into(this.friendBackingAvatarImageView); | ||
.into(imageView); | ||
} | ||
|
||
private void setDefaultTopPadding(final boolean setDefaultPadding) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
<solid | ||
android:color="@color/white" /> | ||
</shape> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
<stroke | ||
android:width="2dp" | ||
android:color="@color/white" /> | ||
</shape> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NonNull
Context