use of org.telegram.ui.Cells.DialogCell 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);
}
}
}
}
use of org.telegram.ui.Cells.DialogCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ThemePreviewActivity method didReceivedNotification.
@SuppressWarnings("unchecked")
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.emojiLoaded) {
if (listView == null) {
return;
}
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof DialogCell) {
DialogCell cell = (DialogCell) child;
cell.update(0);
}
}
} else if (id == NotificationCenter.invalidateMotionBackground) {
if (listView2 != null) {
listView2.invalidateViews();
}
} else if (id == NotificationCenter.didSetNewWallpapper) {
if (page2 != null) {
setCurrentImage(true);
}
} else if (id == NotificationCenter.wallpapersNeedReload) {
if (currentWallpaper instanceof WallpapersListActivity.FileWallpaper) {
WallpapersListActivity.FileWallpaper fileWallpaper = (WallpapersListActivity.FileWallpaper) currentWallpaper;
if (fileWallpaper.slug == null) {
fileWallpaper.slug = (String) args[0];
}
}
} else if (id == NotificationCenter.wallpapersDidLoad) {
ArrayList<TLRPC.WallPaper> arrayList = (ArrayList<TLRPC.WallPaper>) args[0];
patterns.clear();
patternsDict.clear();
boolean added = false;
for (int a = 0, N = arrayList.size(); a < N; a++) {
TLRPC.WallPaper wallPaper = arrayList.get(a);
if (wallPaper instanceof TLRPC.TL_wallPaper && wallPaper.pattern) {
if (wallPaper.document != null && !patternsDict.containsKey(wallPaper.document.id)) {
patterns.add(wallPaper);
patternsDict.put(wallPaper.document.id, wallPaper);
}
if (accent != null && accent.patternSlug.equals(wallPaper.slug)) {
selectedPattern = (TLRPC.TL_wallPaper) wallPaper;
added = true;
setCurrentImage(false);
updateButtonState(false, false);
} else if (accent == null && selectedPattern != null && selectedPattern.slug.equals(wallPaper.slug)) {
added = true;
}
}
}
if (!added && selectedPattern != null) {
patterns.add(0, selectedPattern);
}
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
long acc = 0;
for (int a = 0, N = arrayList.size(); a < N; a++) {
TLRPC.WallPaper wallPaper = arrayList.get(a);
if (wallPaper instanceof TLRPC.TL_wallPaper) {
acc = MediaDataController.calcHash(acc, wallPaper.id);
}
}
TLRPC.TL_account_getWallPapers req = new TLRPC.TL_account_getWallPapers();
req.hash = acc;
int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_account_wallPapers) {
TLRPC.TL_account_wallPapers res = (TLRPC.TL_account_wallPapers) response;
patterns.clear();
patternsDict.clear();
boolean added2 = false;
for (int a = 0, N = res.wallpapers.size(); a < N; a++) {
if (!(res.wallpapers.get(a) instanceof TLRPC.TL_wallPaper)) {
continue;
}
TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) res.wallpapers.get(a);
if (wallPaper.pattern) {
if (wallPaper.document != null && !patternsDict.containsKey(wallPaper.document.id)) {
patterns.add(wallPaper);
patternsDict.put(wallPaper.document.id, wallPaper);
}
if (accent != null && accent.patternSlug.equals(wallPaper.slug)) {
selectedPattern = wallPaper;
added2 = true;
setCurrentImage(false);
updateButtonState(false, false);
} else if (accent == null && selectedPattern != null && selectedPattern.slug.equals(wallPaper.slug)) {
added2 = true;
}
}
}
if (!added2 && selectedPattern != null) {
patterns.add(0, selectedPattern);
}
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
MessagesStorage.getInstance(currentAccount).putWallpapers(res.wallpapers, 1);
}
if (selectedPattern == null && accent != null && !TextUtils.isEmpty(accent.patternSlug)) {
TLRPC.TL_account_getWallPaper req2 = new TLRPC.TL_account_getWallPaper();
TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
inputWallPaperSlug.slug = accent.patternSlug;
req2.wallpaper = inputWallPaperSlug;
int reqId2 = getConnectionsManager().sendRequest(req2, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
if (response1 instanceof TLRPC.TL_wallPaper) {
TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) response1;
if (wallPaper.pattern) {
selectedPattern = wallPaper;
setCurrentImage(false);
updateButtonState(false, false);
patterns.add(0, selectedPattern);
if (patternsAdapter != null) {
patternsAdapter.notifyDataSetChanged();
}
}
}
}));
ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId2, classGuid);
}
}));
ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
}
}
Aggregations