Search in sources :

Example 11 with MediaRecord

use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.

the class MediaPreviewViewModel method setActiveAlbumRailItem.

public void setActiveAlbumRailItem(@NonNull Context context, int activePosition) {
    if (cursor == null) {
        previewData.postValue(new PreviewData(Collections.emptyList(), null, 0));
        return;
    }
    activePosition = getCursorPosition(activePosition);
    cursor.moveToPosition(activePosition);
    MediaRecord activeRecord = MediaRecord.from(context, cursor);
    LinkedList<Media> rail = new LinkedList<>();
    Media activeMedia = toMedia(activeRecord);
    if (activeMedia != null)
        rail.add(activeMedia);
    while (cursor.moveToPrevious()) {
        MediaRecord record = MediaRecord.from(context, cursor);
        if (record.getAttachment().getMmsId() == activeRecord.getAttachment().getMmsId()) {
            Media media = toMedia(record);
            if (media != null)
                rail.addFirst(media);
        } else {
            break;
        }
    }
    cursor.moveToPosition(activePosition);
    while (cursor.moveToNext()) {
        MediaRecord record = MediaRecord.from(context, cursor);
        if (record.getAttachment().getMmsId() == activeRecord.getAttachment().getMmsId()) {
            Media media = toMedia(record);
            if (media != null)
                rail.addLast(media);
        } else {
            break;
        }
    }
    if (!leftIsRecent) {
        Collections.reverse(rail);
    }
    previewData.postValue(new PreviewData(rail.size() > 1 ? rail : Collections.emptyList(), activeRecord.getAttachment().getCaption(), rail.indexOf(activeMedia)));
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) Media(org.thoughtcrime.securesms.mediasend.Media) LinkedList(java.util.LinkedList)

Example 12 with MediaRecord

use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by signalapp.

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)

Example 13 with MediaRecord

use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by signalapp.

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)

Aggregations

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