Java Code Examples for org.telegram.tgnet.TLRPC#TL_messages_stickerSet
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_messages_stickerSet .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void sendReorder() { if (!needReorder) { return; } DataQuery.getInstance(currentAccount).calcNewHash(currentType); needReorder = false; TLRPC.TL_messages_reorderStickerSets req = new TLRPC.TL_messages_reorderStickerSets(); req.masks = currentType == DataQuery.TYPE_MASK; ArrayList<TLRPC.TL_messages_stickerSet> arrayList = DataQuery.getInstance(currentAccount).getStickerSets(currentType); for (int a = 0; a < arrayList.size(); a++) { req.order.add(arrayList.get(a).set.id); } ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { } }); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.stickersDidLoaded, currentType); }
Example 2
Source File: StickersAlert.java From Telegram with GNU General Public License v2.0 | 5 votes |
public StickersAlert(Context context, BaseFragment baseFragment, TLRPC.InputStickerSet set, TLRPC.TL_messages_stickerSet loadedSet, StickersAlertDelegate stickersAlertDelegate) { super(context, false); delegate = stickersAlertDelegate; inputStickerSet = set; stickerSet = loadedSet; parentFragment = baseFragment; loadStickerSet(); init(context); }
Example 3
Source File: StickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public long getItemId(int i) { if (i >= stickersStartRow && i < stickersEndRow) { ArrayList<TLRPC.TL_messages_stickerSet> arrayList = DataQuery.getInstance(currentAccount).getStickerSets(currentType); return arrayList.get(i - stickersStartRow).set.id; } else if (i == suggestRow || i == suggestInfoRow || i == archivedRow || i == archivedInfoRow || i == featuredRow || i == featuredInfoRow || i == masksRow || i == masksInfoRow) { return Integer.MIN_VALUE; } return i; }
Example 4
Source File: StickersAlert.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public StickersAlert(Context context, BaseFragment baseFragment, TLRPC.InputStickerSet set, TLRPC.TL_messages_stickerSet loadedSet, StickersAlertDelegate stickersAlertDelegate) { super(context, false); delegate = stickersAlertDelegate; inputStickerSet = set; stickerSet = loadedSet; parentFragment = baseFragment; loadStickerSet(); init(context); }
Example 5
Source File: StickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void swapElements(int fromIndex, int toIndex) { if (fromIndex != toIndex) { needReorder = true; } ArrayList<TLRPC.TL_messages_stickerSet> arrayList = DataQuery.getInstance(currentAccount).getStickerSets(currentType); TLRPC.TL_messages_stickerSet from = arrayList.get(fromIndex - stickersStartRow); arrayList.set(fromIndex - stickersStartRow, arrayList.get(toIndex - stickersStartRow)); arrayList.set(toIndex - stickersStartRow, from); notifyItemMoved(fromIndex, toIndex); }
Example 6
Source File: StickersSearchAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void installStickerSet(TLRPC.StickerSetCovered pack, FeaturedStickerSetInfoCell cell) { for (int i = 0; i < primaryInstallingStickerSets.length; i++) { if (primaryInstallingStickerSets[i] != null) { final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id); if (s != null && !s.set.archived) { primaryInstallingStickerSets[i] = null; break; } if (primaryInstallingStickerSets[i].set.id == pack.set.id) { return; } } } boolean primary = false; for (int i = 0; i < primaryInstallingStickerSets.length; i++) { if (primaryInstallingStickerSets[i] == null) { primaryInstallingStickerSets[i] = pack; primary = true; break; } } if (!primary && cell != null) { cell.setAddDrawProgress(true, true); } installingStickerSets.put(pack.set.id, pack); if (cell != null) { delegate.onStickerSetAdd(cell.getStickerSet(), primary); } else { for (int i = 0, size = positionsToSets.size(); i < size; i++) { final TLRPC.StickerSetCovered item = positionsToSets.get(i); if (item != null && item.set.id == pack.set.id) { notifyItemChanged(i, PAYLOAD_ANIMATED); break; } } } }
Example 7
Source File: StickerSetCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setStickersSet(TLRPC.TL_messages_stickerSet set, boolean divider) { needDivider = divider; stickersSet = set; imageView.setVisibility(VISIBLE); if (progressView != null) { progressView.setVisibility(INVISIBLE); } textView.setTranslationY(0); textView.setText(stickersSet.set.title); if (stickersSet.set.archived) { textView.setAlpha(0.5f); valueTextView.setAlpha(0.5f); imageView.setAlpha(0.5f); } else { textView.setAlpha(1.0f); valueTextView.setAlpha(1.0f); imageView.setAlpha(1.0f); } ArrayList<TLRPC.Document> documents = set.documents; if (documents != null && !documents.isEmpty()) { valueTextView.setText(LocaleController.formatPluralString("Stickers", documents.size())); TLRPC.Document document = documents.get(0); if (document.thumb != null && document.thumb.location != null) { imageView.setImage(document.thumb.location, null, "webp", null); } } else { valueTextView.setText(LocaleController.formatPluralString("Stickers", 0)); } }
Example 8
Source File: StickerMasksAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public int getTabForPosition(int position) { if (position == 0) { position = 1; } if (stickersPerRow == 0) { int width = gridView.getMeasuredWidth(); if (width == 0) { width = AndroidUtilities.displaySize.x; } stickersPerRow = width / AndroidUtilities.dp(72); } int row = positionToRow.get(position, Integer.MIN_VALUE); if (row == Integer.MIN_VALUE) { return stickerSets[currentType].size() - 1 + stickersTabOffset; } Object pack = rowStartPack.get(row); if (pack instanceof String) { if ("recent".equals(pack)) { return recentTabBum; } else { return favTabBum; } } else { TLRPC.TL_messages_stickerSet set = (TLRPC.TL_messages_stickerSet) pack; int idx = stickerSets[currentType].indexOf(set); return idx + stickersTabOffset; } }
Example 9
Source File: StickerMasksView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public int getTabForPosition(int position) { if (stickersPerRow == 0) { int width = getMeasuredWidth(); if (width == 0) { width = AndroidUtilities.displaySize.x; } stickersPerRow = width / AndroidUtilities.dp(72); } int row = position / stickersPerRow; TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row); if (pack == null) { return recentTabBum; } return stickerSets[currentType].indexOf(pack) + stickersTabOffset; }
Example 10
Source File: StickersActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setStickerSets(List<TLRPC.TL_messages_stickerSet> stickerSets) { this.stickerSets.clear(); this.stickerSets.addAll(stickerSets); }
Example 11
Source File: StickersActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ListAdapter(Context context, List<TLRPC.TL_messages_stickerSet> stickerSets) { mContext = context; this.stickerSets.addAll(stickerSets); }
Example 12
Source File: GroupStickersActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void resolveStickerSet() { if (listAdapter == null) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; } if (queryRunnable != null) { AndroidUtilities.cancelRunOnUIThread(queryRunnable); queryRunnable = null; } selectedStickerSet = null; if (usernameTextView.length() <= 0) { searching = false; searchWas = false; if (selectedStickerRow != -1) { updateRows(); } return; } searching = true; searchWas = true; final String query = usernameTextView.getText().toString(); TLRPC.TL_messages_stickerSet existingSet = MediaDataController.getInstance(currentAccount).getStickerSetByName(query); if (existingSet != null) { selectedStickerSet = existingSet; } if (selectedStickerRow == -1) { updateRows(); } else { listAdapter.notifyItemChanged(selectedStickerRow); } if (existingSet != null) { searching = false; return; } AndroidUtilities.runOnUIThread(queryRunnable = () -> { if (queryRunnable == null) { return; } TLRPC.TL_messages_getStickerSet req = new TLRPC.TL_messages_getStickerSet(); req.stickerset = new TLRPC.TL_inputStickerSetShortName(); req.stickerset.short_name = query; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { searching = false; if (response instanceof TLRPC.TL_messages_stickerSet) { selectedStickerSet = (TLRPC.TL_messages_stickerSet) response; if (donePressed) { saveStickerSet(); } else { if (selectedStickerRow != -1) { listAdapter.notifyItemChanged(selectedStickerRow); } else { updateRows(); } } } else { if (selectedStickerRow != -1) { listAdapter.notifyItemChanged(selectedStickerRow); } if (donePressed) { donePressed = false; showEditDoneProgress(false); if (getParentActivity() != null) { Toast.makeText(getParentActivity(), LocaleController.getString("AddStickersNotFound", R.string.AddStickersNotFound), Toast.LENGTH_SHORT).show(); } } } reqId = 0; })); }, 500); }
Example 13
Source File: StickerMasksView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public int getPositionForPack(TLRPC.TL_messages_stickerSet stickerSet) { return packStartRow.get(stickerSet) * stickersPerRow; }
Example 14
Source File: GroupStickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void resolveStickerSet() { if (listAdapter == null) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; } if (queryRunnable != null) { AndroidUtilities.cancelRunOnUIThread(queryRunnable); queryRunnable = null; } selectedStickerSet = null; if (usernameTextView.length() <= 0) { searching = false; searchWas = false; if (selectedStickerRow != -1) { updateRows(); } return; } searching = true; searchWas = true; final String query = usernameTextView.getText().toString(); TLRPC.TL_messages_stickerSet existingSet = DataQuery.getInstance(currentAccount).getStickerSetByName(query); if (existingSet != null) { selectedStickerSet = existingSet; } if (selectedStickerRow == -1) { updateRows(); } else { listAdapter.notifyItemChanged(selectedStickerRow); } if (existingSet != null) { searching = false; return; } AndroidUtilities.runOnUIThread(queryRunnable = new Runnable() { @Override public void run() { if (queryRunnable == null) { return; } TLRPC.TL_messages_getStickerSet req = new TLRPC.TL_messages_getStickerSet(); req.stickerset = new TLRPC.TL_inputStickerSetShortName(); req.stickerset.short_name = query; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { searching = false; if (response instanceof TLRPC.TL_messages_stickerSet) { selectedStickerSet = (TLRPC.TL_messages_stickerSet) response; if (donePressed) { saveStickerSet(); } else { if (selectedStickerRow != -1) { listAdapter.notifyItemChanged(selectedStickerRow); } else { updateRows(); } } } else { if (selectedStickerRow != -1) { listAdapter.notifyItemChanged(selectedStickerRow); } if (donePressed) { donePressed = false; showEditDoneProgress(false); if (getParentActivity() != null) { Toast.makeText(getParentActivity(), LocaleController.getString("AddStickersNotFound", R.string.AddStickersNotFound), Toast.LENGTH_SHORT).show(); } } } reqId = 0; } }); } }); } }, 500); }
Example 15
Source File: StickerMasksView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public int getPositionForPack(TLRPC.TL_messages_stickerSet stickerSet) { return packStartRow.get(stickerSet) * stickersPerRow; }
Example 16
Source File: StickersActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void swapListElements(List<TLRPC.TL_messages_stickerSet> list, int index1, int index2) { final TLRPC.TL_messages_stickerSet set1 = list.get(index1); list.set(index1, list.get(index2)); list.set(index2, set1); }
Example 17
Source File: TrendingStickersLayout.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void bindStickerSetCell(View view, int position, boolean animated) { final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount); boolean unread = false; final TLRPC.StickerSetCovered stickerSetCovered; if (position < totalItems) { stickerSetCovered = sets.get((Integer) cache.get(position)); final ArrayList<Long> unreadStickers = mediaDataController.getUnreadStickerSets(); unread = unreadStickers != null && unreadStickers.contains(stickerSetCovered.set.id); if (unread) { mediaDataController.markFaturedStickersByIdAsRead(stickerSetCovered.set.id); } } else { stickerSetCovered = sets.get((Integer) cache.get(position)); } mediaDataController.preloadStickerSetThumb(stickerSetCovered); boolean forceInstalled = false; for (int i = 0; i < primaryInstallingStickerSets.length; i++) { if (primaryInstallingStickerSets[i] != null) { final TLRPC.TL_messages_stickerSet s = MediaDataController.getInstance(currentAccount).getStickerSetById(primaryInstallingStickerSets[i].set.id); if (s != null && !s.set.archived) { primaryInstallingStickerSets[i] = null; continue; } if (primaryInstallingStickerSets[i].set.id == stickerSetCovered.set.id) { forceInstalled = true; break; } } } final boolean isSetInstalled = mediaDataController.isStickerPackInstalled(stickerSetCovered.set.id); boolean installing = installingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0; boolean removing = removingStickerSets.indexOfKey(stickerSetCovered.set.id) >= 0; if (installing && isSetInstalled) { installingStickerSets.remove(stickerSetCovered.set.id); installing = false; } else if (removing && !isSetInstalled) { removingStickerSets.remove(stickerSetCovered.set.id); removing = false; } final FeaturedStickerSetInfoCell cell = (FeaturedStickerSetInfoCell) view; cell.setStickerSet(stickerSetCovered, unread, animated, 0, 0, forceInstalled); cell.setAddDrawProgress(!forceInstalled && installing, animated); cell.setNeedDivider(position > 0 && (cache.get(position - 1) == null || !cache.get(position - 1).equals(ITEM_SECTION))); }
Example 18
Source File: StickersActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setStickerSets(List<TLRPC.TL_messages_stickerSet> stickerSets) { this.stickerSets.clear(); this.stickerSets.addAll(stickerSets); }
Example 19
Source File: StickerMasksAlert.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void notifyDataSetChanged() { int width = gridView.getMeasuredWidth(); if (width == 0) { width = AndroidUtilities.displaySize.x; } stickersPerRow = width / AndroidUtilities.dp(72); stickersLayoutManager.setSpanCount(stickersPerRow); rowStartPack.clear(); packStartPosition.clear(); positionToRow.clear(); cache.clear(); totalItems = 0; ArrayList<TLRPC.TL_messages_stickerSet> packs = stickerSets[currentType]; int startRow = 0; for (int a = -3; a < packs.size(); a++) { ArrayList<TLRPC.Document> documents; TLRPC.TL_messages_stickerSet pack = null; String key; if (a == -3) { cache.put(totalItems++, "search"); startRow++; continue; } else if (a == -2) { if (currentType == MediaDataController.TYPE_IMAGE) { documents = favouriteStickers; packStartPosition.put(key = "fav", totalItems); } else { documents = null; key = null; } } else if (a == -1) { documents = recentStickers[currentType]; packStartPosition.put(key = "recent", totalItems); } else { key = null; pack = packs.get(a); documents = pack.documents; packStartPosition.put(pack, totalItems); } if (documents == null || documents.isEmpty()) { continue; } int count = (int) Math.ceil(documents.size() / (float) stickersPerRow); if (pack != null) { cache.put(totalItems, pack); } else { cache.put(totalItems, documents); } positionToRow.put(totalItems, startRow); for (int b = 0; b < documents.size(); b++) { int num = 1 + b + totalItems; cache.put(num, documents.get(b)); if (pack != null) { cacheParents.put(num, pack); } else { cacheParents.put(num, key); } positionToRow.put(1 + b + totalItems, startRow + 1 + b / stickersPerRow); } for (int b = 0; b < count + 1; b++) { if (pack != null) { rowStartPack.put(startRow + b, pack); } else { rowStartPack.put(startRow + b, a == -1 ? "recent" : "fav"); } } totalItems += count * stickersPerRow + 1; startRow += count + 1; } super.notifyDataSetChanged(); }
Example 20
Source File: StickerSetCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public TLRPC.TL_messages_stickerSet getStickersSet() { return stickersSet; }