use of org.telegram.ui.Cells.SharedPhotoVideoCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method getThemeDescriptions.
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
arrayList.add(new ThemeDescription(selectedMessagesCountTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(shadowLine, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_divider));
arrayList.add(new ThemeDescription(deleteItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(deleteItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
if (gotoItem != null) {
arrayList.add(new ThemeDescription(gotoItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(gotoItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
}
if (forwardItem != null) {
arrayList.add(new ThemeDescription(forwardItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(forwardItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
}
arrayList.add(new ThemeDescription(closeButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, new Drawable[] { backDrawable }, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(closeButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
arrayList.add(new ThemeDescription(actionModeLayout, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
arrayList.add(new ThemeDescription(floatingDateView, 0, null, null, null, null, Theme.key_chat_mediaTimeBackground));
arrayList.add(new ThemeDescription(floatingDateView, 0, null, null, null, null, Theme.key_chat_mediaTimeText));
arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip, 0, new Class[] { ScrollSlidingTextTabStrip.class }, new String[] { "selectorDrawable" }, null, null, null, Theme.key_profile_tabSelectedLine));
arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { TextView.class }, null, null, null, Theme.key_profile_tabSelectedText));
arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { TextView.class }, null, null, null, Theme.key_profile_tabText));
arrayList.add(new ThemeDescription(scrollSlidingTextTabStrip.getTabsContainer(), ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[] { TextView.class }, null, null, null, Theme.key_profile_tabSelector));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "frameLayout" }, null, null, null, Theme.key_inappPlayerBackground));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { FragmentContextView.class }, new String[] { "playButton" }, null, null, null, Theme.key_inappPlayerPlayPause));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_inappPlayerTitle));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_FASTSCROLL, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_inappPlayerPerformer));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { FragmentContextView.class }, new String[] { "closeButton" }, null, null, null, Theme.key_inappPlayerClose));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "frameLayout" }, null, null, null, Theme.key_returnToCallBackground));
arrayList.add(new ThemeDescription(fragmentContextView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { FragmentContextView.class }, new String[] { "titleTextView" }, null, null, null, Theme.key_returnToCallText));
for (int a = 0; a < mediaPages.length; a++) {
final int num = a;
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (mediaPages[num].listView != null) {
int count = mediaPages[num].listView.getChildCount();
for (int a1 = 0; a1 < count; a1++) {
View child = mediaPages[num].listView.getChildAt(a1);
if (child instanceof SharedPhotoVideoCell) {
((SharedPhotoVideoCell) child).updateCheckboxColor();
} else if (child instanceof ProfileSearchCell) {
((ProfileSearchCell) child).update(0);
} else if (child instanceof UserCell) {
((UserCell) child).update(0);
}
}
}
};
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { View.class }, Theme.dividerPaint, null, null, Theme.key_divider));
arrayList.add(new ThemeDescription(mediaPages[a].progressView, 0, null, null, null, null, Theme.key_windowBackgroundWhite));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
arrayList.add(new ThemeDescription(mediaPages[a].emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_SECTIONS, new Class[] { GraySectionCell.class }, new String[] { "textView" }, null, null, null, Theme.key_graySectionText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR | ThemeDescription.FLAG_SECTIONS, new Class[] { GraySectionCell.class }, null, null, null, Theme.key_graySection));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { LoadingCell.class }, new String[] { "progressBar" }, null, null, null, Theme.key_progressCircle));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { UserCell.class }, new String[] { "adminTextView" }, null, null, null, Theme.key_profile_creatorIcon));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { UserCell.class }, new String[] { "imageView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { UserCell.class }, new String[] { "nameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { UserCell.class }, new String[] { "statusColor" }, null, null, cellDelegate, Theme.key_windowBackgroundWhiteGrayText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { UserCell.class }, new String[] { "statusOnlineColor" }, null, null, cellDelegate, Theme.key_windowBackgroundWhiteBlueText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { UserCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { ProfileSearchCell.class }, null, new Paint[] { Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint }, null, null, Theme.key_chats_name));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { ProfileSearchCell.class }, null, new Paint[] { Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint }, null, null, Theme.key_chats_secretName));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { ProfileSearchCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { EmptyStubView.class }, new String[] { "emptyTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { SharedDocumentCell.class }, new String[] { "nameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { SharedDocumentCell.class }, new String[] { "dateTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText3));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_PROGRESSBAR, new Class[] { SharedDocumentCell.class }, new String[] { "progressView" }, null, null, null, Theme.key_sharedMedia_startStopLoadIcon));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { SharedDocumentCell.class }, new String[] { "statusImageView" }, null, null, null, Theme.key_sharedMedia_startStopLoadIcon));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOX, new Class[] { SharedDocumentCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkbox));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[] { SharedDocumentCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxCheck));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_IMAGECOLOR, new Class[] { SharedDocumentCell.class }, new String[] { "thumbImageView" }, null, null, null, Theme.key_files_folderIcon));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { SharedDocumentCell.class }, new String[] { "extTextView" }, null, null, null, Theme.key_files_iconText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { LoadingCell.class }, new String[] { "progressBar" }, null, null, null, Theme.key_progressCircle));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOX, new Class[] { SharedAudioCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkbox));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[] { SharedAudioCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxCheck));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { SharedAudioCell.class }, Theme.chat_contextResult_titleTextPaint, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { SharedAudioCell.class }, Theme.chat_contextResult_descriptionTextPaint, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOX, new Class[] { SharedLinkCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkbox));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[] { SharedLinkCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxCheck));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedLinkCell.class }, new String[] { "titleTextPaint" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedLinkCell.class }, null, null, null, Theme.key_windowBackgroundWhiteLinkText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedLinkCell.class }, Theme.linkSelectionPaint, null, null, Theme.key_windowBackgroundWhiteLinkSelection));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedLinkCell.class }, new String[] { "letterDrawable" }, null, null, null, Theme.key_sharedMedia_linkPlaceholderText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { SharedLinkCell.class }, new String[] { "letterDrawable" }, null, null, null, Theme.key_sharedMedia_linkPlaceholder));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR | ThemeDescription.FLAG_SECTIONS, new Class[] { SharedMediaSectionCell.class }, null, null, null, Theme.key_windowBackgroundWhite));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_SECTIONS, new Class[] { SharedMediaSectionCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedMediaSectionCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { SharedPhotoVideoCell.class }, new String[] { "backgroundPaint" }, null, null, null, Theme.key_sharedMedia_photoPlaceholder));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOX, new Class[] { SharedPhotoVideoCell.class }, null, null, cellDelegate, Theme.key_checkbox));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[] { SharedPhotoVideoCell.class }, null, null, cellDelegate, Theme.key_checkboxCheck));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, new Class[] { ContextLinkCell.class }, new String[] { "backgroundPaint" }, null, null, null, Theme.key_sharedMedia_photoPlaceholder));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOX, new Class[] { ContextLinkCell.class }, null, null, cellDelegate, Theme.key_checkbox));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[] { ContextLinkCell.class }, null, null, cellDelegate, Theme.key_checkboxCheck));
arrayList.add(new ThemeDescription(mediaPages[a].listView, 0, null, null, new Drawable[] { pinnedHeaderShadowDrawable }, null, Theme.key_windowBackgroundGrayShadow));
arrayList.add(new ThemeDescription(mediaPages[a].emptyView.title, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(mediaPages[a].emptyView.subtitle, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
}
return arrayList;
}
use of org.telegram.ui.Cells.SharedPhotoVideoCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method onItemClick.
private void onItemClick(int index, View view, MessageObject message, int a, int selectedMode) {
if (message == null || photoVideoChangeColumnsAnimation) {
return;
}
if (isActionModeShowed) {
int loadIndex = message.getDialogId() == dialog_id ? 0 : 1;
if (selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0) {
selectedFiles[loadIndex].remove(message.getId());
if (!message.canDeleteMessage(false, null)) {
cantDeleteMessagesCount--;
}
} else {
if (selectedFiles[0].size() + selectedFiles[1].size() >= 100) {
return;
}
selectedFiles[loadIndex].put(message.getId(), message);
if (!message.canDeleteMessage(false, null)) {
cantDeleteMessagesCount++;
}
}
if (selectedFiles[0].size() == 0 && selectedFiles[1].size() == 0) {
showActionMode(false);
} else {
selectedMessagesCountTextView.setNumber(selectedFiles[0].size() + selectedFiles[1].size(), true);
deleteItem.setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
if (gotoItem != null) {
gotoItem.setVisibility(selectedFiles[0].size() == 1 ? View.VISIBLE : View.GONE);
}
}
scrolling = false;
if (view instanceof SharedDocumentCell) {
((SharedDocumentCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
} else if (view instanceof SharedPhotoVideoCell) {
((SharedPhotoVideoCell) view).setChecked(a, selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
} else if (view instanceof SharedLinkCell) {
((SharedLinkCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
} else if (view instanceof SharedAudioCell) {
((SharedAudioCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
} else if (view instanceof ContextLinkCell) {
((ContextLinkCell) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
} else if (view instanceof SharedPhotoVideoCell2) {
((SharedPhotoVideoCell2) view).setChecked(selectedFiles[loadIndex].indexOfKey(message.getId()) >= 0, true);
}
} else {
if (selectedMode == 0) {
int i = index - sharedMediaData[selectedMode].startOffset;
if (i >= 0 && i < sharedMediaData[selectedMode].messages.size()) {
PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, i, dialog_id, mergeDialogId, provider);
}
} else if (selectedMode == 2 || selectedMode == 4) {
if (view instanceof SharedAudioCell) {
((SharedAudioCell) view).didPressedButton();
}
} else if (selectedMode == 5) {
PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
index = sharedMediaData[selectedMode].messages.indexOf(message);
if (index < 0) {
ArrayList<MessageObject> documents = new ArrayList<>();
documents.add(message);
PhotoViewer.getInstance().openPhoto(documents, 0, 0, 0, provider);
} else {
PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, index, dialog_id, mergeDialogId, provider);
}
} else if (selectedMode == 1) {
if (view instanceof SharedDocumentCell) {
SharedDocumentCell cell = (SharedDocumentCell) view;
TLRPC.Document document = message.getDocument();
if (cell.isLoaded()) {
if (message.canPreviewDocument()) {
PhotoViewer.getInstance().setParentActivity(profileActivity.getParentActivity());
index = sharedMediaData[selectedMode].messages.indexOf(message);
if (index < 0) {
ArrayList<MessageObject> documents = new ArrayList<>();
documents.add(message);
PhotoViewer.getInstance().openPhoto(documents, 0, 0, 0, provider);
} else {
PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, index, dialog_id, mergeDialogId, provider);
}
return;
}
AndroidUtilities.openDocument(message, profileActivity.getParentActivity(), profileActivity);
} else if (!cell.isLoading()) {
MessageObject messageObject = cell.getMessage();
profileActivity.getFileLoader().loadFile(document, messageObject, 0, 0);
cell.updateFileExistIcon(true);
} else {
profileActivity.getFileLoader().cancelLoadFile(document);
cell.updateFileExistIcon(true);
}
}
} else if (selectedMode == 3) {
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(profileActivity.getParentActivity(), profileActivity);
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);
}
}
}
updateForwardItem();
}
use of org.telegram.ui.Cells.SharedPhotoVideoCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method onItemLongClick.
private boolean onItemLongClick(MessageObject item, View view, int a) {
if (isActionModeShowed || profileActivity.getParentActivity() == null || item == null) {
return false;
}
AndroidUtilities.hideKeyboard(profileActivity.getParentActivity().getCurrentFocus());
selectedFiles[item.getDialogId() == dialog_id ? 0 : 1].put(item.getId(), item);
if (!item.canDeleteMessage(false, null)) {
cantDeleteMessagesCount++;
}
deleteItem.setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
if (gotoItem != null) {
gotoItem.setVisibility(View.VISIBLE);
}
selectedMessagesCountTextView.setNumber(1, false);
AnimatorSet animatorSet = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
for (int i = 0; i < actionModeViews.size(); i++) {
View view2 = actionModeViews.get(i);
AndroidUtilities.clearDrawableAnimation(view2);
animators.add(ObjectAnimator.ofFloat(view2, View.SCALE_Y, 0.1f, 1.0f));
}
animatorSet.playTogether(animators);
animatorSet.setDuration(250);
animatorSet.start();
scrolling = false;
if (view instanceof SharedDocumentCell) {
((SharedDocumentCell) view).setChecked(true, true);
} else if (view instanceof SharedPhotoVideoCell) {
((SharedPhotoVideoCell) view).setChecked(a, true, true);
} else if (view instanceof SharedLinkCell) {
((SharedLinkCell) view).setChecked(true, true);
} else if (view instanceof SharedAudioCell) {
((SharedAudioCell) view).setChecked(true, true);
} else if (view instanceof ContextLinkCell) {
((ContextLinkCell) view).setChecked(true, true);
} else if (view instanceof SharedPhotoVideoCell2) {
((SharedPhotoVideoCell2) view).setChecked(true, true);
}
if (!isActionModeShowed) {
showActionMode(true);
}
updateForwardItem();
return true;
}
use of org.telegram.ui.Cells.SharedPhotoVideoCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method checkLoadMoreScroll.
private void checkLoadMoreScroll(MediaPage mediaPage, RecyclerListView recyclerView, LinearLayoutManager layoutManager) {
if (photoVideoChangeColumnsAnimation || jumpToRunnable != null) {
return;
}
long currentTime = System.currentTimeMillis();
if ((recyclerView.getFastScroll() != null && recyclerView.getFastScroll().isPressed()) && (currentTime - mediaPage.lastCheckScrollTime) < 300) {
return;
}
mediaPage.lastCheckScrollTime = currentTime;
if (searching && searchWas || mediaPage.selectedType == 7) {
return;
}
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
int visibleItemCount = firstVisibleItem == RecyclerView.NO_POSITION ? 0 : Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
int totalItemCount = recyclerView.getAdapter().getItemCount();
if (mediaPage.selectedType == 0 || mediaPage.selectedType == 1 || mediaPage.selectedType == 2 || mediaPage.selectedType == 4) {
int type = mediaPage.selectedType;
totalItemCount = sharedMediaData[type].getStartOffset() + sharedMediaData[type].messages.size();
if (sharedMediaData[type].fastScrollDataLoaded && sharedMediaData[type].fastScrollPeriods.size() > 2 && mediaPage.selectedType == 0 && sharedMediaData[type].messages.size() != 0) {
int columnsCount = 1;
if (type == 0) {
columnsCount = mediaColumnsCount;
}
int jumpToTreshold = (int) ((recyclerView.getMeasuredHeight() / ((float) (recyclerView.getMeasuredWidth() / (float) columnsCount))) * columnsCount * 1.5f);
if (jumpToTreshold < 100) {
jumpToTreshold = 100;
}
if (jumpToTreshold < sharedMediaData[type].fastScrollPeriods.get(1).startOffset) {
jumpToTreshold = sharedMediaData[type].fastScrollPeriods.get(1).startOffset;
}
if ((firstVisibleItem > totalItemCount && firstVisibleItem - totalItemCount > jumpToTreshold) || ((firstVisibleItem + visibleItemCount) < sharedMediaData[type].startOffset && sharedMediaData[0].startOffset - (firstVisibleItem + visibleItemCount) > jumpToTreshold)) {
AndroidUtilities.runOnUIThread(jumpToRunnable = () -> {
findPeriodAndJumpToDate(type, recyclerView, false);
jumpToRunnable = null;
});
return;
}
}
}
if (mediaPage.selectedType == 7) {
} else if (mediaPage.selectedType == 6) {
if (visibleItemCount > 0) {
if (!commonGroupsAdapter.endReached && !commonGroupsAdapter.loading && !commonGroupsAdapter.chats.isEmpty() && firstVisibleItem + visibleItemCount >= totalItemCount - 5) {
commonGroupsAdapter.getChats(commonGroupsAdapter.chats.get(commonGroupsAdapter.chats.size() - 1).id, 100);
}
}
} else {
final int threshold;
if (mediaPage.selectedType == 0) {
threshold = 3;
} else if (mediaPage.selectedType == 5) {
threshold = 10;
} else {
threshold = 6;
}
if ((firstVisibleItem + visibleItemCount > totalItemCount - threshold || sharedMediaData[mediaPage.selectedType].loadingAfterFastScroll) && !sharedMediaData[mediaPage.selectedType].loading) {
int type;
if (mediaPage.selectedType == 0) {
type = MEDIA_PHOTOVIDEO;
if (sharedMediaData[0].filterType == FILTER_PHOTOS_ONLY) {
type = MediaDataController.MEDIA_PHOTOS_ONLY;
} else if (sharedMediaData[0].filterType == FILTER_VIDEOS_ONLY) {
type = MediaDataController.MEDIA_VIDEOS_ONLY;
}
} else if (mediaPage.selectedType == 1) {
type = MediaDataController.MEDIA_FILE;
} else if (mediaPage.selectedType == 2) {
type = MediaDataController.MEDIA_AUDIO;
} else if (mediaPage.selectedType == 4) {
type = MediaDataController.MEDIA_MUSIC;
} else if (mediaPage.selectedType == 5) {
type = MediaDataController.MEDIA_GIF;
} else {
type = MediaDataController.MEDIA_URL;
}
if (!sharedMediaData[mediaPage.selectedType].endReached[0]) {
sharedMediaData[mediaPage.selectedType].loading = true;
profileActivity.getMediaDataController().loadMedia(dialog_id, 50, sharedMediaData[mediaPage.selectedType].max_id[0], 0, type, 1, profileActivity.getClassGuid(), sharedMediaData[mediaPage.selectedType].requestIndex);
} else if (mergeDialogId != 0 && !sharedMediaData[mediaPage.selectedType].endReached[1]) {
sharedMediaData[mediaPage.selectedType].loading = true;
profileActivity.getMediaDataController().loadMedia(mergeDialogId, 50, sharedMediaData[mediaPage.selectedType].max_id[1], 0, type, 1, profileActivity.getClassGuid(), sharedMediaData[mediaPage.selectedType].requestIndex);
}
}
int startOffset = sharedMediaData[mediaPage.selectedType].startOffset;
if (mediaPage.selectedType == 0) {
startOffset = photoVideoAdapter.getPositionForIndex(0);
}
if (firstVisibleItem - startOffset < threshold + 1 && !sharedMediaData[mediaPage.selectedType].loading && !sharedMediaData[mediaPage.selectedType].startReached && !sharedMediaData[mediaPage.selectedType].loadingAfterFastScroll) {
loadFromStart(mediaPage.selectedType);
}
if (mediaPages[0].listView == recyclerView && (mediaPages[0].selectedType == 0 || mediaPages[0].selectedType == 5) && firstVisibleItem != RecyclerView.NO_POSITION) {
RecyclerListView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
if (holder != null && holder.getItemViewType() == 0) {
if (holder.itemView instanceof SharedPhotoVideoCell) {
SharedPhotoVideoCell cell = (SharedPhotoVideoCell) holder.itemView;
MessageObject messageObject = cell.getMessageObject(0);
if (messageObject != null) {
floatingDateView.setCustomDate(messageObject.messageOwner.date, false, true);
}
} else if (holder.itemView instanceof ContextLinkCell) {
ContextLinkCell cell = (ContextLinkCell) holder.itemView;
floatingDateView.setCustomDate(cell.getDate(), false, true);
}
}
}
}
}
Aggregations