use of com.github.moko256.twitlatte.view.EmojiToTextViewSetter in project twicalico by moko256.
the class UserInfoFragment method setShowUserInfo.
private void setShowUserInfo(User user) {
if (user.getId() == client.getAccessToken().getUserId()) {
userIsYouOrFollowedYou.setVisibility(View.VISIBLE);
userIsYouOrFollowedYou.setText(R.string.you);
}
MediaUrlConverter mediaUrlConverter = client.getMediaUrlConverter();
String headerUrl = mediaUrlConverter.convertProfileBannerLargeUrl(user);
if (headerUrl != null) {
glideRequests.load(headerUrl).transition(DrawableTransitionOptions.withCrossFade()).into(header);
header.setOnClickListener(v -> startActivity(ShowMediasActivity.Companion.getIntent(v.getContext(), new Media[] { new Media(null, headerUrl, null, Media.MediaType.PICTURE.getValue()) }, CLIENT_TYPE_NOTHING, 0)));
}
glideRequests.load(mediaUrlConverter.convertProfileIconUriBySize(user, DpToPxKt.dpToPx(this, 68))).circleCrop().transition(DrawableTransitionOptions.withCrossFade()).into(icon);
icon.setOnClickListener(v -> startActivity(ShowMediasActivity.Companion.getIntent(v.getContext(), new Media[] { new Media(null, mediaUrlConverter.convertProfileIconOriginalUrl(user), null, Media.MediaType.PICTURE.getValue()) }, CLIENT_TYPE_NOTHING, 0)));
CharSequence userName = TwitterStringUtils.plusUserMarks(user.getName(), userNameText, user.isProtected(), user.isVerified());
CharSequence userBio = TwitterStringUtils.getLinkedSequence(client.getAccessToken(), user.getDescription(), user.getDescriptionLinks());
userNameText.setText(userName);
userBioText.setText(userBio);
Emoji[] userNameEmojis = user.getEmojis();
if (userNameEmojis != null) {
EmojiToTextViewSetter nameSetter = new EmojiToTextViewSetter(glideRequests, userNameText, userName, userNameEmojis);
EmojiToTextViewSetter bioSetter = new EmojiToTextViewSetter(glideRequests, userBioText, userBio, userNameEmojis);
getLifecycle().addObserver(new LifecycleEventObserver() {
@Override
public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {
if (event == Lifecycle.Event.ON_DESTROY) {
nameSetter.dispose();
bioSetter.dispose();
getLifecycle().removeObserver(this);
}
}
});
}
userIdText.setText(TwitterStringUtils.plusAtMark(user.getScreenName()));
if (!TextUtils.isEmpty(user.getLocation())) {
userLocation.setText(getString(R.string.location_is, user.getLocation()));
} else {
userLocation.setVisibility(View.GONE);
}
final String url = user.getUrl();
if (!TextUtils.isEmpty(url)) {
String text = getString(R.string.url_is, url);
SpannableString spannableString = new SpannableString(text);
int start = text.indexOf(url);
spannableString.setSpan(new ClickableNoLineSpan() {
@Override
public void onClick(@NonNull View widget) {
AppCustomTabsKt.launchChromeCustomTabs(widget.getContext(), url, false);
}
}, start, start + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
userUrl.setText(spannableString);
userUrl.setMovementMethod(LinkMovementMethod.getInstance());
} else {
userUrl.setVisibility(View.GONE);
}
userCreatedAt.setText(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL).format(user.getCreatedAt()));
userCounts.setText(getString(R.string.user_counts_is, user.getStatusesCount(), user.getFriendsCount(), user.getFollowersCount()));
}
use of com.github.moko256.twitlatte.view.EmojiToTextViewSetter in project twicalico by moko256.
the class UsersAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
User item = userCache.get(data.get(i));
if (item != null) {
requestManager.load(converter.convertProfileIconUriBySize(item, DpToPxKt.dpToPx(context, 40))).circleCrop().transition(DrawableTransitionOptions.withCrossFade()).into(viewHolder.userUserImage);
CharSequence userNameText = TwitterStringUtils.plusUserMarks(item.getName(), viewHolder.userUserName, item.isProtected(), item.isVerified());
viewHolder.userUserName.setText(userNameText);
Emoji[] userNameEmojis = item.getEmojis();
if (userNameEmojis != null) {
viewHolder.disposable.add(new EmojiToTextViewSetter(requestManager, viewHolder.userUserName, userNameText, userNameEmojis));
}
viewHolder.userUserId.setText(TwitterStringUtils.plusAtMark(item.getScreenName()));
viewHolder.itemView.setOnClickListener(v -> {
ActivityOptionsCompat animation = ActivityOptionsCompat.makeSceneTransitionAnimation(((Activity) context), viewHolder.userUserImage, "icon_image");
context.startActivity(GlobalApplicationKt.setAccountKeyForActivity(ShowUserActivity.getIntent(context, item.getId()), ((Activity) context)), animation.toBundle());
});
}
}
Aggregations