本文整理汇总了Java中org.telegram.tgnet.TLRPC.MESSAGE_FLAG_HAS_VIEWS属性的典型用法代码示例。如果您正苦于以下问题:Java TLRPC.MESSAGE_FLAG_HAS_VIEWS属性的具体用法?Java TLRPC.MESSAGE_FLAG_HAS_VIEWS怎么用?Java TLRPC.MESSAGE_FLAG_HAS_VIEWS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.telegram.tgnet.TLRPC
的用法示例。
在下文中一共展示了TLRPC.MESSAGE_FLAG_HAS_VIEWS属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: measureTime
protected void measureTime(MessageObject messageObject) {
boolean hasSign = !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 && messageObject.messageOwner.post;
TLRPC.User signUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
if (hasSign && signUser == null) {
hasSign = false;
}
if (hasSign) {
currentTimeString = ", " + LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
} else {
currentTimeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
}
if(showEditedMark && messageObject.messageOwner.edit_date > 0)currentTimeString = currentTimeString + " E";
timeTextWidth = timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null));
viewsTextWidth = (int) Math.ceil(timePaint.measureText(currentViewsString));
timeWidth += viewsTextWidth + Theme.viewsCountDrawable[0].getIntrinsicWidth() + AndroidUtilities.dp(10);
}
if (hasSign) {
if (availableTimeWidth == 0) {
availableTimeWidth = AndroidUtilities.dp(1000);
}
CharSequence name = ContactsController.formatName(signUser.first_name, signUser.last_name).replace('\n', ' ');
int widthForSign = availableTimeWidth - timeWidth;
int width = (int) Math.ceil(timePaint.measureText(name, 0, name.length()));
if (width > widthForSign) {
name = TextUtils.ellipsize(name, timePaint, widthForSign, TextUtils.TruncateAt.END);
width = widthForSign;
}
currentTimeString = name + currentTimeString;
timeTextWidth += width;
timeWidth += width;
}
}
示例2: measureTime
private void measureTime(MessageObject messageObject) {
boolean hasSign = !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 && messageObject.messageOwner.post;
TLRPC.User signUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
if (hasSign && signUser == null) {
hasSign = false;
}
String timeString;
TLRPC.User author = null;
if (currentMessageObject.isFromUser()) {
author = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
}
if (messageObject.messageOwner.via_bot_id == 0 && messageObject.messageOwner.via_bot_name == null && (author == null || !author.bot) && (messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_EDITED) != 0) {
timeString = LocaleController.getString("EditedMessage", R.string.EditedMessage) + " " + LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
} else {
timeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
}
if (hasSign) {
currentTimeString = ", " + timeString;
} else {
currentTimeString = timeString;
}
timeTextWidth = timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null));
viewsTextWidth = (int) Math.ceil(timePaint.measureText(currentViewsString));
timeWidth += viewsTextWidth + Theme.viewsCountDrawable[0].getIntrinsicWidth() + dp(10);
}
if (hasSign) {
if (availableTimeWidth == 0) {
availableTimeWidth = dp(1000);
}
CharSequence name = ContactsController.formatName(signUser.first_name, signUser.last_name).replace('\n', ' ');
int widthForSign = availableTimeWidth - timeWidth;
int width = (int) Math.ceil(timePaint.measureText(name, 0, name.length()));
if (width > widthForSign) {
name = TextUtils.ellipsize(name, timePaint, widthForSign, TextUtils.TruncateAt.END);
width = widthForSign;
}
currentTimeString = name + currentTimeString;
timeTextWidth += width;
timeWidth += width;
}
}
示例3: onLayout
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (currentMessageObject == null) {
super.onLayout(changed, left, top, right, bottom);
return;
}
if (changed || !wasLayout) {
layoutWidth = getMeasuredWidth();
layoutHeight = getMeasuredHeight() - substractBackgroundHeight;
if (timeTextWidth < 0) {
timeTextWidth = AndroidUtilities.dp(10);
}
timeLayout = new StaticLayout(currentTimeString, timePaint, timeTextWidth + AndroidUtilities.dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (!mediaBackground) {
if (!currentMessageObject.isOutOwner()) {
//timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(48) : 0);
timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + ( (isChat || showAvatar) && currentMessageObject.isFromUser() ? AndroidUtilities.dp(leftBound) : 0);
//Log.e("ChatBaseCell", "NO MEDIA 0 - timeX " + timeX);
} else {
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(38.5f);
if((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)){
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(38.5f) - AndroidUtilities.dp(leftBound);
}
//Log.e("ChatBaseCell", "NO MEDIA 1 - timeX " + timeX);
checkX = timeX + timeWidth;
}
} else {
if (!currentMessageObject.isOutOwner()) {
//timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat && currentMessageObject.isFromUser() ? AndroidUtilities.dp(48) : 0);
timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + ((isChat || showAvatar) && currentMessageObject.isFromUser() ? AndroidUtilities.dp(leftBound) : 0);
//Log.e("ChatBaseCell", "MEDIA 2 - timeX " + timeX);
} else {
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f);
if((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)){
timeX = layoutWidth - timeWidth - AndroidUtilities.dp(42.0f) - AndroidUtilities.dp(leftBound);
}
//Log.e("ChatBaseCell", "MEDIA 3 - timeX " + timeX);
checkX = timeX + timeWidth;
}
}
if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
viewsLayout = new StaticLayout(currentViewsString, timePaint, viewsTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} else {
viewsLayout = null;
}
if (isAvatarVisible) {
//avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(44), AndroidUtilities.dp(42), AndroidUtilities.dp(42));
if(((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && currentMessageObject.isOutOwner()){
avatarImage.setImageCoords(layoutWidth - avatarSize - avatarLeft, ownAvatarAlignTop ? AndroidUtilities.dp(3) : layoutHeight - AndroidUtilities.dp(3) - avatarSize, avatarSize, avatarSize);
drawStatus = false;
}else{
avatarImage.setImageCoords(avatarLeft, avatarAlignTop ? AndroidUtilities.dp(3) : layoutHeight - AndroidUtilities.dp(3) - avatarSize, avatarSize, avatarSize);
}
}
wasLayout = true;
}
}