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


Java DownloadFilter类代码示例

本文整理汇总了Java中org.chromium.chrome.browser.download.ui.DownloadFilter的典型用法代码示例。如果您正苦于以下问题:Java DownloadFilter类的具体用法?Java DownloadFilter怎么用?Java DownloadFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getIconResId

import org.chromium.chrome.browser.download.ui.DownloadFilter; //导入依赖的package包/类
/**
 * Return an icon for a given file type.
 * @param fileType Type of the file as returned by DownloadFilter.
 * @param iconSize Size of the returned icon.
 * @return Resource ID of the corresponding icon.
 */
public static int getIconResId(int fileType, @IconSize int iconSize) {
    switch (fileType) {
        case DownloadFilter.FILTER_PAGE:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_site_white_24dp
                                               : R.drawable.ic_drive_site_white_36dp;
        case DownloadFilter.FILTER_VIDEO:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_play_arrow_white_24dp
                                               : R.drawable.ic_play_arrow_white_36dp;
        case DownloadFilter.FILTER_AUDIO:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_music_note_white_24dp
                                               : R.drawable.ic_music_note_white_36dp;
        case DownloadFilter.FILTER_IMAGE:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_image_white_24dp
                                               : R.drawable.ic_image_white_36dp;
        case DownloadFilter.FILTER_DOCUMENT:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_text_white_24dp
                                               : R.drawable.ic_drive_text_white_36dp;
        default:
            return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_file_white_24dp
                                               : R.drawable.ic_drive_text_white_36dp;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:29,代码来源:DownloadUtils.java

示例2: recordShareHistograms

import org.chromium.chrome.browser.download.ui.DownloadFilter; //导入依赖的package包/类
private static void recordShareHistograms(int count, int filterType) {
    RecordHistogram.recordEnumeratedHistogram("Android.DownloadManager.Share.FileTypes",
            filterType, DownloadFilter.FILTER_BOUNDARY);

    RecordHistogram.recordLinearCountHistogram("Android.DownloadManager.Share.Count",
            count, 1, 20, 20);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:DownloadUtils.java

示例3: onFilterChanged

import org.chromium.chrome.browser.download.ui.DownloadFilter; //导入依赖的package包/类
@Override
public void onFilterChanged(int filter) {
    String url = DownloadFilter.getUrlForFilter(filter);
    if (mBackStack.isEmpty() || !mBackStack.peek().equals(url)) {
        mBackStack.push(url);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:DownloadActivity.java

示例4: getMediaViewerIntentForDownloadItem

import org.chromium.chrome.browser.download.ui.DownloadFilter; //导入依赖的package包/类
/**
 * Creates an Intent that allows viewing the given file in an internal media viewer.
 * @param fileUri  URI pointing at the file, ideally in file:// form.
 * @param shareUri URI pointing at the file, ideally in content:// form.
 * @param mimeType MIME type of the file.
 * @return Intent that can be fired to open the file.
 */
public static Intent getMediaViewerIntentForDownloadItem(
        Uri fileUri, Uri shareUri, String mimeType) {
    Context context = ContextUtils.getApplicationContext();
    Intent viewIntent = createViewIntentForDownloadItem(fileUri, mimeType);

    Bitmap closeIcon = BitmapFactory.decodeResource(
            context.getResources(), R.drawable.ic_arrow_back_white_24dp);
    Bitmap shareIcon = BitmapFactory.decodeResource(
            context.getResources(), R.drawable.ic_share_white_24dp);

    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    builder.setToolbarColor(Color.BLACK);
    builder.setCloseButtonIcon(closeIcon);
    builder.setShowTitle(true);

    // Create a PendingIntent that can be used to view the file externally.
    // TODO(dfalcantara): Check if this is problematic in multi-window mode, where two
    //                    different viewers could be visible at the same time.
    Intent chooserIntent = Intent.createChooser(viewIntent, null);
    chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String openWithStr = context.getString(R.string.download_manager_open_with);
    PendingIntent pendingViewIntent = PendingIntent.getActivity(
            context, 0, chooserIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.addMenuItem(openWithStr, pendingViewIntent);

    // Create a PendingIntent that shares the file with external apps.
    PendingIntent pendingShareIntent = PendingIntent.getActivity(
            context, 0, createShareIntent(shareUri, mimeType), 0);
    builder.setActionButton(
            shareIcon, context.getString(R.string.share), pendingShareIntent, true);

    // The color of the media viewer is dependent on the file type.
    int backgroundRes;
    if (DownloadFilter.fromMimeType(mimeType) == DownloadFilter.FILTER_IMAGE) {
        backgroundRes = R.color.image_viewer_bg;
    } else {
        backgroundRes = R.color.media_viewer_bg;
    }
    int mediaColor = ApiCompatibilityUtils.getColor(context.getResources(), backgroundRes);

    // Build up the Intent further.
    Intent intent = builder.build().intent;
    intent.setPackage(context.getPackageName());
    intent.setData(fileUri);
    intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_MEDIA_VIEWER, true);
    intent.putExtra(
            CustomTabIntentDataProvider.EXTRA_INITIAL_BACKGROUND_COLOR, mediaColor);
    intent.putExtra(
            CustomTabsIntent.EXTRA_TOOLBAR_COLOR, mediaColor);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    IntentHandler.addTrustedIntentExtras(intent, context);

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClass(context, CustomTabActivity.class);
    return intent;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:64,代码来源:DownloadUtils.java

示例5: getMediaViewerIntentForDownloadItem

import org.chromium.chrome.browser.download.ui.DownloadFilter; //导入依赖的package包/类
/**
 * Creates an Intent that allows viewing the given file in an internal media viewer.
 * @param fileUri    URI pointing at the file, ideally in file:// form.  Used only when
 *                   the media viewer is trying to locate the file on disk.
 * @param contentUri content:// URI pointing at the file.
 * @param mimeType   MIME type of the file.
 * @return Intent that can be fired to open the file.
 */
public static Intent getMediaViewerIntentForDownloadItem(
        Uri fileUri, Uri contentUri, String mimeType) {
    Context context = ContextUtils.getApplicationContext();
    Intent viewIntent = createViewIntentForDownloadItem(contentUri, mimeType);

    Bitmap closeIcon = BitmapFactory.decodeResource(
            context.getResources(), R.drawable.ic_arrow_back_white_24dp);
    Bitmap shareIcon = BitmapFactory.decodeResource(
            context.getResources(), R.drawable.ic_share_white_24dp);

    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    builder.setToolbarColor(Color.BLACK);
    builder.setCloseButtonIcon(closeIcon);
    builder.setShowTitle(true);

    // Create a PendingIntent that can be used to view the file externally.
    // TODO(dfalcantara): Check if this is problematic in multi-window mode, where two
    //                    different viewers could be visible at the same time.
    Intent chooserIntent = Intent.createChooser(viewIntent, null);
    chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String openWithStr = context.getString(R.string.download_manager_open_with);
    PendingIntent pendingViewIntent = PendingIntent.getActivity(
            context, 0, chooserIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.addMenuItem(openWithStr, pendingViewIntent);

    // Create a PendingIntent that shares the file with external apps.
    PendingIntent pendingShareIntent = PendingIntent.getActivity(
            context, 0, createShareIntent(contentUri, mimeType), 0);
    builder.setActionButton(
            shareIcon, context.getString(R.string.share), pendingShareIntent, true);

    // The color of the media viewer is dependent on the file type.
    int backgroundRes;
    if (DownloadFilter.fromMimeType(mimeType) == DownloadFilter.FILTER_IMAGE) {
        backgroundRes = R.color.image_viewer_bg;
    } else {
        backgroundRes = R.color.media_viewer_bg;
    }
    int mediaColor = ApiCompatibilityUtils.getColor(context.getResources(), backgroundRes);

    // Build up the Intent further.
    Intent intent = builder.build().intent;
    intent.setPackage(context.getPackageName());
    intent.setData(contentUri);
    intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_MEDIA_VIEWER, true);
    intent.putExtra(CustomTabIntentDataProvider.EXTRA_MEDIA_VIEWER_URL, fileUri.toString());
    intent.putExtra(CustomTabIntentDataProvider.EXTRA_ENABLE_EMBEDDED_MEDIA_EXPERIENCE, true);
    intent.putExtra(
            CustomTabIntentDataProvider.EXTRA_INITIAL_BACKGROUND_COLOR, mediaColor);
    intent.putExtra(
            CustomTabsIntent.EXTRA_TOOLBAR_COLOR, mediaColor);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    IntentHandler.addTrustedIntentExtras(intent);

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClass(context, ChromeLauncherActivity.class);
    return intent;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:67,代码来源:DownloadUtils.java


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