use of android.view.SurfaceView in project android_frameworks_base by crdroidandroid.
the class TvView method resetSurfaceView.
private void resetSurfaceView() {
if (mSurfaceView != null) {
mSurfaceView.getHolder().removeCallback(mSurfaceHolderCallback);
removeView(mSurfaceView);
}
mSurface = null;
mSurfaceView = new SurfaceView(getContext(), mAttrs, mDefStyleAttr) {
@Override
protected void updateWindow(boolean force, boolean redrawNeeded) {
super.updateWindow(force, redrawNeeded);
relayoutSessionOverlayView();
}
};
// The surface view's content should be treated as secure all the time.
mSurfaceView.setSecure(true);
mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback);
if (mWindowZOrder == ZORDER_MEDIA_OVERLAY) {
mSurfaceView.setZOrderMediaOverlay(true);
} else if (mWindowZOrder == ZORDER_ON_TOP) {
mSurfaceView.setZOrderOnTop(true);
}
addView(mSurfaceView);
}
use of android.view.SurfaceView in project android_frameworks_base by crdroidandroid.
the class CameraTooActivity method onResume.
/**
* Called when our {@code Activity} gains focus. <p>Starts initializing the camera.</p>
*/
@Override
protected void onResume() {
super.onResume();
// Start a background thread to manage camera requests
mBackgroundThread = new HandlerThread("background");
mBackgroundThread.start();
mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
mForegroundHandler = new Handler(getMainLooper());
mCameraManager = (CameraManager) getSystemService(CAMERA_SERVICE);
// Inflate the SurfaceView, set it as the main layout, and attach a listener
View layout = getLayoutInflater().inflate(R.layout.mainactivity, null);
mSurfaceView = (SurfaceView) layout.findViewById(R.id.mainSurfaceView);
mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback);
setContentView(mSurfaceView);
// Control flow continues in mSurfaceHolderCallback.surfaceChanged()
}
use of android.view.SurfaceView in project android_frameworks_base by crdroidandroid.
the class SmartCamera method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simplecamera);
setTitle("Smart Camera");
mContext = new MffContext(this);
mCameraView = (SurfaceView) findViewById(R.id.cameraView);
mGoodBadTextView = (TextView) findViewById(R.id.goodOrBadTextView);
mFPSTextView = (TextView) findViewById(R.id.fpsTextView);
mScoreTextView = (TextView) findViewById(R.id.scoreTextView);
mStartStopButton = (Button) findViewById(R.id.startButton);
mImagesSavedTextView = (TextView) findViewById(R.id.imagesSavedTextView);
mImagesSavedTextView.setText("");
mSpinner = (Spinner) findViewById(R.id.spinner);
mLinearLayout = (LinearLayout) findViewById(R.id.scrollViewLinearLayout);
mImages = new ArrayList<ImageView>();
// Spinner is used to determine how many image views are displayed at the bottom
// of the screen. Based on the item position that is selected, we inflate that
// many imageviews into the bottom linear layout.
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
mLinearLayout.removeViews(0, numImages);
numImages = position + 1;
mImages.clear();
LayoutInflater inflater = getLayoutInflater();
for (int i = 0; i < numImages; i++) {
ImageView tmp = (ImageView) inflater.inflate(R.layout.imageview, null);
mImages.add(tmp);
mLinearLayout.addView(tmp);
}
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
}
});
numImages = mSpinner.getSelectedItemPosition() + 1;
mImages.clear();
LayoutInflater inflater = getLayoutInflater();
for (int i = 0; i < numImages; i++) {
ImageView tmp = (ImageView) inflater.inflate(R.layout.imageview, null);
mImages.add(tmp);
mLinearLayout.addView(tmp);
}
// Button used to start and stop the capture of images when they are deemed great
mStartStopButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mStartStopButton.getText().equals("Start")) {
mGraph.getVariable("startCapture").setValue(true);
mStartStopButton.setText("Stop");
mSpinner.setEnabled(false);
} else {
boolean tmp = (Boolean) mGraph.getVariable("startCapture").getValue();
if (tmp == false) {
return;
}
if (count == numImages - 1)
countHasReachedMax = true;
captureImages();
}
}
});
// Button to open the gallery to show the images in there
Button galleryOpen = (Button) findViewById(R.id.galleryOpenButton);
galleryOpen.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent openGalleryIntent = new Intent(Intent.ACTION_MAIN);
openGalleryIntent.addCategory(Intent.CATEGORY_APP_GALLERY);
startActivity(openGalleryIntent);
}
});
loadGraph();
mGraph.getVariable("startCapture").setValue(false);
runGraph();
}
use of android.view.SurfaceView in project android_frameworks_base by crdroidandroid.
the class MffContext method createDummySurfaceView.
@SuppressWarnings("deprecation")
private SurfaceView createDummySurfaceView(Context context) {
// This is only called on Gingerbread devices, so deprecation warning is unnecessary.
SurfaceView dummySurfaceView = new SurfaceView(context);
dummySurfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
// If we have an activity for this context we'll add the SurfaceView to it (as a 1x1 view
// in the top-left corner). If not, we warn the user that they may need to add one manually.
Activity activity = findActivityForContext(context);
if (activity != null) {
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1, 1);
activity.addContentView(dummySurfaceView, params);
} else {
Log.w("MffContext", "Could not find activity for dummy surface! Consider specifying " + "your own SurfaceView!");
}
return dummySurfaceView;
}
use of android.view.SurfaceView in project android_frameworks_base by crdroidandroid.
the class SurfaceHolderTarget method onBindToView.
@Override
public void onBindToView(View view) {
if (view instanceof SurfaceView) {
SurfaceHolder holder = ((SurfaceView) view).getHolder();
if (holder == null) {
throw new RuntimeException("Could not get SurfaceHolder from SurfaceView " + view + "!");
}
setSurfaceHolder(holder);
} else {
throw new IllegalArgumentException("View must be a SurfaceView!");
}
}
Aggregations