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);
}
}
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));
}
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);
}
}
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);
}
}
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);
}
Aggregations