Chromium Code Reviews| Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/MainActivity.java |
| diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/MainActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/MainActivity.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..87ea3e6108edaaba84388ffe2438744d50e3a797 |
| --- /dev/null |
| +++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/MainActivity.java |
| @@ -0,0 +1,52 @@ |
| +package org.skia.viewer; |
| + |
| +import android.app.Activity; |
| +import android.support.v7.app.ActionBarActivity; |
|
djsollen
2016/05/06 18:45:26
This class has been deprecated and I don't think w
liyuqian
2016/05/06 20:42:30
Done.
|
| +import android.os.Bundle; |
| +import android.util.Log; |
| +import android.view.Surface; |
| +import android.view.SurfaceHolder; |
| +import android.view.SurfaceView; |
| +import android.view.View; |
| +import android.widget.Button; |
| +import android.widget.RelativeLayout; |
| + |
| +public class MainActivity extends ActionBarActivity implements SurfaceHolder.Callback { |
| + private SurfaceView mView; |
| + private long mNativeHandle = 0; // the pointer to the native AppThread object |
| + |
| + private native void onSurfaceCreated(long handle, Surface surface); |
| + private native void onSurfaceChanged(long handle, Surface surface); |
| + private native void onSurfaceDestroyed(long handle); |
| + |
| + @Override |
| + protected void onCreate(Bundle savedInstanceState) { |
| + super.onCreate(savedInstanceState); |
| + setContentView(R.layout.activity_main); |
| + |
| + mNativeHandle = ((ViewerApplication) getApplication()).getNativeHandle(); |
|
djsollen
2016/05/06 18:45:26
don't store this variable locally when you can jus
liyuqian
2016/05/06 20:42:30
Done.
|
| + mView = (SurfaceView) findViewById(R.id.surfaceView); |
| + mView.getHolder().addCallback(this); |
| + } |
| + |
| + @Override |
| + public void surfaceCreated(SurfaceHolder holder) { |
| + if (mNativeHandle != 0) { |
| + onSurfaceCreated(mNativeHandle, holder.getSurface()); |
| + } |
| + } |
| + |
| + @Override |
| + public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
| + if (mNativeHandle != 0) { |
| + onSurfaceChanged(mNativeHandle, holder.getSurface()); |
| + } |
| + } |
| + |
| + @Override |
| + public void surfaceDestroyed(SurfaceHolder holder) { |
| + if (mNativeHandle != 0) { |
| + onSurfaceDestroyed(mNativeHandle); |
| + } |
| + } |
| +} |