Java Code Examples for android.graphics.PixelFormat

The following are top voted examples for showing how to use android.graphics.PixelFormat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Crimson   File: ScreenFilterService.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate() {

    myView = new MyFilterView(this);

    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(myView, mParams);

    super.onCreate();
}
 
Example 2
Project: ucar-weex-core   File: BorderDrawableTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testGetOpacity() throws Exception {
  BorderDrawable opaque = new BorderDrawable();
  opaque.setColor(Color.GREEN);
  assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE));

  BorderDrawable transparent = new BorderDrawable();
  transparent.setColor(WXResourceUtils.getColor("#00ff0000"));
  assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT));

  BorderDrawable half = new BorderDrawable();
  half.setColor(WXResourceUtils.getColor("#aaff0000"));
  assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT));

  BorderDrawable changeAlpha = new BorderDrawable();
  changeAlpha.setColor(Color.RED);
  changeAlpha.setAlpha(15);
  assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT));
}
 
Example 3
Project: Keyguard   File: MaskWindowUtils.java   Source Code and License 6 votes vote down vote up
@Nullable
private View showKeyguardView (boolean showSettings) {
    if (Build.VERSION.SDK_INT >= 23) {
        if (!Settings.canDrawOverlays(mContext)) {
            if (!showSettings)
                return null;
            Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
            mContext.startActivity(i);
            return null;
        }
    }
    View keyguardView = LayoutInflater.from(mContext).inflate(R.layout.layout_keyguard, null);
    WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams();
    wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    wmParams.format = PixelFormat.TRANSPARENT;
    wmParams.flags=WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
    wmParams.width=WindowManager.LayoutParams.MATCH_PARENT;
    wmParams.height= WindowManager.LayoutParams.MATCH_PARENT;
    mManager.addView(keyguardView, wmParams);
    mContext.startActivity(new Intent(mContext, KeyguardLiveActivity.class));
    return keyguardView;
}
 
Example 4
Project: rongyunDemo   File: BitmapUtils.java   Source Code and License 6 votes vote down vote up
public static Bitmap drawableToBitmap(Drawable drawable) {

        Bitmap bitmap = Bitmap
                        .createBitmap(
                            drawable.getIntrinsicWidth(),
                            drawable.getIntrinsicHeight(),
                            drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
                            : Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);

        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                           drawable.getIntrinsicHeight());
        drawable.draw(canvas);

        return bitmap;

    }
 
Example 5
Project: GitHub   File: CameraManager.java   Source Code and License 6 votes vote down vote up
/**
 * A factory method to build the appropriate LuminanceSource object based on the format
 * of the preview buffers, as described by Camera.Parameters.
 *
 * @param data A preview frame.
 * @param width The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
	Rect rect = getFramingRectInPreview();
	int previewFormat = configManager.getPreviewFormat();
	String previewFormatString = configManager.getPreviewFormatString();
	switch (previewFormat) {
	// This is the standard Android format which all devices are REQUIRED to support.
	// In theory, it's the only one we should ever care about.
	case PixelFormat.YCbCr_420_SP:
		// This format has never been seen in the wild, but is compatible as we only care
		// about the Y channel, so allow it.
	case PixelFormat.YCbCr_422_SP:
		return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
				rect.width(), rect.height());
	default:
		// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
		// Fortunately, it too has all the Y data up front, so we can read it.
		if ("yuv420p".equals(previewFormatString)) {
			return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
					rect.width(), rect.height());
		}
	}
	throw new IllegalArgumentException("Unsupported picture format: " +
			previewFormat + '/' + previewFormatString);
}
 
Example 6
Project: AndroidUtilCode-master   File: CacheUtils.java   Source Code and License 6 votes vote down vote up
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
Example 7
Project: decoy   File: SurfaceViewTemplate.java   Source Code and License 6 votes vote down vote up
public SurfaceViewTemplate(Context context, AttributeSet attrs) {
    super(context, attrs);

    mHolder = getHolder();
    mHolder.addCallback(this);

    // 设置Surface在Window(普通视图架构)之上
    setZOrderOnTop(true);
    // 设置色彩格式,半透明
    mHolder.setFormat(PixelFormat.TRANSLUCENT);

    // 设置可获得焦点
    setFocusable(true);
    setFocusableInTouchMode(true);

    // 设置保持屏幕亮
    this.setKeepScreenOn(true);
}
 
Example 8
Project: HeadlineNews   File: SpanUtils.java   Source Code and License 6 votes vote down vote up
private Bitmap drawable2Bitmap(final Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
Example 9
Project: CoolApk-Console   File: ACache.java   Source Code and License 6 votes vote down vote up
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
Example 10
Project: BBSSDK-for-Android   File: ImageUtils.java   Source Code and License 6 votes vote down vote up
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(final Drawable drawable) {
	if (drawable instanceof BitmapDrawable) {
		BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
		if (bitmapDrawable.getBitmap() != null) {
			return bitmapDrawable.getBitmap();
		}
	}
	Bitmap bitmap;
	if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
		bitmap = Bitmap.createBitmap(1, 1,
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	} else {
		bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
				drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
	}
	Canvas canvas = new Canvas(bitmap);
	drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
	drawable.draw(canvas);
	return bitmap;
}
 
Example 11
Project: meipai-Android   File: MediaRecorderBase.java   Source Code and License 6 votes vote down vote up
/** 设置回调 */
protected void setPreviewCallback() {
	Size size = mParameters.getPreviewSize();
	if (size != null) {
		PixelFormat pf = new PixelFormat();
		PixelFormat.getPixelFormatInfo(mParameters.getPreviewFormat(), pf);
		int buffSize = size.width * size.height * pf.bitsPerPixel / 8;
		try {
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.setPreviewCallbackWithBuffer(this);
		} catch (OutOfMemoryError e) {
			Log.e("Yixia", "startPreview...setPreviewCallback...", e);
		}
		Log.e("Yixia", "startPreview...setPreviewCallbackWithBuffer...width:" + size.width + " height:" + size.height);
	} else {
		camera.setPreviewCallback(this);
	}
}
 
Example 12
Project: AndroidBasicLibs   File: ACache.java   Source Code and License 6 votes vote down vote up
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();

    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;

    Bitmap bitmap = Bitmap.createBitmap(w, h, config);

    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);

    drawable.draw(canvas);
    return bitmap;
}
 
Example 13
Project: FaceRecognition   File: CameraInterface.java   Source Code and License 6 votes vote down vote up
public boolean startCameraPreview(){
	try {
		Camera.Parameters parameters = camera.getParameters();
		parameters.setPictureFormat(PixelFormat.JPEG);
		//parameters.setPictureSize(surfaceView.getWidth(), surfaceView.getHeight());  // 部分定制手机,无法正常识别该方法。
		parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
		parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);//1连续对焦
		setDispaly(parameters, camera);
		camera.setParameters(parameters);
		camera.startPreview();
		camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。
	}catch (RuntimeException e){
		Toast.makeText(context, "该手机不支持参数设定", Toast.LENGTH_LONG).show();
	}
	return true;
}
 
Example 14
Project: cwac-crossport   File: TooltipPopup.java   Source Code and License 6 votes vote down vote up
TooltipPopup(Context context) {
    mContext = context;

    mContentView = LayoutInflater.from(mContext).inflate(R.layout.appcompat_tooltip, null);
    mMessageView = (TextView) mContentView.findViewById(R.id.message);

    mLayoutParams.setTitle(getClass().getSimpleName());
    mLayoutParams.packageName = mContext.getPackageName();
    mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
    mLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mLayoutParams.format = PixelFormat.TRANSLUCENT;
    mLayoutParams.windowAnimations = R.style.Animation_CrossPort_Tooltip;
    mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
}
 
Example 15
Project: BuildNumberOverlay   File: OverlayView.java   Source Code and License 6 votes vote down vote up
public void addToWindowManager() {
    WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
            CANVAS_WIDTH,
            CANVAS_HEIGHT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    windowLayoutParams.gravity = Gravity.BOTTOM | Gravity.END;

    mLinearLayout = new LinearLayout(mContext);
    mLinearLayout.setBackgroundColor(Color.BLACK);
    mWindowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(mLinearLayout, windowLayoutParams);

    TextView textView = new TextView(mContext);
    textView.setTextColor(Color.RED);
    textView.setText(
            String.format("Name: %s \n Code: %s",
                    mPackageInfo.versionName,
                    mPackageInfo.versionCode)
    );
    mLinearLayout.addView(textView);
}
 
Example 16
Project: mao-android   File: BaseCameraView.java   Source Code and License 6 votes vote down vote up
private void init() {
    setEGLContextClientVersion(2);
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    getHolder().setFormat(PixelFormat.RGBA_8888);
    setRenderer(this);
    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

    float[] cube = OpenGLUtils.CUBE;
    mCubeBuffer = ByteBuffer.allocateDirect(cube.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mCubeBuffer.put(cube);

    float[] textureCords = OpenGLUtils.getTextureCords(90, mCameraId == CameraInfo.CAMERA_FACING_FRONT, true);
    mTextureBuffer = ByteBuffer.allocateDirect(textureCords.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    mTextureBuffer.put(textureCords);

    List<CameraFilter> filters = new ArrayList<>();
    filters.add(mCameraInputFilter);
    filters.addAll(initFilters());
    mCameraFilterGroup = new CameraFilterGroup(filters);
}
 
Example 17
Project: Mobike   File: CameraManager.java   Source Code and License 6 votes vote down vote up
/**
 * A factory method to build the appropriate LuminanceSource object based on the format
 * of the preview buffers, as described by Camera.Parameters.
 *
 * @param data   A preview frame.
 * @param width  The width of the image.
 * @param height The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
    Rect rect = getFramingRectInPreview();
    int previewFormat = configManager.getPreviewFormat();
    String previewFormatString = configManager.getPreviewFormatString();
    switch (previewFormat) {
        // This is the standard Android format which all devices are REQUIRED to support.
        // In theory, it's the only one we should ever care about.
        case PixelFormat.YCbCr_420_SP:
            // This format has never been seen in the wild, but is compatible as we only care
            // about the Y channel, so allow it.
        case PixelFormat.YCbCr_422_SP:
            return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
                    rect.width(), rect.height());
        default:
            // The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
            // Fortunately, it too has all the Y data up front, so we can read it.
            if ("yuv420p".equals(previewFormatString)) {
                return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
                        rect.width(), rect.height());
            }
    }
    throw new IllegalArgumentException("Unsupported picture format: " +
            previewFormat + '/' + previewFormatString);
}
 
Example 18
Project: EVideoRecorder   File: ERecorderActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void initView() {

    mSurfaceview = (SurfaceView) findViewById(R.id.surfaceview);
    mRlTakeVedio = (RelativeLayout) findViewById(R.id.rl_take_vedio);
    mIvCancel = (ImageView) findViewById(R.id.iv_cancel);
    mTrpbController = (TimeRoundProgressBar) findViewById(R.id.trpb_controller);
    mRlConfrmVedio = (RelativeLayout) findViewById(R.id.rl_confrm_vedio);
    mIvDelete = (ImageView) findViewById(R.id.iv_delete);
    mIvConfirm = (ImageView) findViewById(R.id.iv_confirm);


    mDialog = ERecorderActivityImpl.getCreateVedioDialog(getActivity());
    mTrpbController.setMax(mRecordTime);

    SurfaceHolder holder = mSurfaceview.getHolder();// 取得holder
    holder.setFormat(PixelFormat.TRANSPARENT);
    holder.setKeepScreenOn(true);
    holder.addCallback(this); // holder加入回调接口
}
 
Example 19
Project: RLibrary   File: BmpUtil.java   Source Code and License 6 votes vote down vote up
/**
 * Drawable转换为Bitmap
 *
 * @param drawable the drawable
 * @return bitmap
 */
public static Bitmap getBitmap(Drawable drawable) {
    if (drawable == null)
        return null;

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
 
Example 20
Project: RoadLab-Pro   File: CustomMapView.java   Source Code and License 6 votes vote down vote up
private int detectBestPixelFormat() {

        //Skip check if this is a new device as it will be RGBA_8888 by default.
        if (isRGBA_8888ByDefault) {
            return PixelFormat.RGBA_8888;
        }

        Context context = getContext();
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();

        //Get display pixel format
        int displayFormat = display.getPixelFormat();

        if ( PixelFormat.formatHasAlpha(displayFormat) ) {
            return displayFormat;
        } else {
            return PixelFormat.RGB_565;//Fallback for those who don't support Alpha
        }
    }
 
Example 21
Project: XposedNavigationBar   File: LightAndVolumeController.java   Source Code and License 6 votes vote down vote up
protected void showDialog(Context context) {
    final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int h = getNavbarHeight(context);
    int w = WindowManager.LayoutParams.MATCH_PARENT;
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(w, h, WindowManager.LayoutParams.TYPE_TOAST, 0, PixelFormat.TRANSLUCENT);
    layoutParams.gravity = Gravity.BOTTOM;

    ViewGroup viewGroup;
    if (mType == LIGHT) {
        viewGroup = getLightPanel(context);
    } else {
        viewGroup = getVolumePanel(context);
    }

    if (lightPanel != null && lightPanel.isAttachedToWindow()) {
        wm.removeView(lightPanel);
    }
    if (volumePanel != null && volumePanel.isAttachedToWindow()) {
        wm.removeView(volumePanel);
    }

    wm.addView(viewGroup, layoutParams);
}
 
Example 22
Project: AndroidUtilCode-master   File: ImageUtils.java   Source Code and License 6 votes vote down vote up
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
        if (bitmapDrawable.getBitmap() != null) {
            return bitmapDrawable.getBitmap();
        }
    }
    Bitmap bitmap;
    if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
        bitmap = Bitmap.createBitmap(1, 1,
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    } else {
        bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    }
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
 
Example 23
Project: OSchina_resources_android   File: KJDragGridView.java   Source Code and License 6 votes vote down vote up
/**
 * 创建拖动的镜像
 *
 * @param bitmap
 * @param downX  按下的点相对父控件的X坐标
 * @param downY  按下的点相对父控件的X坐标
 */
private void createDragImage(Bitmap bitmap, int downX, int downY) {
    mWindowLayoutParams = new WindowManager.LayoutParams();
    mWindowLayoutParams.format = PixelFormat.TRANSLUCENT; // 图片之外的其他地方透明

    mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowLayoutParams.x = downX - mPoint2ItemLeft + mOffset2Left;
    mWindowLayoutParams.y = downY - mPoint2ItemTop + mOffset2Top
            - mStatusHeight;
    mWindowLayoutParams.alpha = 0.55f; // 透明度

    mWindowLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;

    mDragImageView = new ImageView(getContext());
    mDragImageView.setImageBitmap(bitmap);
    mWindowManager.addView(mDragImageView, mWindowLayoutParams);
}
 
Example 24
Project: MyFire   File: ACache.java   Source Code and License 6 votes vote down vote up
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
Example 25
Project: RLibrary   File: ACache.java   Source Code and License 6 votes vote down vote up
private static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable == null) {
        return null;
    }
    // 取 drawable 的长宽
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
            : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(w, h, config);
    // 建立对应 bitmap 的画布
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, w, h);
    // 把 drawable 内容画到画布中
    drawable.draw(canvas);
    return bitmap;
}
 
Example 26
Project: Accessibility   File: BitmapUtils.java   Source Code and License 5 votes vote down vote up
public static Bitmap drawableToBitamp(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
        return bitmapDrawable.getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565);

        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
 
Example 27
Project: ucar-weex-core   File: WXViewUtils.java   Source Code and License 5 votes vote down vote up
@Opacity
public static int getOpacityFromColor(int color) {
  int colorAlpha = color >>> 24;
  if (colorAlpha == 255) {
    return PixelFormat.OPAQUE;
  } else if (colorAlpha == 0) {
    return PixelFormat.TRANSPARENT;
  } else {
    return PixelFormat.TRANSLUCENT;
  }
}
 
Example 28
Project: Widgets   File: SquareImageView.java   Source Code and License 5 votes vote down vote up
/**
 * 将Drawable转换为Bitmap
 *
 * @param drawable 要转换的Drawable
 * @return 转换后的Bitmap
 */
private Bitmap d2b(Drawable drawable) {
    if (null != drawable) {
        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();
        } else {
            Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas(bitmap);
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
            drawable.draw(canvas);
            return bitmap;
        }
    }
    return null;
}
 
Example 29
Project: Zxing   File: CameraManager.java   Source Code and License 5 votes vote down vote up
/**
 * A factory method to build the appropriate LuminanceSource object based on
 * the format of the preview buffers, as described by Camera.Parameters.
 * 
 * @param data
 *            A preview frame.
 * @param width
 *            The width of the image.
 * @param height
 *            The height of the image.
 * @return A PlanarYUVLuminanceSource instance.
 */
@SuppressWarnings("deprecation")
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data,
													 int width, int height) {
	Rect rect = getFramingRectInPreview();
	int previewFormat = configManager.getPreviewFormat();
	String previewFormatString = configManager.getPreviewFormatString();
	switch (previewFormat) {
	// This is the standard Android format which all devices are REQUIRED to
	// support.
	// In theory, it's the only one we should ever care about.
	case PixelFormat.YCbCr_420_SP:
		// This format has never been seen in the wild, but is compatible as
		// we only care
		// about the Y channel, so allow it.
	case PixelFormat.YCbCr_422_SP:
		return new PlanarYUVLuminanceSource(data, width, height, rect.left,
				rect.top, rect.width(), rect.height());
	default:
		// The Samsung Moment incorrectly uses this variant instead of the
		// 'sp' version.
		// Fortunately, it too has all the Y data up front, so we can read
		// it.
		if ("yuv420p".equals(previewFormatString)) {
			return new PlanarYUVLuminanceSource(data, width, height,
					rect.left, rect.top, rect.width(), rect.height());
		}
	}
	throw new IllegalArgumentException("Unsupported picture format: "
			+ previewFormat + '/' + previewFormatString);
}
 
Example 30
Project: RX_Demo   File: ResideLayout.java   Source Code and License 5 votes vote down vote up
private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v)) return true;

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}
 
Example 31
Project: tvConnect_android   File: ImageSurfaceView.java   Source Code and License 5 votes vote down vote up
public ImageSurfaceView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mSurHolder = getHolder();
    mSurHolder.addCallback(this);
    this.setOnTouchListener(this);
    setZOrderOnTop(true);//使surfaceview放到最顶层
    getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
 
Example 32
Project: trascendentAR   File: ARLauncher.java   Source Code and License 5 votes vote down vote up
@Override
public void initialize(ApplicationListener listener, AndroidApplicationConfiguration config){
    //Las siguientes dos lines son necesaria para poder añadir markers de la manera que ARToolKit lo maneja
    AssetHelper assetHelper = new AssetHelper(getAssets());
    assetHelper.cacheAssetFolder(this, "Data");

    mainLayout = new FrameLayout(this);
    config.r = 8;
    config.g = 8;
    config.b = 8;
    config.a = 8;

    //Configuraciones basicas
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    gameView = initializeForView(listener, config);

    if(graphics.getView() instanceof SurfaceView){
        SurfaceView glView = (SurfaceView)graphics.getView();
        glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    }

    setContentView(mainLayout);
}
 
Example 33
Project: screenfilter   File: PopupIndicator.java   Source Code and License 5 votes vote down vote up
private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}
 
Example 34
Project: GitHub   File: DrawableUtilsTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testGetOpacityFromColor() {
  assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00000000));
  assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00123456));
  assertEquals(PixelFormat.TRANSPARENT, DrawableUtils.getOpacityFromColor(0x00FFFFFF));
  assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0000000));
  assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0123456));
  assertEquals(PixelFormat.TRANSLUCENT, DrawableUtils.getOpacityFromColor(0xC0FFFFFF));
  assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFF000000));
  assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFF123456));
  assertEquals(PixelFormat.OPAQUE, DrawableUtils.getOpacityFromColor(0xFFFFFFFF));
}
 
Example 35
Project: RLibrary   File: StyleActivity.java   Source Code and License 5 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        L.e(getClass().getSimpleName() + " 任务栈:" + getTaskId());
        getWindow().setFormat(PixelFormat.TRANSLUCENT);//TBS X5

        loadActivityStyle();
        initWindow();
        initUIActivity();

//        onCreateView();
    }
 
Example 36
Project: EasyOne   File: OverlayService.java   Source Code and License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    FrameLayout frameLayout = new FrameLayout(this);

    frameLayout.setBackgroundColor(getResources().getColor(R.color.colorPhoneDark, getTheme()));
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);


    //change this through preferences
    int dragWidth = 20;

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(dragWidth, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT);

    //change this through preferences
    params.gravity = Gravity.START;

    params.x = 0;
    params.y = 0;

    frameLayout.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            Toast.makeText(OverlayService.this, "yo", Toast.LENGTH_SHORT)
                    .show();
            return false;
        }
    });

    if (windowManager != null) {
        windowManager.addView(frameLayout, params);
    }
}
 
Example 37
Project: grafika   File: ColorBarActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_color_bar);

    mSurfaceView = (SurfaceView) findViewById(R.id.colorBarSurfaceView);
    mSurfaceView.getHolder().addCallback(this);
    mSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
}
 
Example 38
Project: Markwon   File: AsyncDrawable.java   Source Code and License 5 votes vote down vote up
@Override
public int getOpacity() {
    final int opacity;
    if (hasResult()) {
        opacity = result.getOpacity();
    } else {
        opacity = PixelFormat.TRANSPARENT;
    }
    return opacity;
}
 
Example 39
Project: accelerator-core-android   File: ScreenSharingFragment.java   Source Code and License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpVirtualDisplay() {

    mScreen = (ViewGroup) getActivity().getWindow().getDecorView().getRootView();

    // display metrics
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    mDensity = metrics.densityDpi;
    Display mDisplay = getActivity().getWindowManager().getDefaultDisplay();

    Point size = new Point();
    mDisplay.getRealSize(size);
    mWidth = size.x;
    mHeight = size.y;

    // start capture reader
    mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2);
    int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;

    mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null);

    size.set(mWidth, mHeight);

    //create ScreenCapturer
    mScreenCapturer = new ScreenSharingCapturer(getActivity(), mScreen, mImageReader);

    mListener.onScreenCapturerReady();
}
 
Example 40
Project: FloatingWidget   File: FloatingWidgetService.java   Source Code and License 5 votes vote down vote up
private void initPosition() {
    mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    mParams.gravity = Gravity.TOP | Gravity.LEFT;
    mParams.x = 0;
    mParams.y = 150;

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    mWindowManager.addView(mFloatingView, mParams);
}
 
Example 41
Project: AgentWebX5   File: CommonActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_common);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);

    mFrameLayout = (FrameLayout) this.findViewById(R.id.container_framelayout);


    int key = getIntent().getIntExtra(TYPE_KEY, -1);
    mFragmentManager = this.getSupportFragmentManager();
    openFragment(key);
}
 
Example 42
Project: SpriteKit-Android   File: SpriteKitSurfaceView.java   Source Code and License 5 votes vote down vote up
public SpriteKitSurfaceView(Context context, SpriteKit spriteKit) {
      super(context);
this.getHolder().setFormat(PixelFormat.RGB_565);
this.getHolder().setFormat(PixelFormat.TRANSPARENT);
      this.setDebugFlags(GLSurfaceView.DEBUG_LOG_GL_CALLS);
      this.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
      this.setEGLContextClientVersion(2);

this.spriteKit = spriteKit;
  }
 
Example 43
Project: stynico   File: TextDrawable.java   Source Code and License 5 votes vote down vote up
@Override
public int getOpacity() {
    int alpha = mPaint.getAlpha();
    if (alpha == 0) {
        return PixelFormat.TRANSPARENT;
    } else if (alpha == 255) {
        return PixelFormat.OPAQUE;
    } else {
        return PixelFormat.TRANSLUCENT;
    }
}
 
Example 44
Project: stynico   File: Takt.java   Source Code and License 5 votes vote down vote up
private Program prepare(Application application) {
    metronome = new Metronome();
    params = new LayoutParams();
    params.width = LayoutParams.WRAP_CONTENT;
    params.height = LayoutParams.WRAP_CONTENT;
    // if (isOverlayApiDeprecated()) {
    // params.type = LayoutParams.TYPE_APPLICATION_OVERLAY;
    // } else {
    params.type = LayoutParams.TYPE_TOAST;
    //}
    params.flags = LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_NOT_FOCUSABLE
            | LayoutParams.FLAG_NOT_TOUCH_MODAL;
    params.format = PixelFormat.TRANSLUCENT;
    params.gravity = Seat.BOTTOM_RIGHT.getGravity();
    params.x = 10;

    app = application;
    wm = WindowManager.class.cast(application.getSystemService(Context.WINDOW_SERVICE));
    LayoutInflater inflater = LayoutInflater.from(app);
    stageView = inflater.inflate(R.layout.stage, new RelativeLayout(app));
    fpsText = (TextView) stageView.findViewById(R.id.takt_fps);

    listener(new Audience() {
        @Override
        public void heartbeat(double fps) {
            if (fpsText != null) {
                fpsText.setText(decimal.format(fps));
            }
        }
    });

    return this;
}
 
Example 45
Project: SweepRobot   File: RockerView.java   Source Code and License 5 votes vote down vote up
/**
 * Drawable 转 Bitmap
 *
 * @param drawable Drawable
 * @return Bitmap
 */
private Bitmap drawable2Bitmap(Drawable drawable) {
    // 取 drawable 的长宽
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    // 取 drawable 的颜色格式
    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    // 建立对应 bitmap
    Bitmap bitmap = Bitmap.createBitmap(width, height, config);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);
    return bitmap;
}
 
Example 46
Project: DroidPlugin   File: INotificationManagerHookHandle.java   Source Code and License 5 votes vote down vote up
private Bitmap drawableToBitMap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bitmapDrawable = ((BitmapDrawable) drawable);
        return bitmapDrawable.getBitmap();
    } else {
        Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
}
 
Example 47
Project: login   File: ClearEditText.java   Source Code and License 5 votes vote down vote up
private Bitmap drawableToBitmap(Drawable drawable) {
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();

    Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ?
            Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    Bitmap bitmap = Bitmap.createBitmap(width, height, config);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);
    return bitmap;
}
 
Example 48
Project: android-instant-apps   File: TextResize.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
}
 
Example 49
Project: PlusGram   File: AnimatedFileDrawable.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSPARENT;
}
 
Example 50
Project: ParticlesDrawable   File: ParticlesDrawable.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
}
 
Example 51
Project: airgram   File: MenuDrawable.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSPARENT;
}
 
Example 52
Project: Ec2m   File: CamaraActivity.java   Source Code and License 4 votes vote down vote up
private void setParams(SurfaceHolder mySurfaceView, int postion) {
    try {
        int PreviewWidth = 0;
        int PreviewHeight = 0;
        WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);//获取窗口的管理器
        /*PreviewWidth = display.();
        PreviewHeight = display.getHeight();*/

        Camera.Parameters parameters = mCamera.getParameters();
        // 选择合适的预览尺寸
        List<Camera.Size> sizeList = parameters.getSupportedPreviewSizes();

        // 如果sizeList只有一个我们也没有必要做什么了,因为就他一个别无选择
        if (sizeList.size() > 1) {
            Iterator<Camera.Size> itor = sizeList.iterator();
            while (itor.hasNext()) {
                Camera.Size cur = itor.next();
                /*if (cur.width >= PreviewWidth
                        && cur.height >= PreviewHeight) {*/
                if (cur.width >= PreviewWidth
                        && cur.height >= PreviewHeight) {
                    PreviewWidth = cur.width;
                    PreviewHeight = cur.height;
                    break;
                }

            }
        }
        parameters.setPreviewSize(PreviewWidth, PreviewHeight); //获得摄像区域的大小
        //parameters.setPreviewFrameRate(3);//每秒3帧  每秒从摄像头里面获得3个画面
        //parameters.setPreviewFpsRange(3,);
        List<int[]> list = parameters.getSupportedPreviewFpsRange();
        int[] v = null;
        int index = 0;
        int min = 0;
        for (int i = 0; i < list.size(); i++) {
            v = list.get(i);
            if (v[0] > min) {
                min = v[0];
                index = i;
            }
        }
        parameters.setPreviewFpsRange(list.get(index)[0], list.get(index)[1]);
        parameters.setPictureFormat(PixelFormat.JPEG);//设置照片输出的格式
        parameters.set("jpeg-quality", 85);//设置照片质量
        parameters.setPictureSize(PreviewWidth, PreviewHeight);//设置拍出来的屏幕大小
        parameters.setRotation(180); //Java部分
        if (Build.VERSION.SDK_INT >= 24) {
            if (postion == 0) {
                mCamera.setDisplayOrientation(90);
            } else {
                mCamera.setDisplayOrientation(270);
            }
        } else {
            mCamera.setDisplayOrientation(90);
        }


        mCamera.setParameters(parameters);//把上面的设置 赋给摄像头
        mCamera.setPreviewDisplay(mySurfaceView);//把摄像头获得画面显示在SurfaceView控件里面
        mholder = mySurfaceView;
        mCamera.setPreviewCallback(new Camera.PreviewCallback() {
            @Override
            public void onPreviewFrame(byte[] data, Camera camera) {

            }
        });
        mCamera.startPreview();//开始预览
        //   mPreviewRunning = true;
    } catch (IOException e) {
        Log.e("tag", e.toString());
    }
}
 
Example 53
Project: Bigbang   File: ArcTipViewController.java   Source Code and License 4 votes vote down vote up
private void reuseSavedWindowMangerPosition(int width_vale, int height_value) {
    //获取windowManager
    int w = width_vale;
    int h = height_value;
    if (layoutParams == null) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        mWindowManager.getDefaultDisplay().getMetrics(displayMetrics);
        density = displayMetrics.density;

        int flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
        int type = 0;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(mContext)) {
            type = WindowManager.LayoutParams.TYPE_PHONE;
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT< Build.VERSION_CODES.N) {
            type = WindowManager.LayoutParams.TYPE_TOAST;
        } else {
            type = WindowManager.LayoutParams.TYPE_PHONE;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            Point point = new Point();
            mWindowManager.getDefaultDisplay().getSize(point);
            mScreenWidth = point.x;
            mScreenHeight = point.y;
        } else {
            mScreenWidth = mWindowManager.getDefaultDisplay().getWidth();
            mScreenHeight = mWindowManager.getDefaultDisplay().getHeight();
        }
        rotation = mWindowManager.getDefaultDisplay().getRotation();
        int x = 0, y = 0;
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
            x = SPHelper.getInt(ConstantUtil.FLOAT_VIEW_PORT_X, mScreenWidth);
            y = SPHelper.getInt(ConstantUtil.FLOAT_VIEW_PORT_Y, mScreenHeight / 2);
        } else {
            x = SPHelper.getInt(ConstantUtil.FLOAT_VIEW_LAND_X, mScreenWidth);
            y = SPHelper.getInt(ConstantUtil.FLOAT_VIEW_LAND_Y, mScreenHeight / 2);
        }

        layoutParams = new WindowManager.LayoutParams(w, h, type, flags, PixelFormat.TRANSLUCENT);
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        layoutParams.x = x;
        layoutParams.y = y;
    } else {
        layoutParams.width = w;
        layoutParams.height = h;
    }

}
 
Example 54
Project: RLibrary   File: Indicator.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.OPAQUE;
}
 
Example 55
Project: Hello-Music-droid   File: SlidingUpPanelLayout.java   Source Code and License 4 votes vote down vote up
private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}
 
Example 56
Project: atlas   File: LottieDrawable.java   Source Code and License 4 votes vote down vote up
@Override public int getOpacity() {
  return PixelFormat.TRANSLUCENT;
}
 
Example 57
Project: Hitalk   File: MaterialProgressDrawable.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
}
 
Example 58
Project: buildAPKsApps   File: BloodType.java   Source Code and License 4 votes vote down vote up
@Override
public void onAttachedToWindow() { //ensures smooth gradient
    super.onAttachedToWindow();
    Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
}
 
Example 59
Project: GifImageLoader   File: CircleBitmapDisplayer.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSLUCENT;
}
 
Example 60
Project: PlusGram   File: CloseProgressDrawable.java   Source Code and License 4 votes vote down vote up
@Override
public int getOpacity() {
    return PixelFormat.TRANSPARENT;
}