commit 722c6ed3e6dcf73936957e285514a80f9bcbd828
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Wed Feb 15 14:37:42 2017 +0000

    Improve Olimpic.

diff --git a/src/main/java/org/distorted/examples/olimpic/OlimpicActivity.java b/src/main/java/org/distorted/examples/olimpic/OlimpicActivity.java
index 3042e97..b5fa4c3 100644
--- a/src/main/java/org/distorted/examples/olimpic/OlimpicActivity.java
+++ b/src/main/java/org/distorted/examples/olimpic/OlimpicActivity.java
@@ -19,25 +19,35 @@
 
 package org.distorted.examples.olimpic;
 
+import org.distorted.examples.R;
 import org.distorted.library.Distorted;
 
 import android.app.Activity;
+import android.opengl.GLSurfaceView;
 import android.os.Bundle;
+import android.widget.TextView;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class OlimpicActivity extends Activity 
 {
-    private OlimpicSurfaceView mView;
+    private TextView mText;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-    
+
+    void setText(String text)
+      {
+      mText.setText(text);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
     @Override
     protected void onCreate(Bundle icicle) 
       {
       super.onCreate(icicle);
-      mView = new OlimpicSurfaceView(this);
-      setContentView(mView);
+      setContentView(R.layout.olimpiclayout);
+      mText = (TextView)findViewById(R.id.olimpicText);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,7 +55,8 @@ public class OlimpicActivity extends Activity
     @Override
     protected void onPause() 
       {
-      mView.onPause();  
+      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
+      view.onPause();
       super.onPause();
       }
 
@@ -55,7 +66,8 @@ public class OlimpicActivity extends Activity
     protected void onResume() 
       {
       super.onResume();
-      mView.onResume();
+      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.olimpicSurfaceView);
+      view.onResume();
       }
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java b/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
index 3cc2a51..34942d7 100644
--- a/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
+++ b/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
@@ -38,6 +38,7 @@ import org.distorted.library.type.Static1D;
 import org.distorted.library.Distorted;
 import org.distorted.library.DistortedTexture;
 
+import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.opengl.GLES30;
@@ -130,7 +131,16 @@ class OlimpicRenderer implements GLSurfaceView.Renderer
       if( mCurrRendered!=mPrevRendered )
         {
         mPrevRendered = mCurrRendered;
-        android.util.Log.d("Olympic", "rendered: "+mCurrRendered+" objects");
+
+        final OlimpicActivity act = (OlimpicActivity)mView.getContext();
+
+        act.runOnUiThread(new Runnable()
+          {
+          public void run()
+            {
+            act.setText("rendered: "+mCurrRendered+" objects");
+            }
+          });
         }
       }
 
diff --git a/src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java b/src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java
index fa76abc..8b56aab 100644
--- a/src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java
+++ b/src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java
@@ -23,6 +23,7 @@ import android.app.ActivityManager;
 import android.content.Context;
 import android.content.pm.ConfigurationInfo;
 import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -30,14 +31,18 @@ class OlimpicSurfaceView extends GLSurfaceView
 {
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-    public OlimpicSurfaceView(Context context) 
+    public OlimpicSurfaceView(Context context, AttributeSet attrs)
       {
-      super(context);
-      final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
-      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
-      android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
-      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
-      setRenderer(new OlimpicRenderer(this));
+      super(context,attrs);
+
+      if(!isInEditMode())
+        {
+        final ActivityManager activityManager     = (android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
+        android.util.Log.e("View", "Using OpenGL ES "+configurationInfo.getGlEsVersion());
+        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
+        setRenderer(new OlimpicRenderer(this));
+        }
       }
 }
 
diff --git a/src/main/res/layout/olimpiclayout.xml b/src/main/res/layout/olimpiclayout.xml
new file mode 100644
index 0000000..611eab6
--- /dev/null
+++ b/src/main/res/layout/olimpiclayout.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <org.distorted.examples.olimpic.OlimpicSurfaceView
+        android:id="@+id/olimpicSurfaceView"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:id="@+id/linearLayout1"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center|fill_horizontal"
+        android:orientation="vertical" >
+
+        <TextView
+                android:id="@+id/olimpicText"
+                android:layout_width="fill_parent"
+                android:layout_height="0dp"
+                android:layout_weight="0.5"
+                android:gravity="center_vertical|center"
+                android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    </LinearLayout>
+
+</LinearLayout>
