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