Java Code Examples for com.facebook.UiLifecycleHelper#onCreate()

The following examples show how to use com.facebook.UiLifecycleHelper#onCreate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    FragmentManager fm = getSupportFragmentManager();
    fragments[SPLASH] = fm.findFragmentById(R.id.splashFragment);
    fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
    fragments[SETTINGS] = fm.findFragmentById(R.id.userSettingsFragment);

    FragmentTransaction transaction = fm.beginTransaction();
    for(int i = 0; i < fragments.length; i++) {
        transaction.hide(fragments[i]);
    }
    transaction.commit();
}
 
Example 2
Source File: FriendPickerSampleActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    resultsTextView = (TextView) findViewById(R.id.resultsTextView);
    pickFriendsButton = (Button) findViewById(R.id.pickFriendsButton);
    pickFriendsButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onClickPickFriends();
        }
    });

    lifecycleHelper = new UiLifecycleHelper(this, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            onSessionStateChanged(session, state, exception);
        }
    });
    lifecycleHelper.onCreate(savedInstanceState);

    ensureOpenSession();
}
 
Example 3
Source File: LoginActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
private void setUpFacebook(final Bundle savedInstanceState) {
    uiLifecycleHelper = new UiLifecycleHelper(this, statusCallback);
    uiLifecycleHelper.onCreate(savedInstanceState);

    LoginButton fbButton = (LoginButton) findViewById(R.id.fb_login_button);
    fbButton.setReadPermissions(Arrays.asList("email", "user_friends"));
}
 
Example 4
Source File: LoginFragment.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	uiHelper = new UiLifecycleHelper(getActivity(), callback);
	uiHelper.onCreate(savedInstanceState);
}
 
Example 5
Source File: FacebookShareActivity.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_facebook_share);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);
    mPendingAction = false;

    // Used to print the hash key
    //getHashKey();

    // Get the intent that started this activity
    Intent intent = getIntent();
    mExtras = intent.getExtras();
    if ((mExtras == null) || mExtras.size() < 1)
    {
        // Nae extras!!! nothing to share, git tae!
        finish();
    }
    else if (!mExtras.getString(Intent.EXTRA_TEXT).isEmpty())
    {
        mPostTextView = (TextView)findViewById(R.id.postText);
        mPostText = mExtras.getString(Intent.EXTRA_TEXT);
        mPostTextView.setText(mPostText);
        mImageView = (ImageView)findViewById(R.id.imagePreview_container);
        mImageView.setImageURI((Uri) mExtras.get(Intent.EXTRA_STREAM));
    }
}
 
Example 6
Source File: LoginFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	uiHelper = new UiLifecycleHelper(getActivity(), callback);
	uiHelper.onCreate(savedInstanceState);
}
 
Example 7
Source File: TitledFragmentActivity.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	KlyphLocale.defineLocale(getBaseContext());

	super.onCreate(savedInstanceState);
	
	currentTheme = getCustomTheme();
	currentLocale = KlyphLocale.getDeviceLocale();

	uiHelper = new UiLifecycleHelper(this, callback);
	uiHelper.onCreate(savedInstanceState);
	
	//getActionBar().setIcon(R.drawable.ic_ab_launcher);

	KlyphDevice.initDeviceValues(this);

	if (!(this instanceof MainActivity))
	{
		setAppIconBackToHomeEnabled(true);
		//displayBackArrow(true);
	}
	else
	{
		setAppIconBackToHomeEnabled(false);
	}

	/*
	 * getActionBar().setStackedBackgroundDrawable(
	 * getResources().getDrawable(
	 * R.drawable.stacked_transparent_light_holo));
	 */

	//enableAds(true);

	if (Session.getActiveSession() == null)
	{
		Session.openActiveSessionFromCache(this);
	}
}
 
Example 8
Source File: FragmentSocialTimeline.java    From aptoide-client with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    Logger.d("FragmentSocialTimeline", " onCreate");
    super.onCreate(savedInstanceState);
    if (savedInstanceState == null) {
        init();
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {

        fbhelper = new UiLifecycleHelper(getActivity(), new Session.StatusCallback() {
            @Override
            public void call(final Session session, SessionState state, Exception exception) {
                if (!AptoideUtils.AccountUtils.isLoggedIn(Aptoide.getContext()) || removeAccount) {
                    try {
                        final AccountManager mAccountManager = AccountManager.get(getActivity());

                        if (session.isOpened()) {
                            Request.newMeRequest(session, new Request.GraphUserCallback() {
                                @Override
                                public void onCompleted(final GraphUser user, Response response) {

                                    if (removeAccount && mAccountManager.getAccountsByType(Aptoide.getConfiguration().getAccountType()).length > 0) {
                                        mAccountManager.removeAccount(mAccountManager.getAccountsByType(Aptoide.getConfiguration().getAccountType())[0], new AccountManagerCallback<Boolean>() {
                                            @Override
                                            public void run(AccountManagerFuture<Boolean> future) {
                                                startLogin(user, session);
                                            }
                                        }, new Handler(Looper.getMainLooper()));
                                    } else {

                                        startLogin(user, session);
                                    }
                                }
                            }).executeAsync();

                        }
                    } catch (Exception e) {
                        Toast.makeText(Aptoide.getContext(), R.string.error_occured, Toast.LENGTH_LONG).show();
                        loginError();
                    }
                }
            }
        });

        fbhelper.onCreate(savedInstanceState);
    }
}
 
Example 9
Source File: MyAccountActivity.java    From aptoide-client with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    //Aptoide.getThemePicker().setAptoideTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.form_logout);
    mToolbar = (Toolbar) findViewById(R.id.toolbar_login);
    mLogout = findViewById(R.id.button_logout);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        uiLifecycleHelper = new UiLifecycleHelper(this, statusCallback);
        uiLifecycleHelper.onCreate(savedInstanceState);
    }

    final String accountType = Aptoide.getConfiguration().getAccountType();
    mAccountManager = AccountManager.get(this);
    if (mAccountManager.getAccountsByType(accountType).length <= 0) {
        addAccount();
        finish();
        return;
    }

    final Account account = mAccountManager.getAccountsByType(accountType)[0];
    ((TextView) findViewById(R.id.username)).setText(account.name);

    final int connectionResult = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this);
    final Collection<Integer> badResults = Arrays.asList(ConnectionResult.SERVICE_MISSING, ConnectionResult.SERVICE_DISABLED);
    final boolean gmsAvailable = BuildConfig.GMS_CONFIGURED && !badResults.contains(connectionResult);
    if (gmsAvailable) {
        mLogout.setEnabled(false);
        final GoogleSignInOptions gso = new GoogleSignInOptions
                .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestServerAuthCode(BuildConfig.GMS_SERVER_ID)
                .build();
        googleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .enableAutoManage(this, this)
                .build();
        googleApiClient.connect();
    }

    mLogout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            singOutGoogle();
            singOutFacebook();
            removeAccount(account);
        }
    });
}
 
Example 10
Source File: FacebookFragment.java    From giraff-android with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(getActivity(), callback);
    uiHelper.onCreate(savedInstanceState);
}
 
Example 11
Source File: TitledFragmentActivity.java    From Klyph with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState)
{
	setTheme(getCustomTheme());
	KlyphLocale.defineLocale(getBaseContext());

	super.onCreate(savedInstanceState);

	currentTheme = getCustomTheme();
	currentLocale = KlyphLocale.getDeviceLocale();

	uiHelper = new UiLifecycleHelper(this, callback);
	uiHelper.onCreate(savedInstanceState);

	KlyphDevice.initDeviceValues(this);

	userHasDonated = KlyphPreferences.hasUserDonated();

	if (!(this instanceof MainActivity))
	{
		setAppIconBackToHomeEnabled(true);
		displayBackArrow(true);
	}
	else
	{
		setAppIconBackToHomeEnabled(false);
	}

	/*
	 * getSupportActionBar().setStackedBackgroundDrawable(
	 * getResources().getDrawable(
	 * R.drawable.stacked_transparent_light_holo));
	 */

	//enableAds(true);

	if (!KlyphSession.isLogged())
	{
		if (!(this instanceof MainActivity))
			logout();
	}
	else if (Session.getActiveSession() == null)
	{
		Session.openActiveSessionFromCache(this);
	}

	if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true)
	{
		String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);

		if (id != null && id.length() > 0)
		{
			new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
		}
	}
}