Search in sources :

Example 6 with SharedAudioCell

use of org.telegram.ui.Cells.SharedAudioCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class FilteredSearchView method onItemClick.

private void onItemClick(int index, View view, MessageObject message, int a) {
    if (message == null) {
        return;
    }
    if (uiCallback.actionModeShowing()) {
        uiCallback.toggleItemSelection(message, view, a);
        return;
    }
    if (view instanceof DialogCell) {
        uiCallback.goToMessage(message);
        return;
    }
    if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_MEDIA) {
        PhotoViewer.getInstance().setParentActivity(parentActivity);
        PhotoViewer.getInstance().openPhoto(messages, index, 0, 0, provider);
        photoViewerClassGuid = PhotoViewer.getInstance().getClassGuid();
    } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_MUSIC || currentSearchFilter.filterType == FiltersView.FILTER_TYPE_VOICE) {
        if (view instanceof SharedAudioCell) {
            ((SharedAudioCell) view).didPressedButton();
        }
    } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_FILES) {
        if (view instanceof SharedDocumentCell) {
            SharedDocumentCell cell = (SharedDocumentCell) view;
            TLRPC.Document document = message.getDocument();
            if (cell.isLoaded()) {
                if (message.canPreviewDocument()) {
                    PhotoViewer.getInstance().setParentActivity(parentActivity);
                    index = messages.indexOf(message);
                    if (index < 0) {
                        ArrayList<MessageObject> documents = new ArrayList<>();
                        documents.add(message);
                        PhotoViewer.getInstance().setParentActivity(parentActivity);
                        PhotoViewer.getInstance().openPhoto(documents, 0, 0, 0, provider);
                        photoViewerClassGuid = PhotoViewer.getInstance().getClassGuid();
                    } else {
                        PhotoViewer.getInstance().setParentActivity(parentActivity);
                        PhotoViewer.getInstance().openPhoto(messages, index, 0, 0, provider);
                        photoViewerClassGuid = PhotoViewer.getInstance().getClassGuid();
                    }
                    return;
                }
                AndroidUtilities.openDocument(message, parentActivity, parentFragment);
            } else if (!cell.isLoading()) {
                MessageObject messageObject = cell.getMessage();
                AccountInstance.getInstance(UserConfig.selectedAccount).getFileLoader().loadFile(document, messageObject, 0, 0);
                cell.updateFileExistIcon(true);
            } else {
                AccountInstance.getInstance(UserConfig.selectedAccount).getFileLoader().cancelLoadFile(document);
                cell.updateFileExistIcon(true);
            }
        }
    } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_LINKS) {
        try {
            TLRPC.WebPage webPage = message.messageOwner.media != null ? message.messageOwner.media.webpage : null;
            String link = null;
            if (webPage != null && !(webPage instanceof TLRPC.TL_webPageEmpty)) {
                if (webPage.cached_page != null) {
                    ArticleViewer.getInstance().setParentActivity(parentActivity, parentFragment);
                    ArticleViewer.getInstance().open(message);
                    return;
                } else if (webPage.embed_url != null && webPage.embed_url.length() != 0) {
                    openWebView(webPage, message);
                    return;
                } else {
                    link = webPage.url;
                }
            }
            if (link == null) {
                link = ((SharedLinkCell) view).getLink(0);
            }
            if (link != null) {
                openUrl(link);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SharedDocumentCell(org.telegram.ui.Cells.SharedDocumentCell) TLRPC(org.telegram.tgnet.TLRPC) DialogCell(org.telegram.ui.Cells.DialogCell) SharedAudioCell(org.telegram.ui.Cells.SharedAudioCell) MessageObject(org.telegram.messenger.MessageObject) SharedLinkCell(org.telegram.ui.Cells.SharedLinkCell)

Example 7 with SharedAudioCell

use of org.telegram.ui.Cells.SharedAudioCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class SharedMediaLayout method saveScrollPosition.

private void saveScrollPosition() {
    for (int k = 0; k < mediaPages.length; k++) {
        RecyclerListView listView = mediaPages[k].listView;
        if (listView != null) {
            int messageId = 0;
            int offset = 0;
            for (int i = 0; i < listView.getChildCount(); i++) {
                View child = listView.getChildAt(i);
                if (child instanceof SharedPhotoVideoCell2) {
                    SharedPhotoVideoCell2 cell = (SharedPhotoVideoCell2) child;
                    messageId = cell.getMessageId();
                    offset = cell.getTop();
                }
                if (child instanceof SharedDocumentCell) {
                    SharedDocumentCell cell = (SharedDocumentCell) child;
                    messageId = cell.getMessage().getId();
                }
                if (child instanceof SharedAudioCell) {
                    SharedAudioCell cell = (SharedAudioCell) child;
                    messageId = cell.getMessage().getId();
                }
                if (messageId != 0) {
                    break;
                }
            }
            if (messageId != 0) {
                int index = -1;
                if (mediaPages[k].selectedType < 0 || mediaPages[k].selectedType >= sharedMediaData.length) {
                    continue;
                }
                for (int i = 0; i < sharedMediaData[mediaPages[k].selectedType].messages.size(); i++) {
                    if (messageId == sharedMediaData[mediaPages[k].selectedType].messages.get(i).getId()) {
                        index = i;
                        break;
                    }
                }
                int position = sharedMediaData[mediaPages[k].selectedType].startOffset + index;
                if (index >= 0) {
                    ((LinearLayoutManager) listView.getLayoutManager()).scrollToPositionWithOffset(position, offset);
                    if (photoVideoChangeColumnsAnimation) {
                        mediaPages[k].animationSupportingLayoutManager.scrollToPositionWithOffset(position, offset);
                    }
                }
            }
        }
    }
}
Also used : SharedPhotoVideoCell2(org.telegram.ui.Cells.SharedPhotoVideoCell2) SharedAudioCell(org.telegram.ui.Cells.SharedAudioCell) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Paint(android.graphics.Paint) SharedDocumentCell(org.telegram.ui.Cells.SharedDocumentCell)

Aggregations

SharedAudioCell (org.telegram.ui.Cells.SharedAudioCell)7 Paint (android.graphics.Paint)4 View (android.view.View)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 ArrayList (java.util.ArrayList)4 MessageObject (org.telegram.messenger.MessageObject)4 SharedDocumentCell (org.telegram.ui.Cells.SharedDocumentCell)4 SharedLinkCell (org.telegram.ui.Cells.SharedLinkCell)3 SharedPhotoVideoCell2 (org.telegram.ui.Cells.SharedPhotoVideoCell2)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 TLRPC (org.telegram.tgnet.TLRPC)2 ContextLinkCell (org.telegram.ui.Cells.ContextLinkCell)2 SharedPhotoVideoCell (org.telegram.ui.Cells.SharedPhotoVideoCell)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1