use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method postOnWall.
/**
* Post a message on the users wall
*
* @param userId the userId
* @param message the message to post
* @param name
* @param link
* @param description
* @param picture
* @param caption
*/
public void postOnWall(String userId, String message, String name, String link, String description, String picture, String caption, ActionListener callback) throws IOException {
checkAuthentication();
FacebookRESTService con = new FacebookRESTService(token, userId, FacebookRESTService.FEED, true);
if (message != null) {
con.addArgument("message", message);
}
if (name != null) {
con.addArgument("name", name);
}
if (link != null) {
con.addArgument("link", link);
}
if (description != null) {
con.addArgument("description", description);
}
if (picture != null) {
con.addArgument("picture", picture);
}
if (caption != null) {
con.addArgument("caption", caption);
}
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.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method getUser.
/**
* Gets a User from a user id
* This is a sync method it will block until a response it returned
* @param userId the user id or null to get details on the authenticated user
* @return the User requested
*/
public User getUser(String userId) throws IOException {
String id = userId;
if (id == null) {
id = "me";
}
final User user = new User();
final Vector err = new Vector();
addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
err.addElement(ne);
removeResponseCodeListener(this);
}
});
getFaceBookObject(id, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
Hashtable t = (Hashtable) v.elementAt(0);
user.copy(t);
}
}, true, false);
if (err.size() > 0) {
throw new IOException(((NetworkEvent) err.elementAt(0)).getResponseCode() + ": " + ((NetworkEvent) err.elementAt(0)).getMessage());
}
return user;
}
use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method getPictureAndWait.
/**
* Gets the picture of the given facebook object id
*
* @param id the object id to query
* @param toScale picture dimension or null
* @return the picture
*/
public EncodedImage getPictureAndWait(String id, Dimension toScale) {
ImageDownloadService im = new ImageDownloadService(getImageURL(id, toScale), (ActionListener) null);
NetworkManager.getInstance().addToQueueAndWait(im);
return im.getResult();
}
use of com.codename1.ui.events.ActionListener 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.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method getPost.
/**
* Gets a Post from a postId
* This is a sync method it will block until a response it returned
* @param postId the post id
* @param needAuth if this object is public needAuth can be false and no
* authentication will be performed
* @return the Post requested
*/
public Post getPost(String postId, boolean needAuth) throws IOException {
final Post post = new Post();
final Vector err = new Vector();
addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
err.addElement(ne);
removeResponseCodeListener(this);
}
});
getFaceBookObject(postId, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
Hashtable t = (Hashtable) v.elementAt(0);
post.copy(t);
}
}, needAuth, false);
if (err.size() > 0) {
throw new IOException(((NetworkEvent) err.elementAt(0)).getResponseCode() + ": " + ((NetworkEvent) err.elementAt(0)).getMessage());
}
return post;
}
Aggregations