Search in sources :

Example 1 with SignInManager

use of com.google.samples.apps.iosched.signin.SignInManager in project iosched by google.

the class MyIOActivity method onCreate.

// -- Lifecycle callbacks
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myio_act);
    setFullscreenLayout();
    GoogleSignInOptions gso = SignInManager.getGoogleSignInOptions(BuildConfig.DEFAULT_WEB_CLIENT_ID);
    mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mSignInManager = new SignInManager(this, this, mGoogleApiClient);
    mDatabaseReference = FirebaseDatabase.getInstance().getReference(SyncUtils.SERVER_TIME_OFFSET_PATH);
    mValueEventListener = new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot snapshot) {
            double offset = snapshot.getValue(Double.class);
            SyncUtils.setServerTimeOffset(MyIOActivity.this, (int) offset);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            LOGW(TAG, "Listener was cancelled");
        }
    };
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions) SignInManager(com.google.samples.apps.iosched.signin.SignInManager) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot)

Example 2 with SignInManager

use of com.google.samples.apps.iosched.signin.SignInManager in project iosched by google.

the class WelcomeActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
    mContentFragment = getCurrentFragment(this);
    // If there's no fragment to use, we're done.
    if (mContentFragment == null) {
        finish();
    } else {
        // Wire up the fragment.
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        Fragment existing = fragmentManager.findFragmentById(R.id.welcome_content);
        if (existing != null) {
            fragmentTransaction.remove(existing);
        }
        fragmentTransaction.add(R.id.welcome_content, mContentFragment);
        fragmentTransaction.commit();
        CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        ctl.setBackgroundResource(mContentFragment.getHeaderColorRes());
        ImageView logo = (ImageView) ctl.findViewById(R.id.logo);
        logo.setImageResource(mContentFragment.getLogoDrawableRes());
    }
    GoogleSignInOptions gso = SignInManager.getGoogleSignInOptions(BuildConfig.DEFAULT_WEB_CLIENT_ID);
    mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mSignInManager = new SignInManager(this, this, mGoogleApiClient);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions) SignInManager(com.google.samples.apps.iosched.signin.SignInManager) ImageView(android.widget.ImageView) Fragment(android.support.v4.app.Fragment)

Aggregations

GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)2 SignInManager (com.google.samples.apps.iosched.signin.SignInManager)2 CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)1 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ImageView (android.widget.ImageView)1 DataSnapshot (com.google.firebase.database.DataSnapshot)1 DatabaseError (com.google.firebase.database.DatabaseError)1 ValueEventListener (com.google.firebase.database.ValueEventListener)1