Java Code Examples for org.telegram.tgnet.TLRPC#TL_messages_search
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_messages_search .
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: MediaActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void queryServerSearch(final String query, final int max_id, long did) { int uid = (int) did; if (uid == 0) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; searchesInProgress--; } if (query == null || query.length() == 0) { globalSearch.clear(); lastReqId = 0; notifyDataSetChanged(); return; } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = 50; req.offset_id = max_id; if (currentType == 1) { req.filter = new TLRPC.TL_inputMessagesFilterDocument(); } else if (currentType == 3) { req.filter = new TLRPC.TL_inputMessagesFilterUrl(); } else if (currentType == 4) { req.filter = new TLRPC.TL_inputMessagesFilterMusic(); } req.q = query; req.peer = MessagesController.getInstance(currentAccount).getInputPeer(uid); if (req.peer == null) { return; } final int currentReqId = ++lastReqId; searchesInProgress++; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { final ArrayList<MessageObject> messageObjects = new ArrayList<>(); if (error == null) { TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { TLRPC.Message message = res.messages.get(a); if (max_id != 0 && message.id > max_id) { continue; } messageObjects.add(new MessageObject(currentAccount, message, false)); } } AndroidUtilities.runOnUIThread(() -> { if (reqId != 0) { if (currentReqId == lastReqId) { globalSearch = messageObjects; searchesInProgress--; notifyDataSetChanged(); } reqId = 0; } }); }, ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 2
Source File: CallLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void getCalls(int max_id, final int count) { if (loading) { return; } loading = true; if (emptyView != null && !firstLoaded) { emptyView.showProgress(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = count; req.peer = new TLRPC.TL_inputPeerEmpty(); req.filter = new TLRPC.TL_inputMessagesFilterPhoneCalls(); req.q = ""; req.offset_id = max_id; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { SparseArray<TLRPC.User> users = new SparseArray<>(); TLRPC.messages_Messages msgs = (TLRPC.messages_Messages) response; endReached = msgs.messages.isEmpty(); for (int a = 0; a < msgs.users.size(); a++) { TLRPC.User user = msgs.users.get(a); users.put(user.id, user); } CallLogRow currentRow = calls.size() > 0 ? calls.get(calls.size() - 1) : null; for (int a = 0; a < msgs.messages.size(); a++) { TLRPC.Message msg = msgs.messages.get(a); if (msg.action == null || msg.action instanceof TLRPC.TL_messageActionHistoryClear) { continue; } int callType = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? TYPE_OUT : TYPE_IN; TLRPC.PhoneCallDiscardReason reason = msg.action.reason; if (callType == TYPE_IN && (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy)) { callType = TYPE_MISSED; } int userID = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? msg.to_id.user_id : msg.from_id; if (currentRow == null || currentRow.user.id != userID || currentRow.type != callType) { if (currentRow != null && !calls.contains(currentRow)) { calls.add(currentRow); } CallLogRow row = new CallLogRow(); row.calls = new ArrayList<>(); row.user = users.get(userID); row.type = callType; currentRow = row; } currentRow.calls.add(msg); } if (currentRow != null && currentRow.calls.size() > 0 && !calls.contains(currentRow)) { calls.add(currentRow); } } else { endReached = true; } loading = false; firstLoaded = true; if (emptyView != null) { emptyView.showTextView(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } }), ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 3
Source File: MediaActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void queryServerSearch(final String query, final int max_id, long did) { int uid = (int) did; if (uid == 0) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; searchesInProgress--; } if (query == null || query.length() == 0) { globalSearch.clear(); lastReqId = 0; notifyDataSetChanged(); return; } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = 50; req.offset_id = max_id; if (currentType == 1) { req.filter = new TLRPC.TL_inputMessagesFilterDocument(); } else if (currentType == 3) { req.filter = new TLRPC.TL_inputMessagesFilterUrl(); } else if (currentType == 4) { req.filter = new TLRPC.TL_inputMessagesFilterMusic(); } req.q = query; req.peer = MessagesController.getInstance(currentAccount).getInputPeer(uid); if (req.peer == null) { return; } final int currentReqId = ++lastReqId; searchesInProgress++; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { final ArrayList<MessageObject> messageObjects = new ArrayList<>(); if (error == null) { TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { TLRPC.Message message = res.messages.get(a); if (max_id != 0 && message.id > max_id) { continue; } messageObjects.add(new MessageObject(currentAccount, message, false)); } } AndroidUtilities.runOnUIThread(() -> { if (reqId != 0) { if (currentReqId == lastReqId) { globalSearch = messageObjects; searchesInProgress--; notifyDataSetChanged(); } reqId = 0; } }); }, ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 4
Source File: CallLogActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void getCalls(int max_id, final int count) { if (loading) { return; } loading = true; if (emptyView != null && !firstLoaded) { emptyView.showProgress(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = count; req.peer = new TLRPC.TL_inputPeerEmpty(); req.filter = new TLRPC.TL_inputMessagesFilterPhoneCalls(); req.q = ""; req.offset_id = max_id; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { SparseArray<TLRPC.User> users = new SparseArray<>(); TLRPC.messages_Messages msgs = (TLRPC.messages_Messages) response; endReached = msgs.messages.isEmpty(); for (int a = 0; a < msgs.users.size(); a++) { TLRPC.User user = msgs.users.get(a); users.put(user.id, user); } CallLogRow currentRow = calls.size() > 0 ? calls.get(calls.size() - 1) : null; for (int a = 0; a < msgs.messages.size(); a++) { TLRPC.Message msg = msgs.messages.get(a); if (msg.action == null || msg.action instanceof TLRPC.TL_messageActionHistoryClear) { continue; } int callType = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? TYPE_OUT : TYPE_IN; TLRPC.PhoneCallDiscardReason reason = msg.action.reason; if (callType == TYPE_IN && (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy)) { callType = TYPE_MISSED; } int userID = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? msg.to_id.user_id : msg.from_id; if (currentRow == null || currentRow.user.id != userID || currentRow.type != callType) { if (currentRow != null && !calls.contains(currentRow)) { calls.add(currentRow); } CallLogRow row = new CallLogRow(); row.calls = new ArrayList<>(); row.user = users.get(userID); row.type = callType; currentRow = row; } currentRow.calls.add(msg); } if (currentRow != null && currentRow.calls.size() > 0 && !calls.contains(currentRow)) { calls.add(currentRow); } } else { endReached = true; } loading = false; firstLoaded = true; if (emptyView != null) { emptyView.showTextView(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } }), ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 5
Source File: MediaActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void queryServerSearch(final String query, final int max_id, long did) { int uid = (int) did; if (uid == 0) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; searchesInProgress--; } if (query == null || query.length() == 0) { globalSearch.clear(); lastReqId = 0; notifyDataSetChanged(); return; } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = 50; req.offset_id = max_id; if (currentType == 1) { req.filter = new TLRPC.TL_inputMessagesFilterDocument(); } else if (currentType == 3) { req.filter = new TLRPC.TL_inputMessagesFilterUrl(); } else if (currentType == 4) { req.filter = new TLRPC.TL_inputMessagesFilterMusic(); } req.q = query; req.peer = MessagesController.getInstance(currentAccount).getInputPeer(uid); if (req.peer == null) { return; } final int currentReqId = ++lastReqId; searchesInProgress++; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { final ArrayList<MessageObject> messageObjects = new ArrayList<>(); if (error == null) { TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { TLRPC.Message message = res.messages.get(a); if (max_id != 0 && message.id > max_id) { continue; } messageObjects.add(new MessageObject(currentAccount, message, false)); } } AndroidUtilities.runOnUIThread(() -> { if (reqId != 0) { if (currentReqId == lastReqId) { globalSearch = messageObjects; searchesInProgress--; int count = getItemCount(); notifyDataSetChanged(); for (int a = 0; a < mediaPages.length; a++) { if (mediaPages[a].listView.getAdapter() == this && count == 0 && actionBar.getTranslationY() != 0) { mediaPages[a].layoutManager.scrollToPositionWithOffset(0, (int) actionBar.getTranslationY()); break; } } } reqId = 0; } }); }, ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 6
Source File: CallLogActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void getCalls(int max_id, final int count) { if (loading) { return; } loading = true; if (emptyView != null && !firstLoaded) { emptyView.showProgress(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = count; req.peer = new TLRPC.TL_inputPeerEmpty(); req.filter = new TLRPC.TL_inputMessagesFilterPhoneCalls(); req.q = ""; req.offset_id = max_id; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { SparseArray<TLRPC.User> users = new SparseArray<>(); TLRPC.messages_Messages msgs = (TLRPC.messages_Messages) response; endReached = msgs.messages.isEmpty(); for (int a = 0; a < msgs.users.size(); a++) { TLRPC.User user = msgs.users.get(a); users.put(user.id, user); } CallLogRow currentRow = calls.size() > 0 ? calls.get(calls.size() - 1) : null; for (int a = 0; a < msgs.messages.size(); a++) { TLRPC.Message msg = msgs.messages.get(a); if (msg.action == null || msg.action instanceof TLRPC.TL_messageActionHistoryClear) { continue; } int callType = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? TYPE_OUT : TYPE_IN; TLRPC.PhoneCallDiscardReason reason = msg.action.reason; if (callType == TYPE_IN && (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy)) { callType = TYPE_MISSED; } int userID = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? msg.to_id.user_id : msg.from_id; if (currentRow == null || currentRow.user.id != userID || currentRow.type != callType) { if (currentRow != null && !calls.contains(currentRow)) { calls.add(currentRow); } CallLogRow row = new CallLogRow(); row.calls = new ArrayList<>(); row.user = users.get(userID); row.type = callType; currentRow = row; } currentRow.calls.add(msg); } if (currentRow != null && currentRow.calls.size() > 0 && !calls.contains(currentRow)) { calls.add(currentRow); } } else { endReached = true; } loading = false; firstLoaded = true; if (emptyView != null) { emptyView.showTextView(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } }), ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 7
Source File: MediaActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void queryServerSearch(final String query, final int max_id, long did) { int uid = (int) did; if (uid == 0) { return; } if (reqId != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true); reqId = 0; searchesInProgress--; } if (query == null || query.length() == 0) { globalSearch.clear(); lastReqId = 0; notifyDataSetChanged(); return; } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = 50; req.offset_id = max_id; if (currentType == 1) { req.filter = new TLRPC.TL_inputMessagesFilterDocument(); } else if (currentType == 3) { req.filter = new TLRPC.TL_inputMessagesFilterUrl(); } else if (currentType == 4) { req.filter = new TLRPC.TL_inputMessagesFilterMusic(); } req.q = query; req.peer = MessagesController.getInstance(currentAccount).getInputPeer(uid); if (req.peer == null) { return; } final int currentReqId = ++lastReqId; searchesInProgress++; reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { final ArrayList<MessageObject> messageObjects = new ArrayList<>(); if (error == null) { TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { TLRPC.Message message = res.messages.get(a); if (max_id != 0 && message.id > max_id) { continue; } messageObjects.add(new MessageObject(currentAccount, message, false)); } } AndroidUtilities.runOnUIThread(() -> { if (reqId != 0) { if (currentReqId == lastReqId) { globalSearch = messageObjects; searchesInProgress--; int count = getItemCount(); notifyDataSetChanged(); for (int a = 0; a < mediaPages.length; a++) { if (mediaPages[a].listView.getAdapter() == this && count == 0 && actionBar.getTranslationY() != 0) { mediaPages[a].layoutManager.scrollToPositionWithOffset(0, (int) actionBar.getTranslationY()); break; } } } reqId = 0; } }); }, ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }
Example 8
Source File: CallLogActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void getCalls(int max_id, final int count) { if (loading) { return; } loading = true; if (emptyView != null && !firstLoaded) { emptyView.showProgress(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } TLRPC.TL_messages_search req = new TLRPC.TL_messages_search(); req.limit = count; req.peer = new TLRPC.TL_inputPeerEmpty(); req.filter = new TLRPC.TL_inputMessagesFilterPhoneCalls(); req.q = ""; req.offset_id = max_id; int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { SparseArray<TLRPC.User> users = new SparseArray<>(); TLRPC.messages_Messages msgs = (TLRPC.messages_Messages) response; endReached = msgs.messages.isEmpty(); for (int a = 0; a < msgs.users.size(); a++) { TLRPC.User user = msgs.users.get(a); users.put(user.id, user); } CallLogRow currentRow = calls.size() > 0 ? calls.get(calls.size() - 1) : null; for (int a = 0; a < msgs.messages.size(); a++) { TLRPC.Message msg = msgs.messages.get(a); if (msg.action == null || msg.action instanceof TLRPC.TL_messageActionHistoryClear) { continue; } int callType = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? TYPE_OUT : TYPE_IN; TLRPC.PhoneCallDiscardReason reason = msg.action.reason; if (callType == TYPE_IN && (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy)) { callType = TYPE_MISSED; } int userID = msg.from_id == UserConfig.getInstance(currentAccount).getClientUserId() ? msg.to_id.user_id : msg.from_id; if (currentRow == null || currentRow.user.id != userID || currentRow.type != callType) { if (currentRow != null && !calls.contains(currentRow)) { calls.add(currentRow); } CallLogRow row = new CallLogRow(); row.calls = new ArrayList<>(); row.user = users.get(userID); row.type = callType; currentRow = row; } currentRow.calls.add(msg); } if (currentRow != null && currentRow.calls.size() > 0 && !calls.contains(currentRow)) { calls.add(currentRow); } } else { endReached = true; } loading = false; firstLoaded = true; if (emptyView != null) { emptyView.showTextView(); } if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } }), ConnectionsManager.RequestFlagFailOnServerErrors); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); }