• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ApiCompatibilityUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:RecentTabsGroupView.java


示例2: onMeasure

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    if (width >= 2 * mIllustration.getWidth() && width > height) {
        mPromoContent.setOrientation(LinearLayout.HORIZONTAL);
        setMaxChildWidth(mMaxChildWidthHorizontal);
        ApiCompatibilityUtils.setPaddingRelative(
                mIllustration, 0, 0, mIllustrationPaddingSide, 0);
    } else {
        mPromoContent.setOrientation(LinearLayout.VERTICAL);
        setMaxChildWidth(mMaxChildWidth);
        mIllustration.setPadding(0, 0, 0, mIllustrationPaddingBottom);
    }

    setMaxChildHeight(height - mFrameHeightMargin);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:DataReductionPromoView.java


示例3: updateSyncSummaryAndIcon

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Updates the summary and icon for this preference to reflect the current state of syncing.
 */
public void updateSyncSummaryAndIcon() {
    setSummary(getSyncStatusSummary(getContext()));

    if (SyncPreference.showSyncErrorIcon(getContext())) {
        setIcon(ApiCompatibilityUtils.getDrawable(
                getContext().getResources(), R.drawable.sync_error));
    } else {
        // Sets preference icon and tints it to blue.
        Drawable icon = ApiCompatibilityUtils.getDrawable(
                getContext().getResources(), R.drawable.permission_background_sync);
        icon.setColorFilter(ApiCompatibilityUtils.getColor(
                                    getContext().getResources(), R.color.light_active_color),
                PorterDuff.Mode.SRC_IN);
        setIcon(icon);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:SyncPreference.java


示例4: createButtonForLayout

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Creates a standardized Button that can be used for DualControlLayouts showing buttons.
 *
 * @param isPrimary Whether or not the button is meant to act as a "Confirm" button.
 * @param text      Text to display on the button.
 * @param listener  Listener to alert when the button has been clicked.
 * @return Button that can be used in the view.
 */
public static Button createButtonForLayout(
        Context context, boolean isPrimary, String text, OnClickListener listener) {
    int lightActiveColor =
            ApiCompatibilityUtils.getColor(context.getResources(), R.color.light_active_color);

    if (isPrimary) {
        ButtonCompat primaryButton = new ButtonCompat(context, lightActiveColor, false);
        primaryButton.setId(R.id.button_primary);
        primaryButton.setOnClickListener(listener);
        primaryButton.setText(text);
        primaryButton.setTextColor(Color.WHITE);
        return primaryButton;
    } else {
        Button secondaryButton = ButtonCompat.createBorderlessButton(context);
        secondaryButton.setId(R.id.button_secondary);
        secondaryButton.setOnClickListener(listener);
        secondaryButton.setText(text);
        secondaryButton.setTextColor(lightActiveColor);
        return secondaryButton;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:30,代码来源:DualControlLayout.java


示例5: initialize

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Initializes the view with the correct strings.
 *
 * @param title   Title of the webpage.
 * @param origin  Origin of the webpage.
 */
public void initialize(String title, String origin) {
    ((TextView) findViewById(R.id.page_title)).setText(title);
    ((TextView) findViewById(R.id.hostname)).setText(origin);

    // Remove the close button, then expand the page information to take up the space formerly
    // occupied by the X.
    View toRemove = findViewById(R.id.close_button);
    ((ViewGroup) toRemove.getParent()).removeView(toRemove);

    int titleEndMargin = getContext().getResources().getDimensionPixelSize(
            R.dimen.payments_section_large_spacing);
    View pageInfoGroup = findViewById(R.id.page_info);
    ApiCompatibilityUtils.setMarginEnd(
            (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMargin);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:PaymentRequestUiErrorView.java


示例6: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    LayoutInflater.from(getContext()).inflate(R.layout.selectable_list_layout, this);

    mEmptyView = (TextView) findViewById(R.id.empty_view);
    mLoadingView = (LoadingView) findViewById(R.id.loading_view);
    mLoadingView.showLoadingUI();

    mToolbarStub = (ViewStub) findViewById(R.id.action_bar_stub);

    FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow);
    if (DeviceFormFactor.isLargeTablet(getContext())) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.init(ApiCompatibilityUtils.getColor(getResources(),
                R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:SelectableListLayout.java


示例7: setUpIcons

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Sets compound drawables (icons) for different kinds of list entries,
 * i.e. New Folder, Normal and Selected.
 */
private void setUpIcons(FolderListEntry entry, TextView textView) {
    int iconId = 0;
    if (entry.mType == FolderListEntry.TYPE_NORMAL) {
        iconId = R.drawable.bookmark_folder;
    } else if (entry.mType == FolderListEntry.TYPE_NEW_FOLDER) {
        // For new folder, start_icon is different.
        iconId = R.drawable.bookmark_add_folder;
    }

    Drawable drawableStart = TintedDrawable.constructTintedDrawable(textView.getResources(),
            iconId);
    // Selected entry has an end_icon, a blue check mark.
    Drawable drawableEnd = entry.mIsSelected ? ApiCompatibilityUtils.getDrawable(
            textView.getResources(), R.drawable.ic_check_googblue_24dp) : null;
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            drawableStart, null, drawableEnd, null);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:BookmarkFolderSelectActivity.java


示例8: onFinishInflate

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mItemsContainer = (BookmarkRecyclerView) findViewById(R.id.bookmark_items_container);
    TextView emptyView = (TextView) findViewById(R.id.bookmark_empty_view);
    emptyView.setText(R.string.bookmarks_folder_empty);
    mItemsContainer.setEmptyView(emptyView);
    mActionBar = (BookmarkActionBar) findViewById(R.id.bookmark_action_bar);
    mLoadingView = (LoadingView) findViewById(R.id.bookmark_initial_loading_view);
    FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow);
    if (DeviceFormFactor.isLargeTablet(getContext())) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.init(ApiCompatibilityUtils.getColor(getResources(),
                R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:BookmarkContentView.java


示例9: AddExceptionPreference

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Construct a AddException preference.
 * @param context The current context.
 * @param key The key to use for the preference.
 * @param message The custom message to show in the dialog.
 * @param callback A callback to receive notifications that an exception has been added.
 */
public AddExceptionPreference(
        Context context, String key, String message, SiteAddedCallback callback) {
    super(context);
    mDialogMessage = message;
    mSiteAddedCallback = callback;
    setOnPreferenceClickListener(this);

    setKey(key);
    Resources resources = getContext().getResources();
    mPrefAccentColor = ApiCompatibilityUtils.getColor(resources, R.color.pref_accent_color);

    Drawable plusIcon = ApiCompatibilityUtils.getDrawable(resources, R.drawable.plus);
    plusIcon.mutate();
    plusIcon.setColorFilter(mPrefAccentColor, PorterDuff.Mode.SRC_IN);
    setIcon(plusIcon);

    setTitle(resources.getString(R.string.website_settings_add_site));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:AddExceptionPreference.java


示例10: getShareIntent

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@VisibleForTesting
public static Intent getShareIntent(Activity activity, String title, String text, String url,
        Uri offlineUri, Uri screenshotUri) {
    if (!TextUtils.isEmpty(url)) {
        url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
        if (!TextUtils.isEmpty(text)) {
            // Concatenate text and URL with a space.
            text = text + " " + url;
        } else {
            text = url;
        }
    }

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag());
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(EXTRA_TASK_ID, activity.getTaskId());

    if (screenshotUri != null) {
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (screenshotUri != null) {
        // To give read access to an Intent target, we need to put |screenshotUri| in clipData
        // because adding Intent.FLAG_GRANT_READ_URI_PERMISSION doesn't work for
        // EXTRA_SHARE_SCREENSHOT_AS_STREAM.
        intent.setClipData(ClipData.newRawUri("", screenshotUri));
        intent.putExtra(EXTRA_SHARE_SCREENSHOT_AS_STREAM, screenshotUri);
    }
    if (offlineUri == null) {
        intent.setType("text/plain");
    } else {
        intent.setType("multipart/related");
        intent.putExtra(Intent.EXTRA_STREAM, offlineUri);
    }
    return intent;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:38,代码来源:ShareHelper.java


示例11: showSnackbar

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Displays Auto sign-in snackbar, which communicates to the users that they
 * were signed in to the web site.
 */
@CalledByNative
private static void showSnackbar(Tab tab, String text) {
    SnackbarManager snackbarManager = tab.getSnackbarManager();
    if (snackbarManager == null) return;
    AutoSigninSnackbarController snackbarController =
            new AutoSigninSnackbarController(snackbarManager, tab);
    Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION,
            Snackbar.UMA_AUTO_LOGIN);
    Resources resources = tab.getWindowAndroid().getActivity().get().getResources();
    int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color);
    Bitmap icon = BitmapFactory.decodeResource(
            resources, R.drawable.account_management_no_picture);
    snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon);
    snackbarManager.showSnackbar(snackbar);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:AutoSigninSnackbarController.java


示例12: BasicNativePage

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
public BasicNativePage(Activity activity, Tab tab) {
    initialize(activity, tab);
    mActivity = activity;
    mTab = tab;
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    Resources res = mActivity.getResources();

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    getView().setLayoutParams(layoutParams);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:BasicNativePage.java


示例13: initialize

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@UiThread
public void initialize(Context context, final BookmarkId folderId,
        BookmarkLoaderCallback callback) {
    mCallback = callback;

    Resources res = context.getResources();
    mLargeIconBridge = new LargeIconBridge(
            Profile.getLastUsedProfile().getOriginalProfile());
    mMinIconSizeDp = (int) res.getDimension(R.dimen.default_favicon_min_size);
    mDisplayedIconSize = res.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = res.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor =
            ApiCompatibilityUtils.getColor(res, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(mDisplayedIconSize, mDisplayedIconSize,
            mCornerRadius, iconColor, textSize);

    mRemainingTaskCount = 1;
    mBookmarkModel = new BookmarkModel();
    mBookmarkModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            loadBookmarks(folderId);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:BookmarkWidgetService.java


示例14: registerForBeam

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * If the device has NFC, construct a BeamCallback and pass it to Android.
 *
 * @param activity Activity that is sending out beam messages.
 * @param provider Provider that returns the URL that should be shared.
 */
public static void registerForBeam(final Activity activity, final BeamProvider provider) {
    final NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
    if (nfcAdapter == null) return;
    if (ApiCompatibilityUtils.checkPermission(
            activity, Manifest.permission.NFC, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_DENIED) {
        return;
    }
    try {
        final BeamCallback beamCallback = new BeamCallback(activity, provider);
        nfcAdapter.setNdefPushMessageCallback(beamCallback, activity);
        nfcAdapter.setOnNdefPushCompleteCallback(beamCallback, activity);
    } catch (IllegalStateException e) {
        Log.w("BeamController", "NFC registration failure. Can't retry, giving up.");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:BeamController.java


示例15: setupImageButton

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
private void setupImageButton(TintedImageButton button, final MenuItem item) {
    // Store and recover the level of image as button.setimageDrawable
    // resets drawable to default level.
    int currentLevel = item.getIcon().getLevel();
    button.setImageDrawable(item.getIcon());
    item.getIcon().setLevel(currentLevel);
    if (item.isChecked()) {
        button.setTint(ApiCompatibilityUtils.getColorStateList(
                button.getResources(), R.color.blue_mode_tint));
    }
    button.setEnabled(item.isEnabled());
    button.setFocusable(item.isEnabled());
    button.setContentDescription(item.getTitleCondensed());

    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });

    // Menu items may be hidden by command line flags before they get to this point.
    button.setVisibility(item.isVisible() ? View.VISIBLE : View.GONE);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:AppMenuAdapter.java


示例16: getLargeNotificationIcon

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
    Resources resources = mContext.getResources();
    int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
    final OvalShape circle = new OvalShape();
    circle.resize(width, height);
    final Paint paint = new Paint();
    paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));

    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    circle.draw(canvas, paint);
    float leftOffset = (width - bitmap.getWidth()) / 2f;
    float topOffset = (height - bitmap.getHeight()) / 2f;
    if (leftOffset >= 0 && topOffset >= 0) {
        canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
    } else {
        // Scale down the icon into the notification icon dimensions
        canvas.drawBitmap(bitmap,
                new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
                new Rect(0, 0, width, height),
                null);
    }
    return result;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:DownloadNotificationService.java


示例17: updateVisualsForTabModel

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void updateVisualsForTabModel(boolean isIncognito) {
    int queryTextColorId;
    if (isIncognito) {
        setBackgroundResource(R.color.incognito_primary_color);
        ColorStateList white = ApiCompatibilityUtils.getColorStateList(getResources(),
                R.color.light_mode_tint);
        mFindNextButton.setTint(white);
        mFindPrevButton.setTint(white);
        mCloseFindButton.setTint(white);
        queryTextColorId = R.color.find_in_page_query_white_color;
    } else {
        setBackgroundColor(Color.WHITE);
        ColorStateList dark = ApiCompatibilityUtils.getColorStateList(getResources(),
                R.color.dark_mode_tint);
        mFindNextButton.setTint(dark);
        mFindPrevButton.setTint(dark);
        mCloseFindButton.setTint(dark);
        queryTextColorId = R.color.find_in_page_query_color;
    }
    mFindQuery.setTextColor(
            ApiCompatibilityUtils.getColor(getContext().getResources(), queryTextColorId));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:FindToolbarPhone.java


示例18: onLayout

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int width = right - left;
    boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);

    // Child positions were already determined during the measurement pass.
    for (int childIndex = 0; childIndex < getChildCount(); childIndex++) {
        View child = getChildAt(childIndex);
        int childLeft = getControlLayoutParams(child).start;
        if (isRtl) childLeft = width - childLeft - child.getMeasuredWidth();

        int childTop = getControlLayoutParams(child).top;
        int childRight = childLeft + child.getMeasuredWidth();
        int childBottom = childTop + child.getMeasuredHeight();
        child.layout(childLeft, childTop, childRight, childBottom);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:InfoBarControlLayout.java


示例19: initialize

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
@Override
protected void initialize(final Activity activity, Tab tab) {
    Resources resources = activity.getResources();
    mSuccessColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_success_color));
    mFailureColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_failure_color));
    mIndeterminateColor = colorToHexValue(ApiCompatibilityUtils.getColor(resources,
            R.color.physical_web_diags_indeterminate_color));

    LayoutInflater inflater = LayoutInflater.from(activity);
    mPageView = inflater.inflate(R.layout.physical_web_diagnostics, null);

    mLaunchButton = (Button) mPageView.findViewById(R.id.physical_web_launch);
    mLaunchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.startActivity(createListUrlsIntent());
        }
    });

    mDiagnosticsText = (TextView) mPageView.findViewById(R.id.physical_web_diagnostics_text);
    mDiagnosticsText.setAutoLinkMask(Linkify.WEB_URLS);
    mDiagnosticsText.setText(Html.fromHtml(createDiagnosticsReportHtml()));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:PhysicalWebDiagnosticsPage.java


示例20: getMetadataFilesForDeletion

import org.chromium.base.ApiCompatibilityUtils; //导入依赖的package包/类
/**
 * Given a list of metadata files, determine which are applicable for deletion based on the
 * deletion strategy of Custom Tabs.
 *
 * @param currentTimeMillis The current time in milliseconds
 *                          ({@link System#currentTimeMillis()}.
 * @param allMetadataFiles The complete list of all metadata files to check.
 * @return The list of metadata files that are applicable for deletion.
 */
protected static List<File> getMetadataFilesForDeletion(
        long currentTimeMillis, List<File> allMetadataFiles) {
    Collections.sort(allMetadataFiles, new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
            long lhsModifiedTime = lhs.lastModified();
            long rhsModifiedTime = rhs.lastModified();

            // Sort such that older files (those with an lower timestamp number) are at the
            // end of the sorted listed.
            return ApiCompatibilityUtils.compareLong(rhsModifiedTime, lhsModifiedTime);
        }
    });

    List<File> stateFilesApplicableForDeletion = new ArrayList<File>();
    for (int i = 0; i < allMetadataFiles.size(); i++) {
        File file = allMetadataFiles.get(i);
        long fileAge = currentTimeMillis - file.lastModified();
        if (i >= MAXIMUM_STATE_FILES || fileAge >= STATE_EXPIRY_THRESHOLD) {
            stateFilesApplicableForDeletion.add(file);
        }
    }
    return stateFilesApplicableForDeletion;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:34,代码来源:CustomTabTabPersistencePolicy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MACSerializer类代码示例发布时间:2022-05-21
下一篇:
Java Scm类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap