1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.cts.verifier.projection.cube; 18 19 import android.content.Context; 20 import android.opengl.GLSurfaceView; 21 import android.os.Bundle; 22 import android.view.Display; 23 import android.view.MotionEvent; 24 import android.view.View; 25 import android.view.View.OnTouchListener; 26 27 import com.android.cts.verifier.R; 28 import com.android.cts.verifier.projection.ProjectedPresentation; 29 30 31 32 /** 33 * Render tumbling cubes 34 * 35 */ 36 public class CubePresentation extends ProjectedPresentation { 37 public CubePresentation(Context context, Display display) { 38 super(context, display); 39 } 40 41 @Override 42 protected void onCreate(Bundle savedInstanceState) { 43 super.onCreate(savedInstanceState); 44 View view = getLayoutInflater().inflate(R.layout.pca_cubes, null); 45 setContentView(view); 46 47 GLSurfaceView cubeView = (GLSurfaceView) view.findViewById(R.id.cube_view); 48 final CubeRenderer renderer = new CubeRenderer(true); 49 cubeView.setRenderer(renderer); 50 51 cubeView.setOnTouchListener(new OnTouchListener() { 52 53 @Override 54 public boolean onTouch(View view, MotionEvent event) { 55 renderer.explode(); 56 return true; 57 } 58 }); 59 } 60 } 61