Skip to content

Instantly share code, notes, and snippets.

@tsuginodan
Last active May 17, 2016 21:54
Show Gist options
  • Save tsuginodan/8d51beb9035e17e3e3c6cea20d5edb01 to your computer and use it in GitHub Desktop.
Save tsuginodan/8d51beb9035e17e3e3c6cea20d5edb01 to your computer and use it in GitHub Desktop.
...
05-18 06:14:11.467 31743-31743/com.dalvarez.someproject D/ViewGroup: addInArray been called, this = android.widget.FrameLayout{4266c6a8 V.E..... ......ID 0,0-800,1183 #7f10007f app:id/fragment_placeholder} ,child = android.support.design.widget.CoordinatorLayout{4227af08 VFE..... ......I. 0,0-0,0} ,call stack =
java.lang.Throwable: addInArray
at android.view.ViewGroup.addInArray(ViewGroup.java:3786)
at android.view.ViewGroup.addViewInner(ViewGroup.java:3740)
at android.view.ViewGroup.addView(ViewGroup.java:3564)
at android.view.ViewGroup.addView(ViewGroup.java:3509)
at android.view.ViewGroup.addView(ViewGroup.java:3485)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5340)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
05-18 06:14:11.582 31743-31743/com.dalvarez.someproject D/dalvikvm: GC_FOR_ALLOC freed 392K (7015), 14% free 24791K/28568K, paused 18ms, total 18ms
... more global variables
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//always first
//fb
FacebookSdk.sdkInitialize(getApplicationContext());
//twitter
TwitterAuthConfig authConfig = new TwitterAuthConfig(Constants.TWITTER_KEY, Constants.TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
setContentView(R.layout.activity_profile);
mCallbackManager = CallbackManager.Factory.create();
mAccessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
Log.v("AccessTokenTracker", "oldAccessToken=" + oldAccessToken + "||" + "CurrentAccessToken" + currentAccessToken);
if (currentAccessToken == null) {
//fb logout
Log.i(TAG, "FB LOGOUT");
afterLogoutRedirect();
}
}
};
//fb start tracking
mAccessTokenTracker.startTracking();
//get current token of social login
//fb
AccessToken fb_session = AccessToken.getCurrentAccessToken();
//twitter
TwitterSession twitter_session = Twitter.getSessionManager().getActiveSession();
//next fragment depends on if exists a session or not
if (fb_session == null && twitter_session == null) {
Log.i(TAG, "NO SESSION");
//go to login
transaction.add(R.id.fragment_placeholder, ProfileLoginFragment.newInstance(), PROFILE_LOGIN).commit();
} else if (fb_session != null) {
Log.i(TAG, "Logged with FB");
loggedWithFacebookAccount(fb_session);
} else if (twitter_session != null) {
Log.i(TAG, "Logged with Twitter");
loggedWithTwitterAccount(twitter_session);
}
//ANTES EVITABA LOS METODOS Y LO HACIA AQUI ... DE ESTA MANERA NO SE MOSTRABA LA ALERTA
//PERO LUEGO TENGO EL PROBLEMA DE OBTENER LA DATA PARA ENVIARLA LUEGO EN BUNDLE
//ProfileInfoFragment profileInfoFragment = new ProfileInfoFragment();
//Bundle fragment_args = new Bundle();
//fragment_args.putSerializable(PROFILE_INFO_DATA, userProfile);
//profileInfoFragment.setArguments(fragment_args);
//transaction.add(R.id.fragment_placeholder, profileInfoFragment, PROFILE_INFO).commit();
}
...more methods
private void loggedWithTwitterAccount(TwitterSession session) {
//method to retrieve profile data
//after complete call method
showProfileInfo(data);
}
private void loggedWithFacebookAccount(AccessToken session) {
//method to retrieve profile data
//after complete call method
showProfileInfo(data);
}
@Override
public void showProfileInfo(Object data) {
//logic to store data in object ... then
ProfileInfoFragment profileInfoFragment = new ProfileInfoFragment();
Bundle fragment_args = new Bundle();
fragment_args.putSerializable(PROFILE_INFO_DATA, userProfile);
profileInfoFragment.setArguments(fragment_args);
transaction.add(R.id.fragment_placeholder, profileInfoFragment, PROFILE_INFO).commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment