You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple {@link Fragment} subclass.
*/
public class LoginFragment extends Fragment implements SocialNetworkManager.OnInitializationCompleteListener, OnLoginCompleteListener, OnRequestSocialPersonCompleteListener {
public static SocialNetworkManager mSocialNetworkManager;
private String userName;
private int socialId = 0;
public LoginFragment() {
// Required empty public constructor
}
@OverRide
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater
.inflate(R.layout.login, container, false);
ButterKnife.bind(this,root);
//Get Keys for initiate SocialNetworks
String TWITTER_CONSUMER_KEY = getActivity().getString(R.string.twitter_consumer_key);
String TWITTER_CONSUMER_SECRET = getActivity().getString(R.string.twitter_consumer_secret);
String TWITTER_CALLBACK_URL = "http://www.appectual.com/";
ArrayList<String> fbScope = new ArrayList<String>();
fbScope.addAll(Arrays.asList("public_profile, email, user_friends"));
String linkedInScope = "r_basicprofile+r_fullprofile+rw_nus+r_network+w_messages+r_emailaddress+r_contactinfo";
//Use manager to manage SocialNetworks
mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(LoginActivity.SOCIAL_NETWORK_TAG);
//Check if manager exist
if (mSocialNetworkManager == null) {
mSocialNetworkManager = new SocialNetworkManager();
//Init and add to manager FacebookSocialNetwork
FacebookSocialNetwork fbNetwork = new FacebookSocialNetwork(this, fbScope);
mSocialNetworkManager.addSocialNetwork(fbNetwork);
//Init and add to manager TwitterSocialNetwork
TwitterSocialNetwork twNetwork = new TwitterSocialNetwork(this, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_CALLBACK_URL);
mSocialNetworkManager.addSocialNetwork(twNetwork);
/*
//Init and add to manager LinkedInSocialNetwork
LinkedInSocialNetwork liNetwork = new LinkedInSocialNetwork(this, LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET, LINKEDIN_CALLBACK_URL, linkedInScope);
mSocialNetworkManager.addSocialNetwork(liNetwork);*/
//Initiate every network from mSocialNetworkManager
getFragmentManager().beginTransaction().add(mSocialNetworkManager, LoginActivity.SOCIAL_NETWORK_TAG).commit();
mSocialNetworkManager.setOnInitializationCompleteListener(this);
} else {
//if manager exist - get and setup login only for initialized SocialNetworks
if(!mSocialNetworkManager.getInitializedSocialNetworks().isEmpty()) {
List<SocialNetwork> socialNetworks = mSocialNetworkManager.getInitializedSocialNetworks();
for (SocialNetwork socialNetwork : socialNetworks) {
socialNetwork.setOnLoginCompleteListener(this);
}
}
}
return root;
}
@OverRide
public void onLoginSuccess(int networkId) {
@OverRide
public void onSocialNetworkManagerInitialized() {
//when init SocialNetworks - get and setup login only for initialized SocialNetworks
for (SocialNetwork socialNetwork : mSocialNetworkManager.getInitializedSocialNetworks()) {
socialNetwork.setOnLoginCompleteListener(this);
socialNetwork.setOnRequestCurrentPersonCompleteListener(this);
}
}
@OnClick(R.id.btnFb)
public void fbLogin(View view) {
socialId = FacebookSocialNetwork.ID;
startLogin(socialId);
/*Intent intent = new Intent(LoginActivity.this, Facebook.class);
startActivity(intent);*/
}
@OnClick(R.id.btnGp)
public void gpLogin(View view) {
socialId = TwitterSocialNetwork.ID;
startLogin(socialId);
/Intent intent = new Intent(LoginActivity.this, Gplus.class);
startActivity(intent);/
}
public void startLogin(int networkId){
SocialNetwork socialNetwork = mSocialNetworkManager.getSocialNetwork(networkId);
I tried to use your library but I am not able to get any callback after entering login password. Below is my code
My loginFragment
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.appectual.ube.R;
import com.github.gorbin.asne.core.SocialNetwork;
import com.github.gorbin.asne.core.SocialNetworkManager;
import com.github.gorbin.asne.core.listener.OnLoginCompleteListener;
import com.github.gorbin.asne.core.listener.OnRequestSocialPersonCompleteListener;
import com.github.gorbin.asne.core.persons.SocialPerson;
import com.github.gorbin.asne.facebook.FacebookSocialNetwork;
import com.github.gorbin.asne.linkedin.LinkedInSocialNetwork;
import com.github.gorbin.asne.twitter.TwitterSocialNetwork;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
A simple {@link Fragment} subclass.
*/
public class LoginFragment extends Fragment implements SocialNetworkManager.OnInitializationCompleteListener, OnLoginCompleteListener, OnRequestSocialPersonCompleteListener {
public static SocialNetworkManager mSocialNetworkManager;
private String userName;
private int socialId = 0;
public LoginFragment() {
// Required empty public constructor
}
@OverRide
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/*
//Init and add to manager LinkedInSocialNetwork
LinkedInSocialNetwork liNetwork = new LinkedInSocialNetwork(this, LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET, LINKEDIN_CALLBACK_URL, linkedInScope);
mSocialNetworkManager.addSocialNetwork(liNetwork);*/
}
@OverRide
public void onLoginSuccess(int networkId) {
}
@OverRide
public void onError(int networkId, String requestID, String errorMessage, Object data) {
Toast.makeText(getActivity(), "ERROR: " + errorMessage, Toast.LENGTH_LONG).show();
}
@OverRide
public void onSocialNetworkManagerInitialized() {
//when init SocialNetworks - get and setup login only for initialized SocialNetworks
for (SocialNetwork socialNetwork : mSocialNetworkManager.getInitializedSocialNetworks()) {
socialNetwork.setOnLoginCompleteListener(this);
socialNetwork.setOnRequestCurrentPersonCompleteListener(this);
}
}
@OnClick(R.id.btnFb)
public void fbLogin(View view) {
socialId = FacebookSocialNetwork.ID;
startLogin(socialId);
}
@OnClick(R.id.btnGp)
public void gpLogin(View view) {
socialId = TwitterSocialNetwork.ID;
startLogin(socialId);
/Intent intent = new Intent(LoginActivity.this, Gplus.class);
startActivity(intent);/
}
public void startLogin(int networkId){
SocialNetwork socialNetwork = mSocialNetworkManager.getSocialNetwork(networkId);
// socialNetwork.requestCurrentPerson();
}
@OverRide
public void onRequestSocialPersonSuccess(int i, SocialPerson socialPerson) {
/* id.setText(socialPerson.id);
String socialPersonString = socialPerson.toString();
String infoString = socialPersonString.substring(socialPersonString.indexOf("{") + 1, socialPersonString.lastIndexOf("}"));
info.setText(infoString.replace(", ", "\n"));
Picasso.with(getActivity())
.load(socialPerson.avatarURL)
.into(photo);*/
}
}
The text was updated successfully, but these errors were encountered: