blob: 01cb709962373715aa668452754778f1281162ba [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;
30import android.util.Config;
31import android.util.Log;
32import android.view.Menu;
33import android.view.MenuItem;
34import android.view.View;
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080035import android.view.MenuInflater;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070036import android.view.Window;
37import android.widget.Button;
38import android.widget.ListView;
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080039import android.net.Uri;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070040
41import java.lang.Runtime;
42
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070043public class SimpleModel extends Activity {
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070044
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070045 private SimpleModelView mView;
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070046
47 @Override
48 public void onCreate(Bundle icicle) {
49 super.onCreate(icicle);
50
51 // Create our Preview view and set it as the content of our
52 // Activity
Alex Sakhartchouk32e09b52010-08-23 10:24:10 -070053 mView = new SimpleModelView(this);
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070054 setContentView(mView);
55 }
56
57 @Override
58 protected void onResume() {
59 // Ideally a game should implement onResume() and onPause()
60 // to take appropriate action when the activity looses focus
61 super.onResume();
Jason Samsbf6ef8d2010-12-06 15:59:59 -080062 mView.resume();
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070063 }
64
65 @Override
66 protected void onPause() {
67 // Ideally a game should implement onResume() and onPause()
68 // to take appropriate action when the activity looses focus
69 super.onPause();
Jason Samsbf6ef8d2010-12-06 15:59:59 -080070 mView.pause();
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -070071 }
72
Alex Sakhartchoukdc165b32011-02-16 16:08:49 -080073 @Override
74 public boolean onCreateOptionsMenu(Menu menu) {
75 MenuInflater inflater = getMenuInflater();
76 inflater.inflate(R.menu.loader_menu, menu);
77 return true;
78 }
79
80 @Override
81 public boolean onOptionsItemSelected(MenuItem item) {
82 // Handle item selection
83 switch (item.getItemId()) {
84 case R.id.load_model:
85 loadModel();
86 return true;
87 case R.id.display_options:
88 return true;
89 default:
90 return super.onOptionsItemSelected(item);
91 }
92 }
93
94 private static final int FIND_A3D_MODEL = 10;
95 public void onActivityResult(int requestCode, int resultCode, Intent data) {
96 if (resultCode == RESULT_OK) {
97 if (requestCode == FIND_A3D_MODEL) {
98 Uri selectedImageUri = data.getData();
99 Log.e("Selected Path: ", selectedImageUri.getPath());
100 mView.loadA3DFile(selectedImageUri.getPath());
101 }
102 }
103 }
104
105 public void loadModel() {
106 Intent intent = new Intent();
107 intent.setAction(Intent.ACTION_PICK);
108 intent.setClassName("com.android.modelviewer",
109 "com.android.modelviewer.A3DSelector");
110 startActivityForResult(intent, FIND_A3D_MODEL);
111 }
112
Alex Sakhartchoukaae74ad2010-06-04 10:06:50 -0700113}
114