Search in sources :

Example 11 with GraphUser

use of com.facebook.model.GraphUser in project Klyph by jonathangerbaud.

the class UserSettingsFragment method fetchUserInfo.

private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {

                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
Also used : ImageResponse(com.facebook.internal.ImageResponse) GraphUser(com.facebook.model.GraphUser) Bundle(android.os.Bundle) ImageRequest(com.facebook.internal.ImageRequest)

Example 12 with GraphUser

use of com.facebook.model.GraphUser in project Klyph by jonathangerbaud.

the class LoginFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login, container, false);
    authButton = (LoginButton) view.findViewById(R.id.authButton);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    TextView tv = (TextView) view.findViewById(R.id.app_name_textview);
    tv.setText(KlyphFlags.IS_PRO_VERSION == true ? R.string.app_pro_large_name : R.string.app_large_name);
    TextView version = (TextView) view.findViewById(R.id.version);
    version.setText(getString(R.string.about_version, ApplicationUtil.getAppVersion(getActivity())));
    authButton.setReadPermissions(Arrays.asList("read_stream", "friends_about_me", "friends_work_history", "friends_activities", "friends_birthday", "user_checkins", "friends_checkins", "user_education_history", "friends_education_history", "user_events", "friends_events", "user_groups", "friends_groups", "user_hometown", "friends_hometown", "user_interests", "friends_interests", "user_likes", "friends_likes", "user_notes", "friends_notes", "user_online_presence", "friends_online_presence", "user_interests", "friends_interests", "user_likes", "friends_likes", "user_notes", "friends_notes", "user_online_presence", "friends_online_presence", "user_religion_politics", "friends_religion_politics", "user_status", "friends_status", "user_subscriptions", "friends_subscriptions", "user_videos", "friends_videos", "user_website", "friends_website", "user_work_history", "friends_work_history", "read_friendlists", "read_mailbox", "read_requests", "read_stream", "xmpp_login", "email", "user_location", "user_photos", "friends_photos"));
    authButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {

        @Override
        public void onUserInfoFetched(GraphUser user) {
            Log.d("LoginFragment", "onUserInfoFetched ");
            if (Session.getActiveSession().isOpened() && user != null) {
                Log.d("LoginFragment", "onUserInfoFetched2 ");
                User u = new User();
                u.setUid(user.getId());
                u.setName(user.getName());
                u.setFirst_name(user.getFirstName());
                u.setMiddle_name(user.getMiddleName());
                u.setLast_name(user.getLastName());
                u.setBirthday(user.getBirthday());
                u.setEmail((String) user.getProperty("email"));
                u.setSex((String) user.getProperty("gender"));
                // u.setIn((String)
                // user.getProperty("interested_in"));
                u.setLocale((String) user.getProperty("locale"));
                u.setRelationship_status((String) user.getProperty("relationship_status"));
                u.setUsername((String) user.getProperty("username"));
                try {
                    u.setTimezone(((Double) user.getProperty("timezone")).intValue());
                } catch (Exception e) {
                }
                KlyphSession.setSessionUser(u);
                if (getActivity() != null) {
                    ((LoginFragmentCallBack) getActivity()).onUserInfoFetched(u);
                }
            }
        }
    });
    authButton.setFragment(this);
    return view;
}
Also used : User(com.abewy.android.apps.klyph.core.fql.User) GraphUser(com.facebook.model.GraphUser) GraphUser(com.facebook.model.GraphUser) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) LoginButton(com.facebook.widget.LoginButton)

Example 13 with GraphUser

use of com.facebook.model.GraphUser in project facebook-api-android-maven by avianey.

the class TestSession method populateTestAccounts.

private static synchronized void populateTestAccounts(Collection<TestAccount> testAccounts, GraphObject userAccountsMap) {
    for (TestAccount testAccount : testAccounts) {
        GraphUser testUser = userAccountsMap.getPropertyAs(testAccount.getId(), GraphUser.class);
        testAccount.setName(testUser.getName());
        storeTestAccount(testAccount);
    }
}
Also used : GraphUser(com.facebook.model.GraphUser)

Example 14 with GraphUser

use of com.facebook.model.GraphUser in project facebook-api-android-maven by avianey.

the class UserSettingsFragment method fetchUserInfo.

private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {

                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
Also used : ImageResponse(com.facebook.internal.ImageResponse) GraphUser(com.facebook.model.GraphUser) Bundle(android.os.Bundle) ImageRequest(com.facebook.internal.ImageRequest)

Example 15 with GraphUser

use of com.facebook.model.GraphUser in project phonegap-facebook-plugin by Wizcorp.

the class UserSettingsFragment method fetchUserInfo.

private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {

                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
Also used : ImageResponse(com.facebook.internal.ImageResponse) GraphUser(com.facebook.model.GraphUser) Bundle(android.os.Bundle) ImageRequest(com.facebook.internal.ImageRequest)

Aggregations

GraphUser (com.facebook.model.GraphUser)22 Bundle (android.os.Bundle)5 Response (com.facebook.Response)5 Session (com.facebook.Session)5 JSONException (org.json.JSONException)5 ActivityNotFoundException (android.content.ActivityNotFoundException)4 Request (com.facebook.Request)4 ImageRequest (com.facebook.internal.ImageRequest)4 ImageResponse (com.facebook.internal.ImageResponse)4 ArrayList (java.util.ArrayList)4 GraphUserCallback (com.facebook.Request.GraphUserCallback)3 GraphUserListCallback (com.facebook.Request.GraphUserListCallback)3 GraphObject (com.facebook.model.GraphObject)3 FacebookAuthorizationException (com.facebook.FacebookAuthorizationException)2 FacebookOperationCanceledException (com.facebook.FacebookOperationCanceledException)2 FacebookRequestError (com.facebook.FacebookRequestError)2 GraphMultiResult (com.facebook.model.GraphMultiResult)2 GraphObjectList (com.facebook.model.GraphObjectList)2 Random (java.util.Random)2 View (android.view.View)1