Android Activity Start prepare(Activity activity, int id, int width)

Here you can find the source of prepare(Activity activity, int id, int width)

Description

prepare

Declaration

public static void prepare(Activity activity, int id, int width) 

Method Source Code

//package com.java2s;

import android.app.Activity;

import android.graphics.Bitmap;
import android.graphics.Rect;

import android.view.ViewGroup;
import android.view.Window;

public class Main {
    private static Bitmap sCoverBitmap = null;
    private static int sWidth = -1;

    public static void prepare(Activity activity, int id, int width) {

        if (sCoverBitmap != null) {
            sCoverBitmap.recycle();/*from  www  . ja va 2 s .c  o  m*/
        }
        Rect rectgle = new Rect();
        Window window = activity.getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
        int statusBarHeight = rectgle.top;

        ViewGroup v1 = (ViewGroup) activity.findViewById(id).getRootView();
        v1.setDrawingCacheEnabled(true);
        Bitmap source = Bitmap.createBitmap(v1.getDrawingCache());
        v1.setDrawingCacheEnabled(false);
        if (statusBarHeight != 0) {
            sCoverBitmap = Bitmap
                    .createBitmap(source, 0, statusBarHeight,
                            source.getWidth(), source.getHeight()
                                    - statusBarHeight);
            source.recycle();
        } else {
            sCoverBitmap = source;
        }
        sWidth = width;

    }
}

Related

  1. startApkActivity(final Context ctx, String packageName)
  2. restartActivity(final Activity activity)
  3. restartPC(final Activity activity)
  4. startActivity(Context context, Class activity)
  5. startNewActivity(Class target, final Activity activity)