android.support.annotation.BinderThread#org.chromium.components.bookmarks.BookmarkId源码实例Demo

下面列出了android.support.annotation.BinderThread#org.chromium.components.bookmarks.BookmarkId 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 365browser   文件: BookmarkFolderSelectActivity.java
private void updateFolderList() {
    List<BookmarkId> folderList = new ArrayList<>();
    List<Integer> depthList = new ArrayList<>();
    mModel.getMoveDestinations(folderList, depthList, mBookmarksToMove);
    List<FolderListEntry> entryList = new ArrayList<>(folderList.size() + 3);

    if (!mIsCreatingFolder) {
        entryList.add(new FolderListEntry(null, 0,
                getString(R.string.bookmark_add_folder), false,
                FolderListEntry.TYPE_NEW_FOLDER));
    }

    for (int i = 0; i < folderList.size(); i++) {
        BookmarkId folder = folderList.get(i);

        if (!mModel.isFolderVisible(folder)) continue;

        String title = mModel.getBookmarkById(folder).getTitle();
        entryList.add(new FolderListEntry(folder, depthList.get(i), title,
                folder.equals(mParentId), FolderListEntry.TYPE_NORMAL));
    }

    mBookmarkIdsAdapter.setEntryList(entryList);
}
 
源代码2 项目: AndroidChromium   文件: BookmarkActionBar.java
@Override
public void onFolderStateSet(BookmarkId folder) {
    mCurrentFolder = mDelegate.getModel().getBookmarkById(folder);

    getMenu().findItem(R.id.search_menu_id).setVisible(true);
    getMenu().findItem(R.id.edit_menu_id).setVisible(mCurrentFolder.isEditable());

    // If the parent folder is a top level node, we don't go up anymore.
    if (mDelegate.getModel().getTopLevelFolderParentIDs().contains(
            mCurrentFolder.getParentId())) {
        if (TextUtils.isEmpty(mCurrentFolder.getTitle())) {
            setTitle(R.string.bookmarks);
        } else {
            setTitle(mCurrentFolder.getTitle());
        }
        setNavigationButton(NAVIGATION_BUTTON_MENU);
    } else {
        setTitle(mCurrentFolder.getTitle());
        setNavigationButton(NAVIGATION_BUTTON_BACK);
    }
}
 
源代码3 项目: AndroidChromium   文件: BookmarkItemsAdapter.java
/**
 * Set folders and bookmarks to show.
 * @param folders This can be null if there is no folders to show.
 */
private void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) {
    if (folders == null) folders = new ArrayList<BookmarkId>();

    mFolderSection.clear();
    mFolderSection.addAll(folders);
    mBookmarkSection.clear();
    mBookmarkSection.addAll(bookmarks);

    updateHeader();
    updateDividerSections();

    // TODO(kkimlabs): Animation is disabled due to a performance issue on bookmark undo.
    //                 http://crbug.com/484174
    notifyDataSetChanged();
}
 
源代码4 项目: 365browser   文件: OfflinePageUtils.java
public static void saveBookmarkOffline(BookmarkId bookmarkId, Tab tab) {
    // If bookmark ID is missing there is nothing to save here.
    if (bookmarkId == null) return;

    // Making sure the feature is enabled.
    if (!OfflinePageBridge.isOfflineBookmarksEnabled()) return;

    // Making sure tab is worth keeping.
    if (shouldSkipSavingTabOffline(tab)) return;

    OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile());
    if (offlinePageBridge == null) return;

    WebContents webContents = tab.getWebContents();
    ClientId clientId = ClientId.createClientIdForBookmarkId(bookmarkId);

    offlinePageBridge.savePage(webContents, clientId, new OfflinePageBridge.SavePageCallback() {
        @Override
        public void onSavePageDone(int savePageResult, String url, long offlineId) {
            // Result of the call is ignored.
        }
    });
}
 
源代码5 项目: AndroidChromium   文件: BookmarkModel.java
/**
 * Delete one or multiple bookmarks from model. If more than one bookmarks are passed here, this
 * method will group these delete operations into one undo bundle so that later if the user
 * clicks undo, all bookmarks deleted here will be restored.
 * @param bookmarks Bookmarks to delete. Note this array should not contain a folder and its
 *                  children, because deleting folder will also remove all its children, and
 *                  deleting children once more will cause errors.
 */
public void deleteBookmarks(BookmarkId... bookmarks) {
    assert bookmarks != null && bookmarks.length > 0;
    // Store all titles of bookmarks.
    String[] titles = new String[bookmarks.length];
    boolean isUndoable = true;
    for (int i = 0; i < bookmarks.length; i++) {
        titles[i] = getBookmarkTitle(bookmarks[i]);
        isUndoable &= (bookmarks[i].getType() == BookmarkType.NORMAL);
    }

    if (bookmarks.length == 1) {
        deleteBookmark(bookmarks[0]);
    } else {
        startGroupingUndos();
        for (BookmarkId bookmark : bookmarks) {
            deleteBookmark(bookmark);
        }
        endGroupingUndos();
    }

    for (BookmarkDeleteObserver observer : mDeleteObservers) {
        observer.onDeleteBookmarks(titles, isUndoable);
    }
}
 
源代码6 项目: 365browser   文件: BookmarkUtils.java
/**
 * Opens a bookmark and reports UMA.
 * @param model Bookmarks model to manage the bookmark.
 * @param activity Activity requesting to open the bookmark.
 * @param bookmarkId ID of the bookmark to be opened.
 * @param launchLocation Location from which the bookmark is being opened.
 * @return Whether the bookmark was successfully opened.
 */
public static boolean openBookmark(BookmarkModel model, Activity activity,
        BookmarkId bookmarkId, int launchLocation) {
    if (model.getBookmarkById(bookmarkId) == null) return false;

    String url = model.getBookmarkById(bookmarkId).getUrl();

    RecordUserAction.record("MobileBookmarkManagerEntryOpened");
    RecordHistogram.recordEnumeratedHistogram(
            "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.COUNT);

    if (DeviceFormFactor.isTablet()) {
        // For tablets, the bookmark manager is open in a tab in the ChromeActivity. Use
        // the ComponentName of the ChromeActivity passed into this method.
        openUrl(activity, url, activity.getComponentName());
    } else {
        // For phones, the bookmark manager is a separate activity. When the activity is
        // launched, an intent extra is set specifying the parent component.
        ComponentName parentComponent = IntentUtils.safeGetParcelableExtra(
                activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
        openUrl(activity, url, parentComponent);
    }

    return true;
}
 
源代码7 项目: 365browser   文件: BookmarkWidgetService.java
@BinderThread
@Override
public long getItemId(int position) {
    Bookmark bookmark = getBookmarkForPosition(position);
    if (bookmark == null) return BookmarkId.INVALID_FOLDER_ID;
    return bookmark.id.getId();
}
 
源代码8 项目: delion   文件: BookmarkBridge.java
private DelayedBookmarkCallback(BookmarkId folderId, BookmarksCallback callback,
        int method, BookmarkBridge handler) {
    mFolderId = folderId;
    mCallback = callback;
    mCallbackMethod = method;
    mHandler = handler;
}
 
源代码9 项目: delion   文件: BookmarkDrawerListViewAdapter.java
/**
 * Sets folders to show.
 */
void setTopFolders(List<BookmarkId> folders) {
    mMiddleSection.clear();

    if (folders.size() > 0) {
        // Add a divider and title to the top of the section.
        mMiddleSection.add(new Item(TYPE_DIVIDER));
        mMiddleSection.add(new Item(TYPE_FOLDERS_TITLE));
    }

    // Add the rest of the items.
    for (BookmarkId id : folders) {
        mMiddleSection.add(new Item(id));
    }
}
 
源代码10 项目: delion   文件: BookmarkEditActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mModel = new BookmarkModel();
    mBookmarkId = BookmarkId.getBookmarkIdFromString(
            getIntent().getStringExtra(INTENT_BOOKMARK_ID));
    mModel.addObserver(mBookmarkModelObserver);
    BookmarkItem item = mModel.getBookmarkById(mBookmarkId);
    if (!mModel.doesBookmarkExist(mBookmarkId) || item == null) {
        finish();
        return;
    }

    setContentView(R.layout.bookmark_edit);
    mTitleEditText = (EmptyAlertEditText) findViewById(R.id.title_text);
    mFolderTextView = (TextView) findViewById(R.id.folder_text);
    mUrlEditText = (EmptyAlertEditText) findViewById(R.id.url_text);

    mFolderTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BookmarkFolderSelectActivity.startFolderSelectActivity(
                    BookmarkEditActivity.this, mBookmarkId);
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    updateViewContent(false);
}
 
源代码11 项目: AndroidChromium   文件: BookmarkUIState.java
static Uri createFolderUrl(BookmarkId folderId) {
    Uri.Builder builder = Uri.parse(UrlConstants.BOOKMARKS_FOLDER_URL).buildUpon();
    // Encodes the path and appends it to the base url. A simple appending
    // does not work because there might be spaces in suffix.
    builder.appendPath(folderId.toString());
    return builder.build();
}
 
源代码12 项目: 365browser   文件: BookmarkFolderSelectActivity.java
public FolderListEntry(BookmarkId bookmarkId, int depth, String title, boolean isSelected,
        int type) {
    assert type == TYPE_NEW_FOLDER || type == TYPE_NORMAL;
    mDepth = depth;
    mId = bookmarkId;
    mTitle = title;
    mIsSelected = isSelected;
    mType = type;
}
 
源代码13 项目: 365browser   文件: BookmarkBridge.java
private DelayedBookmarkCallback(BookmarkId folderId, BookmarksCallback callback,
        int method, BookmarkBridge handler) {
    mFolderId = folderId;
    mCallback = callback;
    mCallbackMethod = method;
    mHandler = handler;
}
 
源代码14 项目: 365browser   文件: BookmarkBridge.java
/**
 * @return The top level folder's parents.
 */
public List<BookmarkId> getTopLevelFolderParentIDs() {
    assert mIsNativeBookmarkModelLoaded;
    List<BookmarkId> result = new ArrayList<BookmarkId>();
    nativeGetTopLevelFolderParentIDs(mNativeBookmarkBridge, result);
    return result;
}
 
源代码15 项目: delion   文件: BookmarkAddEditFolderActivity.java
/**
 * Starts an add folder activity. This method should only be called by
 * {@link BookmarkFolderSelectActivity}.
 */
public static void startAddFolderActivity(BookmarkFolderSelectActivity activity,
        List<BookmarkId> bookmarksToMove) {
    assert bookmarksToMove.size() > 0;
    Intent intent = new Intent(activity, BookmarkAddEditFolderActivity.class);
    intent.putExtra(INTENT_IS_ADD_MODE, true);
    ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarksToMove.size());
    for (BookmarkId id : bookmarksToMove) {
        bookmarkStrings.add(id.toString());
    }
    intent.putStringArrayListExtra(
            BookmarkFolderSelectActivity.INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings);
    activity.startActivityForResult(intent,
            BookmarkFolderSelectActivity.CREATE_FOLDER_REQUEST_CODE);
}
 
源代码16 项目: delion   文件: BookmarkAddEditFolderActivity.java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    assert mIsAddMode;
    if (requestCode == PARENT_FOLDER_REQUEST_CODE && resultCode == RESULT_OK) {
        BookmarkId selectedBookmark = BookmarkId.getBookmarkIdFromString(data.getStringExtra(
                BookmarkFolderSelectActivity.INTENT_SELECTED_FOLDER));
        updateParent(selectedBookmark);
    }
}
 
源代码17 项目: AndroidChromium   文件: BookmarkBridge.java
private BookmarkItem(BookmarkId id, String title, String url, boolean isFolder,
        BookmarkId parentId, boolean isEditable, boolean isManaged) {
    mId = id;
    mTitle = title;
    mUrl = url;
    mIsFolder = isFolder;
    mParentId = parentId;
    mIsEditable = isEditable;
    mIsManaged = isManaged;
}
 
源代码18 项目: delion   文件: BookmarkFolderSelectActivity.java
public FolderListEntry(BookmarkId bookmarkId, int depth, String title, boolean isSelected,
        int type) {
    assert type == TYPE_NEW_FOLDER || type == TYPE_NORMAL;
    mDepth = depth;
    mId = bookmarkId;
    mTitle = title;
    mIsSelected = isSelected;
    mType = type;
}
 
源代码19 项目: delion   文件: BookmarkUtils.java
/**
 * @return The parent {@link BookmarkId} that the user used the last time or null if the user
 *         has never selected a parent folder to use.
 */
static BookmarkId getLastUsedParent(Context context) {
    SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
    if (!preferences.contains(PREF_LAST_USED_PARENT)) return null;

    return BookmarkId.getBookmarkIdFromString(
            preferences.getString(PREF_LAST_USED_PARENT, null));
}
 
源代码20 项目: 365browser   文件: BookmarkFolderSelectActivity.java
/**
 * Starts a select folder activity for the new folder that is about to be created. This method
 * is only supposed to be called by {@link BookmarkAddEditFolderActivity}
 */
public static void startNewFolderSelectActivity(
        BookmarkAddEditFolderActivity activity, List<BookmarkId> bookmarks) {
    assert bookmarks.size() > 0;
    Intent intent = new Intent(activity, BookmarkFolderSelectActivity.class);
    intent.putExtra(INTENT_IS_CREATING_FOLDER, true);
    ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.size());
    for (BookmarkId id : bookmarks) {
        bookmarkStrings.add(id.toString());
    }
    intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings);
    activity.startActivityForResult(intent,
            BookmarkAddEditFolderActivity.PARENT_FOLDER_REQUEST_CODE);
}
 
源代码21 项目: delion   文件: BookmarkBridge.java
/**
 * Fetches the bookmarks of the current folder. Callback will be
 * synchronous if the bookmark model is already loaded and async if it is loaded in the
 * background.
 * @param folderId The current folder id.
 * @param callback Instance of a callback object.
 */
public void getBookmarksForFolder(BookmarkId folderId, BookmarksCallback callback) {
    if (mIsNativeBookmarkModelLoaded) {
        nativeGetBookmarksForFolder(mNativeBookmarkBridge, folderId, callback,
                new ArrayList<BookmarkItem>());
    } else {
        mDelayedBookmarkCallbacks.add(new DelayedBookmarkCallback(folderId, callback,
                DelayedBookmarkCallback.GET_BOOKMARKS_FOR_FOLDER, this));
    }
}
 
源代码22 项目: delion   文件: BookmarkActionBar.java
private static void openBookmarksInNewTabs(
        List<BookmarkId> bookmarks, TabDelegate tabDelegate, BookmarkModel model) {
    for (BookmarkId id : bookmarks) {
        tabDelegate.createNewTab(new LoadUrlParams(model.getBookmarkById(id).getUrl()),
                TabLaunchType.FROM_LONGPRESS_BACKGROUND, null);
    }
}
 
源代码23 项目: 365browser   文件: BookmarkItemsAdapter.java
/**
 * Set folders and bookmarks to show.
 * @param folders This can be null if there is no folders to show.
 */
private void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) {
    if (folders == null) folders = new ArrayList<BookmarkId>();

    mFolderSection.clear();
    mFolderSection.addAll(folders);
    mBookmarkSection.clear();
    mBookmarkSection.addAll(bookmarks);

    updateHeaderAndNotify();
}
 
源代码24 项目: delion   文件: BookmarkManager.java
@Override
public void clearSelection() {
    mSelectedBookmarks.clear();
    for (BookmarkUIObserver observer : mUIObservers) {
        observer.onSelectionStateChange(new ArrayList<BookmarkId>(mSelectedBookmarks));
    }
}
 
源代码25 项目: AndroidChromium   文件: BookmarkBridge.java
@CalledByNative
private static void addToBookmarkMatchList(List<BookmarkMatch> bookmarkMatchList,
        long id, int type, int[] titleMatchStartPositions,
        int[] titleMatchEndPositions, int[] urlMatchStartPositions,
        int[] urlMatchEndPositions) {
    bookmarkMatchList.add(new BookmarkMatch(new BookmarkId(id, type),
            createPairsList(titleMatchStartPositions, titleMatchEndPositions),
            createPairsList(urlMatchStartPositions, urlMatchEndPositions)));
}
 
/**
 * Starts a select folder activity.
 */
public static void startFolderSelectActivity(Context context, BookmarkId... bookmarks) {
    assert bookmarks.length > 0;
    Intent intent = new Intent(context, BookmarkFolderSelectActivity.class);
    intent.putExtra(INTENT_IS_CREATING_FOLDER, false);
    ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.length);
    for (BookmarkId id : bookmarks) {
        bookmarkStrings.add(id.toString());
    }
    intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings);
    context.startActivity(intent);
}
 
/**
 * Sets folders to show.
 */
void setTopFolders(List<BookmarkId> folders) {
    mBottomSection.clear();

    if (folders.size() > 0) {
        // Add a divider and title to the top of the section.
        mBottomSection.add(new Item(TYPE_DIVIDER));
        mBottomSection.add(new Item(TYPE_FOLDERS_TITLE));
    }

    // Add the rest of the items.
    for (BookmarkId id : folders) {
        mBottomSection.add(new Item(id));
    }
}
 
源代码28 项目: 365browser   文件: BookmarkUtils.java
/** Starts an {@link BookmarkEditActivity} for the given {@link BookmarkId}. */
public static void startEditActivity(Context context, BookmarkId bookmarkId) {
    Intent intent = new Intent(context, BookmarkEditActivity.class);
    intent.putExtra(BookmarkEditActivity.INTENT_BOOKMARK_ID, bookmarkId.toString());
    if (context instanceof BookmarkActivity) {
        ((BookmarkActivity) context).startActivityForResult(
                intent, BookmarkActivity.EDIT_BOOKMARK_REQUEST_CODE);
    } else {
        context.startActivity(intent);
    }
}
 
源代码29 项目: delion   文件: BookmarkBridge.java
/**
 * Fetches the folder hierarchy of the given folder. Callback will be
 * synchronous if the bookmark model is already loaded and async if it is loaded in the
 * background.
 * @param folderId The current folder id.
 * @param callback Instance of a callback object.
 */
public void getCurrentFolderHierarchy(BookmarkId folderId, BookmarksCallback callback) {
    if (mIsNativeBookmarkModelLoaded) {
        nativeGetCurrentFolderHierarchy(mNativeBookmarkBridge, folderId, callback,
                new ArrayList<BookmarkItem>());
    } else {
        mDelayedBookmarkCallbacks.add(new DelayedBookmarkCallback(folderId, callback,
                DelayedBookmarkCallback.GET_CURRENT_FOLDER_HIERARCHY, this));
    }
}
 
/**
 * Starts a select folder activity for the new folder that is about to be created. This method
 * is only supposed to be called by {@link BookmarkAddEditFolderActivity}
 */
public static void startNewFolderSelectActivity(
        BookmarkAddEditFolderActivity activity, List<BookmarkId> bookmarks) {
    assert bookmarks.size() > 0;
    Intent intent = new Intent(activity, BookmarkFolderSelectActivity.class);
    intent.putExtra(INTENT_IS_CREATING_FOLDER, true);
    ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.size());
    for (BookmarkId id : bookmarks) {
        bookmarkStrings.add(id.toString());
    }
    intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings);
    activity.startActivityForResult(intent,
            BookmarkAddEditFolderActivity.PARENT_FOLDER_REQUEST_CODE);
}