本文整理汇总了Java中android.view.SurfaceHolder.addCallback方法的典型用法代码示例。如果您正苦于以下问题:Java SurfaceHolder.addCallback方法的具体用法?Java SurfaceHolder.addCallback怎么用?Java SurfaceHolder.addCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.SurfaceHolder
的用法示例。
在下文中一共展示了SurfaceHolder.addCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
playBeep = true;
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
playBeep = false;
}
initBeepSound();
vibrate = true;
}
示例2: GameView
import android.view.SurfaceHolder; //导入方法依赖的package包/类
public GameView(
@NonNull Context context,
@NonNull AttributeSet attributeSet) {
super(context, attributeSet);
_logger = new SmartMirrorLogger(TAG);
_logger.Debug("GameView created...");
_receiverController = new ReceiverController(context);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
setFocusable(true);
_thread = new GameThread(holder);
}
示例3: onResume
import android.view.SurfaceHolder; //导入方法依赖的package包/类
/**
* 启动相机预览与扫描,在Activity/Fragment的onResume方法中调用。
*/
public void onResume() {
if (checkCameraHardware()) {
mCameraManager = new CameraManager(this);
if (frameWidth > 0 && frameHeight > 0) {
mCameraManager.setManualFramingRect(frameWidth, frameHeight, frameTopOffset);
}
SurfaceHolder surfaceHolder = getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
}
} else {
if (mOnBarcodeReadListener != null) {
mOnBarcodeReadListener.onCameraNotFound();
}
}
}
示例4: onCreate
import android.view.SurfaceHolder; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.TRANSLUCENT); // 使得窗口支持透明度
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.nim_capture_video_activity);
setTitle(R.string.video_record);
parseIntent();
findViews();
initActionBar();
setViewsListener();
updateRecordUI();
getVideoPreviewSize();
surfaceview = (SurfaceView) this.findViewById(R.id.videoView);
SurfaceHolder holder = surfaceview.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
holder.addCallback(this);
resizeSurfaceView();
}
示例5: initView
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@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加入回调接口
}
示例6: setVideoSurfaceHolder
import android.view.SurfaceHolder; //导入方法依赖的package包/类
/**
* Sets the {@link SurfaceHolder} that holds the {@link Surface} onto which video will be
* rendered. The player will track the lifecycle of the surface automatically.
*
* @param surfaceHolder The surface holder.
*/
public void setVideoSurfaceHolder(SurfaceHolder surfaceHolder) {
removeSurfaceCallbacks();
this.surfaceHolder = surfaceHolder;
if (surfaceHolder == null) {
setVideoSurfaceInternal(null, false);
} else {
setVideoSurfaceInternal(surfaceHolder.getSurface(), false);
surfaceHolder.addCallback(componentListener);
}
}
示例7: initRenderer
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void initRenderer() {
mRenderer = new RendererImpl(mGLSurfaceView);
mGLSurfaceView.setEGLContextClientVersion(2);
mGLSurfaceView.setRenderer(mRenderer);
mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
SurfaceHolder surfaceHolder = mGLSurfaceView.getHolder();
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
surfaceHolder.addCallback(mSurfaceHolderCallback);
}
示例8: setSurfaceHolder
import android.view.SurfaceHolder; //导入方法依赖的package包/类
/**
* 设置预览输出SurfaceHolder
* @param sh
*/
@SuppressWarnings("deprecation")
public void setSurfaceHolder(SurfaceHolder sh) {
if (sh != null) {
sh.addCallback(this);
if (!DeviceUtils.hasHoneycomb()) {
sh.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
}
}
示例9: DreamView
import android.view.SurfaceHolder; //导入方法依赖的package包/类
public DreamView(Context context, AttributeSet attrs) {
super(context, attrs);
// Disable hardware acceleration so we can use BlurMaskFilter
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
mRenderThread = new RenderThread(context, holder);
}
示例10: onCreate
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
mPermissionsChecker = new PermissionsChecker(this);
streamer = new EvilsLiveStreamer(this);
// ViewGroup.LayoutParams layoutParams = mPreviewView.getLayoutParams();
// layoutParams.width = 640;
// layoutParams.height = 480;
// mPreviewView.setLayoutParams(layoutParams);
SurfaceHolder holder = mPreviewView.getHolder();
holder.addCallback(this);
audioCapture = new AudioCapture();
audioPlay = new AudioPlayer();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
ActivityComponent activityComponent = DaggerActivityComponent.builder()
.activityModule(new ActivityModule(this)).build();
activityComponent.getActivity();
// CameraComponent cameraComponent = DaggerCameraComponent.builder().activityComponent(activityComponent).
// cameraModule(new com.thinkkeep.videolib.di.modules.CameraModule(this)).build();
// cameraComponent.inject(this);
}
示例11: init
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void init(Context context) {
if (!this.isInEditMode()) {
splats[0] = BitmapFactory.decodeResource(getResources(), R.drawable.splat1);
splats[1] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
splats[2] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
anchor[0] = BitmapFactory.decodeResource(getResources(), R.drawable.anchor_sm);
axes[0] = BitmapFactory.decodeResource(getResources(), R.drawable.axe2);
bgs[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sea);
fgtops[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sail);
fgbottoms[0] = BitmapFactory.decodeResource(getResources(), R.drawable.shipside2);
final SurfaceHolder holder = getHolder();
holder.addCallback(this);
TypedArray fish = getResources().obtainTypedArray(R.array.fish);
int[] values = getResources().getIntArray(R.array.points);
totalValue = 0;
for (int i = 0; i < fish.length(); i++) {
FlyingItem item = new FlyingItem(BitmapFactory.decodeResource(getResources(), fish.getResourceId(i, 0)));
item.setValue(values[i]);
availableItems.add(item);
totalValue += (100 - values[i]);
}
fish.recycle();
this.setOnTouchListener(this);
mLinePaint = new Paint();
mLinePaint.setARGB(255, 255, 64, 64);
mLinePaint.setStrokeWidth(5);
mBGPaint = new Paint();
mBGPaint.setARGB(255, 127, 127, 200);
mTextPaint = new Paint();
mTextPaint.setColor(Color.BLACK);
mTextPaint.setShadowLayer(8,8,8,Color.WHITE);
mTextPaint.setTextSize(80);
}
}
示例12: onResume
import android.view.SurfaceHolder; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
decodeFormats = null;
characterSet = null;
}
示例13: init
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void init() {
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed
SurfaceHolder holder = getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
mKeyguardManager = ((KeyguardManager)getContext().getSystemService(Context.KEYGUARD_SERVICE));
}
示例14: SeismoView
import android.view.SurfaceHolder; //导入方法依赖的package包/类
public SeismoView(Context ctx, int period) {
super(ctx);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
setKeepScreenOn(true);
ctx_ = ctx;
period_ = period;
}
示例15: init
import android.view.SurfaceHolder; //导入方法依赖的package包/类
private void init() {
LayoutInflater.from(getContext()).inflate(R.layout.preview_layout, this);
mPreviewView = findViewById(R.id.preview);
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
SurfaceHolder holder = mPreviewView.getHolder();
holder.addCallback(new PreviewCallback());
// deprecated setting, but required on Android versions prior to 3.0
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}