use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class FaceBookAccess method getUser.
/**
* Gets a user from a user id
*
* @param userId the user id or null to get detaild on the authenticated user
* @param user an object to fill with the user details
* @param callback the callback that should be updated when the data arrives
*/
public void getUser(String userId, final User user, final ActionListener callback) throws IOException {
String id = userId;
if (id == null) {
id = "me";
}
getFaceBookObject(id, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
Hashtable t = (Hashtable) v.elementAt(0);
if (user != null) {
user.copy(t);
}
if (callback != null) {
callback.actionPerformed(evt);
}
}
});
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class FaceBookAccess method getFaceBookObjectItems.
/**
* Get a list of FaceBook objects for a given id
*
* @param faceBookId the id to preform the query upon
* @param itemsConnection the type of the query
* @param feed
* @param params
* @param callback the callback that should be updated when the data arrives
*/
public void getFaceBookObjectItems(String faceBookId, String itemsConnection, final DefaultListModel feed, Hashtable params, final ActionListener callback) throws IOException {
checkAuthentication();
final FacebookRESTService con = new FacebookRESTService(token, faceBookId, itemsConnection, false);
con.setResponseDestination(feed);
con.addResponseListener(new Listener(con, callback));
if (params != null) {
Enumeration keys = params.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
con.addArgument(key, (String) params.get(key));
}
}
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 FaceBookAccess method postComment.
/**
* Post a comment on a given post
*
* @param postId the post id
* @param message the message to post
*/
public void postComment(String postId, String message, ActionListener callback) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, postId, FacebookRESTService.COMMENTS, true);
con.addResponseListener(new Listener(con, callback));
con.addArgument("message", "" + message);
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 createNote.
/**
* Post a note onto the users wall
*
* @param userId the userId
* @param message the message to post
*/
public void createNote(String userId, String subject, String message, ActionListener callback) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, userId, FacebookRESTService.NOTES, true);
con.addResponseListener(new Listener(con, callback));
con.addArgument("subject", "" + subject);
con.addArgument("message", "" + message);
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
}
current = con;
System.out.println(con.getUrl());
NetworkManager.getInstance().addToQueueAndWait(con);
}
use of com.codename1.util.Callback in project CodenameOne by codenameone.
the class AndroidImplementation method startBackgroundFetchService.
/**
* Starts the background fetch service.
*/
public void startBackgroundFetchService() {
LocalNotification n = new LocalNotification();
n.setId(BACKGROUND_FETCH_NOTIFICATION_ID);
cancelLocalNotification(BACKGROUND_FETCH_NOTIFICATION_ID);
// We schedule a local notification
// First callback will be at the repeat interval
// We don't specify a repeat interval because the scheduleLocalNotification will
// set that for us using the getPreferredBackgroundFetchInterval method.
scheduleLocalNotification(n, System.currentTimeMillis() + getPreferredBackgroundFetchInterval() * 1000, 0);
}
Aggregations