本文整理汇总了Java中android.provider.UserDictionary类的典型用法代码示例。如果您正苦于以下问题:Java UserDictionary类的具体用法?Java UserDictionary怎么用?Java UserDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserDictionary类属于android.provider包,在下文中一共展示了UserDictionary类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: hasWord
import android.provider.UserDictionary; //导入依赖的package包/类
private boolean hasWord(final String word, final Context context) {
final Cursor cursor;
// mLocale == "" indicates this is an entry for all languages. Here, mLocale can't
// be null at all (it's ensured by the updateLocale method).
if ("".equals(mLocale)) {
cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ALL_LOCALES,
new String[] { word }, null /* sort order */);
} else {
cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
HAS_WORD_PROJECTION, HAS_WORD_SELECTION_ONE_LOCALE,
new String[] { word, mLocale }, null /* sort order */);
}
try {
if (null == cursor) return false;
return cursor.getCount() > 0;
} finally {
if (null != cursor) cursor.close();
}
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:21,代码来源:UserDictionaryAddWordContents.java
示例2: createCursor
import android.provider.UserDictionary; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private Cursor createCursor(final String locale) {
// Locale can be any of:
// - The string representation of a locale, as returned by Locale#toString()
// - The empty string. This means we want a cursor returning words valid for all locales.
// - null. This means we want a cursor for the current locale, whatever this is.
// Note that this contrasts with the data inside the database, where NULL means "all
// locales" and there should never be an empty string. The confusion is called by the
// historical use of null for "all locales".
// TODO: it should be easy to make this more readable by making the special values
// human-readable, like "all_locales" and "current_locales" strings, provided they
// can be guaranteed not to match locales that may exist.
if ("".equals(locale)) {
// Case-insensitive sort
return getActivity().managedQuery(UserDictionary.Words.CONTENT_URI, QUERY_PROJECTION,
QUERY_SELECTION_ALL_LOCALES, null,
"UPPER(" + UserDictionary.Words.WORD + ")");
}
final String queryLocale = null != locale ? locale : Locale.getDefault().toString();
return getActivity().managedQuery(UserDictionary.Words.CONTENT_URI, QUERY_PROJECTION,
QUERY_SELECTION, new String[] { queryLocale },
"UPPER(" + UserDictionary.Words.WORD + ")");
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:UserDictionarySettings.java
示例3: open
import android.provider.UserDictionary; //导入依赖的package包/类
public void open() {
Log.i(mTag, "open()");
// Schedule the initial load to run immediately. It's possible that the first call to
// isValidWord occurs before the dictionary has actually loaded, so it should not
// assume that the dictionary has been loaded.
loadPersonalDictionary();
// Register the observer to be notified on changes to the personal dictionary and all
// individual items.
//
// If the user is interacting with the Personal Dictionary settings UI, or with the
// "Add to dictionary" drop-down option, duplicate notifications will be sent for the same
// edit: if a new entry is added, there is a notification for the entry itself, and
// separately for the entire dictionary. However, when used programmatically,
// only notifications for the specific edits are sent. Thus, the observer is registered to
// receive every possible notification, and instead has throttling logic to avoid doing too
// many reloads.
mResolver.registerContentObserver(
UserDictionary.Words.CONTENT_URI,
true /* notifyForDescendents */,
mPersonalDictionaryContentObserver);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:24,代码来源:PersonalDictionaryLookup.java
示例4: onCreate
import android.provider.UserDictionary; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView dictListView = (ListView) findViewById(R.id.dictionary_list_view);
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(UserDictionary.Words.CONTENT_URI, null, null, null, null);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.listview_layout, cursor, COLUMNS_TO_BE_FOUND, LAYOUT_ITEMS_TO_FILL, 0);
dictListView.setAdapter(adapter);
registerForContextMenu(dictListView);
}
开发者ID:SuperHaker,项目名称:Fictionary,代码行数:12,代码来源:MainActivity.java
示例5: createCursor
import android.provider.UserDictionary; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private Cursor createCursor(final String locale) {
// Locale can be any of:
// - The string representation of a locale, as returned by Locale#toString()
// - The empty string. This means we want a cursor returning words valid for all locales.
// - null. This means we want a cursor for the current locale, whatever this is.
// Note that this contrasts with the data inside the database, where NULL means "all
// locales" and there should never be an empty string. The confusion is called by the
// historical use of null for "all locales".
// TODO: it should be easy to make this more readable by making the special values
// human-readable, like "all_locales" and "current_locales" strings, provided they
// can be guaranteed not to match locales that may exist.
if ("".equals(locale)) {
// Case-insensitive sort
return getActivity().managedQuery(UserDictionary.Words.CONTENT_URI, QUERY_PROJECTION,
QUERY_SELECTION_ALL_LOCALES, null,
"UPPER(" + UserDictionary.Words.WORD + ")");
} else {
final String queryLocale = null != locale ? locale : Locale.getDefault().toString();
return getActivity().managedQuery(UserDictionary.Words.CONTENT_URI, QUERY_PROJECTION,
QUERY_SELECTION, new String[] { queryLocale },
"UPPER(" + UserDictionary.Words.WORD + ")");
}
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:25,代码来源:UserDictionarySettings.java
示例6: getWord
import android.provider.UserDictionary; //导入依赖的package包/类
private String getWord(final int position) {
if (null == mCursor) return null;
mCursor.moveToPosition(position);
// Handle a possible race-condition
if (mCursor.isAfterLast()) return null;
return mCursor.getString(
mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD));
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:10,代码来源:UserDictionarySettings.java
示例7: getShortcut
import android.provider.UserDictionary; //导入依赖的package包/类
private String getShortcut(final int position) {
if (!IS_SHORTCUT_API_SUPPORTED) return null;
if (null == mCursor) return null;
mCursor.moveToPosition(position);
// Handle a possible race-condition
if (mCursor.isAfterLast()) return null;
return mCursor.getString(
mCursor.getColumnIndexOrThrow(UserDictionary.Words.SHORTCUT));
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:11,代码来源:UserDictionarySettings.java
示例8: deleteWord
import android.provider.UserDictionary; //导入依赖的package包/类
public static void deleteWord(final String word, final String shortcut,
final ContentResolver resolver) {
if (!IS_SHORTCUT_API_SUPPORTED) {
resolver.delete(UserDictionary.Words.CONTENT_URI, DELETE_SELECTION_SHORTCUT_UNSUPPORTED,
new String[] { word });
} else if (TextUtils.isEmpty(shortcut)) {
resolver.delete(
UserDictionary.Words.CONTENT_URI, DELETE_SELECTION_WITHOUT_SHORTCUT,
new String[] { word });
} else {
resolver.delete(
UserDictionary.Words.CONTENT_URI, DELETE_SELECTION_WITH_SHORTCUT,
new String[] { word, shortcut });
}
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:16,代码来源:UserDictionarySettings.java
示例9: MyAdapter
import android.provider.UserDictionary; //导入依赖的package包/类
public MyAdapter(final Context context, final int layout, final Cursor c,
final String[] from, final int[] to) {
super(context, layout, c, from, to, 0 /* flags */);
if (null != c) {
final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
}
setViewBinder(mViewBinder);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:12,代码来源:UserDictionarySettings.java
示例10: addWord
import android.provider.UserDictionary; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void addWord(final Context context, final String word,
final int freq, final String shortcut, final Locale locale) {
if (BuildCompatUtils.EFFECTIVE_SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
addWordWithShortcut(context, word, freq, shortcut, locale);
return;
}
// Fall back to the pre-JellyBean method.
final Locale currentLocale = context.getResources().getConfiguration().locale;
final int localeType = currentLocale.equals(locale)
? UserDictionary.Words.LOCALE_TYPE_CURRENT : UserDictionary.Words.LOCALE_TYPE_ALL;
UserDictionary.Words.addWord(context, word, freq, localeType);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:14,代码来源:UserDictionaryCompatUtils.java
示例11: getUserDictionaryLocalesSet
import android.provider.UserDictionary; //导入依赖的package包/类
public static TreeSet<String> getUserDictionaryLocalesSet(Activity activity) {
@SuppressWarnings("deprecation")
final Cursor cursor = activity.managedQuery(UserDictionary.Words.CONTENT_URI,
new String[] { UserDictionary.Words.LOCALE },
null, null, null);
final TreeSet<String> localeList = new TreeSet<String>();
boolean addedAllLocale = false;
if (null == cursor) {
// The user dictionary service is not present or disabled. Return null.
return null;
} else if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
final String locale = cursor.getString(columnIndex);
final boolean allLocale = TextUtils.isEmpty(locale);
localeList.add(allLocale ? "" : locale);
if (allLocale) {
addedAllLocale = true;
}
} while (cursor.moveToNext());
}
if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED && !addedAllLocale) {
// For ICS, we need to show "For all languages" in case that the keyboard locale
// is different from the system locale
localeList.add("");
}
localeList.add(Locale.getDefault().toString());
return localeList;
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:30,代码来源:UserDictionaryList.java
示例12: MyAdapter
import android.provider.UserDictionary; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to,
UserDictionarySettings settings) {
super(context, layout, c, from, to);
if (null != c) {
final String alphabet = context.getString(R.string.user_dict_fast_scroll_alphabet);
final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
}
setViewBinder(mViewBinder);
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:13,代码来源:UserDictionarySettings.java
示例13: addWordWithShortcut
import android.provider.UserDictionary; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private static void addWordWithShortcut(final Context context, final String word,
final int freq, final String shortcut, final Locale locale) {
UserDictionary.Words.addWord(context, word, freq, shortcut, locale);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:6,代码来源:UserDictionaryCompatUtils.java
注:本文中的android.provider.UserDictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论