use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class ThreadDatabase method updateThread.
private void updateThread(long threadId, long count, String body, @Nullable Uri attachment, long date, int status, int receiptCount, long type, boolean unarchive, long expiresIn) {
ContentValues contentValues = new ContentValues(7);
contentValues.put(DATE, date - date % 1000);
contentValues.put(MESSAGE_COUNT, count);
contentValues.put(SNIPPET, body);
contentValues.put(SNIPPET_URI, attachment == null ? null : attachment.toString());
contentValues.put(SNIPPET_TYPE, type);
contentValues.put(STATUS, status);
contentValues.put(RECEIPT_COUNT, receiptCount);
contentValues.put(EXPIRES_IN, expiresIn);
if (unarchive) {
contentValues.put(ARCHIVED, 0);
}
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.update(TABLE_NAME, contentValues, ID + " = ?", new String[] { threadId + "" });
notifyConversationListListeners();
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class ThreadDatabase method setLastSeen.
public void setLastSeen(long threadId) {
SQLiteDatabase db = databaseHelper.getWritableDatabase();
ContentValues contentValues = new ContentValues(1);
contentValues.put(LAST_SEEN, System.currentTimeMillis());
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] { String.valueOf(threadId) });
notifyConversationListListeners();
}
use of android.content.ContentValues in project Signal-Android by WhisperSystems.
the class ThreadDatabase method setRead.
public List<MarkedMessageInfo> setRead(long threadId, boolean lastSeen) {
ContentValues contentValues = new ContentValues(1);
contentValues.put(READ, 1);
if (lastSeen) {
contentValues.put(LAST_SEEN, System.currentTimeMillis());
}
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.update(TABLE_NAME, contentValues, ID_WHERE, new String[] { threadId + "" });
final List<MarkedMessageInfo> smsRecords = DatabaseFactory.getSmsDatabase(context).setMessagesRead(threadId);
final List<MarkedMessageInfo> mmsRecords = DatabaseFactory.getMmsDatabase(context).setMessagesRead(threadId);
notifyConversationListListeners();
return new LinkedList<MarkedMessageInfo>() {
{
addAll(smsRecords);
addAll(mmsRecords);
}
};
}
use of android.content.ContentValues in project okhttp-OkGo by jeasonlzy.
the class DownloadInfo method buildContentValues.
public static ContentValues buildContentValues(DownloadInfo downloadInfo) {
ContentValues values = new ContentValues();
values.put(TASK_KEY, downloadInfo.getTaskKey());
values.put(URL, downloadInfo.getUrl());
values.put(TARGET_FOLDER, downloadInfo.getTargetFolder());
values.put(TARGET_PATH, downloadInfo.getTargetPath());
values.put(FILE_NAME, downloadInfo.getFileName());
values.put(PROGRESS, downloadInfo.getProgress());
values.put(TOTAL_LENGTH, downloadInfo.getTotalLength());
values.put(DOWNLOAD_LENGTH, downloadInfo.getDownloadLength());
values.put(NETWORK_SPEED, downloadInfo.getNetworkSpeed());
values.put(STATE, downloadInfo.getState());
BaseRequest request = downloadInfo.getRequest();
DownloadRequest downloadRequest = downloadInfo.getDownloadRequest();
downloadRequest.cacheKey = request.getCacheKey();
downloadRequest.cacheTime = request.getCacheTime();
downloadRequest.cacheMode = request.getCacheMode();
downloadRequest.url = request.getBaseUrl();
downloadRequest.params = request.getParams();
downloadRequest.headers = request.getHeaders();
downloadRequest.method = DownloadRequest.getMethod(request);
ByteArrayOutputStream baos = null;
ObjectOutputStream oos = null;
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(downloadRequest);
oos.flush();
byte[] requestData = baos.toByteArray();
values.put(DownloadInfo.DOWNLOAD_REQUEST, requestData);
} catch (IOException e) {
OkLogger.e(e);
} finally {
try {
if (oos != null)
oos.close();
if (baos != null)
baos.close();
} catch (IOException e) {
OkLogger.e(e);
}
}
try {
baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(downloadInfo.getData());
oos.flush();
byte[] data = baos.toByteArray();
values.put(DownloadInfo.DATA, data);
} catch (IOException e) {
OkLogger.e(e);
} finally {
try {
if (oos != null)
oos.close();
if (baos != null)
baos.close();
} catch (IOException e) {
OkLogger.e(e);
}
}
return values;
}
use of android.content.ContentValues in project ZhihuDailyPurify by izzyleung.
the class DailyNewsDataSource method insertDailyNewsList.
public List<DailyNews> insertDailyNewsList(String date, String content) {
ContentValues values = new ContentValues();
values.put(DBHelper.COLUMN_DATE, date);
values.put(DBHelper.COLUMN_CONTENT, content);
long insertId = database.insert(DBHelper.TABLE_NAME, null, values);
Cursor cursor = database.query(DBHelper.TABLE_NAME, allColumns, DBHelper.COLUMN_ID + " = " + insertId, null, null, null, null);
cursor.moveToFirst();
List<DailyNews> newsList = cursorToNewsList(cursor);
cursor.close();
return newsList;
}
Aggregations