当前位置: 首页>>代码示例>>Java>>正文


Java FaceBookAccess类代码示例

本文整理汇总了Java中com.codename1.facebook.FaceBookAccess的典型用法代码示例。如果您正苦于以下问题:Java FaceBookAccess类的具体用法?Java FaceBookAccess怎么用?Java FaceBookAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FaceBookAccess类属于com.codename1.facebook包,在下文中一共展示了FaceBookAccess类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showMyFriends

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
private Component showMyFriends() {
    final Container c = new Container(new BorderLayout());
    c.setScrollable(false);
    BorderLayout bl = new BorderLayout();
    bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
    Container p = new Container(bl);
    p.addComponent(BorderLayout.CENTER, new InfiniteProgress());

    c.addComponent(BorderLayout.CENTER, p);
    final List myFriends = new List();
    myFriends.setRenderer(new FriendsRenderer());
    try {
        FaceBookAccess.getInstance().getUserFriends("me", (DefaultListModel) myFriends.getModel(), new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                c.removeAll();
                c.addComponent(BorderLayout.CENTER, myFriends);
                c.revalidate();
            }
        });
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    return c;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:26,代码来源:FBDemo.java

示例2: getCellRendererComponent

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
public Component getCellRendererComponent(Component list, Object model, Object value, int index, boolean isSelected) {
    Hashtable v = (Hashtable) value;
    setText((String)v.get("name"));
    Image im = (Image)v.get("pic");
    String id = (String)v.get("id");
    
    if(im == null && id != null && v.get("fetching") == null){
        v.put("fetching", Boolean.TRUE);
        try {
            FaceBookAccess.getInstance().getPicture(id, (List)list, index, "pic", imageSize, true);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }else{
        setIcon(im);        
    }
    return this;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:19,代码来源:FriendsRenderer.java

示例3: login

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
public static void login(final Form form) {
    if (firstLogin()) {
        Login logForm = new Login(form);
        logForm.show();
    } else {
        //token exists no need to authenticate
        TOKEN = (String) Storage.getInstance().readObject("token");
        FaceBookAccess.setToken(TOKEN);
        //in case token has expired re-authenticate
        FaceBookAccess.getInstance().addResponseCodeListener(new ActionListener() {
            
            public void actionPerformed(ActionEvent evt) {
                NetworkEvent ne = (NetworkEvent) evt;
                int code = ne.getResponseCode();
                //token has expired
                if (code == 400) {
                    signIn(form);
                }                    
            }
        });
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:23,代码来源:Login.java

示例4: login

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
@Override
public void login() {
    loginCompleted = false;
    loginCancelled = false;
    nativeInterface.facebookLogin(this);
    Display.getInstance().invokeAndBlock(new Runnable() {
        public void run() {
            while(!loginCompleted && !loginCancelled) {
                try {
                    Thread.sleep(50);
                } catch(InterruptedException ie) {}
            }
        }
    });
    if (loginCancelled) {
        return;
    }
    if(callback != null) {
        if(isLoggedIn()) {
            FaceBookAccess.setToken(getToken());
            callback.loginSuccessful();
        } else {
            callback.loginFailed("");
        }
    } 
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:FacebookImpl.java

示例5: actionPerformed

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void actionPerformed(ActionEvent evt) {
    if(!FaceBookAccess.getInstance().isAuthenticated()) {
        FaceBookAccess.setClientId(appId);
        FaceBookAccess.setRedirectURI(redirectURI);
        FaceBookAccess.setClientSecret(clientSecret);
        if(permissions != null) {
            FaceBookAccess.setPermissions(permissions);            
        }
        FaceBookAccess.getInstance().showAuthentication(this);
        return;
    }
    if(evt.getSource() instanceof Exception) {
        return;
    }
    try {
        FaceBookAccess.getInstance().postLike(getPostId());
    } catch (IOException ex) {
        Log.e(ex);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:LikeButton.java

示例6: login

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
@Override
public void login() {
    nativeInterface.facebookLogin(this);
    Display.getInstance().invokeAndBlock(new Runnable() {
        public void run() {
            while(!loginCompleted) {
                try {
                    Thread.sleep(50);
                } catch(InterruptedException ie) {}
            }
        }
    });
    if(callback != null) {
        if(isLoggedIn()) {
            FaceBookAccess.setToken(getToken());
            callback.loginSuccessful();
        } else {
            callback.loginFailed("");
        }
    } 
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:FacebookImpl.java

示例7: actionPerformed

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void actionPerformed(ActionEvent evt) {
    if(!FaceBookAccess.getInstance().isAuthenticated()) {
        FaceBookAccess.setClientId(appId);
        FaceBookAccess.setRedirectURI(redirectURI);
        FaceBookAccess.setClientSecret(clientSecret);
        if(permissions != null) {
            FaceBookAccess.setPermissions(permissions);            
        }
        FaceBookAccess.getInstance().showAuthentication(this);
        return;
    }
    if(evt.getSource() instanceof Exception) {
        return;
    }
    try {
        FaceBookAccess.getInstance().postLike(getPostId());
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:LikeButton.java

示例8: WallRenderer

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
public WallRenderer(boolean myWall) {
    setLayout(new BorderLayout());
    addComponent(BorderLayout.WEST, userIcon);
    addComponent(BorderLayout.NORTH, userName);
    addComponent(BorderLayout.CENTER, post);
    this.myWall = myWall;
    if(myWall){
        try {
            FaceBookAccess.getInstance().getPicture("me", userIcon, userIconSize, false);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:15,代码来源:WallRenderer.java

示例9: signIn

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
private static void signIn(final Form main) {
    FaceBookAccess.setClientId("132970916828080");
    FaceBookAccess.setClientSecret("6aaf4c8ea791f08ea15735eb647becfe");
    FaceBookAccess.setRedirectURI("http://www.codenameone.com/");
    FaceBookAccess.setPermissions(new String[]{"user_location", "user_photos", "friends_photos", "publish_stream", "read_stream", "user_relationships", "user_birthday",
                "friends_birthday", "friends_relationships", "read_mailbox", "user_events", "friends_events", "user_about_me"});
    
    FaceBookAccess.getInstance().showAuthentication(new ActionListener() {
        
        public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() instanceof String) {
                String token = (String) evt.getSource();
                String expires = Oauth2.getExpires();
                TOKEN = token;
                System.out.println("recived a token " + token + " which expires on " + expires);
                //store token for future queries.
                Storage.getInstance().writeObject("token", token);
                if (main != null) {
                    main.showBack();
                }
            } else {
                Exception err = (Exception) evt.getSource();
                err.printStackTrace();
                Dialog.show("Error", "An error occurred while logging in: " + err, "OK", null);
            }
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:29,代码来源:Login.java

示例10: actionPerformed

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void actionPerformed(ActionEvent evt) {
    if (!FaceBookAccess.getInstance().isAuthenticated()) {
        FaceBookAccess.getInstance().showAuthentication(this);
        return;
    }
    if (evt.getSource() instanceof Exception) {
        return;
    }
    if (evt.getSource() instanceof String) {
        token = (String) evt.getSource();
    }

    super.actionPerformed(evt);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:18,代码来源:FacebookShare.java

示例11: doLogout

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
/**
 * Logs out the current user from facebook
 *
 */
public void doLogout() {
    super.doLogout();
    if(!isNativeLoginSupported()){
        FaceBookAccess.logOut();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:11,代码来源:FacebookConnect.java

示例12: createOauth2

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
@Override
protected Oauth2 createOauth2() {
    FaceBookAccess.setClientId(clientId);
    FaceBookAccess.setClientSecret(clientSecret);
    FaceBookAccess.setRedirectURI(redirectURI);
    FaceBookAccess.setPermissions(permissions);
    return FaceBookAccess.getInstance().createOAuth();        
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:9,代码来源:FacebookConnect.java

示例13: actionPerformed

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void actionPerformed(ActionEvent evt) {
    if (!FaceBookAccess.getInstance().isAuthenticated()) {
        FaceBookAccess.getInstance().showAuthentication(this);
        return;
    }
    if (evt.getSource() instanceof Exception) {
        return;
    }
    if (evt.getSource() instanceof String) {
        token = (String) evt.getSource();
    }

    super.actionPerformed(evt);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:FacebookShare.java

示例14: getListCellRendererComponent

import com.codename1.facebook.FaceBookAccess; //导入依赖的package包/类
public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
    Hashtable v = (Hashtable) value;
    String txt = (String) v.get("message");
    if (txt == null) {
        txt = (String) v.get("story");
        if (txt == null) {
            txt = (String) v.get("name");
        }
    }
    String picture = (String) v.get("picture");
    post.setText(txt);
    Image im = (Image) v.get("post_pic");
    if (im == null && picture != null && v.get("fetching_post_pic") == null) {
        v.put("fetching_post_pic", Boolean.TRUE);
        ImageDownloadService.createImageToStorage(picture, (List) list, index, "post_pic", (String)v.get("id"), postIconSize);
    } else {
        post.setIcon(im);
    }
    
    if(!myWall){
        Hashtable from = (Hashtable)v.get("from");
        if(from != null && from.get("id") != null){
            userName.setText((String)from.get("name"));

            im = (Image) v.get("user_pic");
            if(im == null && v.get("fetching_user_pic") == null){
                v.put("fetching_user_pic", Boolean.TRUE);
                try {
                    FaceBookAccess.getInstance().getPicture((String)from.get("id"), (List)list, index, "user_pic", userIconSize, true);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }else{
                userIcon.setIcon(im);        
            }
        }else{
            userName.setText("");
            userIcon.setIcon(null);        
        }
    }
    return this;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:43,代码来源:WallRenderer.java


注:本文中的com.codename1.facebook.FaceBookAccess类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。