Clean up RetroActivityFuture a little. Remove a pointless if statement check (the only Android versions this launches on are the ones that satisfy this condition).
Also misc other cleanup.
This commit is contained in:
parent
f57210cb41
commit
6bdaadb82e
|
@ -9,18 +9,20 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.NativeActivity;
|
import android.app.NativeActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.SurfaceTexture;
|
import android.graphics.SurfaceTexture;
|
||||||
|
import android.graphics.SurfaceTexture.OnFrameAvailableListener;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
//For Android 3.0 and up
|
//For Android 3.0 and up
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public final class RetroActivityFuture extends NativeActivity
|
public final class RetroActivityFuture extends NativeActivity
|
||||||
{
|
{
|
||||||
private Camera mCamera;
|
private Camera mCamera;
|
||||||
private long lastTimestamp = 0;
|
private long lastTimestamp = 0;
|
||||||
private SurfaceTexture texture;
|
private SurfaceTexture texture;
|
||||||
private Boolean updateSurface = true;
|
private boolean updateSurface = true;
|
||||||
private Intent pendingIntent = null;
|
private Intent pendingIntent = null;
|
||||||
|
|
||||||
public void onCameraStart()
|
public void onCameraStart()
|
||||||
|
@ -38,12 +40,11 @@ public final class RetroActivityFuture extends NativeActivity
|
||||||
mCamera = Camera.open();
|
mCamera = Camera.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
public boolean onCameraPoll()
|
public boolean onCameraPoll()
|
||||||
{
|
{
|
||||||
if (texture == null)
|
if (texture == null)
|
||||||
{
|
{
|
||||||
Log.i("RetroActivity", "no texture");
|
Log.i("RetroActivity", "No texture");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
|
@ -72,35 +73,27 @@ public final class RetroActivityFuture extends NativeActivity
|
||||||
mCamera.release();
|
mCamera.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
public void onCameraTextureInit(int gl_texid)
|
public void onCameraTextureInit(int gl_texid)
|
||||||
{
|
{
|
||||||
texture = new SurfaceTexture(gl_texid);
|
texture = new SurfaceTexture(gl_texid);
|
||||||
texture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
|
texture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
private final OnFrameAvailableListener onCameraFrameAvailableListener = new OnFrameAvailableListener()
|
||||||
private SurfaceTexture.OnFrameAvailableListener onCameraFrameAvailableListener =
|
{
|
||||||
new SurfaceTexture.OnFrameAvailableListener() {
|
@Override
|
||||||
@Override
|
public void onFrameAvailable(SurfaceTexture surfaceTexture)
|
||||||
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
|
{
|
||||||
updateSurface = true;
|
updateSurface = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
public void onCameraSetTexture(int gl_texid) throws IOException
|
public void onCameraSetTexture(int gl_texid) throws IOException
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
if (texture == null)
|
||||||
{
|
onCameraTextureInit(gl_texid);
|
||||||
if (texture == null)
|
|
||||||
onCameraTextureInit(gl_texid);
|
mCamera.setPreviewTexture(texture);
|
||||||
mCamera.setPreviewTexture(texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mCamera.setPreviewDisplay(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,9 +116,9 @@ public final class RetroActivityFuture extends NativeActivity
|
||||||
public void onNewIntent(Intent intent)
|
public void onNewIntent(Intent intent)
|
||||||
{
|
{
|
||||||
Log.i("RetroActivity", "onNewIntent invoked.");
|
Log.i("RetroActivity", "onNewIntent invoked.");
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
setIntent(intent);
|
setIntent(intent);
|
||||||
pendingIntent = intent;
|
pendingIntent = intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPendingIntentFullPath()
|
public String getPendingIntentFullPath()
|
||||||
|
|
Loading…
Reference in New Issue