comparison android-project/src/org/libsdl/app/SDLActivity.java @ 4998:a514bfe6952a

The window is changed to reflect the actual screen dimensions, for now. Implemented SDL_SetWindowTitle(), which turned out to be fairly complex
author Sam Lantinga <slouken@libsdl.org>
date Thu, 13 Jan 2011 15:10:17 -0800
parents 8d7315668e35
children c66b2a778b7e
comparison
equal deleted inserted replaced
4997:a21501393bef 4998:a514bfe6952a
65 protected void onResume() { 65 protected void onResume() {
66 //Log.v("SDL", "onResume()"); 66 //Log.v("SDL", "onResume()");
67 super.onResume(); 67 super.onResume();
68 } 68 }
69 69
70 // Messages from the SDLMain thread
71 static int COMMAND_CHANGE_TITLE = 1;
72
73 // Handler for the messages
74 Handler commandHandler = new Handler() {
75 public void handleMessage(Message msg) {
76 if (msg.arg1 == COMMAND_CHANGE_TITLE) {
77 setTitle((String)msg.obj);
78 }
79 }
80 };
81
82 // Send a message from the SDLMain thread
83 void sendCommand(int command, Object data) {
84 Message msg = commandHandler.obtainMessage();
85 msg.arg1 = command;
86 msg.obj = data;
87 commandHandler.sendMessage(msg);
88 }
70 89
71 // C functions we call 90 // C functions we call
72 public static native void nativeInit(); 91 public static native void nativeInit();
73 public static native void nativeQuit(); 92 public static native void nativeQuit();
74 public static native void onNativeResize(int x, int y, int format); 93 public static native void onNativeResize(int x, int y, int format);
79 public static native void onNativeAccel(float x, float y, float z); 98 public static native void onNativeAccel(float x, float y, float z);
80 public static native void nativeRunAudioThread(); 99 public static native void nativeRunAudioThread();
81 100
82 101
83 // Java functions called from C 102 // Java functions called from C
84 private static void createGLContext() { 103
104 public static void createGLContext() {
85 mSurface.initEGL(); 105 mSurface.initEGL();
86 } 106 }
87 107
88 public static void flipBuffers() { 108 public static void flipBuffers() {
89 mSurface.flipEGL(); 109 mSurface.flipEGL();
110 }
111
112 public static void setActivityTitle(String title) {
113 // Called from SDLMain() thread and can't directly affect the view
114 mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
90 } 115 }
91 116
92 // Audio 117 // Audio
93 private static Object buf; 118 private static Object buf;
94 119
175 } catch(Exception e) { 200 } catch(Exception e) {
176 Log.v("SDL", "Problem stopping audio thread: " + e); 201 Log.v("SDL", "Problem stopping audio thread: " + e);
177 } 202 }
178 mAudioThread = null; 203 mAudioThread = null;
179 204
180 Log.v("SDL", "Finished waiting for audio thread"); 205 //Log.v("SDL", "Finished waiting for audio thread");
181 } 206 }
182 207
183 if (mAudioTrack != null) { 208 if (mAudioTrack != null) {
184 mAudioTrack.stop(); 209 mAudioTrack.stop();
185 mAudioTrack = null; 210 mAudioTrack = null;