use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class FaceBookAccess method getFaceBookObject.
/**
* This method returns immediately and will call the callback when it returns with
* the FaceBook Object data.
*
* @param faceBookId the object id that we would like to query
* @param callback the callback that should be updated when the data arrives
* @param needToken if true authentication is being checked
*/
public void getFaceBookObject(String faceBookId, final ActionListener callback, boolean needToken, boolean async) throws IOException {
if (needToken) {
checkAuthentication();
}
final FacebookRESTService con = new FacebookRESTService(token, faceBookId, "", false);
con.addResponseListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (!con.isAlive()) {
return;
}
if (callback != null) {
callback.actionPerformed(evt);
}
}
});
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
}
current = con;
if (async) {
NetworkManager.getInstance().addToQueue(con);
} else {
NetworkManager.getInstance().addToQueueAndWait(con);
}
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class FaceBookAccess method postLike.
/**
* Post like on a given post
*
* @param postId the post Id
*/
public void postLike(String postId, ActionListener callback) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, postId, FacebookRESTService.LIKES, true);
con.addResponseListener(new Listener(con, callback));
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
}
current = con;
NetworkManager.getInstance().addToQueueAndWait(con);
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class FaceBookAccess method getFaceBookObject.
/**
* This method returns immediately and will call the callback when it returns with
* the FaceBook Object data.
*
* @param faceBookId the object id that we would like to query
* @param callback the callback that should be updated when the data arrives
*/
public void getFaceBookObject(String faceBookId, final ActionListener callback) throws IOException {
checkAuthentication();
final FacebookRESTService con = new FacebookRESTService(token, faceBookId, "", false);
con.addResponseListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (!con.isAlive()) {
return;
}
if (callback != null) {
callback.actionPerformed(evt);
}
}
});
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
}
current = con;
NetworkManager.getInstance().addToQueue(con);
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class IOSImplementation method capturePhoto.
/**
* Captures a photo and notifies with the image data when available
* @param response callback for the resulting image
*/
public void capturePhoto(ActionListener response) {
if (!nativeInstance.checkCameraUsage()) {
throw new RuntimeException("Please add the ios.NSCameraUsageDescription build hint");
}
captureCallback = new EventDispatcher();
captureCallback.addListener(response);
nativeInstance.captureCamera(false);
dropEvents = true;
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class IOSImplementation method captureVideo.
/**
* Captures a video and notifies with the data when available
* @param response callback for the resulting video
*/
public void captureVideo(ActionListener response) {
if (!nativeInstance.checkCameraUsage() || !nativeInstance.checkMicrophoneUsage()) {
throw new RuntimeException("Please add the ios.NSCameraUsageDescription and ios.NSMicrophoneUsageDescription build hints");
}
captureCallback = new EventDispatcher();
captureCallback.addListener(response);
nativeInstance.captureCamera(true);
dropEvents = true;
}
Aggregations