org.telegram.tgnet.TLObject Java Examples
The following examples show how to use
org.telegram.tgnet.TLObject.
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: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onControllerPreRelease(){ if(needSendDebugLog){ String debugLog=controller.getDebugLog(); TLRPC.TL_phone_saveCallDebug req=new TLRPC.TL_phone_saveCallDebug(); req.debug=new TLRPC.TL_dataJSON(); req.debug.data=debugLog; req.peer=new TLRPC.TL_inputPhoneCall(); req.peer.access_hash=call.access_hash; req.peer.id=call.id; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate(){ @Override public void run(TLObject response, TLRPC.TL_error error){ if (BuildVars.LOGS_ENABLED) { FileLog.d("Sent debug logs, response=" + response); } } }); } }
Example #2
Source File: ChannelAdminLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void loadAdmins() { TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants(); req.channel = MessagesController.getInputChannel(currentChat); req.filter = new TLRPC.TL_channelParticipantsAdmins(); req.offset = 0; req.limit = 200; int 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() { if (error == null) { TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; MessagesController.getInstance(currentAccount).putUsers(res.users, false); admins = res.participants; if (visibleDialog instanceof AdminLogFilterAlert) { ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins); } } } }); } }); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example #3
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override protected void onControllerPreRelease(){ if(needSendDebugLog){ String debugLog=controller.getDebugLog(); TLRPC.TL_phone_saveCallDebug req=new TLRPC.TL_phone_saveCallDebug(); req.debug=new TLRPC.TL_dataJSON(); req.debug.data=debugLog; req.peer=new TLRPC.TL_inputPhoneCall(); req.peer.access_hash=call.access_hash; req.peer.id=call.id; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate(){ @Override public void run(TLObject response, TLRPC.TL_error error){ if (BuildVars.LOGS_ENABLED) { FileLog.d("Sent debug logs, response=" + response); } } }); } }
Example #4
Source File: ChannelAdminLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void loadAdmins() { TLRPC.TL_channels_getParticipants req = new TLRPC.TL_channels_getParticipants(); req.channel = MessagesController.getInputChannel(currentChat); req.filter = new TLRPC.TL_channelParticipantsAdmins(); req.offset = 0; req.limit = 200; int 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() { if (error == null) { TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; MessagesController.getInstance(currentAccount).putUsers(res.users, false); admins = res.participants; if (visibleDialog instanceof AdminLogFilterAlert) { ((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins); } } } }); } }); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example #5
Source File: ChannelCreateActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void generateLink() { if (loadingInvite || invite != null) { return; } loadingInvite = true; TLRPC.TL_channels_exportInvite req = new TLRPC.TL_channels_exportInvite(); req.channel = MessagesController.getInstance(currentAccount).getInputChannel(chatId); 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() { if (error == null) { invite = (TLRPC.ExportedChatInvite) response; } loadingInvite = false; privateContainer.setText(invite != null ? invite.link : LocaleController.getString("Loading", R.string.Loading), false); } }); } }); }
Example #6
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 #7
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TLObject getItem(int i) { if (showContacts) { i -= 3; if (i < 0 || i >= ContactsController.getInstance(currentAccount).contacts.size()) { return null; } return MessagesController.getInstance(currentAccount).getUser(ContactsController.getInstance(currentAccount).contacts.get(i).user_id); } ArrayList<TLRPC.TL_dialog> arrayList = getDialogsArray(); if (hasHints) { int count = MessagesController.getInstance(currentAccount).hintDialogs.size(); if (i < 2 + count) { return MessagesController.getInstance(currentAccount).hintDialogs.get(i - 1); } else { i -= count + 2; } } if (i < 0 || i >= arrayList.size()) { return null; } return arrayList.get(i); }
Example #8
Source File: PhotoPickerActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void searchBotUser() { if (searchingUser) { return; } searchingUser = true; TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername(); req.username = MessagesController.getInstance(currentAccount).imageSearchBot; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (response != null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response; MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); String str = lastSearchImageString; lastSearchImageString = null; searchImages(str, "", false); } }); } } }); }
Example #9
Source File: ContactsController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void resetImportedContacts() { TLRPC.TL_contacts_resetSaved req = new TLRPC.TL_contacts_resetSaved(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { } }); }
Example #10
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void removeAllLocationSharings() { Utilities.stageQueue.postRunnable(new Runnable() { @Override public void run() { for (int a = 0; a < sharingLocations.size(); a++) { SharingLocationInfo info = sharingLocations.get(a); TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) info.did); req.id = info.mid; req.stop_geo_live = true; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { return; } MessagesController.getInstance(currentAccount).processUpdates((TLRPC.Updates) response, false); } }); } sharingLocations.clear(); sharingLocationsMap.clear(); saveSharingLocation(null, 2); stop(true); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { sharingLocationsUI.clear(); sharingLocationsMapUI.clear(); stopService(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged); } }); } }); }
Example #11
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) did); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error != null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); } }); } }); }
Example #12
Source File: DialogsSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void putRecentSearch(final long did, TLObject object) { RecentSearchObject recentSearchObject = recentSearchObjectsById.get(did); if (recentSearchObject == null) { recentSearchObject = new RecentSearchObject(); recentSearchObjectsById.put(did, recentSearchObject); } else { recentSearchObjects.remove(recentSearchObject); } recentSearchObjects.add(0, recentSearchObject); recentSearchObject.did = did; recentSearchObject.object = object; recentSearchObject.date = (int) (System.currentTimeMillis() / 1000); notifyDataSetChanged(); MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO search_recent VALUES(?, ?)"); state.requery(); state.bindLong(1, did); state.bindInteger(2, (int) (System.currentTimeMillis() / 1000)); state.step(); state.dispose(); } catch (Exception e) { FileLog.e(e); } }); }
Example #13
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void resendCode() { final Bundle params = new Bundle(); params.putString("phone", phone); params.putString("ephone", emailPhone); params.putString("phoneFormated", requestPhone); nextPressed = true; needShowProgress(); final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); req.phone_number = requestPhone; req.phone_code_hash = phoneHash; 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() { nextPressed = false; if (error == null) { fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response); } else { AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req); if (error.text.contains("PHONE_CODE_EXPIRED")) { onBackPressed(); setPage(0, true, null, true); } } needHideProgress(); } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example #14
Source File: ArchivedStickersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void getStickers() { if (loadingStickers || endReached) { return; } loadingStickers = true; if (emptyView != null && !firstLoaded) { emptyView.showProgress(); } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } TLRPC.TL_messages_getArchivedStickers req = new TLRPC.TL_messages_getArchivedStickers(); req.offset_id = sets.isEmpty() ? 0 : sets.get(sets.size() - 1).set.id; req.limit = 15; req.masks = currentType == DataQuery.TYPE_MASK; int 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() { if (error == null) { TLRPC.TL_messages_archivedStickers res = (TLRPC.TL_messages_archivedStickers) response; sets.addAll(res.sets); endReached = res.sets.size() != 15; loadingStickers = false; firstLoaded = true; if (emptyView != null) { emptyView.showTextView(); } updateRows(); } } }); } }); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example #15
Source File: ChannelCreateActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public ChannelCreateActivity(Bundle args) { super(args); currentStep = args.getInt("step", 0); if (currentStep == 0) { avatarDrawable = new AvatarDrawable(); imageUpdater = new ImageUpdater(); TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername(); req.username = "1"; req.channel = new TLRPC.TL_inputChannelEmpty(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH"); } }); } }); } else { if (currentStep == 1) { canCreatePublic = args.getBoolean("canCreatePublic", true); isPrivate = !canCreatePublic; if (!canCreatePublic) { loadAdminedChannels(); } } chatId = args.getInt("chat_id", 0); } }
Example #16
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) did); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error != null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); } }); } }); }
Example #17
Source File: DialogsSearchAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void putRecentSearch(final long did, TLObject object) { RecentSearchObject recentSearchObject = recentSearchObjectsById.get(did); if (recentSearchObject == null) { recentSearchObject = new RecentSearchObject(); recentSearchObjectsById.put(did, recentSearchObject); } else { recentSearchObjects.remove(recentSearchObject); } recentSearchObjects.add(0, recentSearchObject); recentSearchObject.did = did; recentSearchObject.object = object; recentSearchObject.date = (int) (System.currentTimeMillis() / 1000); notifyDataSetChanged(); MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO search_recent VALUES(?, ?)"); state.requery(); state.bindLong(1, did); state.bindInteger(2, (int) (System.currentTimeMillis() / 1000)); state.step(); state.dispose(); } catch (Exception e) { FileLog.e(e); } }); }
Example #18
Source File: WallpapersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void loadWallpapers() { TLRPC.TL_account_getWallPapers req = new TLRPC.TL_account_getWallPapers(); int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error != null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { wallPapers.clear(); TLRPC.Vector res = (TLRPC.Vector) response; wallpappersByIds.clear(); for (Object obj : res.objects) { wallPapers.add((TLRPC.WallPaper) obj); wallpappersByIds.put(((TLRPC.WallPaper) obj).id, (TLRPC.WallPaper) obj); } if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } if (backgroundImage != null) { processSelectedBackground(); } MessagesStorage.getInstance(currentAccount).putWallpapers(wallPapers); } }); } }); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example #19
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void resendCode() { final Bundle params = new Bundle(); params.putString("phone", phone); nextPressed = true; needShowProgress(); final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); req.phone_number = phone; req.phone_code_hash = phoneHash; 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() { nextPressed = false; if (error == null) { fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response); } else { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } needHideProgress(); } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example #20
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void resendCode() { final Bundle params = new Bundle(); params.putString("phone", phone); nextPressed = true; needShowProgress(); final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode(); req.phone_number = phone; req.phone_code_hash = phoneHash; 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() { nextPressed = false; if (error == null) { fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response); } else { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } needHideProgress(); } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example #21
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected void updateServerConfig(){ final SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); VoIPServerConfig.setConfig(preferences.getString("voip_server_config", "{}")); ConnectionsManager.getInstance(currentAccount).sendRequest(new TLRPC.TL_phone_getCallConfig(), new RequestDelegate(){ @Override public void run(TLObject response, TLRPC.TL_error error){ if(error==null){ String data=((TLRPC.TL_dataJSON) response).data; VoIPServerConfig.setConfig(data); preferences.edit().putString("voip_server_config", data).commit(); } } }); }
Example #22
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
protected void callFailed(int errorCode) { if (call != null) { if (BuildVars.LOGS_ENABLED) { FileLog.d("Discarding failed call"); } TLRPC.TL_phone_discardCall req = new TLRPC.TL_phone_discardCall(); req.peer = new TLRPC.TL_inputPhoneCall(); req.peer.access_hash = call.access_hash; req.peer.id = call.id; req.duration = controller != null && controllerStarted ? (int) (controller.getCallDuration() / 1000) : 0; req.connection_id = controller != null && controllerStarted ? controller.getPreferredRelayID() : 0; req.reason = new TLRPC.TL_phoneCallDiscardReasonDisconnect(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { if (BuildVars.LOGS_ENABLED) { FileLog.e("error on phone.discardCall: " + error); } } else { if (BuildVars.LOGS_ENABLED) { FileLog.d("phone.discardCall " + response); } } } }); } super.callFailed(errorCode); }
Example #23
Source File: DialogsAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public TLObject getItem(int i) { if (showContacts) { i -= 3; if (i < 0 || i >= ContactsController.getInstance(currentAccount).contacts.size()) { return null; } return MessagesController.getInstance(currentAccount).getUser(ContactsController.getInstance(currentAccount).contacts.get(i).user_id); } ArrayList<TLRPC.TL_dialog> arrayList = getDialogsArray(); if (hasHints) { int count = MessagesController.getInstance(currentAccount).hintDialogs.size(); if (i < 2 + count) { return MessagesController.getInstance(currentAccount).hintDialogs.get(i - 1); } else { i -= count + 2; } } if (i < 0 || i >= arrayList.size()) { return null; } return arrayList.get(i); }
Example #24
Source File: ChannelCreateActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public ChannelCreateActivity(Bundle args) { super(args); currentStep = args.getInt("step", 0); if (currentStep == 0) { avatarDrawable = new AvatarDrawable(); imageUpdater = new ImageUpdater(); TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername(); req.username = "1"; req.channel = new TLRPC.TL_inputChannelEmpty(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { canCreatePublic = error == null || !error.text.equals("CHANNELS_ADMIN_PUBLIC_TOO_MUCH"); } }); } }); } else { if (currentStep == 1) { canCreatePublic = args.getBoolean("canCreatePublic", true); isPrivate = !canCreatePublic; if (!canCreatePublic) { loadAdminedChannels(); } } chatId = args.getInt("chat_id", 0); } }
Example #25
Source File: ChatUsersActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = new ManageChatUserCell(mContext, 2, true); view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); ((ManageChatUserCell) view).setDelegate((cell, click) -> { TLObject object = getItem((Integer) cell.getTag()); if (object instanceof TLRPC.ChatParticipant) { TLRPC.ChatParticipant participant = (TLRPC.ChatParticipant) getItem((Integer) cell.getTag()); return createMenuForParticipant(participant, !click); } else { return false; } }); return new RecyclerListView.Holder(view); }
Example #26
Source File: SearchAdapterHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void mergeResults(ArrayList<TLObject> localResults) { localSearchResults = localResults; if (globalSearchMap.size() == 0 || localResults == null) { return; } int count = localResults.size(); for (int a = 0; a < count; a++) { TLObject obj = localResults.get(a); if (obj instanceof TLRPC.User) { TLRPC.User user = (TLRPC.User) obj; TLRPC.User u = (TLRPC.User) globalSearchMap.get(user.id); if (u != null) { globalSearch.remove(u); localServerSearch.remove(u); globalSearchMap.remove(u.id); } } else if (obj instanceof TLRPC.Chat) { TLRPC.Chat chat = (TLRPC.Chat) obj; TLRPC.Chat c = (TLRPC.Chat) globalSearchMap.get(-chat.id); if (c != null) { globalSearch.remove(c); localServerSearch.remove(c); globalSearchMap.remove(-c.id); } } } }
Example #27
Source File: BackupImageView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setImage(TLObject path, String filter, Drawable thumb, int size) { setImage(path, null, filter, thumb, null, null, null, null, size); }
Example #28
Source File: ContactsController.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void reloadContactsStatuses() { saveContactsLoadTime(); MessagesController.getInstance(currentAccount).clearFullUsers(); SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); final SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("needGetStatuses", true).commit(); TLRPC.TL_contacts_getStatuses req = new TLRPC.TL_contacts_getStatuses(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { editor.remove("needGetStatuses").commit(); TLRPC.Vector vector = (TLRPC.Vector) response; if (!vector.objects.isEmpty()) { ArrayList<TLRPC.User> dbUsersStatus = new ArrayList<>(); for (Object object : vector.objects) { TLRPC.User toDbUser = new TLRPC.TL_user(); TLRPC.TL_contactStatus status = (TLRPC.TL_contactStatus) object; if (status == null) { continue; } if (status.status instanceof TLRPC.TL_userStatusRecently) { status.status.expires = -100; } else if (status.status instanceof TLRPC.TL_userStatusLastWeek) { status.status.expires = -101; } else if (status.status instanceof TLRPC.TL_userStatusLastMonth) { status.status.expires = -102; } TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(status.user_id); if (user != null) { user.status = status.status; } toDbUser.status = status.status; dbUsersStatus.add(toDbUser); } MessagesStorage.getInstance(currentAccount).updateUsers(dbUsersStatus, true, true, true); } NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_STATUS); } }); } } }); }
Example #29
Source File: BackupImageView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void setImage(TLObject path, String filter, Bitmap thumb, int size) { setImage(path, null, filter, null, thumb, null, null, null, size); }
Example #30
Source File: AndroidUtilities.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static void openForView(TLObject media, Activity activity) throws Exception { if (media == null || activity == null) { return; } String fileName = FileLoader.getAttachFileName(media); File f = FileLoader.getPathToAttach(media, true); if (f != null && f.exists()) { String realMimeType = null; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); MimeTypeMap myMime = MimeTypeMap.getSingleton(); int idx = fileName.lastIndexOf('.'); if (idx != -1) { String ext = fileName.substring(idx + 1); realMimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); if (realMimeType == null) { if (media instanceof TLRPC.TL_document) { realMimeType = ((TLRPC.TL_document) media).mime_type; } if (realMimeType == null || realMimeType.length() == 0) { realMimeType = null; } } } if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", f), realMimeType != null ? realMimeType : "text/plain"); } else { intent.setDataAndType(Uri.fromFile(f), realMimeType != null ? realMimeType : "text/plain"); } if (realMimeType != null) { try { activity.startActivityForResult(intent, 500); } catch (Exception e) { if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".provider", f), "text/plain"); } else { intent.setDataAndType(Uri.fromFile(f), "text/plain"); } activity.startActivityForResult(intent, 500); } } else { activity.startActivityForResult(intent, 500); } } }