org.telegram.messenger.MessageObject Java Examples

The following examples show how to use org.telegram.messenger.MessageObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
    if (fileLocation == null) {
        return null;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    if (user != null && user.photo != null && user.photo.photo_big != null) {
        TLRPC.FileLocation photoBig = user.photo.photo_big;
        if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
            int coords[] = new int[2];
            avatarImage.getLocationInWindow(coords);
            PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
            object.viewX = coords[0];
            object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);
            object.parentView = avatarImage;
            object.imageReceiver = avatarImage.getImageReceiver();
            object.dialogId = UserConfig.getInstance(currentAccount).getClientUserId();
            object.thumb = object.imageReceiver.getBitmapSafe();
            object.size = -1;
            object.radius = avatarImage.getImageReceiver().getRoundRadius();
            object.scale = avatarImage.getScaleX();
            return object;
        }
    }
    return null;
}
 
Example #2
Source File: PhotoPickerActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index, boolean needPreview) {
    PhotoAttachPhotoCell cell = getCellForIndex(index);
    if (cell != null) {
        BackupImageView imageView = cell.getImageView();
        int[] coords = new int[2];
        imageView.getLocationInWindow(coords);
        PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
        object.viewX = coords[0];
        object.viewY = coords[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight);
        object.parentView = listView;
        object.imageReceiver = imageView.getImageReceiver();
        object.thumb = object.imageReceiver.getBitmapSafe();
        object.scale = cell.getScale();
        cell.showCheck(false);
        return object;
    }
    return null;
}
 
Example #3
Source File: SharedAudioCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setMessageObject(MessageObject messageObject, boolean divider) {
    needDivider = divider;
    currentMessageObject = messageObject;
    TLRPC.Document document = messageObject.getDocument();

    TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 240) : null;
    if (thumb instanceof TLRPC.TL_photoSize) {
        radialProgress.setImageOverlay(thumb, document, messageObject);
    } else {
        String artworkUrl = messageObject.getArtworkUrl(true);
        if (!TextUtils.isEmpty(artworkUrl)) {
            radialProgress.setImageOverlay(artworkUrl);
        } else {
            radialProgress.setImageOverlay(null, null, null);
        }
    }
    updateButtonState(false, false);
    requestLayout();
}
 
Example #4
Source File: PaymentFormActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(MessageObject message, TLRPC.TL_payments_paymentReceipt receipt) {
    currentStep = 5;
    paymentForm = new TLRPC.TL_payments_paymentForm();
    paymentForm.bot_id = receipt.bot_id;
    paymentForm.invoice = receipt.invoice;
    paymentForm.provider_id = receipt.provider_id;
    paymentForm.users = receipt.users;
    shippingOption = receipt.shipping;
    messageObject = message;
    botUser = MessagesController.getInstance(currentAccount).getUser(receipt.bot_id);
    if (botUser != null) {
        currentBotName = botUser.first_name;
    } else {
        currentBotName = "";
    }
    currentItemName = message.messageOwner.media.title;
    if (receipt.info != null) {
        validateRequest = new TLRPC.TL_payments_validateRequestedInfo();
        validateRequest.info = receipt.info;
    }
    cardName = receipt.credentials_title;
}
 
Example #5
Source File: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setDialog(long dialog_id, MessageObject messageObject, int date)
{
    currentDialogId = dialog_id;
    message = messageObject;
    isDialogCell = false;
    lastMessageDate = date;
    currentEditDate = messageObject != null ? messageObject.messageOwner.edit_date : 0;
    unreadCount = 0;
    markUnread = false;
    messageId = messageObject != null ? messageObject.getId() : 0;
    mentionCount = 0;
    lastUnreadState = messageObject != null && messageObject.isUnread();
    if (message != null)
    {
        lastSendState = message.messageOwner.send_state;
    }
    update(0);
}
 
Example #6
Source File: ChannelAdminLogActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private String getMessageContent(MessageObject messageObject, int previousUid, boolean name) {
    String str = "";
    if (name) {
        if (previousUid != messageObject.messageOwner.from_id) {
            if (messageObject.messageOwner.from_id > 0) {
                TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.from_id);
                if (user != null) {
                    str = ContactsController.formatName(user.first_name, user.last_name) + ":\n";
                }
            } else if (messageObject.messageOwner.from_id < 0) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-messageObject.messageOwner.from_id);
                if (chat != null) {
                    str = chat.title + ":\n";
                }
            }
        }
    }
    if (messageObject.type == 0 && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else {
        str += messageObject.messageText;
    }
    return str;
}
 
Example #7
Source File: PaymentFormActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example #8
Source File: AboutLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setTextAndIcon(String text, int resId, boolean parseLinks) {
    if (TextUtils.isEmpty(text) || text != null && oldText != null && text.equals(oldText)) {
        return;
    }
    oldText = text;
    stringBuilder = new SpannableStringBuilder(oldText);
    if (parseLinks) {
        MessageObject.addLinks(false, stringBuilder, false);
    }
    Emoji.replaceEmoji(stringBuilder, Theme.profile_aboutTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    requestLayout();
    if (resId == 0) {
        imageView.setImageDrawable(null);
    } else {
        imageView.setImageResource(resId);
    }
}
 
Example #9
Source File: AudioPlayerCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setMessageObject(MessageObject messageObject) {
    currentMessageObject = messageObject;
    TLRPC.Document document = messageObject.getDocument();
    TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90) : null;
    if (thumb instanceof TLRPC.TL_photoSize) {
        radialProgress.setImageOverlay(thumb, document, messageObject);
    } else {
        String artworkUrl = messageObject.getArtworkUrl(true);
        if (!TextUtils.isEmpty(artworkUrl)) {
            radialProgress.setImageOverlay(artworkUrl);
        } else {
            radialProgress.setImageOverlay(null, null, null);
        }
    }
    requestLayout();
    updateButtonState(false, false);
}
 
Example #10
Source File: PaymentFormActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example #11
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private String getMessageContent(MessageObject messageObject, int previousUid, boolean name) {
    String str = "";
    if (name) {
        if (previousUid != messageObject.messageOwner.from_id) {
            if (messageObject.messageOwner.from_id > 0) {
                TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.from_id);
                if (user != null) {
                    str = ContactsController.formatName(user.first_name, user.last_name) + ":\n";
                }
            } else if (messageObject.messageOwner.from_id < 0) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-messageObject.messageOwner.from_id);
                if (chat != null) {
                    str = chat.title + ":\n";
                }
            }
        }
    }
    if (messageObject.type == 0 && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.message != null) {
        str += messageObject.messageOwner.message;
    } else {
        str += messageObject.messageText;
    }
    return str;
}
 
Example #12
Source File: AudioPlayerCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setMessageObject(MessageObject messageObject) {
    currentMessageObject = messageObject;
    TLRPC.Document document = messageObject.getDocument();
    TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90) : null;
    if (thumb instanceof TLRPC.TL_photoSize) {
        radialProgress.setImageOverlay(thumb, document, messageObject);
    } else {
        String artworkUrl = messageObject.getArtworkUrl(true);
        if (!TextUtils.isEmpty(artworkUrl)) {
            radialProgress.setImageOverlay(artworkUrl);
        } else {
            radialProgress.setImageOverlay(null, null, null);
        }
    }
    requestLayout();
    updateButtonState(false, false);
}
 
Example #13
Source File: DialogCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setDialog(long dialog_id, MessageObject messageObject, int date, boolean useMe) {
    currentDialogId = dialog_id;
    message = messageObject;
    useMeForMyMessages = useMe;
    isDialogCell = false;
    lastMessageDate = date;
    currentEditDate = messageObject != null ? messageObject.messageOwner.edit_date : 0;
    unreadCount = 0;
    markUnread = false;
    messageId = messageObject != null ? messageObject.getId() : 0;
    mentionCount = 0;
    lastUnreadState = messageObject != null && messageObject.isUnread();
    if (message != null) {
        lastSendState = message.messageOwner.send_state;
    }
    update(0);
}
 
Example #14
Source File: AudioPlayerAlert.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateProgress(MessageObject messageObject) {
    if (seekBarView != null) {
        int newTime;
        if (seekBarView.isDragging()) {
            newTime = (int) (messageObject.getDuration() * seekBarView.getProgress());
        } else {
            seekBarView.setProgress(messageObject.audioProgress);
            seekBarView.setBufferedProgress(messageObject.bufferedProgress);
            newTime = messageObject.audioProgressSec;
        }
        if (lastTime != newTime) {
            lastTime = newTime;
            timeTextView.setText(AndroidUtilities.formatShortDuration(newTime));
        }
    }
}
 
Example #15
Source File: StatisticPostInfoCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setData(StatisticActivity.RecentPostInfo postInfo) {
    MessageObject messageObject = postInfo.message;
    if (messageObject.photoThumbs != null) {
        TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
        TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs,50);
        imageView.setImage(
                ImageLocation.getForObject(size, messageObject.photoThumbsObject), "50_50",
                ImageLocation.getForObject(thumbSize, messageObject.photoThumbsObject), "b1", 0, messageObject);
        imageView.setRoundRadius(AndroidUtilities.dp(4));
    } else if (chat.chat_photo.sizes.size() > 0) {
        imageView.setImage(ImageLocation.getForPhoto(chat.chat_photo.sizes.get(0), chat.chat_photo), "50_50", null, null, chat);
        imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1);
    }

    String text;
    if (messageObject.isMusic()) {
        text = String.format("%s, %s", messageObject.getMusicTitle().trim(), messageObject.getMusicAuthor().trim());
    } else {
        text = messageObject.caption != null ? messageObject.caption.toString() : messageObject.messageText.toString();
    }

    message.setText(text.replace("\n", " ").trim());
    views.setText(String.format(LocaleController.getPluralString("Views", postInfo.counters.views), AndroidUtilities.formatCount(postInfo.counters.views)));
    date.setText(LocaleController.formatDateAudio(postInfo.message.messageOwner.date, false));
    shares.setText(String.format(LocaleController.getPluralString("Shares", postInfo.counters.forwards), AndroidUtilities.formatCount(postInfo.counters.forwards)));
}
 
Example #16
Source File: BlockingUpdateView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void show(int account, TLRPC.TL_help_appUpdate update) {
    pressCount = 0;
    appUpdate = update;
    accountNum = account;
    if (update.document instanceof TLRPC.TL_document) {
        fileName = FileLoader.getAttachFileName(update.document);
    }
    if (getVisibility() != VISIBLE) {
        setVisibility(VISIBLE);
    }
    SpannableStringBuilder builder = new SpannableStringBuilder(update.text);
    MessageObject.addEntitiesToText(builder, update.entities, false, 0, false, false, false);
    textView.setText(builder);
    if (update.document instanceof TLRPC.TL_document) {
        acceptTextView.setText(LocaleController.getString("Update", R.string.Update).toUpperCase() + String.format(Locale.US, " (%1$s)", AndroidUtilities.formatFileSize(update.document.size)));
    } else {
        acceptTextView.setText(LocaleController.getString("Update", R.string.Update).toUpperCase());
    }
    NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.FileDidLoaded);
    NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.FileDidFailedLoad);
    NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.FileLoadProgressChanged);
}
 
Example #17
Source File: MediaActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateSearchResults(final ArrayList<MessageObject> documents) {
    AndroidUtilities.runOnUIThread(() -> {
        if (!searching) {
            return;
        }
        searchesInProgress--;
        searchResult = documents;
        int count = getItemCount();
        notifyDataSetChanged();
        for (int a = 0; a < mediaPages.length; a++) {
            if (mediaPages[a].listView.getAdapter() == this && count == 0 && actionBar.getTranslationY() != 0) {
                mediaPages[a].layoutManager.scrollToPositionWithOffset(0, (int) actionBar.getTranslationY());
                break;
            }
        }
    });
}
 
Example #18
Source File: MediaActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateSearchResults(final ArrayList<MessageObject> documents) {
    AndroidUtilities.runOnUIThread(() -> {
        searchesInProgress--;
        searchResult = documents;
        notifyDataSetChanged();
    });
}
 
Example #19
Source File: ChannelAdminLogActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void alertUserOpenError(MessageObject message) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    if (message.type == 3) {
        builder.setMessage(LocaleController.getString("NoPlayerInstalled", R.string.NoPlayerInstalled));
    } else {
        builder.setMessage(LocaleController.formatString("NoHandleAppInstalled", R.string.NoHandleAppInstalled, message.getDocument().mime_type));
    }
    showDialog(builder.create());
}
 
Example #20
Source File: PollVotesAlert.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static void showForPoll(ChatActivity parentFragment, MessageObject messageObject) {
    if (parentFragment == null || parentFragment.getParentActivity() == null) {
        return;
    }
    PollVotesAlert alert = new PollVotesAlert(parentFragment, messageObject);
    parentFragment.showDialog(alert);
}
 
Example #21
Source File: ChatAttachAlertPhotoLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
    PhotoAttachPhotoCell cell = getCellForIndex(index);
    if (cell != null) {
        return cell.getImageView().getImageReceiver().getBitmapSafe();
    }
    return null;
}
 
Example #22
Source File: ShareAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static ShareAlert createShareAlert(final Context context, MessageObject messageObject,
                                          final String text, boolean publicChannel,
                                          final String copyLink, boolean fullScreen)
{
    ArrayList<MessageObject> arrayList;
    if (messageObject != null)
    {
        arrayList = new ArrayList<>();
        arrayList.add(messageObject);
    }
    else
        arrayList = null;

    return new ShareAlert(context, arrayList, text, publicChannel, copyLink, fullScreen, false);
}
 
Example #23
Source File: ChatListItemAnimator.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void groupWillChanged(MessageObject.GroupedMessages groupedMessages) {
    if (groupedMessages.messages.size() == 0) {
        groupedMessages.transitionParams.drawBackgroundForDeletedItems = true;
    } else {
        if (groupedMessages.transitionParams.top == 0 && groupedMessages.transitionParams.bottom == 0 && groupedMessages.transitionParams.left == 0 && groupedMessages.transitionParams.right == 0)  {
            int n = recyclerListView.getChildCount();
            for (int i = 0; i < n; i++) {
                View child = recyclerListView.getChildAt(i);
                if (child instanceof ChatMessageCell) {
                    ChatMessageCell cell = (ChatMessageCell) child;
                    MessageObject messageObject = cell.getMessageObject();
                    if (cell.getTransitionParams().wasDraw && groupedMessages.messages.contains(messageObject)) {
                        groupedMessages.transitionParams.top = cell.getTop() +  cell.getBackgroundDrawableTop();
                        groupedMessages.transitionParams.bottom = cell.getTop() +  cell.getBackgroundDrawableBottom();
                        groupedMessages.transitionParams.left = cell.getLeft() + cell.getBackgroundDrawableLeft();
                        groupedMessages.transitionParams.right = cell.getLeft() + cell.getBackgroundDrawableRight();
                        groupedMessages.transitionParams.drawCaptionLayout = cell.hasCaptionLayout();
                        groupedMessages.transitionParams.pinnedTop = cell.isPinnedTop();
                        groupedMessages.transitionParams.pinnedBotton = cell.isPinnedBottom();
                        groupedMessages.transitionParams.isNewGroup = true;
                        break;
                    }
                }
            }
        }
        willChangedGroups.add(groupedMessages);
    }
}
 
Example #24
Source File: PhotoPickerActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ImageReceiver.BitmapHolder getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
    PhotoPickerPhotoCell cell = getCellForIndex(index);
    if (cell != null) {
        return cell.photoImage.getImageReceiver().getBitmapSafe();
    }
    return null;
}
 
Example #25
Source File: PopupAudioView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setMessageObject(MessageObject messageObject) {
    if (currentMessageObject != messageObject) {
        currentAccount = messageObject.currentAccount;
        seekBar.setColors(Theme.getColor(Theme.key_chat_inAudioSeekbar), Theme.getColor(Theme.key_chat_inAudioSeekbar), Theme.getColor(Theme.key_chat_inAudioSeekbarFill), Theme.getColor(Theme.key_chat_inAudioSeekbarFill), Theme.getColor(Theme.key_chat_inAudioSeekbarSelected));
        progressView.setProgressColors(0xffd9e2eb, 0xff86c5f8); //TODO

        currentMessageObject = messageObject;
        wasLayout = false;

        requestLayout();
    }
    updateButtonState();
}
 
Example #26
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example #27
Source File: SharedLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setLink(MessageObject messageObject, boolean divider) {
    needDivider = divider;
    resetPressedLink();
    message = messageObject;

    requestLayout();
}
 
Example #28
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example #29
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example #30
Source File: AudioPlayerAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void updateProgress(MessageObject messageObject) {
    if (seekBarView != null) {
        if (!seekBarView.isDragging()) {
            seekBarView.setProgress(messageObject.audioProgress);
            seekBarView.setBufferedProgress(messageObject.bufferedProgress);
        }
        if (lastTime != messageObject.audioProgressSec) {
            lastTime = messageObject.audioProgressSec;
            timeTextView.setText(String.format("%d:%02d", messageObject.audioProgressSec / 60, messageObject.audioProgressSec % 60));
        }
    }
}