本文整理汇总了Java中android.provider.Browser.BookmarkColumns类的典型用法代码示例。如果您正苦于以下问题:Java BookmarkColumns类的具体用法?Java BookmarkColumns怎么用?Java BookmarkColumns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BookmarkColumns类属于android.provider.Browser包,在下文中一共展示了BookmarkColumns类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBookmark
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
private long addBookmark(ContentValues values) {
String url = values.getAsString(Browser.BookmarkColumns.URL);
String title = values.getAsString(Browser.BookmarkColumns.TITLE);
boolean isFolder = false;
if (values.containsKey(BOOKMARK_IS_FOLDER_PARAM)) {
isFolder = values.getAsBoolean(BOOKMARK_IS_FOLDER_PARAM);
}
long parentId = INVALID_BOOKMARK_ID;
if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
}
long id = nativeAddBookmark(mNativeChromeBrowserProvider, url, title, isFolder, parentId);
if (id == INVALID_BOOKMARK_ID) return id;
if (isFolder) {
updateLastModifiedBookmarkFolder(id);
} else {
updateLastModifiedBookmarkFolder(parentId);
}
return id;
}
示例2: getString
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
@Override
public String getString(int column) {
switch (column) {
case COLUMN_ID:
return mCursor.getString(mCursor.getColumnIndex(BookmarkColumns._ID));
case COLUMN_SUGGEST_INTENT_ACTION:
return Intent.ACTION_VIEW;
case COLUMN_SUGGEST_INTENT_DATA:
return mCursor.getString(mCursor.getColumnIndex(BookmarkColumns.URL));
case COLUMN_SUGGEST_TEXT_1:
return mCursor.getString(mCursor.getColumnIndex(BookmarkColumns.TITLE));
case COLUMN_SUGGEST_TEXT_2:
case COLUMN_SUGGEST_TEXT_2_URL:
return mCursor.getString(mCursor.getColumnIndex(BookmarkColumns.URL));
case COLUMN_SUGGEST_ICON_1:
// This is the icon displayed to the left of the result in QSB.
return Integer.toString(R.mipmap.app_icon);
case COLUMN_SUGGEST_LAST_ACCESS_HINT:
// After clearing history, the Chrome bookmarks database will have a last
// access time of 0 for all bookmarks. In the Android provider, this will
// yield a negative last access time. A negative last access time will
// cause global search to discard the result, so fix it up before
// we return it.
long lastAccess = mCursor.getLong(
mCursor.getColumnIndex(BookmarkColumns.DATE));
return lastAccess < 0 ? "0" : "" + lastAccess;
default:
throw new UnsupportedOperationException();
}
}
示例3: getLong
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
@Override
public long getLong(int c) {
switch (c) {
case 7:
// See comments above in getString() re. negative last access times.
long lastAccess = mCursor.getLong(
mCursor.getColumnIndex(BookmarkColumns.DATE));
return lastAccess < 0 ? 0 : lastAccess;
default:
throw new UnsupportedOperationException();
}
}
示例4: insert
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
if (!canHandleContentProviderApiCall()) return null;
int match = mUriMatcher.match(uri);
Uri res = null;
long id;
switch (match) {
case URI_MATCH_BOOKMARKS:
id = addBookmark(values);
if (id == INVALID_BOOKMARK_ID) return null;
break;
case URL_MATCH_API_BOOKMARK_CONTENT:
values.put(BookmarkColumns.BOOKMARK, 1);
//$FALL-THROUGH$
case URL_MATCH_API_BOOKMARK:
case URL_MATCH_API_HISTORY_CONTENT:
id = addBookmarkFromAPI(values);
if (id == INVALID_CONTENT_PROVIDER_ID) return null;
break;
case URL_MATCH_API_SEARCHES:
id = addSearchTermFromAPI(values);
if (id == INVALID_CONTENT_PROVIDER_ID) return null;
break;
default:
throw new IllegalArgumentException(TAG + ": insert - unknown URL " + uri);
}
res = ContentUris.withAppendedId(uri, id);
getContext().getContentResolver().notifyChange(res, null);
return res;
}
示例5: buildBookmarkWhereClause
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
/**
* @return a SQL where class which is inserted the bookmark condition.
*/
private static String buildBookmarkWhereClause(String selection, boolean is_bookmark) {
StringBuffer sb = new StringBuffer();
sb.append(BookmarkColumns.BOOKMARK);
sb.append(is_bookmark ? " = 1 " : " = 0");
if (!TextUtils.isEmpty(selection)) {
sb.append(" AND (");
sb.append(selection);
sb.append(")");
}
return sb.toString();
}
示例6: fromContentValues
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
static BookmarkRow fromContentValues(ContentValues values) {
BookmarkRow row = new BookmarkRow();
if (values.containsKey(BookmarkColumns.URL)) {
row.url = values.getAsString(BookmarkColumns.URL);
}
if (values.containsKey(BookmarkColumns.BOOKMARK)) {
row.isBookmark = values.getAsInteger(BookmarkColumns.BOOKMARK) != 0;
}
if (values.containsKey(BookmarkColumns.CREATED)) {
row.created = values.getAsLong(BookmarkColumns.CREATED);
}
if (values.containsKey(BookmarkColumns.DATE)) {
row.date = values.getAsLong(BookmarkColumns.DATE);
}
if (values.containsKey(BookmarkColumns.FAVICON)) {
row.favicon = values.getAsByteArray(BookmarkColumns.FAVICON);
// We need to know that the caller set the favicon column.
if (row.favicon == null) {
row.favicon = new byte[0];
}
}
if (values.containsKey(BookmarkColumns.TITLE)) {
row.title = values.getAsString(BookmarkColumns.TITLE);
}
if (values.containsKey(BookmarkColumns.VISITS)) {
row.visits = values.getAsInteger(BookmarkColumns.VISITS);
}
if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
row.parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
}
return row;
}
示例7: update
import android.provider.Browser.BookmarkColumns; //导入依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
if (!canHandleContentProviderApiCall()) return 0;
// Check for invalid id values if provided.
// If it represents a bookmark node then it's the root node and not mutable.
// Otherwise it represents a SQLite row id, so 0 is invalid.
long bookmarkId = INVALID_CONTENT_PROVIDER_ID;
try {
bookmarkId = ContentUris.parseId(uri);
if (bookmarkId == INVALID_CONTENT_PROVIDER_ID) return 0;
} catch (Exception e) {
}
int match = mUriMatcher.match(uri);
int result;
switch (match) {
case URI_MATCH_BOOKMARKS_ID:
String url = null;
if (values.containsKey(Browser.BookmarkColumns.URL)) {
url = values.getAsString(Browser.BookmarkColumns.URL);
}
String title = values.getAsString(Browser.BookmarkColumns.TITLE);
long parentId = INVALID_BOOKMARK_ID;
if (values.containsKey(BOOKMARK_PARENT_ID_PARAM)) {
parentId = values.getAsLong(BOOKMARK_PARENT_ID_PARAM);
}
result = nativeUpdateBookmark(mNativeChromeBrowserProvider, bookmarkId, url, title,
parentId);
updateLastModifiedBookmarkFolder(parentId);
break;
case URL_MATCH_API_BOOKMARK_ID:
result = updateBookmarkFromAPI(values, buildWhereClause(bookmarkId, selection),
selectionArgs);
break;
case URL_MATCH_API_BOOKMARK:
result = updateBookmarkFromAPI(values, selection, selectionArgs);
break;
case URL_MATCH_API_SEARCHES_ID:
result = updateSearchTermFromAPI(values, buildWhereClause(bookmarkId, selection),
selectionArgs);
break;
case URL_MATCH_API_SEARCHES:
result = updateSearchTermFromAPI(values, selection, selectionArgs);
break;
case URL_MATCH_API_HISTORY_CONTENT:
result = updateBookmarkFromAPI(values, buildHistoryWhereClause(selection),
selectionArgs);
break;
case URL_MATCH_API_HISTORY_CONTENT_ID:
result = updateBookmarkFromAPI(values,
buildHistoryWhereClause(bookmarkId, selection), selectionArgs);
break;
case URL_MATCH_API_BOOKMARK_CONTENT:
result = updateBookmarkFromAPI(values, buildBookmarkWhereClause(selection),
selectionArgs);
break;
case URL_MATCH_API_BOOKMARK_CONTENT_ID:
result = updateBookmarkFromAPI(values,
buildBookmarkWhereClause(bookmarkId, selection), selectionArgs);
break;
default:
throw new IllegalArgumentException(TAG + ": update - unknown URL " + uri);
}
if (result != 0) {
getContext().getContentResolver().notifyChange(uri, null);
}
return result;
}