blob: 00e8a5e3560575fdf7bc20daeab132dced909519 [file] [log] [blame]
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -07001/*
2 * Copyright (C) 2008 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.android.modelviewer;
18
19import android.renderscript.RSSurfaceView;
20import android.renderscript.RenderScript;
21
22import android.app.Activity;
23import android.content.res.Configuration;
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080024import android.content.Intent;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070025import android.os.Bundle;
26import android.os.Handler;
27import android.os.Looper;
28import android.os.Message;
29import android.provider.Settings.System;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070030import android.util.Log;
31import android.view.Menu;
32import android.view.MenuItem;
33import android.view.View;
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080034import android.view.MenuInflater;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070035import android.view.Window;
36import android.widget.Button;
37import android.widget.ListView;
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080038import android.net.Uri;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070039
40import java.lang.Runtime;
41
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070042public class SimpleModel extends Activity {
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070043
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070044 private SimpleModelView mView;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070045
46 @Override
47 public void onCreate(Bundle icicle) {
48 super.onCreate(icicle);
49
50 // Create our Preview view and set it as the content of our
51 // Activity
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070052 mView = new SimpleModelView(this);
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070053 setContentView(mView);
54 }
55
56 @Override
57 protected void onResume() {
58 // Ideally a game should implement onResume() and onPause()
59 // to take appropriate action when the activity looses focus
60 super.onResume();
Jason Samsbf6ef8d2010-12-06 15:59:59 -080061 mView.resume();
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070062 }
63
64 @Override
65 protected void onPause() {
66 // Ideally a game should implement onResume() and onPause()
67 // to take appropriate action when the activity looses focus
68 super.onPause();
Jason Samsbf6ef8d2010-12-06 15:59:59 -080069 mView.pause();
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070070 }
71
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080072 @Override
73 public boolean onCreateOptionsMenu(Menu menu) {
74 MenuInflater inflater = getMenuInflater();
75 inflater.inflate(R.menu.loader_menu, menu);
76 return true;
77 }
78
79 @Override
80 public boolean onOptionsItemSelected(MenuItem item) {
81 // Handle item selection
82 switch (item.getItemId()) {
83 case R.id.load_model:
84 loadModel();
85 return true;
86 case R.id.display_options:
87 return true;
88 default:
89 return super.onOptionsItemSelected(item);
90 }
91 }
92
93 private static final int FIND_A3D_MODEL = 10;
94 public void onActivityResult(int requestCode, int resultCode, Intent data) {
95 if (resultCode == RESULT_OK) {
96 if (requestCode == FIND_A3D_MODEL) {
97 Uri selectedImageUri = data.getData();
98 Log.e("Selected Path: ", selectedImageUri.getPath());
99 mView.loadA3DFile(selectedImageUri.getPath());
100 }
101 }
102 }
103
104 public void loadModel() {
105 Intent intent = new Intent();
106 intent.setAction(Intent.ACTION_PICK);
107 intent.setClassName("com.android.modelviewer",
108 "com.android.modelviewer.A3DSelector");
109 startActivityForResult(intent, FIND_A3D_MODEL);
110 }
111
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -0700112}
113