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);
}
}
}
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);
}
}
}
}
}
}
Aggregations