org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable Java Examples

The following examples show how to use org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownloadManagerUi.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void deleteSelectedItems() {
    List<DownloadHistoryItemWrapper> selectedItems =
            mBackendProvider.getSelectionDelegate().getSelectedItems();
    final List<DownloadHistoryItemWrapper> itemsToDelete = getItemsForDeletion();

    mBackendProvider.getSelectionDelegate().clearSelection();

    if (itemsToDelete.isEmpty()) return;

    mHistoryAdapter.removeItemsFromAdapter(itemsToDelete);

    dismissUndoDeletionSnackbars();

    boolean singleItemDeleted = selectedItems.size() == 1;
    String snackbarText = singleItemDeleted ? selectedItems.get(0).getDisplayFileName() :
            String.format(Locale.getDefault(), "%d", selectedItems.size());
    int snackbarTemplateId = singleItemDeleted ? R.string.undo_bar_delete_message
            : R.string.undo_bar_multiple_downloads_delete_message;

    Snackbar snackbar = Snackbar.make(snackbarText, mUndoDeletionSnackbarController,
            Snackbar.TYPE_ACTION, Snackbar.UMA_DOWNLOAD_DELETE_UNDO);
    snackbar.setAction(mActivity.getString(R.string.undo), itemsToDelete);
    snackbar.setTemplateText(mActivity.getString(snackbarTemplateId));

    ((SnackbarManageable) mActivity).getSnackbarManager().showSnackbar(snackbar);
}
 
Example #2
Source File: BookmarkManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of {@link BookmarkManager}. It also initializes resources,
 * bookmark models and jni bridges.
 * @param activity The activity context to use.
 * @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
 */
public BookmarkManager(Activity activity, boolean isDialogUi) {
    mActivity = activity;
    mIsDialogUi = isDialogUi;

    mBookmarkModel = new BookmarkModel();
    mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);
    mDrawer = (DrawerLayout) mMainView.findViewById(R.id.bookmark_drawer_layout);
    mDrawerListView = (BookmarkDrawerListView) mMainView.findViewById(
            R.id.bookmark_drawer_list);
    mContentView = (BookmarkContentView) mMainView.findViewById(R.id.bookmark_content_view);
    mViewSwitcher = (ViewSwitcher) mMainView.findViewById(R.id.bookmark_view_switcher);
    mUndoController = new BookmarkUndoController(activity, mBookmarkModel,
            ((SnackbarManageable) activity).getSnackbarManager());
    mSearchView = (BookmarkSearchView) getView().findViewById(R.id.bookmark_search_view);
    mBookmarkModel.addObserver(mBookmarkModelObserver);
    initializeToLoadingState();
    mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);

    // Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
    // code, but that might be executed much later. Especially on L, showing loading
    // progress bar blocks that so it won't be loaded. http://crbug.com/429383
    PartnerBookmarksShim.kickOffReading(activity);

    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);
}
 
Example #3
Source File: BookmarkPage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize(Activity activity, NativePageHost host) {
    mManager = new BookmarkManager(
            activity, false, ((SnackbarManageable) activity).getSnackbarManager());
    mManager.setBasicNativePage(this);
    mTitle = activity.getString(R.string.bookmarks);
}
 
Example #4
Source File: BookmarkManager.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public SnackbarManager getSnackbarManager() {
    return ((SnackbarManageable) mActivity).getSnackbarManager();
}
 
Example #5
Source File: BookmarkManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of {@link BookmarkManager}. It also initializes resources,
 * bookmark models and jni bridges.
 * @param activity The activity context to use.
 * @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
 */
public BookmarkManager(Activity activity, boolean isDialogUi) {
    mActivity = activity;
    mIsDialogUi = isDialogUi;

    mSelectionDelegate = new SelectionDelegate<BookmarkId>() {
        @Override
        public boolean toggleSelectionForItem(BookmarkId bookmark) {
            if (!mBookmarkModel.getBookmarkById(bookmark).isEditable()) return false;
            return super.toggleSelectionForItem(bookmark);
        }
    };

    mBookmarkModel = new BookmarkModel();
    mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);
    mDrawer = (DrawerLayout) mMainView.findViewById(R.id.bookmark_drawer_layout);
    mDrawerListView = (BookmarkDrawerListView) mMainView.findViewById(
            R.id.bookmark_drawer_list);
    mContentView = (BookmarkContentView) mMainView.findViewById(R.id.bookmark_content_view);
    mViewSwitcher = (ViewSwitcher) mMainView.findViewById(R.id.bookmark_view_switcher);
    mUndoController = new BookmarkUndoController(activity, mBookmarkModel,
            ((SnackbarManageable) activity).getSnackbarManager());
    mSearchView = (BookmarkSearchView) getView().findViewById(R.id.bookmark_search_view);
    mBookmarkModel.addObserver(mBookmarkModelObserver);
    initializeToLoadingState();
    mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);

    // Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
    // code, but that might be executed much later. Especially on L, showing loading
    // progress bar blocks that so it won't be loaded. http://crbug.com/429383
    PartnerBookmarksShim.kickOffReading(activity);

    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    RecordUserAction.record("MobileBookmarkManagerOpen");
    if (!isDialogUi) {
        RecordUserAction.record("MobileBookmarkManagerPageOpen");
    }
}
 
Example #6
Source File: DownloadManagerUi.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void dismissUndoDeletionSnackbars() {
    ((SnackbarManageable) mActivity).getSnackbarManager().dismissSnackbars(
            mUndoDeletionSnackbarController);
}
 
Example #7
Source File: DownloadManagerUi.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
public SnackbarManager getSnackbarManagerForTesting() {
    return ((SnackbarManageable) mActivity).getSnackbarManager();
}
 
Example #8
Source File: HistoryPage.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize(Activity activity, final NativePageHost host) {
    mHistoryManager = new HistoryManager(
            activity, false, ((SnackbarManageable) activity).getSnackbarManager());
    mTitle = activity.getString(R.string.menu_history);
}