本文整理汇总了Java中com.onegravity.rteditor.api.media.RTImage类的典型用法代码示例。如果您正苦于以下问题:Java RTImage类的具体用法?Java RTImage怎么用?Java RTImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RTImage类属于com.onegravity.rteditor.api.media包,在下文中一共展示了RTImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startImg
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
private void startImg(Attributes attributes) {
int len = mResult.length();
String src = attributes.getValue("", "src");
RTImage image = mMediaFactory.createImage(src);
if (image != null && image.exists()) {
String path = image.getFilePath(RTFormat.SPANNED);
File file = new File(path);
if (file.isDirectory()) {
// there were crashes when an image was a directory all of a sudden...
// the root cause is unknown and this is a desparate work around
return;
}
// Unicode Character 'OBJECT REPLACEMENT CHARACTER' (U+FFFC)
// see http://www.fileformat.info/info/unicode/char/fffc/index.htm
mResult.append("\uFFFC");
ImageSpan imageSpan = new ImageSpan(image, true);
mResult.setSpan(imageSpan, len, len + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
示例2: onActivityResult
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == MediaAction.PICK_PICTURE.requestCode() && data != null) {
mMediaChooserMgr.processMedia(MediaAction.PICK_PICTURE, data);
} else if (requestCode == MediaAction.CAPTURE_PICTURE.requestCode()) {
mMediaChooserMgr.processMedia(MediaAction.CAPTURE_PICTURE, data); // data may be null here
} else if (requestCode == Constants.CROP_IMAGE) {
String path = data.getStringExtra(CropImageActivity.IMAGE_DESTINATION_FILE);
if (path != null && mSelectedMedia instanceof RTImage) {
EventBus.getDefault().postSticky( new MediaEvent(mSelectedMedia) );
finish();
}
}
} else {
setResult(RESULT_CANCELED);
finish();
}
}
示例3: processMedia
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
protected void processMedia() throws IOException, Exception {
InputStream in = super.getInputStream();
if (in == null) {
if (mListener != null) {
mListener.onError("No file found to process");
}
} else {
RTMediaSource source = new RTMediaSource(RTMediaType.IMAGE, in, getOriginalFile(), getMimeType());
RTImage image = mMediaFactory.createImage(source);
if (image != null && mListener != null) {
mListener.onImageProcessed(image);
}
}
}
示例4: setRichTextEditing
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
/**
* Sets the edit mode to plain or rich text and updates the content at the
* same time. The caller needs to make sure the content matches the correct
* format (if you pass in html code as plain text the editor will show the
* html code).
*
* @param useRTFormatting True if the edit mode should be rich text, False if the edit
* mode should be plain text
* @param content The new content
*/
public void setRichTextEditing(boolean useRTFormatting, String content) {
assertRegistration();
if (useRTFormatting != mUseRTFormatting) {
mUseRTFormatting = useRTFormatting;
if (mListener != null) {
mListener.onRichTextEditingChanged(this, mUseRTFormatting);
}
}
RTText rtText = useRTFormatting ?
new RTHtml<RTImage, RTAudio, RTVideo>(RTFormat.HTML, content) :
new RTPlainText(content);
setText(rtText);
}
示例5: onActivityResult
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == MediaAction.PICK_PICTURE.requestCode() && data != null) {
mMediaChooserMgr.processMedia(MediaAction.PICK_PICTURE, data);
} else if (requestCode == MediaAction.CAPTURE_PICTURE.requestCode()) {
mMediaChooserMgr.processMedia(MediaAction.CAPTURE_PICTURE, data); // data may be null here
} else if (requestCode == Constants.CROP_IMAGE) {
String path = data.getStringExtra(CropImageActivity.IMAGE_DESTINATION_FILE);
if (path != null && mSelectedMedia instanceof RTImage) {
EventBus.getDefault().post( new MediaEvent(mSelectedMedia) );
finish();
}
}
} else {
setResult(RESULT_CANCELED);
finish();
}
}
示例6: convert
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
/**
* Converts a spanned text to HTML
*/
public RTHtml<RTImage, RTAudio, RTVideo> convert(final Spanned text, RTFormat.Html rtFormat) {
mText = text;
mRTFormat = rtFormat;
mOut = new StringBuilder();
mImages = new ArrayList<>();
mParagraphStyles.clear();
// convert paragraphs
convertParagraphs();
return new RTHtml<>(rtFormat, mOut.toString(), mImages);
}
示例7: convert
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
public static RTPlainText convert(RTHtml<? extends RTImage, ? extends RTAudio, ? extends RTVideo> input) {
String result = Html.fromHtml(input.getText(), null, new HtmlToTextTagHandler())
.toString()
.replace(PREVIEW_OBJECT_CHARACTER, PREVIEW_OBJECT_REPLACEMENT)
.replace(NBSP_CHARACTER, NBSP_REPLACEMENT);
return new RTPlainText(result);
}
示例8: createImage
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
/* @inheritDoc */
public RTImage createImage(RTMediaSource mediaSource) {
File targetFile = loadMedia(mediaSource);
return targetFile == null ? null :
new RTImageImpl(targetFile.getAbsolutePath());
}
示例9: convertTo
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
public RTText convertTo(RTFormat destFormat, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
if (destFormat instanceof RTFormat.Html) {
return ConverterTextToHtml.convert(this);
} else if (destFormat instanceof RTFormat.Spanned) {
return new RTSpanned(new SpannedString(getText()));
}
return super.convertTo(destFormat, mediaFactory);
}
示例10: convertTo
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
public RTText convertTo(RTFormat destFormat, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
if (destFormat instanceof RTFormat.Html) {
clean();
return new ConverterSpannedToHtml().convert(mEditor.getText(), (RTFormat.Html) destFormat);
} else if (destFormat instanceof RTFormat.PlainText) {
clean();
RTHtml<RTImage, RTAudio, RTVideo> rtHtml = new ConverterSpannedToHtml().convert(mEditor.getText(), RTFormat.HTML);
RTText rtText = rtHtml.convertTo(RTFormat.PLAIN_TEXT, mediaFactory);
return new RTPlainText(rtText.getText());
}
return super.convertTo(destFormat, mediaFactory);
}
示例11: convertTo
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
public RTText convertTo(RTFormat destFormat, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
if (destFormat instanceof RTFormat.PlainText) {
return ConverterHtmlToText.convert(this);
} else if (destFormat instanceof RTFormat.Spanned) {
return new ConverterHtmlToSpanned().convert(this, mediaFactory);
}
return super.convertTo(destFormat, mediaFactory);
}
示例12: RTApi
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
/**
* @param context Can be an Application or an Activity context
* @param rtProxy The RTProxy provided by the app.
* @param mediaFactory the RTMediaFactory provided by the app.
*/
public RTApi(Context context, RTProxy rtProxy, RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory) {
synchronized (sTheLock) {
sAppContext = context.getApplicationContext();
}
sDarkTheme = DialogUtils.resolveBoolean(context, R.attr.md_dark_theme, false);
mRTProxy = rtProxy;
mMediaFactory = mediaFactory;
}
示例13: MediaChooserManager
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
MediaChooserManager(MonitoredActivity activity, MediaAction mediaAction,
RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory,
MediaChooserListener listener, Bundle savedInstanceState) {
mActivity = activity;
mMediaFactory = mediaFactory;
mMediaAction = mediaAction;
mListener = listener;
if (savedInstanceState != null) {
mOriginalFile = savedInstanceState.getString("mOriginalFile");
}
}
示例14: ImageChooserManager
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
ImageChooserManager(MonitoredActivity activity, MediaAction mediaAction,
RTMediaFactory<RTImage, RTAudio, RTVideo> mediaFactory,
ImageChooserListener listener, Bundle savedInstanceState) {
super(activity, mediaAction, mediaFactory, listener, savedInstanceState);
mListener = listener;
}
示例15: onImageProcessed
import com.onegravity.rteditor.api.media.RTImage; //导入依赖的package包/类
@Override
/* ImageProcessorListener */
public void onImageProcessed(RTImage image) {
if (mListener != null) {
mListener.onImageChosen(image);
}
}