use of org.telegram.ui.FilteredSearchView in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method getThemeDescriptors.
public void getThemeDescriptors(ArrayList<ThemeDescription> arrayList) {
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) instanceof FilteredSearchView) {
arrayList.addAll(((FilteredSearchView) getChildAt(i)).getThemeDescriptions());
}
}
int n = viewsByType.size();
for (int i = 0; i < n; i++) {
View v = viewsByType.valueAt(i);
if (v instanceof FilteredSearchView) {
arrayList.addAll(((FilteredSearchView) v).getThemeDescriptions());
}
}
if (noMediaFiltersSearchView != null) {
arrayList.addAll(noMediaFiltersSearchView.getThemeDescriptions());
}
arrayList.add(new ThemeDescription(emptyView.title, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
arrayList.add(new ThemeDescription(emptyView.subtitle, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
}
use of org.telegram.ui.FilteredSearchView in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method showActionMode.
private void showActionMode(boolean show) {
if (isActionModeShowed == show) {
return;
}
if (show && parent.getActionBar().isActionModeShowed()) {
return;
}
if (show && !parent.getActionBar().actionModeIsExist(actionModeTag)) {
ActionBarMenu actionMode = parent.getActionBar().createActionMode(true, actionModeTag);
selectedMessagesCountTextView = new NumberTextView(actionMode.getContext());
selectedMessagesCountTextView.setTextSize(18);
selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedMessagesCountTextView.setTextColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon));
actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
selectedMessagesCountTextView.setOnTouchListener((v, event) -> true);
gotoItem = actionMode.addItemWithWidth(gotoItemId, R.drawable.msg_message, AndroidUtilities.dp(54), LocaleController.getString("AccDescrGoToMessage", R.string.AccDescrGoToMessage));
forwardItem = actionMode.addItemWithWidth(forwardItemId, R.drawable.msg_forward, AndroidUtilities.dp(54), LocaleController.getString("Forward", R.string.Forward));
}
if (parent.getActionBar().getBackButton().getDrawable() instanceof MenuDrawable) {
parent.getActionBar().setBackButtonDrawable(new BackDrawable(false));
}
isActionModeShowed = show;
if (show) {
AndroidUtilities.hideKeyboard(parent.getParentActivity().getCurrentFocus());
parent.getActionBar().showActionMode();
selectedMessagesCountTextView.setNumber(selectedFiles.size(), false);
gotoItem.setVisibility(View.VISIBLE);
forwardItem.setVisibility(View.VISIBLE);
} else {
parent.getActionBar().hideActionMode();
selectedFiles.clear();
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) instanceof FilteredSearchView) {
((FilteredSearchView) getChildAt(i)).update();
}
}
if (noMediaFiltersSearchView != null) {
noMediaFiltersSearchView.update();
}
int n = viewsByType.size();
for (int i = 0; i < n; i++) {
View v = viewsByType.valueAt(i);
if (v instanceof FilteredSearchView) {
((FilteredSearchView) v).update();
}
}
}
}
use of org.telegram.ui.FilteredSearchView in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method search.
private void search(View view, int position, String query, boolean reset) {
long dialogId = 0;
long minDate = 0;
long maxDate = 0;
boolean includeFolder = false;
for (int i = 0; i < currentSearchFilters.size(); i++) {
FiltersView.MediaFilterData data = currentSearchFilters.get(i);
if (data.filterType == FiltersView.FILTER_TYPE_CHAT) {
if (data.chat instanceof TLRPC.User) {
dialogId = ((TLRPC.User) data.chat).id;
} else if (data.chat instanceof TLRPC.Chat) {
dialogId = -((TLRPC.Chat) data.chat).id;
}
} else if (data.filterType == FiltersView.FILTER_TYPE_DATE) {
minDate = data.dateData.minDate;
maxDate = data.dateData.maxDate;
} else if (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE) {
includeFolder = true;
}
}
if (view == searchContainer) {
if (dialogId == 0 && minDate == 0 && maxDate == 0) {
lastSearchScrolledToTop = false;
dialogsSearchAdapter.searchDialogs(query, includeFolder ? 1 : 0);
dialogsSearchAdapter.setFiltersDelegate(filteredSearchViewDelegate, false);
noMediaFiltersSearchView.animate().setListener(null).cancel();
noMediaFiltersSearchView.setDelegate(null, false);
if (reset) {
emptyView.showProgress(!dialogsSearchAdapter.isSearching(), false);
emptyView.showProgress(dialogsSearchAdapter.isSearching(), false);
} else {
if (!dialogsSearchAdapter.hasRecentSearch()) {
emptyView.showProgress(dialogsSearchAdapter.isSearching(), true);
}
}
if (reset) {
noMediaFiltersSearchView.setVisibility(View.GONE);
} else {
if (noMediaFiltersSearchView.getVisibility() != View.GONE) {
noMediaFiltersSearchView.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
noMediaFiltersSearchView.setVisibility(View.GONE);
}
}).setDuration(150).start();
}
}
noMediaFiltersSearchView.setTag(null);
} else {
noMediaFiltersSearchView.setTag(1);
noMediaFiltersSearchView.setDelegate(filteredSearchViewDelegate, false);
noMediaFiltersSearchView.animate().setListener(null).cancel();
if (reset) {
noMediaFiltersSearchView.setVisibility(View.VISIBLE);
noMediaFiltersSearchView.setAlpha(1f);
} else {
if (noMediaFiltersSearchView.getVisibility() != View.VISIBLE) {
noMediaFiltersSearchView.setVisibility(View.VISIBLE);
noMediaFiltersSearchView.setAlpha(0f);
reset = true;
}
noMediaFiltersSearchView.animate().alpha(1f).setDuration(150).start();
}
noMediaFiltersSearchView.search(dialogId, minDate, maxDate, null, includeFolder, query, reset);
emptyView.setVisibility(View.GONE);
}
emptyView.setKeyboardHeight(keyboardSize, false);
noMediaFiltersSearchView.setKeyboardHeight(keyboardSize, false);
} else {
((FilteredSearchView) view).setKeyboardHeight(keyboardSize, false);
((FilteredSearchView) view).search(dialogId, minDate, maxDate, FiltersView.filters[position - 1], includeFolder, query, reset);
}
}
use of org.telegram.ui.FilteredSearchView in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method messagesDeleted.
public void messagesDeleted(long channelId, ArrayList<Integer> markAsDeletedMessages) {
int n = viewsByType.size();
for (int i = 0; i < n; i++) {
View v = viewsByType.valueAt(i);
if (v instanceof FilteredSearchView) {
((FilteredSearchView) v).messagesDeleted(channelId, markAsDeletedMessages);
}
}
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) instanceof FilteredSearchView) {
((FilteredSearchView) getChildAt(i)).messagesDeleted(channelId, markAsDeletedMessages);
}
}
noMediaFiltersSearchView.messagesDeleted(channelId, markAsDeletedMessages);
if (!selectedFiles.isEmpty()) {
ArrayList<FilteredSearchView.MessageHashId> toRemove = null;
Iterator<FilteredSearchView.MessageHashId> iterator = selectedFiles.keySet().iterator();
while (iterator.hasNext()) {
FilteredSearchView.MessageHashId hashId = iterator.next();
MessageObject messageObject = selectedFiles.get(hashId);
long dialogId = messageObject.getDialogId();
int currentChannelId = dialogId < 0 && ChatObject.isChannel((int) -dialogId, currentAccount) ? (int) -dialogId : 0;
if (currentChannelId == channelId) {
for (int i = 0; i < markAsDeletedMessages.size(); i++) {
if (messageObject.getId() == markAsDeletedMessages.get(i)) {
toRemove = new ArrayList<>();
toRemove.add(hashId);
}
}
}
if (toRemove != null) {
for (int a = 0, N = toRemove.size(); a < N; a++) {
selectedFiles.remove(toRemove.get(a));
}
selectedMessagesCountTextView.setNumber(selectedFiles.size(), true);
if (gotoItem != null) {
gotoItem.setVisibility(selectedFiles.size() == 1 ? View.VISIBLE : View.GONE);
}
}
}
}
}
use of org.telegram.ui.FilteredSearchView in project Telegram-FOSS by Telegram-FOSS-Team.
the class SearchViewPager method updateColors.
public void updateColors() {
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i) instanceof FilteredSearchView) {
RecyclerListView recyclerListView = ((FilteredSearchView) getChildAt(i)).recyclerListView;
int count = recyclerListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = recyclerListView.getChildAt(a);
if (child instanceof DialogCell) {
((DialogCell) child).update(0);
}
}
}
}
int n = viewsByType.size();
for (int i = 0; i < n; i++) {
View v = viewsByType.valueAt(i);
if (v instanceof FilteredSearchView) {
RecyclerListView recyclerListView = ((FilteredSearchView) v).recyclerListView;
int count = recyclerListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = recyclerListView.getChildAt(a);
if (child instanceof DialogCell) {
((DialogCell) child).update(0);
}
}
}
}
if (noMediaFiltersSearchView != null) {
RecyclerListView recyclerListView = noMediaFiltersSearchView.recyclerListView;
int count = recyclerListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = recyclerListView.getChildAt(a);
if (child instanceof DialogCell) {
((DialogCell) child).update(0);
}
}
}
}
Aggregations