当前位置: 首页>>代码示例>>Java>>正文


Java Helper类代码示例

本文整理汇总了Java中com.onegravity.rteditor.utils.Helper的典型用法代码示例。如果您正苦于以下问题:Java Helper类的具体用法?Java Helper怎么用?Java Helper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Helper类属于com.onegravity.rteditor.utils包,在下文中一共展示了Helper类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: endDiv

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void endDiv() {
    int end = mResult.length();
    Object obj = getLast(mResult, Div.class);
    int start = mResult.getSpanStart(obj);

    mResult.removeSpan(obj);
    if (start != end) {
        if (!checkDuplicateSpan(mResult, start, AlignmentSpan.class)) {
            Div divObj = (Div) obj;
            Layout.Alignment align = divObj.mAlign.equalsIgnoreCase("center") ? Layout.Alignment.ALIGN_CENTER :
                    divObj.mAlign.equalsIgnoreCase("right") ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL;
            if (align != null) {
                if (mResult.charAt(end - 1) != '\n') {
                    // yes we need that linefeed, or we will get crashes
                    mResult.append('\n');
                }
                // use SPAN_EXCLUSIVE_EXCLUSIVE here, will be replaced later anyway when the cleanup function is called
                boolean isRTL = Helper.isRTL(mResult, start, end);
                mResult.setSpan(new AlignmentSpan(align, isRTL), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:24,代码来源:ConverterHtmlToSpanned.java

示例2: applyToSelection

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
@Override
public void applyToSelection(RTEditText editor, Selection selectedParagraphs, Layout.Alignment alignment) {
    final Spannable str = editor.getText();

    mSpans2Process.clear();

    for (Paragraph paragraph : editor.getParagraphs()) {
        // find existing AlignmentSpan and add them to mSpans2Process to be removed
        List<RTSpan<Layout.Alignment>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
        mSpans2Process.removeSpans(existingSpans, paragraph);

        // if the paragraph is selected then we sure have an alignment
        boolean hasExistingSpans = !existingSpans.isEmpty();
        Alignment newAlignment = paragraph.isSelected(selectedParagraphs) ? alignment :
                                 hasExistingSpans ? existingSpans.get(0).getValue() : null;

        if (newAlignment != null) {
            boolean isRTL = Helper.isRTL(str, paragraph.start(), paragraph.end());
            AlignmentSpan alignmentSpan = new AlignmentSpan(newAlignment, isRTL);
            mSpans2Process.addSpan(alignmentSpan, paragraph);
        }
    }

    // add or remove spans
    mSpans2Process.process(str);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:27,代码来源:AlignmentEffect.java

示例3: endDiv

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void endDiv() {
    int end = mResult.length();
    Object obj = getLast(mResult, Div.class);
    int start = mResult.getSpanStart(obj);

    mResult.removeSpan(obj);
    if (start != end && !checkDuplicateSpan(mResult, start, AlignmentSpan.class)) {
        Div divObj = (Div) obj;
        Layout.Alignment align = divObj.mAlign.equalsIgnoreCase("center") ? Layout.Alignment.ALIGN_CENTER :
                divObj.mAlign.equalsIgnoreCase("right") ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL;
        if (align != null) {
            if (mResult.charAt(end - 1) != '\n') {
                // yes we need that linefeed, or we will get crashes
                mResult.append('\n');
            }
            // use SPAN_EXCLUSIVE_EXCLUSIVE here, will be replaced later anyway when the cleanup function is called
            boolean isRTL = Helper.isRTL(mResult, start, end);
            mResult.setSpan(new AlignmentSpan(align, isRTL), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:22,代码来源:ConverterHtmlToSpanned.java

示例4: save

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
public static String save(Context context, File outFile, String html) {
    Reader in = null;
    Writer out = null;

    try {
        in = new StringReader(html);
        out = new FileWriter(outFile);

        IOUtils.copy(in, out);

        return outFile.getAbsolutePath();
    } catch (IOException ioe) {
        String toastMsg = context.getString(R.string.save_as_failure, ioe.getMessage());
        Toast.makeText(context, toastMsg, Toast.LENGTH_LONG).show();
    } finally {
        Helper.closeQuietly(in);
        Helper.closeQuietly(out);
    }

    return null;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:22,代码来源:FileHelper.java

示例5: load

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
public static String load(Context context, String filePath) {
    File inFile = new File(filePath);
    Reader in = null;
    Writer out = null;

    try {
        in = new FileReader(inFile);
        out = new StringWriter();

        IOUtils.copy(in, out);

        return out.toString();
    } catch (IOException ioe) {
        String toastMsg = context.getString(R.string.load_failure_2, ioe.getMessage());
        Toast.makeText(context, toastMsg, Toast.LENGTH_LONG).show();
    } finally {
        Helper.closeQuietly(in);
        Helper.closeQuietly(out);
    }

    return null;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:23,代码来源:FileHelper.java

示例6: setFontSize

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
/**
 * Set the text size.
 *
 * @param size the text size, if -1 then no text size is set (e.g. when selection spans more than one text size)
 */
@Override
public void setFontSize(int size) {
    if (mFontSize != null) {
        if (size <= 0) {
            mFontSizeAdapter.updateSpinnerTitle("");
            mFontSizeAdapter.setSelectedItem(0);
            mFontSize.setSelection(0);
        } else {
            size = Helper.convertSpToPx(size);
            mFontSizeAdapter.updateSpinnerTitle(Integer.toString(size));
            for (int pos = 0; pos < mFontSizeAdapter.getCount(); pos++) {
                FontSizeSpinnerItem item = mFontSizeAdapter.getItem(pos);
                if (size == item.getFontSize()) {
                    mFontSizeAdapter.setSelectedItem(pos);
                    mFontSize.setSelection(pos);
                    break;
                }
            }
        }
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:27,代码来源:HorizontalRTToolbar.java

示例7: getIndentation

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
public int getIndentation() {
    if (mType.isIndentation()) {
        float margin = Helper.getLeadingMarging();
        float indentation = ((IndentationSpan) mStyle).getValue();
        return Math.round(indentation / margin);
    } else if (mType.isBullet() || mType.isNumbering()) {
        return 1;
    }
    return 0;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:11,代码来源:SingleParagraphStyle.java

示例8: validate

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void validate(Dialog dialog, TextView addressView, TextView textView) {
    // retrieve link address and do some cleanup
    final String address = addressView.getText().toString().trim();

    boolean isEmail = sEmailValidator.isValid(address);
    boolean isUrl = sUrlValidator.isValid(address);
    if (requiredFieldValid(addressView) && (isUrl || isEmail)) {
        // valid url or email address

        // encode address
        String newAddress = Helper.encodeQuery(address);

        // add mailto: for email addresses
        if (isEmail && !startsWithMailto(newAddress)) {
            newAddress = "mailto:" + newAddress;
        }

        // use the original address text as link text if the user didn't enter anything
        String linkText = textView.getText().toString();
        if (linkText.length() == 0) {
            linkText = address;
        }

        EventBus.getDefault().post(new LinkEvent(LinkFragment.this, new Link(linkText, newAddress), false));
        try { dialog.dismiss(); } catch (Exception ignore) {}
    } else {
        // invalid address (neither a url nor an email address
        String errorMessage = getString(R.string.rte_invalid_link, address);
        addressView.setError(errorMessage);
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:32,代码来源:LinkFragment.java

示例9: copyFile

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void copyFile(InputStream in, File targetFile) {
    OutputStream out = null;
    try {
        out = new FileOutputStream(targetFile);
        IOUtils.copy(in, out);
    } catch (IOException ioe) {
        Log.e(getClass().getSimpleName(), ioe.getMessage(), ioe);
    } finally {
        Helper.closeQuietly(out);
        Helper.closeQuietly(in);
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:13,代码来源:RTMediaFactoryImpl.java

示例10: saveOutput

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void saveOutput(Bitmap croppedImage) {
    if (mSaveUri != null) {
        OutputStream out = null;
        try {
            out = getContentResolver().openOutputStream(mSaveUri);
            if (out != null) {
                croppedImage.compress(mOutputFormat, 90, out);
            }
        } catch (IOException ex) {
            Log.e(getClass().getSimpleName(), "Cannot open file: " + mSaveUri, ex);
            setResult(RESULT_CANCELED);
            finish();
            return;
        } finally {
            Helper.closeQuietly(out);
        }

        Bundle extras = new Bundle();
        Intent intent = new Intent(mSaveUri.toString());
        intent.putExtras(extras);
        intent.putExtra(IMAGE_SOURCE_FILE, mImageSource);
        intent.putExtra(IMAGE_DESTINATION_FILE, mImageDest);
        intent.putExtra(ORIENTATION_IN_DEGREES,
                getOrientationInDegree(this));
        setResult(RESULT_OK, intent);

    } else {
        Log.e(getClass().getSimpleName(), "not defined image url");
    }
    croppedImage.recycle();
    finish();
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:33,代码来源:CropImageActivity.java

示例11: getPathFromUri

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private static String getPathFromUri(Context context, Uri imageUri) {
    String filePath = "";

    if (imageUri.toString().startsWith("content://com.android.gallery3d.provider")) {
        imageUri = Uri.parse(imageUri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
    }

    Cursor cursor = null;
    try {
        String column = MediaColumns.DATA;
        String[] proj = {MediaColumns.DATA};

        cursor = context.getContentResolver().query(imageUri, proj, null, null, null);
        cursor.moveToFirst();

        if (imageUri.toString().startsWith("content://com.google.android.gallery3d")) {
            filePath = imageUri.toString();
        } else {
            filePath = cursor.getString(cursor.getColumnIndexOrThrow(column));
        }
    } catch (Exception ignore) {
        // Google Drive content provider throws an exception that we ignore
        // content://com.google.android.apps.docs.storage
    } finally {
        Helper.closeQuietly(cursor);
    }

    if (isNullOrEmpty(filePath) || !new File(filePath).exists() ||
            imageUri.toString().startsWith("content://com.google.android.gallery3d")) {
        filePath = imageUri.toString();
    }

    return filePath;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:35,代码来源:MediaUtils.java

示例12: applyToSelection

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
@Override
public synchronized void applyToSelection(RTEditText editor, Selection selectedParagraphs, Boolean enable) {
    final Spannable str = editor.getText();

    mSpans2Process.clear();

    for (Paragraph paragraph : editor.getParagraphs()) {
        // find existing BulletSpan and add them to mSpans2Process to be removed
        List<RTSpan<Boolean>> existingSpans = getSpans(str, paragraph, SpanCollectMode.SPAN_FLAGS);
        mSpans2Process.removeSpans(existingSpans, paragraph);

        // if the paragraph is selected then we sure have a bullet
        boolean hasExistingSpans = !existingSpans.isEmpty();
        boolean hasBullet = paragraph.isSelected(selectedParagraphs) ? enable : hasExistingSpans;

        // if we have a bullet then apply a new span
        if (hasBullet) {
            int margin = Helper.getLeadingMarging();
            BulletSpan bulletSpan = new BulletSpan(margin, paragraph.isEmpty(), paragraph.isFirst(), paragraph.isLast());
            mSpans2Process.addSpan(bulletSpan, paragraph);

            // if the paragraph has number spans, then remove them
            Effects.NUMBER.findSpans2Remove(str, paragraph, mSpans2Process);
        }
    }

    // add or remove spans
    mSpans2Process.process(str);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:30,代码来源:BulletEffect.java

示例13: onItemSelected

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
@Override
public void onItemSelected(FontSizeSpinnerItem spinnerItem, int position) {
    int size = spinnerItem.getFontSize();
    mFontSizeAdapter.updateSpinnerTitle(spinnerItem.isEmpty() ? "" : Integer.toString(size));
    size = Helper.convertPxToSp(size);
    mListener.onEffectSelected(Effects.FONTSIZE, size);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:8,代码来源:HorizontalRTToolbar.java

示例14: validate

import com.onegravity.rteditor.utils.Helper; //导入依赖的package包/类
private void validate(DialogInterface dialog, TextView addressView, TextView textView) {
    // retrieve link address and do some cleanup
    final String address = addressView.getText().toString().trim();

    boolean isEmail = sEmailValidator.isValid(address);
    boolean isUrl = sUrlValidator.isValid(address);
    if (requiredFieldValid(addressView) && (isUrl || isEmail)) {
        // valid url or email address

        // encode address
        String newAddress = Helper.encodeUrl(address);

        // add mailto: for email addresses
        if (isEmail && !startsWithMailto(newAddress)) {
            newAddress = "mailto:" + newAddress;
        }

        // use the original address text as link text if the user didn't enter anything
        String linkText = textView.getText().toString();
        if (linkText.length() == 0) {
            linkText = address;
        }

        EventBus.getDefault().post(new LinkEvent(LinkFragment.this, new Link(linkText, newAddress), false));
        try { dialog.dismiss(); } catch (Exception ignore) {}
    } else {
        // invalid address (neither a url nor an email address
        String errorMessage = getString(R.string.rte_invalid_link, address);
        addressView.setError(errorMessage);
    }
}
 
开发者ID:1gravity,项目名称:Android-RTEditor,代码行数:32,代码来源:LinkFragment.java


注:本文中的com.onegravity.rteditor.utils.Helper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。