Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package co.ortizol;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.v4.app.Fragment;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.Toolbar;
- import android.util.Log;
- import android.view.Menu;
- import android.view.MenuItem;
- import com.google.android.gms.auth.api.Auth;
- import com.google.android.gms.auth.api.signin.GoogleSignInResult;
- import co.ortizol.fragments.InicioSesionFragment;
- /**
- * Representa la actividad principal y host de fragmentos de la aplicación.
- */
- public class MainActivity extends AppCompatActivity {
- private static final String TAG = MainActivity.class.getSimpleName();
- private Toolbar toolbar;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- toolbar.setSubtitle(getString(R.string.inicio_sesion));
- getSupportFragmentManager().beginTransaction()
- .replace(R.id.layContenedor, new InicioSesionFragment(), "INICIO_SESION_FRAGMENT")
- .commit();
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- Fragment frg = getSupportFragmentManager().findFragmentByTag("INICIO_SESION_FRAGMENT");
- Log.i(TAG, "MainActivity:OnActivityResult; requestCode: " + requestCode);
- if (frg instanceof InicioSesionFragment) {
- if (requestCode == InicioSesionFragment.SIGN_IN_GOOGLE_REQUEST_CODE) {
- Log.i(TAG, "MainActivity:OnActivityResult:SIGN_IN_GOOGLE_REQUEST_CODE");
- GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
- ((InicioSesionFragment) frg).handleSignInResult(result);
- } else {
- Log.i(TAG, "MainActivity:OnActivityResult:FACEBOOK");
- frg.onActivityResult(requestCode, resultCode, data);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement