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


Java Editable.getChars方法代码示例

本文整理汇总了Java中android.text.Editable.getChars方法的典型用法代码示例。如果您正苦于以下问题:Java Editable.getChars方法的具体用法?Java Editable.getChars怎么用?Java Editable.getChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.Editable的用法示例。


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

示例1: fromUser

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Creates a SafeHelperFactory from an Editable, such as what you get by
 * calling getText() on an EditText.
 *
 * The Editable will be cleared as part of this call.
 *
 * @param editor the user's supplied passphrase
 * @return a SafeHelperFactory
 */
public static SafeHelperFactory fromUser(Editable editor) {
  char[] passphrase=new char[editor.length()];
  SafeHelperFactory result;

  editor.getChars(0, editor.length(), passphrase, 0);

  try {
    result=new SafeHelperFactory(passphrase);
  }
  finally {
    editor.clear();
  }

  return(result);
}
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:25,代码来源:SafeHelperFactory.java

示例2: rekey

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Changes the passphrase associated with this database. The supplied
 * Editable is cleared as part of this operation.
 *
 * @param editor source of passphrase, presumably from a user
 */
public void rekey(Editable editor) {
  char[] passphrase=new char[editor.length()];

  editor.getChars(0, editor.length(), passphrase, 0);

  try {
    rekey(passphrase);
  }
  finally {
    editor.clear();
  }
}
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:19,代码来源:Database.java

示例3: getCharArray

import android.text.Editable; //导入方法依赖的package包/类
final char[] getCharArray(boolean clear) {
    Editable editable = super.getText();
    char[] chars = new char[editable.length()];
    editable.getChars(0, chars.length, chars, 0);
    if (clear) editable.clear();
    return chars;
}
 
开发者ID:tresorit,项目名称:ZeroKit-Android-SDK,代码行数:8,代码来源:PasswordEditText.java

示例4: commitText

import android.text.Editable; //导入方法依赖的package包/类
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
    Editable currentText = getText();
    if (currentText == null) return super.commitText(text, newCursorPosition);

    int selectionStart = Selection.getSelectionStart(currentText);
    int selectionEnd = Selection.getSelectionEnd(currentText);
    int autocompleteIndex = currentText.getSpanStart(mAutocompleteSpan);
    // If the text being committed is a single character that matches the next character
    // in the selection (assumed to be the autocomplete text), we only move the text
    // selection instead clearing the autocomplete text causing flickering as the
    // autocomplete text will appear once the next suggestions are received.
    //
    // To be confident that the selection is an autocomplete, we ensure the selection
    // is at least one character and the end of the selection is the end of the
    // currently entered text.
    if (newCursorPosition == 1 && selectionStart > 0 && selectionStart != selectionEnd
            && selectionEnd >= currentText.length()
            && autocompleteIndex == selectionStart
            && text.length() == 1) {
        currentText.getChars(selectionStart, selectionStart + 1, mTempSelectionChar, 0);
        if (mTempSelectionChar[0] == text.charAt(0)) {

            // Since the text isn't changing, TalkBack won't read out the typed characters.
            // To work around this, explicitly send an accessibility event. crbug.com/416595
            if (mAccessibilityManager != null && mAccessibilityManager.isEnabled()) {
                AccessibilityEvent event = AccessibilityEvent.obtain(
                        AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
                event.setFromIndex(selectionStart);
                event.setRemovedCount(0);
                event.setAddedCount(1);
                event.setBeforeText(currentText.toString().substring(0, selectionStart));
                sendAccessibilityEventUnchecked(event);
            }

            setAutocompleteText(
                    currentText.subSequence(0, selectionStart + 1),
                    currentText.subSequence(selectionStart + 1, selectionEnd));
            if (!mInBatchEditMode) {
                notifyAutocompleteTextStateChanged(false);
            }
            return true;
        }
    }

    boolean retVal = super.commitText(text, newCursorPosition);

    // Ensure the autocomplete span is removed if it is no longer valid after committing the
    // text.
    if (getText().getSpanStart(mAutocompleteSpan) >= 0) clearAutocompleteSpanIfInvalid();

    return retVal;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:UrlBar.java

示例5: encrypt

import android.text.Editable; //导入方法依赖的package包/类
/**
 * Replaces this database with a version encrypted with the supplied
 * passphrase, deleting the original. Do not call this while the database
 * is open, which includes during any Room migrations.
 *
 * The passphrase is untouched in this call. If you are going to turn around
 * and use it with SafeHelperFactory.fromUser(), fromUser() will clear the
 * passphrase. If not, please set all bytes of the passphrase to 0 or something
 * to clear out the passphrase.
 *
 * @param ctxt a Context
 * @param dbName the name of the database, as used with Room, SQLiteOpenHelper,
 *               etc.
 * @param editor the passphrase, such as obtained by calling getText() on an
 *               EditText
 * @throws IOException
 */
public static void encrypt(Context ctxt, String dbName, Editable editor)
  throws IOException {
  char[] passphrase=new char[editor.length()];

  editor.getChars(0, editor.length(), passphrase, 0);
  encrypt(ctxt, dbName, passphrase);
}
 
开发者ID:commonsguy,项目名称:cwac-saferoom,代码行数:25,代码来源:SQLCipherUtils.java


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