Style and unused code cleanup.

This commit is contained in:
James Sanford 2012-10-23 16:40:46 -07:00
parent 47d896ec95
commit 0e2ec5d590
8 changed files with 32 additions and 26 deletions

View File

@ -79,7 +79,7 @@ class BitmapThread extends Thread {
mRectSrc = new Rect(bitmapSize.getRectSrc());
mRectDst = new Rect(bitmapSize.getRectDst());
mSurfaceLock.unlock();
updateScreen(); // Note: UI thread.
updateScreen(); // NOTE: UI thread.
}
public void setHaveSurface(boolean haveSurface) {
@ -89,7 +89,7 @@ class BitmapThread extends Thread {
if (haveSurface) {
// Refresh the canvas when we obtain a surface.
updateScreen(); // Note: UI thread.
updateScreen(); // NOTE: UI thread.
}
}
}

View File

@ -28,7 +28,7 @@ public class CopyHelper {
//
// Caller could check for final file name.
public void copy() throws java.io.IOException {
Log.e("kegs", "CopyHelper to " + mDir + "/" + mFile);
Log.i("kegs", "CopyHelper to " + mDir + "/" + mFile);
final File dir = new File(mDir);
dir.mkdirs();

View File

@ -9,7 +9,6 @@ import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.AsyncTask;
import android.util.Log;
@ -155,7 +154,9 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
} else {
mConfigFile.defaultConfig();
getThread().setReady(true);
mKegsView.postDelayed(new Runnable() { public void run() { new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE); } }, 1000);
mKegsView.postDelayed(new Runnable() { public void run() {
new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE);
} }, 1000);
}
}
}
@ -173,7 +174,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
}
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false); // lame
dialog.setCanceledOnTouchOutside(false);
return dialog;
}
@ -189,7 +190,6 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(getResources().getText(R.string.rom_error));
// TODO do getActivity().finish() on button clicks
// TODO setCanceledOnTouchOutside(false) ? otherwise can accidentally dismiss the error.
return builder.create();
}
@ -386,7 +386,9 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
public void onSizeChanged(final int w, final int h, int oldw, int oldh) {
final long now = System.currentTimeMillis();
mScreenSizeTime = now;
mKegsView.postDelayed(new Runnable() { public void run() { updateScreenSize(w, h, now); } }, 250);
mKegsView.postDelayed(new Runnable() { public void run() {
updateScreenSize(w, h, now);
} }, 250);
}
}
);
@ -414,7 +416,9 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset, Asse
} else {
mConfigFile.defaultConfig();
getThread().setReady(true);
mKegsView.postDelayed(new Runnable() { public void run() { new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE); } }, 1000);
mKegsView.postDelayed(new Runnable() { public void run() {
new DiskImageFragment().show(getFragmentManager(), FRAGMENT_DISKIMAGE);
} }, 1000);
}
}

View File

@ -15,9 +15,9 @@ import android.opengl.GLUtils;
import android.opengl.GLSurfaceView;
class KegsRenderer implements GLSurfaceView.Renderer {
public static final int TextureWidth = 1024;
public static final int TextureHeight = 512;
private Bitmap mBitmap;
private static final int mTexWidth = 1024;
private static final int mTexHeight = 512;
// Buffer holding the vertices
final FloatBuffer mVertexBuffer;
@ -116,21 +116,18 @@ class KegsRenderer implements GLSurfaceView.Renderer {
checkGlError(gl, "surfaceCreatedA0");
Bitmap blank = Bitmap.createBitmap(mTexWidth, mTexHeight, Bitmap.Config.RGB_565);
Bitmap blank = Bitmap.createBitmap(TextureWidth,
TextureHeight,
Bitmap.Config.RGB_565);
int[] textures = new int[2];
gl.glGenTextures(2, textures, 0);
checkGlError(gl, "surfaceCreatedGen");
mTexId = textures[0]; // FIXME
mTexId = textures[0];
mTexId2 = textures[1];
mTexLast = 1;
mTexIdOK = true;
int[] crop = new int [4];
crop[0] = 0;
crop[1] = mTexHeight;
crop[2] = mTexWidth;
crop[3] = -mTexHeight;
for(int i=0; i < 2; i++) {
gl.glBindTexture(gl.GL_TEXTURE_2D, textures[i]);
// gl.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
@ -176,7 +173,9 @@ class KegsRenderer implements GLSurfaceView.Renderer {
// gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
// GL10.GL_MODULATE);
gl.glClearColor(0.643f, 0.776f, 0.223f, 1.0f); // Green color for testing.
gl.glClearColor(0f, 0f, 0f, 1.0f); // Black.
// Testing: This green color is useful for testing beyond the texture area.
// gl.glClearColor(0.643f, 0.776f, 0.223f, 1.0f); // Green.
gl.glClear(gl.GL_COLOR_BUFFER_BIT);
gl.glLoadIdentity();
@ -185,7 +184,7 @@ class KegsRenderer implements GLSurfaceView.Renderer {
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureBuffer);
gl.glScalef(mTexWidth, mTexHeight, 0.0f);
gl.glScalef(TextureWidth, TextureHeight, 0.0f);
if (mScaled) {
// Additional scale on top of earlier scale.
gl.glScalef(mScaleX, mScaleY, 0.0f);
@ -200,13 +199,13 @@ class KegsRenderer implements GLSurfaceView.Renderer {
private void checkGlError(GL10 gl, String op) {
int error;
while ((error = gl.glGetError()) != GL10.GL_NO_ERROR) {
Log.e("kegsgl", op + ": glError " + error);
Log.e("kegs", op + ": glError " + error);
throw new RuntimeException(op + ": glError " + error);
}
}
public void updateScreenSize(BitmapSize bitmapSize) {
// There should probably be a lock surrounding updating these.
// TODO: There should probably be a lock surrounding updating these.
mWidth = bitmapSize.getViewWidth();
mHeight = bitmapSize.getViewHeight();
mScaleX = bitmapSize.getScaleX();
@ -214,6 +213,6 @@ class KegsRenderer implements GLSurfaceView.Renderer {
mCropBorder = bitmapSize.doCropBorder();
mScaled = bitmapSize.isScaled();
mSizeChange = true;
Log.e("kegs", "screen size " + mWidth + "x" + mHeight + " " + mScaleX + ":" + mScaleY + " crop=" + mCropBorder);
Log.i("kegs", "screen size " + mWidth + "x" + mHeight + " " + mScaleX + ":" + mScaleY + " crop=" + mCropBorder);
}
}

View File

@ -19,7 +19,8 @@ class KegsViewGL extends GLSurfaceView implements KegsThread.UpdateScreen {
public KegsViewGL(Context context, AttributeSet attrs) {
super(context, attrs);
Bitmap bitmap = Bitmap.createBitmap(1024, 512, // OpenGL FIXME
Bitmap bitmap = Bitmap.createBitmap(KegsRenderer.TextureWidth,
KegsRenderer.TextureHeight,
Bitmap.Config.RGB_565);
mBitmap = bitmap;

View File

@ -26,7 +26,7 @@ public class RomDialogFragment extends DialogFragment {
}
});
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false); // lame
dialog.setCanceledOnTouchOutside(false);
return dialog;
}

View File

@ -5,6 +5,8 @@ import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
// A RelativeLayout that sends notifications when its screen size changes.
class SpecialRelativeLayout extends RelativeLayout {
public SpecialRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);

View File

@ -15,7 +15,7 @@ class TouchJoystick {
private ConcurrentLinkedQueue mEventQueue;
private int mTouchSlop;
public int mMotionPointer = -1; // active pointer Id
private int mMotionPointer = -1; // active pointer Id
private int mButton1 = 0; // buttons pressed? lower two bits.
private MotionEvent trackA; // original A down event
private MotionEvent trackB; // original B down event