use of org.thoughtcrime.securesms.database.model.ThreadRecord in project Signal-Android by WhisperSystems.
the class ConversationListAdapter method getItemId.
@Override
public long getItemId(@NonNull Cursor cursor) {
ThreadRecord record = getThreadRecord(cursor);
StringBuilder builder = new StringBuilder("" + record.getThreadId());
for (long recipientId : record.getRecipients().getIds()) {
builder.append("::").append(recipientId);
}
return Conversions.byteArrayToLong(digest.digest(builder.toString().getBytes()));
}
use of org.thoughtcrime.securesms.database.model.ThreadRecord in project Signal-Android by WhisperSystems.
the class DirectShareService method onGetChooserTargets.
@Override
public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
List<ChooserTarget> results = new LinkedList<>();
MasterSecret masterSecret = KeyCachingService.getMasterSecret(this);
if (masterSecret == null) {
return results;
}
ComponentName componentName = new ComponentName(this, ShareActivity.class);
ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(this);
Cursor cursor = threadDatabase.getDirectShareList();
try {
ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, new MasterCipher(masterSecret));
ThreadRecord record;
while ((record = reader.getNext()) != null && results.size() < 10) {
Recipients recipients = RecipientFactory.getRecipientsForIds(this, record.getRecipients().getIds(), false);
String name = recipients.toShortString();
Drawable drawable = recipients.getContactPhoto().asDrawable(this, recipients.getColor().toConversationColor(this));
Bitmap avatar = BitmapUtil.createFromDrawable(drawable, 500, 500);
Bundle bundle = new Bundle();
bundle.putLong(ShareActivity.EXTRA_THREAD_ID, record.getThreadId());
bundle.putLongArray(ShareActivity.EXTRA_RECIPIENT_IDS, recipients.getIds());
bundle.putInt(ShareActivity.EXTRA_DISTRIBUTION_TYPE, record.getDistributionType());
results.add(new ChooserTarget(name, Icon.createWithBitmap(avatar), 1.0f, componentName, bundle));
}
return results;
} finally {
if (cursor != null)
cursor.close();
}
}
use of org.thoughtcrime.securesms.database.model.ThreadRecord in project Signal-Android by WhisperSystems.
the class ShareListAdapter method bindView.
@Override
public void bindView(View view, Context context, Cursor cursor) {
if (masterCipher != null) {
ThreadDatabase.Reader reader = threadDatabase.readerFor(cursor, masterCipher);
ThreadRecord record = reader.getCurrent();
((ShareListItem) view).set(record);
}
}
Aggregations