List of usage examples for android.view SurfaceView getHolder
public SurfaceHolder getHolder()
From source file:meizhi.meizhi.malin.utils.DestroyCleanUtil.java
@SuppressLint("ObsoleteSdkInt") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void unBindView(View view) { if (view == null) return;//from ww w . jav a 2 s .c om Drawable drawable; int i; //1. try { view.setOnClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //2. try { view.setOnCreateContextMenuListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //3. try { view.setOnFocusChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //4. try { view.setOnKeyListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //5. try { view.setOnLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //6. try { view.setOnTouchListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //7. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { view.setOnApplyWindowInsetsListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //8. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnContextClickListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //9. try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { view.setOnScrollChangeListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //10. try { view.setOnDragListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //11. try { view.setOnGenericMotionListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } //12. try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {//13 view.setOnHoverListener(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } //13. try { view.setOnSystemUiVisibilityChangeListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } /** * @see SwipeRefreshLayout#onDetachedFromWindow() */ if (view.getBackground() != null && !view.getClass().getName().equals(CIRCLE_CLASS)) { try { view.getBackground().setCallback(null); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {//16 view.setBackgroundDrawable(null); } else { view.setBackground(null); } } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageView if (view instanceof ImageView) { try { ImageView imageView = (ImageView) view; drawable = imageView.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageView.setImageDrawable(null); imageView.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //TextView if (view instanceof TextView) { try { TextView textView = (TextView) view; textView.setCompoundDrawables(null, null, null, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { textView.setCompoundDrawablesRelative(null, null, null, null); } textView.setCursorVisible(false); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ImageButton if (view instanceof ImageButton) { try { ImageButton imageButton = (ImageButton) view; drawable = imageButton.getDrawable(); if (drawable != null) { drawable.setCallback(null); } imageButton.setImageDrawable(null); imageButton.setImageBitmap(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //ListView if (view instanceof ListView) { ListView listView = (ListView) view; try { listView.setAdapter(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnScrollListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemLongClickListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } try { listView.setOnItemSelectedListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //RecyclerView if (view instanceof RecyclerView) { try { RecyclerView recyclerView = (RecyclerView) view; recyclerView.setAdapter(null); recyclerView.setChildDrawingOrderCallback(null); recyclerView.setOnScrollListener(null); recyclerView.addOnScrollListener(null); recyclerView.removeOnScrollListener(null); recyclerView.setRecyclerListener(null); } catch (Throwable e) { CrashReport.postCatchedException(e); } } //WebView if (view instanceof WebView) { WebView webView = (WebView) view; try { webView.stopLoading(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.removeAllViews(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebChromeClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.setWebViewClient(null); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { webView.destroy(); } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } try { if (null != view.getParent() && view.getParent() instanceof ViewGroup) { ((ViewGroup) view.getParent()).removeView(view); } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } //SurfaceView if (view instanceof SurfaceView) { try { SurfaceView surfaceView = (SurfaceView) view; SurfaceHolder holder = surfaceView.getHolder(); if (holder != null) { Surface surface = holder.getSurface(); if (surface != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { surface.release(); } } } } catch (Throwable ignored) { CrashReport.postCatchedException(ignored); } } view.destroyDrawingCache(); view.clearAnimation(); if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; int childCount = (viewGroup).getChildCount(); for (i = 0; i < childCount; i++) { unBindView((viewGroup).getChildAt(i)); } } }
From source file:mtmo.test.mediadrm.absplayer.ABSPlayer.java
public ABSPlayer(SurfaceView surfaceView) { surfaceView.getHolder().addCallback(this); mSurfaceView = surfaceView;/* w ww . j a va2 s . co m*/ mSurfaceView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pause(); } }); }
From source file:mtmo.test.mediadrm.player.Player.java
public Player(SurfaceView surfaceView) { surfaceView.getHolder().addCallback(this); mSurfaceView = surfaceView;// w w w . j a v a2 s .c o m mSurfaceView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pause(); } }); }
From source file:com.github.dev.williamg.red5propoc.PublishFragment.java
private void preview() { // camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); SurfaceView surface = (SurfaceView) getActivity().findViewById(R.id.surfaceView); surface.getHolder().addCallback(this); }
From source file:org.skia.viewer.ViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView); surfaceView.getHolder().addCallback(this); surfaceView.setOnTouchListener(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); if (mDrawerLayout != null) { // xlarge-land has no drawer layout (drawer is always open) mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close);// w w w . j av a 2 s .co m mDrawerLayout.addDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); } mDrawerList = (ListView) findViewById(R.id.leftDrawer); mStateAdapter = new StateAdapter(this); mDrawerList.setAdapter(mStateAdapter); mApplication = (ViewerApplication) getApplication(); mApplication.setViewerActivity(this); }
From source file:com.jwetherell.QRComm575.DecoderActivity.java
@Override protected void onPause() { super.onPause(); Log.v(TAG, "onPause()"); if (handler != null) { handler.quitSynchronously();//from w ww . ja v a 2s . co m handler = null; } cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } }
From source file:com.jwetherell.QRComm575.DecoderActivity.java
@Override protected void onResume() { super.onResume(); Log.v(TAG, "onResume()"); // CameraManager must be initialized here, not in onCreate(). if (cameraManager == null) cameraManager = new CameraManager(getApplication()); if (viewfinderView == null) { viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); }/*from ww w . ja v a2 s . c o m*/ showScanner(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }
From source file:com.jwetherell.quick_response_code.DecoderActivity.java
@Override protected void onPause() { super.onPause(); if (handler != null) { handler.quitSynchronously();/* w w w .j a v a2 s. c om*/ handler = null; } cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } }
From source file:com.msohm.blackberry.samples.bdvideoplayback.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Initialize BlackBerry Dynamics. GDAndroid.getInstance().activityInit(this); setContentView(R.layout.activity_main); copyButton = (Button) findViewById(R.id.copyButton); //The copy button is used to copy an existing video file you have into the secure //BlackBerry Dynamics file system. This only needs to be run once. copyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Ensure we have permission to read the file being copied. int permissionCheck = ContextCompat.checkSelfPermission(v.getContext(), Manifest.permission.READ_EXTERNAL_STORAGE); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { //Permission isn't set. Request it. ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } else { copyFile();/*from ww w. java 2 s . co m*/ } } }); playButton = (Button) findViewById(R.id.playButton); //Initializes the MediaPlayer. playButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { if (!isPaused) { BDMediaDataSource source = new BDMediaDataSource(FILENAME); mp.setDataSource(source); mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.start(); } }); mp.prepareAsync(); } else { mp.start(); } isPaused = false; } catch (IOException ioex) { } } }); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView); SurfaceHolder holder = surfaceView.getHolder(); holder.addCallback(this); mp = new MediaPlayer(); isPaused = false; }
From source file:com.jwetherell.quick_response_code.DecoderActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). if (cameraManager == null) { cameraManager = new CameraManager(getApplication()); }// w w w. j a v a 2s . c o m if (viewfinderView == null) { viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); } showScanner(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } }