use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method getAlbum.
/**
* Gets a Album from a albumId
* This is a sync method it will block until a response it returned
* @param the albumId
* @param needAuth if this object is public needAuth can be false and no
* authentication will be performed
*
* @return the Album requested
*/
public Album getAlbum(String albumId, boolean needAuth) throws IOException {
final Album album = new Album();
final Vector err = new Vector();
addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
err.addElement(ne);
removeResponseCodeListener(this);
}
});
getFaceBookObject(albumId, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
Hashtable t = (Hashtable) v.elementAt(0);
album.copy(t);
}
}, needAuth, false);
if (err.size() > 0) {
throw new IOException(((NetworkEvent) err.elementAt(0)).getResponseCode() + ": " + ((NetworkEvent) err.elementAt(0)).getMessage());
}
return album;
}
use of com.codename1.ui.events.ActionListener 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.ui.events.ActionListener 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.ui.events.ActionListener in project CodenameOne by codenameone.
the class FaceBookAccess method getPage.
/**
* Gets a Page from a pageId/name
* This is a sync method it will block until a response it returned
* @param pageId the pageId
* @return the Page requested
*/
public Page getPage(String pageId) throws IOException {
final Page page = new Page();
final Vector err = new Vector();
addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NetworkEvent ne = (NetworkEvent) evt;
err.addElement(ne);
removeResponseCodeListener(this);
}
});
getFaceBookObject(pageId, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Vector v = (Vector) ((NetworkEvent) evt).getMetaData();
Hashtable t = (Hashtable) v.elementAt(0);
page.copy(t);
}
}, false, false);
if (err.size() > 0) {
throw new IOException(((NetworkEvent) err.elementAt(0)).getResponseCode() + ": " + ((NetworkEvent) err.elementAt(0)).getMessage());
}
return page;
}
use of com.codename1.ui.events.ActionListener 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);
}
Aggregations