Warning 2 part Question: I am using Gwt Google Picker in an app.
While trying to get the result back I am hitting an error here is my code:
private final static String appId = "ViDemantay";
private final static AppUser appUser = GWT.create(AppUser.class);
private static HandlesMedia handler;
private static GooglePickerCell pickerCell;
private final static AbstractPickerCallback callback = new AbstractPickerCallback(){
@Override
public void onCanceled() {
// TODO Auto-generated method stub
}
@Override
public void onPicked(ViewToken viewToken, BaseResult result) {
$.console.log(result);
DocumentResult docs = result.<DocumentResult>cast();
String mediaUrl = docs.getDocs().get(0).getEmbedUrl();
String thumbnail = docs.getDocs().get(0).getThumbnails().get(0).getUrl();
handler.setMediaUrl(thumbnail);
handler.setMediaUrl(mediaUrl);
$.console.log("The handler is " + handler);
pickerCell.setValue(null, null, handler);
}}; ///////////end callback////////////////////////////
private static Picker picker;
public static void get(){PickerLoader.loadApi(apiKey, new Runnable(){
@Override
public void run() {
appUser.load($(window).prop("appUser"));
picker = PickerBuilder.create().addCallback(callback).setAppId(appId)
.setAuthUser(appUser.getAcctId()).setOAuthToken(appUser.getAuthToken())
.addView(ViewId.DOCS).addView(ViewId.YOUTUBE)
.hideTitleBar().build();
picker.setVisible(false);
}});}
It would seem that the callback is never called back instead on the browser's console I get this error:
TypeError: this$static_0_g$ is undefined
This is what is executed after a file is picked ... but no result.
So my problem was that my callback was final and static . Once I changed it two an anonymous class all was gravy: should be
picker = PickerBuilder.create().addCallback( new AbstractPickerCallback(){
@Override
public void onCanceled() {
// TODO Auto-generated method stub
}
@Override
public void onPicked(ViewToken viewToken, BaseResult result) {
$.console.log(result);
DocumentResult docs = result.<DocumentResult>cast();
String mediaUrl = docs.getDocs().get(0).getEmbedUrl();
String thumbnail = docs.getDocs().get(0).getThumbnails().get(0).getUrl();
handler.setMediaUrl(thumbnail);
handler.setMediaUrl(mediaUrl);
$.console.log("The handler is " + handler);
pickerCell.setValue(null, null, handler);
}})
.setAppId(appId)
.setAuthUser(appUser.getAcctId()).setOAuthToken(appUser.getAuthToken())
.addView(ViewId.DOCS).addView(ViewId.YOUTUBE)
.hideTitleBar().build();
picker.setVisible(false);
So now the result is back... mental note always check for null on the result url or thumbnails.
As far as part two is concerned , Ill be looking into EditableCell implementation because the cell value was changed but the client wasn't updated.