Search in sources :

Example 6 with MediaModel

use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method startMediaDeleteService.

private void startMediaDeleteService(ArrayList<MediaModel> mediaToDelete) {
    if (!NetworkUtils.isNetworkAvailable(this)) {
        AppLog.v(AppLog.T.MEDIA, "Unable to start MediaDeleteService, internet connection required.");
        return;
    }
    if (mDeleteService != null) {
        if (mediaToDelete != null && !mediaToDelete.isEmpty()) {
            for (MediaModel media : mediaToDelete) {
                mDeleteService.addMediaToDeleteQueue(media);
            }
        }
    } else {
        Intent intent = new Intent(this, MediaDeleteService.class);
        intent.putExtra(MediaDeleteService.SITE_KEY, mSite);
        if (mediaToDelete != null) {
            intent.putExtra(MediaDeleteService.MEDIA_LIST_KEY, mediaToDelete);
            doBindDeleteService(intent);
        }
        startService(intent);
    }
}
Also used : MediaModel(org.wordpress.android.fluxc.model.MediaModel) Intent(android.content.Intent)

Example 7 with MediaModel

use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.

the class EditPostActivity method onMediaUploadCancelClicked.

@Override
public void onMediaUploadCancelClicked(String mediaId, boolean delete) {
    MediaModel media = new MediaModel();
    media.setMediaId(Long.valueOf(mediaId));
    MediaPayload payload = new MediaPayload(mSite, media);
    mDispatcher.dispatch(MediaActionBuilder.newCancelMediaUploadAction(payload));
}
Also used : MediaModel(org.wordpress.android.fluxc.model.MediaModel) MediaPayload(org.wordpress.android.fluxc.store.MediaStore.MediaPayload)

Example 8 with MediaModel

use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.

the class EditPostActivity method startMediaUploadService.

/**
     * Starts the upload service to upload selected media.
     */
private void startMediaUploadService() {
    if (mPendingUploads != null && !mPendingUploads.isEmpty()) {
        ArrayList<MediaModel> mediaList = new ArrayList<>();
        for (MediaModel media : mPendingUploads) {
            if (media.getUploadState().equals(UploadState.QUEUED.name())) {
                mediaList.add(media);
            }
        }
        MediaUploadService.startService(this, mSite, mediaList);
    }
}
Also used : MediaModel(org.wordpress.android.fluxc.model.MediaModel) ArrayList(java.util.ArrayList)

Example 9 with MediaModel

use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.

the class EditPostActivity method addExistingMediaToEditor.

private void addExistingMediaToEditor(long mediaId) {
    MediaModel media = mMediaStore.getSiteMediaWithId(mSite, mediaId);
    if (media != null) {
        MediaFile mediaFile = FluxCUtils.mediaFileFromMediaModel(media);
        trackAddMediaFromWPLibraryEvents(mediaFile.isVideo(), media.getMediaId());
        String urlToUse = TextUtils.isEmpty(media.getUrl()) ? media.getFilePath() : media.getUrl();
        mEditorFragment.appendMediaFile(mediaFile, urlToUse, mImageLoader);
    }
}
Also used : MediaFile(org.wordpress.android.util.helpers.MediaFile) MediaModel(org.wordpress.android.fluxc.model.MediaModel)

Example 10 with MediaModel

use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.

the class EditPostActivity method onMediaRetryClicked.

@Override
public void onMediaRetryClicked(String mediaId) {
    MediaModel media = null;
    List<MediaModel> localMediaList = mMediaStore.getLocalSiteMedia(mSite);
    for (MediaModel localMedia : localMediaList) {
        if (String.valueOf(localMedia.getId()).equals(mediaId)) {
            media = localMedia;
            break;
        }
    }
    if (media != null) {
        media.setUploadState(UploadState.QUEUED.name());
        mDispatcher.dispatch(MediaActionBuilder.newUpdateMediaAction(media));
        mPendingUploads.add(media);
        startMediaUploadService();
    }
    AnalyticsTracker.track(Stat.EDITOR_UPLOAD_MEDIA_RETRIED);
}
Also used : MediaModel(org.wordpress.android.fluxc.model.MediaModel)

Aggregations

MediaModel (org.wordpress.android.fluxc.model.MediaModel)23 ArrayList (java.util.ArrayList)6 MediaFile (org.wordpress.android.util.helpers.MediaFile)5 Intent (android.content.Intent)3 SuppressLint (android.annotation.SuppressLint)2 AlertDialog (android.app.AlertDialog)2 Builder (android.app.AlertDialog.Builder)2 DialogInterface (android.content.DialogInterface)2 Uri (android.net.Uri)2 File (java.io.File)2 OnClickListener (android.content.DialogInterface.OnClickListener)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 AlignmentSpan (android.text.style.AlignmentSpan)1 ImageSpan (android.text.style.ImageSpan)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Subscribe (org.greenrobot.eventbus.Subscribe)1 MediaActionBuilder (org.wordpress.android.fluxc.generated.MediaActionBuilder)1 MediaPayload (org.wordpress.android.fluxc.store.MediaStore.MediaPayload)1