use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaAdapter method onBindItemViewHolder.
@Override
public void onBindItemViewHolder(final ViewHolder viewHolder, @NonNull final Cursor cursor) {
final ThumbnailView imageView = viewHolder.imageView;
final MediaRecord mediaRecord = MediaRecord.from(cursor);
Slide slide = MediaUtil.getSlideForAttachment(getContext(), mediaRecord.getAttachment());
if (slide != null) {
imageView.setImageResource(masterSecret, slide, false);
}
imageView.setOnClickListener(new OnMediaClickListener(mediaRecord));
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaOverviewActivity method saveToDisk.
private void saveToDisk() {
final Context c = this;
SaveAttachmentTask.showWarningDialog(this, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
new ProgressDialogAsyncTask<Void, Void, List<SaveAttachmentTask.Attachment>>(c, R.string.ConversationFragment_collecting_attahments, R.string.please_wait) {
@Override
protected List<SaveAttachmentTask.Attachment> doInBackground(Void... params) {
Cursor cursor = DatabaseFactory.getMediaDatabase(c).getMediaForThread(threadId);
List<SaveAttachmentTask.Attachment> attachments = new ArrayList<>(cursor.getCount());
while (cursor != null && cursor.moveToNext()) {
MediaRecord record = MediaRecord.from(cursor);
attachments.add(new SaveAttachmentTask.Attachment(record.getAttachment().getDataUri(), record.getContentType(), record.getDate()));
}
return attachments;
}
@Override
protected void onPostExecute(List<SaveAttachmentTask.Attachment> attachments) {
super.onPostExecute(attachments);
SaveAttachmentTask saveTask = new SaveAttachmentTask(c, masterSecret, attachments.size());
saveTask.execute(attachments.toArray(new SaveAttachmentTask.Attachment[attachments.size()]));
}
}.execute();
}
}, gridView.getAdapter().getItemCount());
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by signalapp.
the class MediaGalleryAdapter method onBindItemViewHolder.
@Override
public void onBindItemViewHolder(ItemViewHolder viewHolder, int section, int offset) {
MediaRecord mediaRecord = media.get(section, offset);
ThumbnailView thumbnailView = ((ViewHolder) viewHolder).imageView;
Slide slide = MediaUtil.getSlideForAttachment(context, mediaRecord.getAttachment());
if (slide != null) {
thumbnailView.setImageResource(glideRequests, slide, false, false);
}
thumbnailView.setOnClickListener(new OnMediaClickListener(mediaRecord));
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaGalleryAllAdapter method toggleSelection.
public void toggleSelection(@NonNull MediaRecord mediaRecord) {
AttachmentId attachmentId = mediaRecord.getAttachment().getAttachmentId();
MediaDatabase.MediaRecord removed = selected.remove(attachmentId);
if (removed == null) {
selected.put(attachmentId, mediaRecord);
}
notifyItemRangeChanged(0, getItemCount(), PAYLOAD_SELECTED);
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaGalleryAllAdapter method selectAllMedia.
void selectAllMedia() {
int sectionCount = media.getSectionCount();
for (int section = 0; section < sectionCount; section++) {
int sectionItemCount = media.getSectionItemCount(section);
for (int item = 0; item < sectionItemCount; item++) {
MediaRecord mediaRecord = media.get(section, item);
selected.put(mediaRecord.getAttachment().getAttachmentId(), mediaRecord);
}
}
this.notifyItemRangeChanged(0, getItemCount(), PAYLOAD_SELECTED);
}
Aggregations