Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java

Issue 1952323004: Initial commit of our new Android app to demo Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
index 950d6b2d5bee33963b08eb80c37e3034f4235095..48cec39f483d658970297cc17813b460b75dc53b 100644
--- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
+++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
@@ -7,22 +7,48 @@
package org.skia.viewer;
-import android.app.ActionBar;
+import android.app.Activity;
import android.os.Bundle;
-import android.provider.Settings;
-import android.view.View;
-import android.view.WindowManager;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+public class ViewerActivity extends Activity implements SurfaceHolder.Callback {
+ private SurfaceView mView;
+ private ViewerApplication mApplication;
+
+ private native void onSurfaceCreated(long handle, Surface surface);
+ private native void onSurfaceChanged(long handle, Surface surface);
+ private native void onSurfaceDestroyed(long handle);
-public class ViewerActivity extends android.app.NativeActivity {
- static {
- System.loadLibrary("skia_android");
- }
-
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ActionBar ab = this.getActionBar();
- ab.hide();
+ setContentView(R.layout.activity_main);
+
+ mApplication = (ViewerApplication) getApplication();
+ mView = (SurfaceView) findViewById(R.id.surfaceView);
+ mView.getHolder().addCallback(this);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (mApplication.getNativeHandle() != 0) {
+ onSurfaceCreated(mApplication.getNativeHandle(), holder.getSurface());
+ }
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ if (mApplication.getNativeHandle() != 0) {
+ onSurfaceChanged(mApplication.getNativeHandle(), holder.getSurface());
+ }
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ if (mApplication.getNativeHandle() != 0) {
+ onSurfaceDestroyed(mApplication.getNativeHandle());
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698