Search in sources :

Example 1 with MediaRecord

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));
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) Slide(org.thoughtcrime.securesms.mms.Slide) ThumbnailView(org.thoughtcrime.securesms.components.ThumbnailView)

Example 2 with 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());
}
Also used : Context(android.content.Context) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) SaveAttachmentTask(org.thoughtcrime.securesms.util.SaveAttachmentTask) MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with MediaRecord

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));
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) Slide(org.thoughtcrime.securesms.mms.Slide) ThumbnailView(org.thoughtcrime.securesms.components.ThumbnailView)

Example 4 with 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);
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) MediaDatabase(org.thoughtcrime.securesms.database.MediaDatabase) AttachmentId(org.thoughtcrime.securesms.attachments.AttachmentId)

Example 5 with MediaRecord

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);
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord)

Aggregations

MediaRecord (org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord)8 Slide (org.thoughtcrime.securesms.mms.Slide)4 MediaDatabase (org.thoughtcrime.securesms.database.MediaDatabase)3 ThumbnailView (org.thoughtcrime.securesms.components.ThumbnailView)2 AudioSlide (org.thoughtcrime.securesms.mms.AudioSlide)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Cursor (android.database.Cursor)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 AttachmentId (org.thoughtcrime.securesms.attachments.AttachmentId)1 Media (org.thoughtcrime.securesms.mediasend.Media)1 SaveAttachmentTask (org.thoughtcrime.securesms.util.SaveAttachmentTask)1 ProgressDialogAsyncTask (org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask)1