|
@@ -15,25 +15,92 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package org.litesoft.hello.client; |
17 |
17 |
|
|
18 |
|
- |
import com.google.gwt.core.client.EntryPoint; |
19 |
|
- |
import com.google.gwt.event.dom.client.ClickEvent; |
20 |
|
- |
import com.google.gwt.event.dom.client.ClickHandler; |
21 |
|
- |
import com.google.gwt.user.client.Window; |
22 |
|
- |
import com.google.gwt.user.client.ui.Button; |
23 |
|
- |
import com.google.gwt.user.client.ui.RootPanel; |
|
18 |
+ |
import com.google.gwt.core.client.*; |
|
19 |
+ |
import com.google.gwt.event.dom.client.*; |
|
20 |
+ |
import com.google.gwt.user.client.*; |
|
21 |
+ |
import com.google.gwt.user.client.ui.*; |
|
22 |
+ |
import com.googlecode.gwtphonegap.client.*; |
24 |
23 |
|
|
25 |
24 |
|
/** |
26 |
25 |
|
* HelloWorld application. |
27 |
26 |
|
*/ |
28 |
|
- |
public class Hello implements EntryPoint { |
|
27 |
+ |
public class Hello implements EntryPoint |
|
28 |
+ |
{ |
|
29 |
+ |
private Label mLabel; |
|
30 |
+ |
private int mDecaSecs = 1; |
29 |
31 |
|
|
30 |
|
- |
public void onModuleLoad() { |
31 |
|
- |
Button b = new Button("Click me", new ClickHandler() { |
32 |
|
- |
public void onClick(ClickEvent event) { |
33 |
|
- |
Window.alert("Hello"); |
34 |
|
- |
} |
35 |
|
- |
}); |
|
32 |
+ |
public void onModuleLoad() |
|
33 |
+ |
{ |
|
34 |
+ |
Button b = new Button( "Click me", new ClickHandler() |
|
35 |
+ |
{ |
|
36 |
+ |
public void onClick( ClickEvent event ) |
|
37 |
+ |
{ |
|
38 |
+ |
mDecaSecs += 20; |
|
39 |
+ |
} |
|
40 |
+ |
} ); |
|
41 |
+ |
VerticalPanel zPanel = new VerticalPanel(); |
|
42 |
+ |
zPanel.add( mLabel = new Label( "0" ) ); |
|
43 |
+ |
zPanel.add( new HTML( " " ) ); |
|
44 |
+ |
zPanel.add( new HTML( " " ) ); |
|
45 |
+ |
zPanel.add( new HTML( " " ) ); |
|
46 |
+ |
zPanel.add( new HTML( " " ) ); |
|
47 |
+ |
zPanel.add( new HTML( " " ) ); |
|
48 |
+ |
zPanel.add( b ); |
|
49 |
+ |
RootPanel.get().add( zPanel ); |
36 |
50 |
|
|
37 |
|
- |
RootPanel.get().add(b); |
38 |
|
- |
} |
|
51 |
+ |
GWT.setUncaughtExceptionHandler( new GWT.UncaughtExceptionHandler() |
|
52 |
+ |
{ |
|
53 |
+ |
@Override |
|
54 |
+ |
public void onUncaughtException( Throwable e ) |
|
55 |
+ |
{ |
|
56 |
+ |
Window.alert( "uncaught: " + // e.getLocalizedMessage() ); |
|
57 |
+ |
e.getMessage() ); |
|
58 |
+ |
} |
|
59 |
+ |
} ); |
|
60 |
+ |
|
|
61 |
+ |
final PhoneGap phoneGap = GWT.create( PhoneGap.class ); |
|
62 |
+ |
|
|
63 |
+ |
phoneGap.addHandler( new PhoneGapAvailableHandler() |
|
64 |
+ |
{ |
|
65 |
+ |
@Override |
|
66 |
+ |
public void onPhoneGapAvailable( PhoneGapAvailableEvent event ) |
|
67 |
+ |
{ |
|
68 |
+ |
startShowCase( phoneGap ); |
|
69 |
+ |
} |
|
70 |
+ |
} ); |
|
71 |
+ |
|
|
72 |
+ |
phoneGap.addHandler( new PhoneGapTimeoutHandler() |
|
73 |
+ |
{ |
|
74 |
+ |
@Override |
|
75 |
+ |
public void onPhoneGapTimeout( PhoneGapTimeoutEvent event ) |
|
76 |
+ |
{ |
|
77 |
+ |
Window.alert( "can not load phonegap" ); |
|
78 |
+ |
} |
|
79 |
+ |
} ); |
|
80 |
+ |
|
|
81 |
+ |
new Timer() |
|
82 |
+ |
{ |
|
83 |
+ |
long started = System.currentTimeMillis(); |
|
84 |
+ |
@Override |
|
85 |
+ |
public void run() |
|
86 |
+ |
{ |
|
87 |
+ |
int delay; |
|
88 |
+ |
do { |
|
89 |
+ |
String zText = " " + (mDecaSecs++); |
|
90 |
+ |
zText = zText.substring( zText.length() - 10 ); |
|
91 |
+ |
zText = zText.substring( 0, 9 ) + '.' + zText.substring( 9 ); |
|
92 |
+ |
mLabel.setText( zText ); |
|
93 |
+ |
delay = (int)((started + (mDecaSecs * 100)) - System.currentTimeMillis()); |
|
94 |
+ |
} while (delay < 10); |
|
95 |
+ |
schedule( delay ); |
|
96 |
+ |
} |
|
97 |
+ |
}.schedule( 100 ); |
|
98 |
+ |
|
|
99 |
+ |
phoneGap.initializePhoneGap(); |
|
100 |
+ |
} |
|
101 |
+ |
|
|
102 |
+ |
private void startShowCase( PhoneGap phoneGap ) |
|
103 |
+ |
{ |
|
104 |
+ |
Window.alert( "phonegap ready!" ); |
|
105 |
+ |
} |
39 |
106 |
|
} |