Search in sources :

Example 6 with ChromeActivity

use of org.chromium.chrome.browser.ChromeActivity in project AndroidChromium by JackyAndroid.

the class ScreenshotTask method create.

/**
     * Prepares screenshot (possibly asynchronously) and invokes the callback when the screenshot
     * is available, or collection has failed. The asynchronous path is only taken when the activity
     * that is passed in is a {@link ChromeActivity}.
     * The callback is always invoked asynchronously.
     */
public static void create(Activity activity, final ScreenshotTaskCallback callback) {
    if (activity instanceof ChromeActivity) {
        Rect rect = new Rect();
        activity.getWindow().getDecorView().getRootView().getWindowVisibleDisplayFrame(rect);
        createCompositorScreenshot(((ChromeActivity) activity).getWindowAndroid(), rect, callback);
        return;
    }
    final Bitmap bitmap = prepareScreenshot(activity, null);
    ThreadUtils.postOnUiThread(new Runnable() {

        @Override
        public void run() {
            callback.onGotBitmap(bitmap);
        }
    });
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) ChromeActivity(org.chromium.chrome.browser.ChromeActivity)

Aggregations

ChromeActivity (org.chromium.chrome.browser.ChromeActivity)6 Activity (android.app.Activity)2 TabModelSelector (org.chromium.chrome.browser.tabmodel.TabModelSelector)2 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Rect (android.graphics.Rect)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 WeakReference (java.lang.ref.WeakReference)1 Tab (org.chromium.chrome.browser.tab.Tab)1 SingleTabModelSelector (org.chromium.chrome.browser.tabmodel.SingleTabModelSelector)1 TabReparentingParams (org.chromium.chrome.browser.tabmodel.TabReparentingParams)1 WebContents (org.chromium.content_public.browser.WebContents)1