use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.
the class EditPostSettingsFragment method updateFeaturedImage.
public void updateFeaturedImage(long id) {
if (mFeaturedImageId != id) {
mFeaturedImageId = id;
if (mFeaturedImageId > 0) {
MediaModel media = mMediaStore.getSiteMediaWithId(mSite, mFeaturedImageId);
if (media == null) {
return;
}
mFeaturedImageView.setVisibility(View.VISIBLE);
mFeaturedImageButton.setVisibility(View.GONE);
// Get max width for photon thumbnail
int maxWidth = getResources().getDisplayMetrics().widthPixels;
int padding = DisplayUtils.dpToPx(getActivity(), 16);
int imageWidth = (maxWidth - padding);
WordPressMediaUtils.loadNetworkImage(media.getThumbnailUrl() + "?w=" + imageWidth, mFeaturedImageView, mImageLoader);
} else {
mFeaturedImageView.setVisibility(View.GONE);
mFeaturedImageButton.setVisibility(View.VISIBLE);
}
}
}
use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.
the class EditPostActivity method queueFileForUpload.
private MediaModel queueFileForUpload(Uri uri, String mimeType, UploadState startingState) {
String path = getRealPathFromURI(uri);
// Invalid file path
if (TextUtils.isEmpty(path)) {
Toast.makeText(this, R.string.editor_toast_invalid_path, Toast.LENGTH_SHORT).show();
return null;
}
// File not found
File file = new File(path);
if (!file.exists()) {
Toast.makeText(this, R.string.file_not_found, Toast.LENGTH_SHORT).show();
return null;
}
MediaModel media = buildMediaModel(uri, mimeType, startingState);
mDispatcher.dispatch(MediaActionBuilder.newUpdateMediaAction(media));
mPendingUploads.add(media);
startMediaUploadService();
return media;
}
use of org.wordpress.android.fluxc.model.MediaModel in project WordPress-Android by wordpress-mobile.
the class EditPostActivity method addMediaLegacyEditor.
private boolean addMediaLegacyEditor(Uri mediaUri, boolean isVideo) {
trackAddMediaFromDeviceEvents(isVideo, false, mediaUri, null);
MediaModel mediaModel = buildMediaModel(mediaUri, getContentResolver().getType(mediaUri), UploadState.QUEUED);
if (isVideo) {
mediaModel.setTitle(getResources().getString(R.string.video));
} else {
mediaModel.setTitle(ImageUtils.getTitleForWPImageSpan(this, mediaUri.getEncodedPath()));
}
mediaModel.setPostId(mPost.getId());
mDispatcher.dispatch(MediaActionBuilder.newUpdateMediaAction(mediaModel));
MediaFile mediaFile = FluxCUtils.mediaFileFromMediaModel(mediaModel);
mEditorFragment.appendMediaFile(mediaFile, mediaFile.getFilePath(), mImageLoader);
return true;
}
Aggregations