1 package jme3test.android; 2 import android.app.Activity; 3 import android.content.Intent; 4 import android.content.pm.ActivityInfo; 5 import android.os.Bundle; 6 import android.view.View; 7 import android.widget.AdapterView.OnItemClickListener; 8 import android.widget.AdapterView.OnItemSelectedListener; 9 import android.widget.*; 10 import java.util.ArrayList; 11 import java.util.List; 12 13 public class DemoMainActivity extends Activity { 14 15 /** Called when the activity is first created. */ 16 @Override onCreate(Bundle savedInstanceState)17 public void onCreate(Bundle savedInstanceState) { 18 super.onCreate(savedInstanceState); 19 setContentView(R.layout.main); 20 21 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 22 23 final Intent myIntent = new Intent(DemoMainActivity.this, DemoAndroidHarness.class); 24 25 //Next create the bundle and initialize it 26 final Bundle bundle = new Bundle(); 27 28 29 final Spinner spinnerConfig = (Spinner) findViewById(R.id.spinnerConfig); 30 ArrayAdapter<CharSequence> adapterDropDownConfig = ArrayAdapter.createFromResource( 31 this, R.array.eglconfig_array, android.R.layout.simple_spinner_item); 32 adapterDropDownConfig.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 33 spinnerConfig.setAdapter(adapterDropDownConfig); 34 35 36 spinnerConfig.setOnItemSelectedListener(new OnItemSelectedListener() { 37 38 @Override 39 public void onItemSelected(AdapterView<?> parent, 40 View view, int pos, long id) { 41 Toast.makeText(parent.getContext(), "Set EGLConfig " + 42 parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); 43 //Add the parameters to bundle as 44 bundle.putString("EGLCONFIG", parent.getItemAtPosition(pos).toString()); 45 } 46 47 public void onNothingSelected(AdapterView parent) { 48 // Do nothing. 49 } 50 }); 51 52 53 final Spinner spinnerLogging = (Spinner) findViewById(R.id.spinnerLogging); 54 ArrayAdapter<CharSequence> adapterDropDownLogging = ArrayAdapter.createFromResource( 55 this, R.array.logging_array, android.R.layout.simple_spinner_item); 56 adapterDropDownLogging.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 57 spinnerLogging.setAdapter(adapterDropDownLogging); 58 59 60 spinnerLogging.setOnItemSelectedListener(new OnItemSelectedListener() { 61 62 @Override 63 public void onItemSelected(AdapterView<?> parent, 64 View view, int pos, long id) { 65 Toast.makeText(parent.getContext(), "Set Logging " + 66 parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); 67 68 //Add the parameters to bundle as 69 bundle.putBoolean("VERBOSE", parent.getItemAtPosition(pos).toString().equals("Verbose")); 70 } 71 72 public void onNothingSelected(AdapterView parent) { 73 // Do nothing. 74 } 75 }); 76 77 78 ListView list = (ListView) findViewById(R.id.ListView01); 79 list.setClickable(true); 80 81 final List<DemoLaunchEntry> listDemos = new ArrayList<DemoLaunchEntry>(); 82 83 listDemos.add(new DemoLaunchEntry("jme3test.android.SimpleTexturedTest", "An field of textured boxes rotating")); 84 listDemos.add(new DemoLaunchEntry("jme3test.android.TestSkyLoadingLagoon", "Sky box demonstration with jpg")); 85 listDemos.add(new DemoLaunchEntry("jme3test.android.TestSkyLoadingPrimitives", "Sky box demonstration with png")); 86 listDemos.add(new DemoLaunchEntry("jme3test.android.TestBumpModel", "Shows a bump mapped well with a moving light")); 87 listDemos.add(new DemoLaunchEntry("jme3test.android.TestNormalMapping", "Shows a normal mapped sphere")); 88 listDemos.add(new DemoLaunchEntry("jme3test.android.TestUnshadedModel", "Shows an unshaded model of the sphere")); 89 listDemos.add(new DemoLaunchEntry("jme3test.android.TestMovingParticle", "Demonstrates particle effects")); 90 listDemos.add(new DemoLaunchEntry("jme3test.android.TestAmbient", "Positional sound - You sit in a dark cave under a waterfall")); 91 92 //listDemos.add(new DemoLaunchEntry("jme3test.effect.TestParticleEmitter", "")); 93 //listDemos.add(new DemoLaunchEntry("jme3test.effect.TestPointSprite", "")); 94 //listDemos.add(new DemoLaunchEntry("jme3test.light.TestLightRadius", "")); 95 listDemos.add(new DemoLaunchEntry("jme3test.android.TestMotionPath", "Shows cinematics - see a teapot on its journey - model loading needs a long time - just let it load, looks like freezed")); 96 //listDemos.add(new DemoLaunchEntry("com.jme3.androiddemo.TestSimpleWater", "Post processors - not working correctly due to missing framebuffer support, looks interresting :)")); 97 //listDemos.add(new DemoLaunchEntry("jme3test.model.TestHoverTank", "")); 98 //listDemos.add(new DemoLaunchEntry("jme3test.niftygui.TestNiftyGui", "")); 99 //listDemos.add(new DemoLaunchEntry("com.jme3.androiddemo.TestNiftyGui", "")); 100 101 102 DemoLaunchAdapter adapterList = new DemoLaunchAdapter(this, listDemos); 103 104 list.setOnItemClickListener(new OnItemClickListener() { 105 106 @Override 107 public void onItemClick(AdapterView<?> arg0, View view, int position, long index) { 108 System.out.println("onItemClick"); 109 showToast(listDemos.get(position).getName()); 110 111 112 //Add the parameters to bundle as 113 bundle.putString("APPCLASSNAME", listDemos.get(position).getName()); 114 115 //Add this bundle to the intent 116 myIntent.putExtras(bundle); 117 118 //Start the JME3 app harness activity 119 DemoMainActivity.this.startActivity(myIntent); 120 121 } 122 }); 123 124 list.setAdapter(adapterList); 125 } 126 showToast(String message)127 private void showToast(String message) { 128 Toast.makeText(this, message, Toast.LENGTH_LONG).show(); 129 } 130 } 131 132