当前位置: 首页>>代码示例>>Java>>正文


Java TLRPC.MESSAGE_FLAG_HAS_VIEWS属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:34,代码来源:ChatBaseCell.java

示例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;
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:43,代码来源:ChatMessageCell.java

示例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;
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:62,代码来源:ChatBaseCell.java


注:本文中的org.telegram.tgnet.TLRPC.MESSAGE_FLAG_HAS_VIEWS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。