summaryrefslogtreecommitdiff
path: root/android/src/org/rockbox/RockboxActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/src/org/rockbox/RockboxActivity.java')
-rw-r--r--android/src/org/rockbox/RockboxActivity.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java
index 6226455deb..f775597d30 100644
--- a/android/src/org/rockbox/RockboxActivity.java
+++ b/android/src/org/rockbox/RockboxActivity.java
@@ -32,6 +32,7 @@ import android.view.WindowManager;
32public class RockboxActivity extends Activity 32public class RockboxActivity extends Activity
33{ 33{
34 private ProgressDialog loadingdialog; 34 private ProgressDialog loadingdialog;
35 private RockboxService rbservice;
35 /** Called when the activity is first created. */ 36 /** Called when the activity is first created. */
36 @Override 37 @Override
37 public void onCreate(Bundle savedInstanceState) 38 public void onCreate(Bundle savedInstanceState)
@@ -40,8 +41,7 @@ public class RockboxActivity extends Activity
40 requestWindowFeature(Window.FEATURE_NO_TITLE); 41 requestWindowFeature(Window.FEATURE_NO_TITLE);
41 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN 42 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
42 ,WindowManager.LayoutParams.FLAG_FULLSCREEN); 43 ,WindowManager.LayoutParams.FLAG_FULLSCREEN);
43 final Intent intent = new Intent(this, 44 final Intent intent = new Intent(this, RockboxService.class);
44 RockboxService.class);
45 /* prepare a please wait dialog in case we need 45 /* prepare a please wait dialog in case we need
46 * to wait for unzipping libmisc.so 46 * to wait for unzipping libmisc.so
47 */ 47 */
@@ -50,6 +50,7 @@ public class RockboxActivity extends Activity
50 loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 50 loadingdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
51 loadingdialog.setCancelable(false); 51 loadingdialog.setCancelable(false);
52 startService(intent); 52 startService(intent);
53 rbservice = RockboxService.get_instance();
53 /* Now it gets a bit tricky: 54 /* Now it gets a bit tricky:
54 * The service is started in the same thread as we are now, 55 * The service is started in the same thread as we are now,
55 * but the service also initializes the framebuffer 56 * but the service also initializes the framebuffer
@@ -68,8 +69,8 @@ public class RockboxActivity extends Activity
68 while (true) 69 while (true)
69 { 70 {
70 Thread.sleep(250); 71 Thread.sleep(250);
71 if (RockboxService.fb != null) 72 if (isRockboxRunning())
72 break; 73 break;
73 /* if it's still null show the please wait dialog 74 /* if it's still null show the please wait dialog
74 * but not before 0.5s are over */ 75 * but not before 0.5s are over */
75 if (!loadingdialog.isShowing() && i > 0) 76 if (!loadingdialog.isShowing() && i > 0)
@@ -92,32 +93,37 @@ public class RockboxActivity extends Activity
92 { 93 {
93 public void run() { 94 public void run() {
94 loadingdialog.dismiss(); 95 loadingdialog.dismiss();
95 if (RockboxService.fb == null) 96 if (rbservice.get_fb() == null)
96 throw new IllegalStateException("FB NULL"); 97 throw new IllegalStateException("FB NULL");
97 setContentView(RockboxService.fb); 98 setContentView(rbservice.get_fb());
98 RockboxService.fb.invalidate(); 99 rbservice.get_fb().invalidate();
99 } 100 }
100 }); 101 });
101 } 102 }
102 }).start(); 103 }).start();
103 } 104 }
105 private boolean isRockboxRunning()
106 {
107 if (rbservice == null)
108 rbservice = RockboxService.get_instance();
109 return (rbservice!= null && rbservice.isRockboxRunning() == true);
110 }
104 111
105 public void onResume() 112 public void onResume()
106 { 113 {
107 super.onResume(); 114 super.onResume();
108 115 if (isRockboxRunning())
109 if (RockboxService.fb != null)
110 { 116 {
111 try { 117 try {
112 setContentView(RockboxService.fb); 118 setContentView(rbservice.get_fb());
113 } catch (IllegalStateException e) { 119 } catch (IllegalStateException e) {
114 /* we are already using the View, 120 /* we are already using the View,
115 * need to remove it and re-attach it */ 121 * need to remove it and re-attach it */
116 ViewGroup g = (ViewGroup)RockboxService.fb.getParent(); 122 ViewGroup g = (ViewGroup)rbservice.get_fb().getParent();
117 g.removeView(RockboxService.fb); 123 g.removeView(rbservice.get_fb());
118 setContentView(RockboxService.fb); 124 setContentView(rbservice.get_fb());
119 } finally { 125 } finally {
120 RockboxService.fb.resume(); 126 rbservice.get_fb().resume();
121 } 127 }
122 } 128 }
123 } 129 }
@@ -129,20 +135,20 @@ public class RockboxActivity extends Activity
129 protected void onPause() 135 protected void onPause()
130 { 136 {
131 super.onPause(); 137 super.onPause();
132 RockboxService.fb.suspend(); 138 rbservice.get_fb().suspend();
133 } 139 }
134 140
135 @Override 141 @Override
136 protected void onStop() 142 protected void onStop()
137 { 143 {
138 super.onStop(); 144 super.onStop();
139 RockboxService.fb.suspend(); 145 rbservice.get_fb().suspend();
140 } 146 }
141 147
142 @Override 148 @Override
143 protected void onDestroy() 149 protected void onDestroy()
144 { 150 {
145 super.onDestroy(); 151 super.onDestroy();
146 RockboxService.fb.suspend(); 152 rbservice.get_fb().suspend();
147 } 153 }
148} \ No newline at end of file 154}