org.telegram.messenger.NotificationCenter Java Examples
The following examples show how to use
org.telegram.messenger.NotificationCenter.
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: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.albumsDidLoaded) { if (photoAttachAdapter != null) { loading = false; progressView.showTextView(); photoAttachAdapter.notifyDataSetChanged(); cameraAttachAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.reloadInlineHints) { if (adapter != null) { adapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.cameraInitied) { checkCamera(false); } }
Example #2
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static void processCreate(EditTextBoldCursor editText, AlertDialog alertDialog, BaseFragment fragment) { if (fragment == null || fragment.getParentActivity() == null) { return; } AndroidUtilities.hideKeyboard(editText); Theme.ThemeInfo themeInfo = Theme.createNewTheme(editText.getText().toString()); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.themeListUpdated); ThemeEditorView themeEditorView = new ThemeEditorView(); themeEditorView.show(fragment.getParentActivity(), themeInfo); alertDialog.dismiss(); SharedPreferences preferences = MessagesController.getGlobalMainSettings(); if (preferences.getBoolean("themehint", false)) { return; } preferences.edit().putBoolean("themehint", true).commit(); try { Toast.makeText(fragment.getParentActivity(), LocaleController.getString("CreateNewThemeHelp", R.string.CreateNewThemeHelp), Toast.LENGTH_LONG).show(); } catch (Exception e) { FileLog.e(e); } }
Example #3
Source File: ChatAttachAlert.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.albumsDidLoaded) { if (photoAttachAdapter != null) { loading = false; progressView.showTextView(); photoAttachAdapter.notifyDataSetChanged(); cameraAttachAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.reloadInlineHints) { if (adapter != null) { adapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.cameraInitied) { checkCamera(false); } }
Example #4
Source File: ThemePreviewActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onFragmentDestroy() { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad); if (frameLayout != null && onGlobalLayoutListener != null) { frameLayout.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener); } if (screenType == SCREEN_TYPE_CHANGE_BACKGROUND) { if (blurredBitmap != null) { blurredBitmap.recycle(); blurredBitmap = null; } Theme.applyChatServiceMessageColor(); } else if (screenType == SCREEN_TYPE_ACCENT_COLOR) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper); } if (screenType != SCREEN_TYPE_PREVIEW || accent != null) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.wallpapersNeedReload); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.wallpapersDidLoad); } super.onFragmentDestroy(); }
Example #5
Source File: ChatEditActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean onFragmentCreate() { currentChat = MessagesController.getInstance(currentAccount).getChat(chatId); if (currentChat == null) { currentChat = MessagesStorage.getInstance(currentAccount).getChatSync(chatId); if (currentChat != null) { MessagesController.getInstance(currentAccount).putChat(currentChat, true); } else { return false; } if (info == null) { info = MessagesStorage.getInstance(currentAccount).loadChatInfo(chatId, new CountDownLatch(1), false, false); if (info == null) { return false; } } } isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup; imageUpdater.parentFragment = this; imageUpdater.delegate = this; signMessages = currentChat.signatures; NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatInfoDidLoad); return super.onFragmentCreate(); }
Example #6
Source File: StickersAdapter.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, final Object... args) { if (id == NotificationCenter.fileDidLoad || id == NotificationCenter.fileDidFailToLoad) { if (stickers != null && !stickers.isEmpty() && !stickersToLoad.isEmpty() && visible) { String fileName = (String) args[0]; stickersToLoad.remove(fileName); if (stickersToLoad.isEmpty()) { boolean show = stickers != null && !stickers.isEmpty() && stickersToLoad.isEmpty(); if (show) { keywordResults = null; } delegate.needChangePanelVisibility(show); } } } else if (id == NotificationCenter.newEmojiSuggestionsAvailable) { if ((keywordResults == null || keywordResults.isEmpty()) && !TextUtils.isEmpty(lastSticker) && getItemCount() == 0) { searchEmojiByKeyword(); } } }
Example #7
Source File: PopupNotificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
protected void onFinish() { if (finished) { return; } finished = true; if (isReply) { popupMessages.clear(); } for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.appDidLogout); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidReset); NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.contactsDidLoaded); } NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.pushMessagesUpdated); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); if (chatActivityEnterView != null) { chatActivityEnterView.onDestroy(); } if (wakeLock.isHeld()) { wakeLock.release(); } }
Example #8
Source File: TwoStepVerificationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.didSetTwoStepPassword) { if (args != null && args.length > 0 && args[0] != null) { currentPasswordHash = (byte[]) args[0]; if (closeAfterSet) { String email = (String) args[4]; if (TextUtils.isEmpty(email) && closeAfterSet) { removeSelfFromStack(); } } } loadPasswordInfo(false); updateRows(); } }
Example #9
Source File: TwoStepVerificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void loadPasswordInfo(final boolean silent) { if (!silent) { loading = true; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { loading = false; currentPassword = (TLRPC.TL_account_password) response; if (!canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (!silent) { passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password; } initPasswordNewAlgo(currentPassword); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword); } updateRows(); }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #10
Source File: TrendingStickersLayout.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.stickersDidLoad) { if ((Integer) args[0] == MediaDataController.TYPE_IMAGE) { if (loaded) { updateVisibleTrendingSets(); } else { adapter.refreshStickerSets(); } } } else if (id == NotificationCenter.featuredStickersDidLoad) { if (hash != MediaDataController.getInstance(currentAccount).getFeaturesStickersHashWithoutUnread()) { loaded = false; } if (loaded) { updateVisibleTrendingSets(); } else { adapter.refreshStickerSets(); } } }
Example #11
Source File: GroupStickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.stickersDidLoaded) { if ((Integer) args[0] == DataQuery.TYPE_IMAGE) { updateRows(); } } else if (id == NotificationCenter.chatInfoDidLoaded) { TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0]; if (chatFull.id == chatId) { if (info == null && chatFull.stickerset != null) { selectedStickerSet = DataQuery.getInstance(currentAccount).getGroupStickerSetById(chatFull.stickerset); } info = chatFull; updateRows(); } } else if (id == NotificationCenter.groupStickersDidLoaded) { long setId = (Long) args[0]; if (info != null && info.stickerset != null && info.stickerset.id == id) { updateRows(); } } }
Example #12
Source File: ProfileActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void kickUser(int uid) { if (uid != 0) { MessagesController.getInstance(currentAccount).deleteUserFromChat(chat_id, MessagesController.getInstance(currentAccount).getUser(uid), info); } else { NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.closeChats); if (AndroidUtilities.isTablet()) { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats, -(long) chat_id); } else { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats); } MessagesController.getInstance(currentAccount).deleteUserFromChat(chat_id, MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()), info); playProfileAnimation = false; finishFragment(); } }
Example #13
Source File: SettingsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.updateInterfaces) { int mask = (Integer) args[0]; if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) { updateUserData(); } } else if (id == NotificationCenter.userInfoDidLoad) { Integer uid = (Integer) args[0]; if (uid == UserConfig.getInstance(currentAccount).getClientUserId() && listAdapter != null) { userInfo = (TLRPC.UserFull) args[1]; if (!TextUtils.equals(userInfo.about, currentBio)) { listAdapter.notifyItemChanged(bioRow); } } } else if (id == NotificationCenter.emojiDidLoad) { if (listView != null) { listView.invalidateViews(); } } }
Example #14
Source File: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBackPressed() { destroyTimer(); destroyCodeTimer(); currentParams = null; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; }
Example #15
Source File: GroupCreateActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onFragmentDestroy() { super.onFragmentDestroy(); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.contactsDidLoad); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatDidCreated); AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid, true); }
Example #16
Source File: PrivacySettingsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.privacyRulesUpdated) { if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } }
Example #17
Source File: FiltersSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { updateRows(true); getMessagesController().loadRemoteFilters(true); getNotificationCenter().addObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().addObserver(this, NotificationCenter.suggestedFiltersLoaded); if (getMessagesController().suggestedFilters.isEmpty()) { getMessagesController().loadSuggestedFilters(); } return super.onFragmentCreate(); }
Example #18
Source File: BlockingUpdateView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void setVisibility(int visibility) { super.setVisibility(visibility); if (visibility == GONE) { NotificationCenter.getInstance(accountNum).removeObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance(accountNum).removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance(accountNum).removeObserver(this, NotificationCenter.FileLoadProgressChanged); } }
Example #19
Source File: CallLogActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { super.onFragmentCreate(); getCalls(0, 50); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didReceiveNewMessages); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagesDeleted); return true; }
Example #20
Source File: GroupStickersActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void saveStickerSet() { if (info == null || info.stickerset != null && selectedStickerSet != null && selectedStickerSet.set.id == info.stickerset.id || info.stickerset == null && selectedStickerSet == null) { finishFragment(); return; } showEditDoneProgress(true); TLRPC.TL_channels_setStickers req = new TLRPC.TL_channels_setStickers(); req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId); if (selectedStickerSet == null) { req.stickerset = new TLRPC.TL_inputStickerSetEmpty(); } else { MessagesController.getEmojiSettings(currentAccount).edit().remove("group_hide_stickers_" + info.id).commit(); req.stickerset = new TLRPC.TL_inputStickerSetID(); req.stickerset.id = selectedStickerSet.set.id; req.stickerset.access_hash = selectedStickerSet.set.access_hash; } ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { if (selectedStickerSet == null) { info.stickerset = null; } else { info.stickerset = selectedStickerSet.set; MediaDataController.getInstance(currentAccount).putGroupStickerSet(selectedStickerSet); } if (info.stickerset == null) { info.flags |= 256; } else { info.flags = info.flags &~ 256; } MessagesStorage.getInstance(currentAccount).updateChatInfo(info, false); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoad, info, 0, true, null); finishFragment(); } else { Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show(); donePressed = false; showEditDoneProgress(false); } })); }
Example #21
Source File: ChatAvatarContainer.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (parentFragment != null) { NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didUpdateConnectionState); } }
Example #22
Source File: ChannelCreateActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatDidCreated); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatDidFailCreate); if (currentStep == 1) { generateLink(); } if (imageUpdater != null) { imageUpdater.parentFragment = this; imageUpdater.delegate = this; } return super.onFragmentCreate(); }
Example #23
Source File: ContactsActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { super.onFragmentCreate(); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsDidLoad); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.encryptedChatCreated); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.closeChats); checkPermission = UserConfig.getInstance(currentAccount).syncContacts; if (arguments != null) { onlyUsers = arguments.getBoolean("onlyUsers", false); destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false); returnAsResult = arguments.getBoolean("returnAsResult", false); createSecretChat = arguments.getBoolean("createSecretChat", false); selectAlertString = arguments.getString("selectAlertString"); allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true); needForwardCount = arguments.getBoolean("needForwardCount", true); allowBots = arguments.getBoolean("allowBots", true); allowSelf = arguments.getBoolean("allowSelf", true); channelId = arguments.getInt("channelId", 0); needFinishFragment = arguments.getBoolean("needFinishFragment", true); chatId = arguments.getInt("chat_id", 0); disableSections = arguments.getBoolean("disableSections", false); resetDelegate = arguments.getBoolean("resetDelegate", false); } else { needPhonebook = true; } if (!createSecretChat && !returnAsResult) { sortByName = SharedConfig.sortContactsByName; } getContactsController().checkInviteText(); getContactsController().reloadContactsStatusesMaybe(); return true; }
Example #24
Source File: PlayingGameDrawable.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void checkUpdate() { if (started) { if (!NotificationCenter.getInstance(currentAccount).isAnimationInProgress()) { update(); } else { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { checkUpdate(); } }, 100); } } }
Example #25
Source File: StickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onFragmentDestroy() { super.onFragmentDestroy(); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.stickersDidLoaded); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.archivedStickersCountDidLoaded); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoaded); sendReorder(); }
Example #26
Source File: PhotoViewerCaptionEnterView.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.emojiDidLoad) { if (emojiView != null) { emojiView.invalidateViews(); } } }
Example #27
Source File: StickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public boolean onFragmentCreate() { super.onFragmentCreate(); DataQuery.getInstance(currentAccount).checkStickers(currentType); if (currentType == DataQuery.TYPE_IMAGE) { DataQuery.getInstance(currentAccount).checkFeaturedStickers(); } NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stickersDidLoaded); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.archivedStickersCountDidLoaded); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.featuredStickersDidLoaded); updateRows(); return true; }
Example #28
Source File: ChatEditTypeActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.chatInfoDidLoad) { TLRPC.ChatFull chatFull = (TLRPC.ChatFull) args[0]; if (chatFull.id == chatId) { info = chatFull; invite = chatFull.exported_invite; updatePrivatePublic(); } } }
Example #29
Source File: PhotoViewerCaptionEnterView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.emojiDidLoad) { if (emojiView != null) { emojiView.invalidateViews(); } } }
Example #30
Source File: UpdateAppAlertDialog.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.fileDidLoad); NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.fileDidFailToLoad); NotificationCenter.getInstance(accountNum).addObserver(this, NotificationCenter.FileLoadProgressChanged); buttonsLayout.addView(radialProgressView, LayoutHelper.createFrame(36, 36)); }