Java 类com.facebook.ProfileTracker 实例源码

项目:CustomAndroidOneSheeld    文件:FacebookShield.java   
private void initFBSdk() {
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
        FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    }
    callbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            if (eventHandler != null) {
                if (currentProfile != null)
                    eventHandler.onFacebookLoggedIn();
            }
        }
    };
}
项目:PlatePicks-Android    文件:LoginFragment.java   
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());

    callbackManager = CallbackManager.Factory.create();

    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {

        }
    };

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            //Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show();
            //displayMessage(currentProfile);

        }
    };

    accessTokenTracker.startTracking();
    profileTracker.startTracking();
}
项目:SplitApp    文件:LoginActivity.java   
private void addLoginButton() {
    LoginButton loginButton = (LoginButton) this.findViewById(R.id.login_button);
    loginButton.setReadPermissions(Arrays.asList("email", "user_friends",
            "public_profile", "user_birthday"));
    loginButton.registerCallback(fbCallbackManager, new FacebookCallback<LoginResult>() {

        private ProfileTracker mProfileTracker;

        @Override
        public void onSuccess(LoginResult loginResult) {

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });
}
项目:android-fagyi    文件:FacebookHandler.java   
/**
 * Start tracking profile.
 */
public void startProfileTracking() {
    //Track profile
    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(
                Profile oldProfile,
                Profile currentProfile) {

            // App code comes here.
            if (currentProfile != null && Config.IS_DEBUG_MODE)
                Log.d(TAG, currentProfile.getName());

        }
    };
}
项目:1Sheeld-Android-App    文件:FacebookShield.java   
private void initFBSdk() {
    if (!FacebookSdk.isInitialized()) {
        FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id"));
        FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    }
    callbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            if (eventHandler != null) {
                if (currentProfile != null)
                    eventHandler.onFacebookLoggedIn();
            }
        }
    };
}
项目:batatas-android    文件:MainFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();

    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            final Profile profile = currentProfile;
            if (profile != null) {
                final Thread thread = new Thread() {
                    public void run() {
                        createUserFromFacebook(profile);
                        openListsOverview();
                    }
                };
                thread.start();
            }
        }
    };

    printKeyHash(getActivity());
}
项目:AndroidBlueprints    文件:FacebookHelper.java   
private void initProfileTracker() {
    mProfileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            //                Toast.makeText(mActivity, "Facebook current profile changed", Toast.LENGTH_SHORT)
            //                        .show();
        }
    };
}
项目:PlaySoduko    文件:HomeActivity.java   
/**
 * Initialises buttons on this xml with their respective elements. Updates facebook profile if
 * changed because the Profile is loaded asynchronously so it returns null right after log in.
 */
private void initComponents() {
    playButton = (Button) findViewById(R.id.playButton);
    solveButton = (Button) findViewById(R.id.solveButton);
    logOutButton = (Button) findViewById(R.id.log_out_button);
    welcomeView = (TextView) findViewById(R.id.user_name);
    profilePictureView = (ProfilePictureView) findViewById(R.id.profile_picture);

    // Checks if the profile is changed and hence current profile is null. If so updates the profile
    if (Profile.getCurrentProfile() != null) {
        welcomeView.setText(WELCOME_TAG + Profile.getCurrentProfile().getName());
        profilePictureView.setProfileId(Profile.getCurrentProfile().getId());
    } else {
        ProfileTracker profileTracker = new ProfileTracker() {
            @Override
            protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
                this.stopTracking();
                Profile.setCurrentProfile(currentProfile);
                profilePictureView.setProfileId(currentProfile.getId());
                welcomeView.setText(WELCOME_TAG + currentProfile.getName());
            }
        };
        profileTracker.startTracking();
    }

    intentPlay = new Intent(this, PlayActivity.class);
    intentSolve = new Intent(this, SolveActivity.class);
    intentLogIn = new Intent(this, LogInActivity.class);
}
项目:Material-Login    文件:Login.java   
private void setupProfileTracker() {
    mProfileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
            Log.d("scion", "" + currentProfile);

        }
    };
}
项目:YourAppIdea    文件:FacebookDelegate.java   
public FacebookDelegate(UserHelper userHelper, Activity activity, String... permissions) {
    this.mUserHelper = userHelper;

    FacebookSdk.sdkInitialize(activity.getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();
    mActivity = activity;
    mPermissions = Arrays.asList(permissions);
    LoginManager.getInstance().registerCallback(mCallbackManager, this);

    mAccessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(
                AccessToken oldAccessToken,
                AccessToken currentAccessToken) {
            mAccessToken = AccessToken.getCurrentAccessToken();
        }
    };

    mProfileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(
                Profile oldProfile,
                Profile currentProfile) {
            if (currentProfile == null) {
                mUserHelper.setCurrentUser(null);

                // Logout
                if (oldProfile != null && mUserSessionCallback != null) {
                    mUserSessionCallback.onLogout();
                }
            } else {
                requestUserData();
            }
        }
    };

    // If the access token is available already assign it.
    mAccessToken = AccessToken.getCurrentAccessToken();
}
项目:Guanajoven    文件:LoginFragment.java   
/**
 * Método de arranque. Se instancian todas las referencias del login con Google y Facebook.
 * @param savedInstanceState {Bundle}
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Se instancian las GoogleSignInOptions y el GoogleApiClient.
    googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestProfile()
            .build();

    if(googleApiClient == null) {
        googleApiClient = new GoogleApiClient.Builder(getActivity())
                .enableAutoManage(getActivity(), new GoogleApiClient.OnConnectionFailedListener() {
                    @Override
                    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                        OKDialog.showOKDialog(getActivity(), "Error", "Hubo un error en la conexión, reintentar más adelante");
                    }
                })
                .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions).addApi(LocationServices.API)
                .build();
    }


    //Configuración de Facebook.
    callbackManager = CallbackManager.Factory.create();
    accessTokenTracker = new AccessTokenTracker() {
        @Override
        protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {

        }
    };
    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) { }
    };
    accessTokenTracker.startTracking();
    profileTracker.startTracking();


    //Instancia de las preferencias.
    prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());


    //Instancia de retrofit para servicio de API
    retrofit = ((MyApplication) getActivity().getApplication()).getRetrofitInstance();
    usuarioAPI = retrofit.create(UsuarioAPI.class);

}
项目:Walk-Ranger    文件:LaunActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());

    callbackManager = CallbackManager.Factory.create();

    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            updateUI();
        }

        @Override
        public void onCancel() {
            updateUI();
        }

        @Override
        public void onError(FacebookException e) {
            updateUI();
        }
    });
    setContentView(R.layout.activity_laun);

    userName = (TextView) findViewById(R.id.user_name);
    profilePicture = (ProfilePictureView) findViewById(R.id.profile_picture);
    profileTracker = new ProfileTracker() {
        @Override
        protected void onCurrentProfileChanged(Profile profile, Profile profile1) {
            updateUI();
        }
    };

    mainMenu = (Button) findViewById(R.id.main_menu);
    mainMenu.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View V){
            profile = Profile.getCurrentProfile();
            MemberStatic.setFbID(profile.getId());
            new SimpleTask().execute("http://203.151.92.179:8080/fblogin?name="+profile.getFirstName() + "%20" + profile.getLastName() +"&fb-code="+profile.getId());


        }
    });
}
项目:CE-SMART-TRACKER-DEV    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.fragment_login);
    setStatus(0);
    setBtnLogin();
    setBtnRegister();

    getSupportActionBar().setTitle("CE SMART TRACKER");
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#003366")));

    rbS = (RadioButton)findViewById(R.id.radioStd);
    rbT = (RadioButton)findViewById(R.id.radioTeacher);
    rbS.setChecked(true);
    rbT.setChecked(false);

    mCallbackManager = CallbackManager.Factory.create();
    mCallback = new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            mProfileTracker = new ProfileTracker() {
                @Override
                protected void onCurrentProfileChanged(Profile profile, Profile profile2) {
                    if(profile2 != null) {
                        String fbId = profile2.getId();
                        int st = logingWithFB(fbId);
                        if(st==0){
                            Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
                            intent.putExtra("fbId", fbId);
                            startActivity(intent);
                        }
                        else {
                            if (((getSt().equals("teacher")&&getStatus()==1) || (getSt().equals("student")&&getStatus()==0))) {
                                startActivity(new Intent(LoginActivity.this, MainActivity.class));
                                finish();
                            } else {
                                SingletonID.getInstance().clear();
                                FacebookSdk.clearLoggingBehaviors();
                                Intent intent = new Intent(LoginActivity.this, LoginActivity.class);
                                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                                startActivity(intent);
                                finish();
                            }
                        }
                    }

                }
            };
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException e) {

        }
    };

    LoginButton loginButton = (LoginButton)findViewById(R.id.login_button);
    loginButton.setReadPermissions("user_friends");
    loginButton.registerCallback(mCallbackManager, mCallback);
    LoginManager.getInstance().logOut();

    mtextDetial = (TextView)findViewById(R.id.textView);
}
项目:AndroidBlueprints    文件:FacebookHelper.java   
/**
 * Gets facebook profile tracker.
 *
 * @return the facebook profile tracker
 */
public ProfileTracker getFacebookProfileTracker() {
    return this.mProfileTracker;
}