List of usage examples for android.view SurfaceView SurfaceView
public SurfaceView(Context context)
From source file:org.blanco.lacuenta.misc.EmptyFragment.java
@Override public View getView() { SurfaceView v = new SurfaceView(getActivity()); v.setBackgroundColor(Color.BLUE); return v; }
From source file:com.enib.anthony.snappercentpicture.CameraSourcePreview.java
public CameraSourcePreview(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;/* w w w. jav a2 s .c o m*/ mStartRequested = false; mSurfaceAvailable = false; mSurfaceView = new SurfaceView(context); mSurfaceView.getHolder().addCallback(new SurfaceCallback()); addView(mSurfaceView); }
From source file:ui.camera.CameraSourcePreview.java
public CameraSourcePreview(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;/*w ww . j a va 2 s .co m*/ mStartRequested = false; mSurfaceAvailable = false; DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); w = displayMetrics.widthPixels; h = displayMetrics.heightPixels; mSurfaceView = new SurfaceView(context); mSurfaceView.getHolder().addCallback(new SurfaceCallback()); addView(mSurfaceView); }
From source file:com.pyamsoft.zaptorch.service.OriginalCamera.java
OriginalCamera(final @NonNull Context context, final @NonNull VolumeServiceInteractor interactor) { super(context, interactor); Timber.d("OLD CAMERA API"); opened = false;//from w ww .j a va2s. c om surfaceView = new SurfaceView(getAppContext()); windowManager = (WindowManager) getAppContext().getSystemService(Context.WINDOW_SERVICE); params = new WindowManager.LayoutParams(); params.width = 1; params.height = 1; params.gravity = Gravity.TOP | Gravity.START; params.format = PixelFormat.TRANSLUCENT; params.type = WindowManager.LayoutParams.TYPE_TOAST; params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; }
From source file:ch.jeda.platform.android.CanvasFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final SurfaceView result = new SurfaceView(this.getActivity()); result.setFocusable(true);//from ww w.j ava 2 s .c o m result.setFocusableInTouchMode(true); result.setOnKeyListener(this); result.setOnTouchListener(this); this.surfaceHolder = result.getHolder(); this.surfaceHolder.addCallback(this); return result; }
From source file:net.microtrash.clapcamera.Preview.java
private void init(Context context) { setKeepScreenOn(true);//from w ww. ja v a2s. c o m this.context = context; mSurfaceView = new SurfaceView(context); addView(mSurfaceView); mHolder = mSurfaceView.getHolder(); // <4> mHolder.addCallback(this); // <5> mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // <6> }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout frameLayout = new FrameLayout(getActivity()); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);//from w ww. j av a 2s. c om frameLayout.setLayoutParams(layoutParams); surfaceView = new SurfaceView(getActivity()); surfaceView.setLayoutParams(layoutParams); viewfinderView = new ViewfinderView(getActivity()); viewfinderView.setLayoutParams(layoutParams); frameLayout.addView(surfaceView); frameLayout.addView(viewfinderView); View v = frameLayout; inactivityTimer = new InactivityTimer(this.getActivity()); ambientLightManager = new AmbientLightManager(this.getActivity()); return v; }
From source file:com.kupay.decoder.DecoderActivity.java
public void startCamera() { //(SurfaceView) getView().findViewById(R.id.preview_view); RelativeLayout rl = (RelativeLayout) getView().findViewById(R.id.fitCamera); surfaceView = new SurfaceView(getActivity()); SurfaceHolder surfaceHolder = surfaceView.getHolder(); Log.v("app", "Cargando camara"); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); if (rl != null && surfaceView != null) rl.addView(surfaceView);/* ww w . j a v a 2s .co m*/ }
From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.flashlight.FlashlightService.java
@Override public void onCreate() { sIsRunning = true;/*w ww . j a va 2 s . c om*/ NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(getResources().getString(R.string.persistent_flash_active)); builder.setContentText(getResources().getString(R.string.persistent_flash_active_tap)); builder.setSmallIcon(R.drawable.ic_persistent_flash); builder.setContentIntent( PendingIntent.getBroadcast(this, -1, new Intent(getPackageName() + ".STOP_FLASH"), 0)); startForeground(NOTIFICATION_ID, builder.build()); mContainer = new LinearLayout(getApplicationContext()); LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mContainer.setLayoutParams(lparams); mContainer.setOrientation(LinearLayout.VERTICAL); mTurnOffButton = new ImageButton(getApplicationContext()); mTurnOffButton.setImageResource(R.drawable.ic_persistent_flash); mTurnOffButton.setBackgroundColor(0x80000000); mTurnOffButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopSelf(); } }); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = ConstantHolder.getLockscreenType(); params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; params.x = 0; params.y = 0; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.height = params.width; params.gravity = Gravity.CENTER; params.format = PixelFormat.TRANSLUCENT; mContainer.addView(mTurnOffButton); String method = TogglesResolver.getFlashlightType(getApplicationContext()); if (method.equals("default")) { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } else if (method.equals("htc")) { mFlashManipulator = new HTCFlashlightManipulator(); } else if (method.equals("nosurfaceview")) { mFlashManipulator = new NoSurfaceViewFlashlightManipulator(); } else { mDummySurfaceView = new SurfaceView(getApplicationContext()); mDummySurfaceView.setAlpha(0.01f); ViewGroup.LayoutParams sparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 1); mDummySurfaceView.setLayoutParams(sparams); mFlashManipulator = new DefaultFlashlightManipulator(mDummySurfaceView); mContainer.addView(mDummySurfaceView); } mWindowManager.addView(mContainer, params); mHandler = new Handler(); mActor = new Runnable() { @Override public void run() { mFlashManipulator.turnFlashlightOn(); } }; mScreenOffReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); mHandler.postDelayed(mActor, 200); } }; mStopServiceReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mFlashManipulator.turnFlashlightOff(); stopSelf(); } }; registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mStopServiceReceiver, new IntentFilter(getPackageName() + ".STOP_FLASH")); }
From source file:im.ene.toro.exoplayer.ExoVideoView.java
public ExoVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // By default, TextureView is used for Android 23 and below, and SurfaceView is for the rest boolean useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ExoVideoView, 0, 0); try {/* w w w. j a v a2 s. c o m*/ int surfaceType = a.getInt(R.styleable.ExoVideoView_tx1_surfaceType, SURFACE_TYPE_DEFAULT); switch (surfaceType) { case SURFACE_TYPE_SURFACE_VIEW: useTextureView = false; break; case SURFACE_TYPE_TEXTURE_VIEW: useTextureView = true; break; case SURFACE_TYPE_DEFAULT: default: // Unchanged, so don't need to execute the line below // useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); break; } resizeMode = a.getInt(R.styleable.ExoVideoView_tx1_resizeMode, RESIZE_MODE_FIXED_WIDTH); } finally { a.recycle(); } } View view = useTextureView ? new TextureView(context) : new SurfaceView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(params); surfaceView = view; addView(surfaceView, 0); playerListener = new VideoPlayerListener(); SurfaceHelper surfaceHelper = SurfaceHelper.Factory.getInstance(this, surfaceView); surfaceHelper.setupForView(surfaceView); setFocusable(true); setFocusableInTouchMode(true); requestFocus(); }