org.telegram.SQLite.SQLitePreparedStatement Java Examples
The following examples show how to use
org.telegram.SQLite.SQLitePreparedStatement.
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: DialogsSearchAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 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 #2
Source File: DialogsSearchAdapter.java From Telegram with GNU General Public License v2.0 | 6 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 #3
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void saveSharingLocation(final SharingLocationInfo info, final int remove) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(new Runnable() { @Override public void run() { try { if (remove == 2) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM sharing_locations WHERE 1").stepThis().dispose(); } else if (remove == 1) { if (info == null) { return; } MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM sharing_locations WHERE uid = " + info.did).stepThis().dispose(); } else { if (info == null) { return; } SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO sharing_locations VALUES(?, ?, ?, ?, ?)"); state.requery(); NativeByteBuffer data = new NativeByteBuffer(info.messageObject.messageOwner.getObjectSize()); info.messageObject.messageOwner.serializeToStream(data); state.bindLong(1, info.did); state.bindInteger(2, info.mid); state.bindInteger(3, info.stopTime); state.bindInteger(4, info.period); state.bindByteBuffer(5, data); state.step(); state.dispose(); data.reuse(); } } catch (Exception e) { FileLog.e(e); } } }); }
Example #4
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 #5
Source File: SearchAdapterHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void putRecentHashtags(final ArrayList<HashtagObject> arrayList) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO hashtag_recent_v2 VALUES(?, ?)"); for (int a = 0; a < arrayList.size(); a++) { if (a == 100) { break; } HashtagObject hashtagObject = arrayList.get(a); state.requery(); state.bindString(1, hashtagObject.hashtag); state.bindInteger(2, hashtagObject.date); state.step(); } state.dispose(); MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); if (arrayList.size() >= 100) { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); for (int a = 100; a < arrayList.size(); a++) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM hashtag_recent_v2 WHERE id = '" + arrayList.get(a).hashtag + "'").stepThis().dispose(); } MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); } } catch (Exception e) { FileLog.e(e); } }); }
Example #6
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void saveSharingLocation(final SharingLocationInfo info, final int remove) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(new Runnable() { @Override public void run() { try { if (remove == 2) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM sharing_locations WHERE 1").stepThis().dispose(); } else if (remove == 1) { if (info == null) { return; } MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM sharing_locations WHERE uid = " + info.did).stepThis().dispose(); } else { if (info == null) { return; } SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO sharing_locations VALUES(?, ?, ?, ?, ?)"); state.requery(); NativeByteBuffer data = new NativeByteBuffer(info.messageObject.messageOwner.getObjectSize()); info.messageObject.messageOwner.serializeToStream(data); state.bindLong(1, info.did); state.bindInteger(2, info.mid); state.bindInteger(3, info.stopTime); state.bindInteger(4, info.period); state.bindByteBuffer(5, data); state.step(); state.dispose(); data.reuse(); } } catch (Exception e) { FileLog.e(e); } } }); }
Example #7
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 #8
Source File: SearchAdapterHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void putRecentHashtags(final ArrayList<HashtagObject> arrayList) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO hashtag_recent_v2 VALUES(?, ?)"); for (int a = 0; a < arrayList.size(); a++) { if (a == 100) { break; } HashtagObject hashtagObject = arrayList.get(a); state.requery(); state.bindString(1, hashtagObject.hashtag); state.bindInteger(2, hashtagObject.date); state.step(); } state.dispose(); MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); if (arrayList.size() >= 100) { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); for (int a = 100; a < arrayList.size(); a++) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM hashtag_recent_v2 WHERE id = '" + arrayList.get(a).hashtag + "'").stepThis().dispose(); } MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); } } catch (Exception e) { FileLog.e(e); } }); }
Example #9
Source File: LocationController.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void saveSharingLocation(final SharingLocationInfo info, final int remove) { getMessagesStorage().getStorageQueue().postRunnable(() -> { try { if (remove == 2) { getMessagesStorage().getDatabase().executeFast("DELETE FROM sharing_locations WHERE 1").stepThis().dispose(); } else if (remove == 1) { if (info == null) { return; } getMessagesStorage().getDatabase().executeFast("DELETE FROM sharing_locations WHERE uid = " + info.did).stepThis().dispose(); } else { if (info == null) { return; } SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO sharing_locations VALUES(?, ?, ?, ?, ?)"); state.requery(); NativeByteBuffer data = new NativeByteBuffer(info.messageObject.messageOwner.getObjectSize()); info.messageObject.messageOwner.serializeToStream(data); state.bindLong(1, info.did); state.bindInteger(2, info.mid); state.bindInteger(3, info.stopTime); state.bindInteger(4, info.period); state.bindByteBuffer(5, data); state.step(); state.dispose(); data.reuse(); } } catch (Exception e) { FileLog.e(e); } }); }
Example #10
Source File: SearchAdapterHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void putRecentHashtags(final ArrayList<HashtagObject> arrayList) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO hashtag_recent_v2 VALUES(?, ?)"); for (int a = 0; a < arrayList.size(); a++) { if (a == 100) { break; } HashtagObject hashtagObject = arrayList.get(a); state.requery(); state.bindString(1, hashtagObject.hashtag); state.bindInteger(2, hashtagObject.date); state.step(); } state.dispose(); MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); if (arrayList.size() >= 100) { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); for (int a = 100; a < arrayList.size(); a++) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM hashtag_recent_v2 WHERE id = '" + arrayList.get(a).hashtag + "'").stepThis().dispose(); } MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); } } catch (Exception e) { FileLog.e(e); } }); }
Example #11
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void saveSharingLocation(final SharingLocationInfo info, final int remove) { getMessagesStorage().getStorageQueue().postRunnable(() -> { try { if (remove == 2) { getMessagesStorage().getDatabase().executeFast("DELETE FROM sharing_locations WHERE 1").stepThis().dispose(); } else if (remove == 1) { if (info == null) { return; } getMessagesStorage().getDatabase().executeFast("DELETE FROM sharing_locations WHERE uid = " + info.did).stepThis().dispose(); } else { if (info == null) { return; } SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO sharing_locations VALUES(?, ?, ?, ?, ?)"); state.requery(); NativeByteBuffer data = new NativeByteBuffer(info.messageObject.messageOwner.getObjectSize()); info.messageObject.messageOwner.serializeToStream(data); state.bindLong(1, info.did); state.bindInteger(2, info.mid); state.bindInteger(3, info.stopTime); state.bindInteger(4, info.period); state.bindByteBuffer(5, data); state.step(); state.dispose(); data.reuse(); } } catch (Exception e) { FileLog.e(e); } }); }
Example #12
Source File: SearchAdapterHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void putRecentHashtags(final ArrayList<HashtagObject> arrayList) { MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> { try { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); SQLitePreparedStatement state = MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("REPLACE INTO hashtag_recent_v2 VALUES(?, ?)"); for (int a = 0; a < arrayList.size(); a++) { if (a == 100) { break; } HashtagObject hashtagObject = arrayList.get(a); state.requery(); state.bindString(1, hashtagObject.hashtag); state.bindInteger(2, hashtagObject.date); state.step(); } state.dispose(); MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); if (arrayList.size() >= 100) { MessagesStorage.getInstance(currentAccount).getDatabase().beginTransaction(); for (int a = 100; a < arrayList.size(); a++) { MessagesStorage.getInstance(currentAccount).getDatabase().executeFast("DELETE FROM hashtag_recent_v2 WHERE id = '" + arrayList.get(a).hashtag + "'").stepThis().dispose(); } MessagesStorage.getInstance(currentAccount).getDatabase().commitTransaction(); } } catch (Exception e) { FileLog.e(e); } }); }