Home | History | Annotate | Download | only in cube
      1 /*
      2  * Copyright (C) 2013 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.google.android.car.kitchensink.cube;
     18 
     19 import android.opengl.GLSurfaceView;
     20 import android.os.Bundle;
     21 import android.support.v4.app.Fragment;
     22 import android.view.LayoutInflater;
     23 import android.view.MotionEvent;
     24 import android.view.View;
     25 import android.view.ViewGroup;
     26 
     27 import com.google.android.car.kitchensink.R;
     28 
     29 public class CubesTestFragment extends Fragment {
     30     private GLSurfaceView mSurfaceView;
     31 
     32     @Override
     33     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
     34         View view = inflater.inflate(R.layout.cubes, container, false);
     35         mSurfaceView = (GLSurfaceView)view.findViewById(R.id.surface_view);
     36         final CubeRenderer renderer = new CubeRenderer(false);
     37         mSurfaceView.setRenderer(renderer);
     38         mSurfaceView.setOnTouchListener(new View.OnTouchListener() {
     39 
     40             @Override
     41             public boolean onTouch(View view, MotionEvent event) {
     42                 renderer.explode();
     43                 return true;
     44             }
     45         });
     46 
     47         return view;
     48     }
     49 
     50     @Override
     51     public void onResume() {
     52         super.onResume();
     53         mSurfaceView.onResume();
     54     }
     55 
     56     @Override
     57     public void onPause() {
     58         super.onPause();
     59         mSurfaceView.onPause();
     60     }
     61 }
     62