|
@@ -24,45 +24,39 @@ |
24 |
24 |
|
import com.gwtmobile.ui.client.event.*; |
25 |
25 |
|
import com.gwtmobile.ui.client.page.*; |
26 |
26 |
|
|
27 |
|
- |
public class FileTransferUi extends Page |
28 |
|
- |
{ |
|
27 |
+ |
public class FileTransferUi extends Page { |
29 |
28 |
|
|
30 |
|
- |
@UiField HTML text; |
31 |
|
- |
private static FileTransferUiUiBinder uiBinder = GWT.create( FileTransferUiUiBinder.class ); |
32 |
|
- |
|
33 |
|
- |
interface FileTransferUiUiBinder extends UiBinder<Widget, FileTransferUi> |
34 |
|
- |
{ |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
public FileTransferUi() { |
38 |
|
- |
initWidget(uiBinder.createAndBindUi(this)); |
39 |
|
- |
} |
|
29 |
+ |
@UiField HTML text; |
|
30 |
+ |
private static FileTransferUiUiBinder uiBinder = GWT.create( FileTransferUiUiBinder.class ); |
|
31 |
+ |
|
|
32 |
+ |
interface FileTransferUiUiBinder extends UiBinder<Widget, FileTransferUi> { |
|
33 |
+ |
} |
|
34 |
+ |
|
|
35 |
+ |
public FileTransferUi() { |
|
36 |
+ |
initWidget( uiBinder.createAndBindUi( this ) ); |
|
37 |
+ |
} |
40 |
38 |
|
|
41 |
39 |
|
@UiHandler("list") |
42 |
|
- |
void onListSelectionChanged(SelectionChangedEvent e) { |
43 |
|
- |
switch (e.getSelection()) { |
44 |
|
- |
case 0: |
45 |
|
- |
transferFile(); |
46 |
|
- |
break; |
47 |
|
- |
} |
|
40 |
+ |
void onListSelectionChanged( SelectionChangedEvent e ) { |
|
41 |
+ |
switch ( e.getSelection() ) { |
|
42 |
+ |
case 0: |
|
43 |
+ |
transferFile(); |
|
44 |
+ |
break; |
|
45 |
+ |
} |
48 |
46 |
|
} |
49 |
47 |
|
|
50 |
48 |
|
void transferFile() { |
51 |
|
- |
Camera.getPicture( new Camera.Callback() |
52 |
|
- |
{ |
|
49 |
+ |
Camera.getPicture( new Camera.Callback() { |
53 |
50 |
|
|
54 |
51 |
|
@Override |
55 |
|
- |
public void onSuccess( String imageData ) |
56 |
|
- |
{ |
|
52 |
+ |
public void onSuccess( String imageData ) { |
57 |
53 |
|
String serverUrl = "http://gwtmobile-services.appspot.com/filetransfer"; |
58 |
54 |
|
FileTransfer ft = FileMgr.newFileTransfer(); |
59 |
55 |
|
final String lb = "<br/>"; |
60 |
56 |
|
Notification.activityStart( "Uploading", "Hang in there..." ); |
61 |
|
- |
ft.upload( imageData, serverUrl, new FileTransferCallback() |
62 |
|
- |
{ |
|
57 |
+ |
ft.upload( imageData, serverUrl, new FileTransferCallback() { |
63 |
58 |
|
@Override |
64 |
|
- |
public void onSuccess( FileTransferResult result ) |
65 |
|
- |
{ |
|
59 |
+ |
public void onSuccess( FileTransferResult result ) { |
66 |
60 |
|
Notification.activityStop(); |
67 |
61 |
|
text.setHTML( "response code: " + result.getResponseCode() + lb + |
68 |
62 |
|
"bytes sent: " + result.getBytesSent() + lb + |
|
@@ -70,17 +64,16 @@ |
70 |
64 |
|
} |
71 |
65 |
|
|
72 |
66 |
|
@Override |
73 |
|
- |
public void onError( FileTransferError error ) |
74 |
|
- |
{ |
|
67 |
+ |
public void onError( FileTransferError error ) { |
75 |
68 |
|
Notification.activityStop(); |
76 |
69 |
|
text.setHTML( error.getCode().toString() ); |
77 |
70 |
|
} |
78 |
|
- |
}, FileTransferOptions.newInstance().fileKey( "file" ).fileName( imageData.substring( imageData.lastIndexOf( '/' ) + 1 ) ).mimeType( "image/jpeg" ) ); |
|
71 |
+ |
}, FileTransferOptions.newInstance().fileKey( "file" ).fileName( imageData.substring( imageData.lastIndexOf( '/' ) + 1 ) ) |
|
72 |
+ |
.mimeType( "image/jpeg" ) ); |
79 |
73 |
|
} |
80 |
74 |
|
|
81 |
75 |
|
@Override |
82 |
|
- |
public void onError( String message ) |
83 |
|
- |
{ |
|
76 |
+ |
public void onError( String message ) { |
84 |
77 |
|
text.setHTML( "Error: " + message ); |
85 |
78 |
|
} |
86 |
79 |
|
}, new Camera.Options().quality( 50 ).sourceType( SourceType.CAMERA ).destinationType( DestinationType.FILE_URI ).allowEdit( false ) ); |