@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button); loginButton.setReadPermissions("user_friends"); loginButton.setFragment(this); loginButton.registerCallback(mCallbackManager, mCallback); }
// what happens when the view is created @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // find fb login button by id and assign it to variable LoginButton login_button = (LoginButton) view.findViewById(R.id.login_button); login_button.setFragment(this); // set login button as a fragment login_button.registerCallback(callBackManager, callback); // register callback to button }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); btnConnectWithFacebook = (LoginButton) getActivity().findViewById(R.id.btnConnectWithFacebok); btnConnectWithFacebook.setTypeface( FontManager.setFont(getActivity(), FontManager.Font.OpenSansSemiBold)); btnConnectWithFacebook.setReadPermissions(Arrays.asList("public_profile, email")); btnConnectWithFacebook.setFragment(this); btnConnectWithFacebook.registerCallback(callbackManager, callback); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // mTextDisplayed = (TextView) view.findViewById(R.id.text_details); // Create facebook button and initialize permissions. fbLoginButton = (LoginButton) view.findViewById(R.id.login_button); fbLoginButton.setPublishPermissions("publish_actions"); fbLoginButton.setFragment(this); fbLoginButton.registerCallback(mCallbackManager, facebookCallback); // Creating loginButton and setting the callback. twitterLoginButton = (TwitterLoginButton) view.findViewById(R.id.twitter_login_button); twitterLoginButton.setCallback(twitterSessionCallback); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); loginButton = (LoginButton) view.findViewById(R.id.ivfb); tvUser = (TextView) getView().findViewById(R.id.tvUser); etEmail = (EditText) getView().findViewById(R.id.etEmail); etUser = (EditText) getView().findViewById(R.id.etUser); etPhone = (EditText) getView().findViewById(R.id.etPhone); etPass = (EditText) getView().findViewById(R.id.etPass); bLogin = (Button) view.findViewById(R.id.bLogin); bReg = (Button) view.findViewById(R.id.bReg); ivgp = (ImageView) view.findViewById(R.id.ivgp); loginButton.setReadPermissions("user_friends"); loginButton.setFragment(this); loginButton.registerCallback(callbackManager, callback); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.splash, container, false); callbackManager = CallbackManager.Factory.create(); loginButton = (LoginButton) view.findViewById(R.id.login_button); loginButton.setReadPermissions("user_friends"); loginButton.setFragment(this); loginButton.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Toast.makeText(getActivity(), "Login successful", Toast.LENGTH_SHORT).show(); } @Override public void onCancel() { Toast.makeText(getActivity(), "Login canceled", Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException exception) { Toast.makeText(getActivity(), "Login error", Toast.LENGTH_SHORT).show(); } }); skipLoginButton = (TextView) view.findViewById(R.id.skip_login_button); skipLoginButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (skipLoginCallback != null) { skipLoginCallback.onSkipLoginPressed(); } } }); return view; }
public void showSocialLoginDialog() { smsPB.setVisibility(View.GONE); final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()) .customView(R.layout.smartdialog, false) .title("Sign Up") .titleGravity(GravityEnum.CENTER) .positiveText("SKIP") .cancelable(false) .callback( new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); dialog.dismiss(); mixpanel.track("Login - Skipped"); Intent mIntent = new Intent(getActivity(), LoginUserDetails.class); startActivity(mIntent); } }) .show(); View view = dialog.getCustomView(); callbackManager = CallbackManager.Factory.create(); LoginButton facebookBtn = (LoginButton) view.findViewById(R.id.smartDialogFacebook); facebookBtn.setFragment(this); facebookBtn.setReadPermissions(Arrays.asList("public_profile, email, user_birthday")); facebookBtn.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(TAG, "Facebook login success"); try { getUserFacebookDetails(loginResult); } catch (Exception e) { Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } } @Override public void onCancel() { Log.d(TAG, "Facebook login cancel"); } @Override public void onError(FacebookException e) { Log.d(TAG, "Facebook login error"); Toast.makeText( getActivity(), "Couldn't login with facebook, try again" + e.getMessage(), Toast.LENGTH_SHORT) .show(); } }); SignInButton googleBtn = (SignInButton) view.findViewById(R.id.smartDialogGoogle); googleBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mGoogleApiClient.isConnected()) { Plus.AccountApi.clearDefaultAccount(mGoogleApiClient); mGoogleApiClient.disconnect(); } else { mShouldResolve = true; mGoogleApiClient.connect(); } } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.v(LOG_TAG, "OnCreateView for LoginActivity Fragment"); View view = inflater.inflate(R.layout.fragment_landing, container, false); loginButtonFaceBook = (LoginButton) view.findViewById(R.id.login_button); signButton = (Button) view.findViewById(R.id.signup); loginButton = (Button) view.findViewById(R.id.login); loginButtonFaceBook.setReadPermissions("user_friends"); googleButton = (com.google.android.gms.common.SignInButton) view.findViewById(R.id.google); // If using in a fragment loginButtonFaceBook.setFragment(this); // Other app specific specialization callbackManager = CallbackManager.Factory.create(); // Callback registration signButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Log.v(LOG_TAG, "Signup button clicked, switching to SignUp fragment"); getActivity() .getSupportFragmentManager() .beginTransaction() .replace(R.id.frame_layout, new SignUpFragment()) .commit(); } }); loginButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Log.v(LOG_TAG, "Login button clicked, switching to SplatterLogin fragment"); getActivity() .getSupportFragmentManager() .beginTransaction() .replace(R.id.frame_layout, new SplatterLoginFragment()) .commit(); } }); googleButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Log.v(LOG_TAG, "Sign-in with Google clicked, switching to Google activity"); Intent intent = new Intent(getActivity(), GoogleActivity.class); getActivity().startActivity(intent); } }); loginButtonFaceBook.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.i(LOG_TAG, "Sign-in with Facebook successful"); String username = loginResult.getAccessToken().getUserId(); HttpAgent.tokenValue = loginResult.getAccessToken().toString(); Log.v( LOG_TAG, String.format("Username %s, AccessToken %s", username, HttpAgent.tokenValue)); SharedPreferences sharedPref = getActivity() .getSharedPreferences( getString(R.string.preference_file), Context.MODE_PRIVATE); SharedPreferences.Editor prefEdit = sharedPref.edit(); prefEdit.putString( getString(R.string.login_method), getString(R.string.facebook_login)); prefEdit.putString(getString(R.string.key_username), username); prefEdit.putString(getString(R.string.access_token), HttpAgent.tokenValue); prefEdit.apply(); String k = JsonHandler.stringifyNormal(loginResult); getActivity() .getSupportFragmentManager() .beginTransaction() .replace(R.id.frame_layout, new SelectTagsFragment()) .commit(); } @Override public void onCancel() { Log.i(LOG_TAG, "Facebook login operation cancelled"); } @Override public void onError(FacebookException exception) { Log.e(LOG_TAG, "In Facebook Sign-in, got exception: ", exception); } }); return view; }
@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; }