예제 #1
0
 private void updateWithToken(AccessToken currentAccessToken) {
   if (currentAccessToken != null) {
     FbProfileInfo FBInfo = new FbProfileInfo(getActivity());
     FBInfo.getProfileInformation(getActivity());
     setUpFriendListPage();
   } else {
     backToLogin();
   }
 }
예제 #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // initialize our instance of CallbackManager
    callbackManager = CallbackManager.Factory.create();

    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_one, container, false);

    logo = (ImageView) view.findViewById(R.id.conveneLogo);
    logo.bringToFront();

    userName = (TextView) view.findViewById(R.id.userName);
    btnSyncContacts = (Button) view.findViewById(R.id.btnSearchContacts);
    info = (TextView) view.findViewById(R.id.info);
    orText = (TextView) view.findViewById(R.id.ortext);
    profileImage = (ImageView) view.findViewById(R.id.profileimage);
    backButtons = (LinearLayout) view.findViewById(R.id.backButtonsContainer);
    loginButton = (LoginButton) view.findViewById(R.id.login_button);
    lvFriend = (ListView) view.findViewById(R.id.lvFriend);
    userInfo = (RelativeLayout) view.findViewById(R.id.fbInfoContainer);

    // get user permission to access to friends list
    loginButton.setReadPermissions(Arrays.asList("user_friends"));
    loginButton.setFragment(this);

    // create a callback to handle the results of the login attempts and
    // register it with the CallbackManager
    loginButton.registerCallback(
        callbackManager,
        new FacebookCallback<LoginResult>() {
          @Override
          public void onSuccess(LoginResult loginResult) {
            Log.d("FragmentOne.FBLOGIN", "Login attempt a success!!.");
          }

          @Override
          public void onCancel() {
            Log.d("FragmentOne.FBLOGIN", "Login attempt cancelled.");
          }

          @Override
          public void onError(FacebookException e) {
            Log.d("FragmentOne.FBLOGIN", "Login attempt failed.");
          }
        });

    friendListArray.clear();
    // NOTE: simple list item 1 = Android predefined TextView resource id
    // adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1,
    // friendListArray);

    newadapter = new myAdapter(getContext(), R.layout.list_row, friendListArray);

    lvFriend.setAdapter(newadapter);

    lvFriend.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            int friendListID = (int) id;
            newadapter.setSelectedIndex(position);
            People person = (People) lvFriend.getItemAtPosition(friendListID);
            utils.setFriend(person.name);
          }
        });

    Profile profile = Profile.getCurrentProfile();
    if (profile == null) {
      //
    } else {
      FbProfileInfo FBInfo = new FbProfileInfo(getActivity());
      FBInfo.getProfileInformation(getActivity());
      setUpFriendListPage();
    }

    return view;
  }