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
17package com.google.android.car.kitchensink.cube;
18
19import android.opengl.GLSurfaceView;
20import android.os.Bundle;
21import android.support.v4.app.Fragment;
22import android.view.LayoutInflater;
23import android.view.MotionEvent;
24import android.view.View;
25import android.view.ViewGroup;
26
27import com.google.android.car.kitchensink.R;
28
29public 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