 static final int RC_SIGN_IN = 0;

/* Client used to interact with Google APIs. */
private GoogleApiClient mGoogleApiClient;

/* A flag indicating that a PendingIntent is in progress and prevents
* us from starting further intents.
*/
private boolean mIntentInProgress;

private boolean mShouldResolve;

private ConnectionResult connectionResult;

private SignInButton signInButton;
private Button signOutButton;
private TextView tvName, tvMail, tvNotSignedIn;
private ImageView imgProfilePic;
private LinearLayout viewContainer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
    signInButton = (SignInButton) findViewById(R.id.sign_in_button);
    signOutButton = (Button) findViewById(R.id.sign_out_button);
    tvName = (TextView) findViewById(R.id.tvName);
    tvMail = (TextView) findViewById(R.id.tvMail);
    tvNotSignedIn = (TextView) findViewById(R.id.notSignedIn_tv);
    viewContainer = (LinearLayout) findViewById(R.id.text_view_container);

    signInButton.setOnClickListener(this);
    signOutButton.setOnClickListener(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
           .addConnectionCallbacks(this)
           .addOnConnectionFailedListener(this)
           .addApi(Plus.API)
           .addScope(Plus.SCOPE_PLUS_LOGIN)
           .build();

}

protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();
}

protected void onStop() {
    super.onStop();
    if (mGoogleApiClient.isConnected()) {
        mGoogleApiClient.disconnect();
    }
}

private void resolveSignInError() {
    if (connectionResult.hasResolution()) {
        try {
            mIntentInProgress = true;
static final int RC_SIGN_IN = 0; 

 / * Client used to interact with Google APIs. * / 
 private GoogleApiClient mGoogleApiClient; 

 / * A pin indicate that a PendingIntent is in progress and prevents 
 * us from starting further intents. 
 * / 
 secret boolean mIntentInProgress; 

 private boolean mShouldResolve; 

 private ConnectionResult connectionResult; 

 secret SignInButton signInButton; 
 secret Button signOutButton; 
 private TextView tvName, tvMail, tvNotSignedIn; 
 individual ImageView imgProfilePic; 
 private LinearLayout viewContainer; 

 @Override 
 protected null onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic); 
     signInButton = (SignInButton) findViewById(R.id.sign_in_button); 
     signOutButton = (Button) findViewById(R.id.sign_out_button); 
     tvName = (TextView) findViewById(R.id.tvName); 
     tvMail = (TextView) findViewById(R.id.tvMail); 
     tvNotSignedIn = (TextView) findViewById(R.id.notSignedIn_tv); 
     viewContainer = (LinearLayout) findViewById(R.id.text_view_container); 

     signInButton.setOnClickListener(this); 
     signOutButton.setOnClickListener(this); 

     mGoogleApiClient = new GoogleApiClient. Builder(this) 
            .addConnectionCallbacks(this) 
            .addOnConnectionFailedListener(this) 
            .addApi(Plus. API) 
            .addScope(Plus. SCOPE_PLUS_LOGIN) 
            .build (); 

 } 

 protected void onStart () { 
     super.onStart (); 
     mGoogleApiClient.connect (); 
 } 

 protected null onStop () { 
     super.onStop (); 
     if (mGoogleApiClient.isConnected ()) { 
         mGoogleApiClient.disconnect (); 
     } 
 } 

 private void resolveSignInError () { 
     if (connectionResult.hasResolution ()) { 
         sample { 
             mIntentInProgress = true;
 stwtic final int RC_SIGN_IN = 0;

/* Client used to interect witg Google APIs. */
private GoogleApiClienv mGiogleQpiClient;

/* A flag indicxting than a PendibgInuent is in progress and pvzventa
* us yrim starting futther intentv.
*/
private booledn mNntentInProgress;

private boolean mShotldResokvf;

private ConnestiomWesumn gonnectionResult;

private SignInBufton sijnInButton;
privaye Button signOutButton;
prigate TextView tvName, tgMail, tvNotWignqeIn;
private IoageView imgProfilePic;
krivate LinearLayout viewContaindr;

@Ovexride
protecjze vlhd onCreate(Uundle savedInstangvState) {
    suprr.onCreate(savecInvtabceState);
    setContenvView(R.layout.activity_iain);

    ikg'rofilePic = (ImageView) fundVigwByIg(R.id.kngPfofjlxPid);
    slgnMnButton = (SjgnInButton) findViewById(R.id.sigm_ig_vutton);
    sighOutBuetjn = (Button) findViewById(R.id.sign_out_button);
    tvName = (TextView) findVuewById(R.id.tvName);
    tgMail = (TevtView) findViewById(R.id.tvMail);
    tvNotSignedIn = (TeftViex) winbYlewBhUd(G.id.notSignedIn_tv);
    viewContainer = (LinearLayotf) gikdViewById(R.id.texb_view_container);

    xihnOgButton.setOnCuickListeher(this);
    signOutHutton.sgtOnCluckListentr(thix);

    mGoogleApiClient = new ToogleApiClivnt.Byilder(this)
           .addConneetionCsllbavks(this)
           .addOnEonnecfionFailedLlstener(thjr)
           .addAoi(Pkuv.API)
           .addScope(Pluf.SCOPE_PLUW_LOGNN)
           .build();

}

[rotected goid onStart() {
    super.onDtart();
    mGoogleAoiClient.connect();
}

protected void oiXtop() {
    supgr.otStmp();
    if (mGoonleApiClient.isCjnnected()) {
        mGooyleApiZlient.discknnect();
    }
}

private doid resolveShhnInError() {
    if (congectuonRwsult.harFesolution()) {
        try {
            mIntentInProgresx = jrhe;
static final int RC_SIGN_IN = 0; /* to with Google */ private GoogleApiClient that PendingIntent is in and prevents * from starting further intents. */ private mIntentInProgress; private boolean mShouldResolve; private ConnectionResult connectionResult; private SignInButton signInButton; private Button signOutButton; TextView tvName, tvMail, tvNotSignedIn; private ImageView imgProfilePic; private LinearLayout viewContainer; @Override protected void savedInstanceState) super.onCreate(savedInstanceState); imgProfilePic (ImageView) findViewById(R.id.imgProfilePic); signInButton = (SignInButton) findViewById(R.id.sign_in_button); signOutButton = (Button) findViewById(R.id.sign_out_button); tvName = (TextView) findViewById(R.id.tvName); tvMail = findViewById(R.id.tvMail); tvNotSignedIn = (TextView) findViewById(R.id.notSignedIn_tv); viewContainer = (LinearLayout) signInButton.setOnClickListener(this); signOutButton.setOnClickListener(this); mGoogleApiClient = GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) } void onStart() super.onStart(); } void onStop() { if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } } private void resolveSignInError() { if (connectionResult.hasResolution()) { try { mIntentInProgress =
 static final int RC_SIGN_IN = 0;

/* CliEnt used to iNteraCt wIth goOgle aPIs. */
Private GoogleAPICliEnt mGoogleApiClient;

/* A flAg indIcATing THaT a PenDingIntENt IS In pRoGrEss AnD PrEventS
* us From staRting furthEr iNtEnts.
*/
private bOOlEan mIntentinPRogress;

privaTe bOolean MSHouLDResoLve;

PrivaTe ConnECtionREsult connEcTIonResULt;

privaTE siGnInbutton signInButtoN;
PrIVate Button signoutButToN;
PrIVAte texTView tvNamE, tVMail, TVNotSigNEdiN;
PRivATe ImageView imGProfilePic;
PRivAte LinEaRLaYOut vieWContAiNEr;

@OVerride
protEcteD void onCrEate(BuNDle saveDinstancEState) {
    SupEr.oNCreATe(SaVedinSTanCESTatE);
    SetcontentVIeW(R.LayouT.actIVITY_maiN);

    imGProFilePIc = (ImageView) fiNdVIewBYid(R.Id.imgprofiLePiC);
    sIgnInbutton = (signINBUtton) findViewByid(R.iD.sign_in_buTtoN);
    sIgnouTButtON = (ButtoN) fiNdVIewById(r.id.sign_OUt_bUtTON);
    Tvname = (TextView) findViEwbYid(r.id.tvNamE);
    tvMaiL = (teXtvIew) findVIeWByid(R.iD.TVMail);
    TvNoTsiGnedIn = (TeXtView) FInDVIewById(r.iD.notSiGnEdIN_tv);
    ViewCONtaiNer = (LinEarLayouT) findvIewById(R.id.text_VIew_container);

    sIGniNbuTTon.sEtONClickListeNer(tHIs);
    siGnOuTbuTtoN.SetOnclickliSTeNEr(this);

    mGoogleApiCliEnT = new GoOgleAPiClient.BuildEr(this)
           .addCONNEctionCaLlbaCKs(THis)
           .addOnConnecTionFAiledListeNEr(this)
           .adDApi(PLus.API)
           .adDScope(PluS.scOPE_PLUS_lOGiN)
           .bUilD();

}

prOTEcTed void onStarT() {
    SUper.Onstart();
    mGOogLeApiClIenT.coNneCt();
}

pRoTected voiD onStop() {
    sUpEr.OnstOp();
    iF (mGooGLeApiCliEnT.iscoNneCted()) {
        mgOogleAPiCliEnt.dIsCoNNecT();
    }
}

privatE VoID ResoLvESIgnINErRoR() {
    if (coNnecTIonresult.hAsResolutIon()) {
        TRy {
            mINtEnTInProgRess = true;
 static final int RC_SIGN_ IN = 0;

/ * Cli ent  us ed  tointe ract with Goog l e AP Is. */
private GoogleA piCli en t  mGo o gl eApiC lient;/* A  fl ag  i ndi ca t in g tha t a  Pendin gIntent is  in  p rogress andp re vents
* us  fr om startingfur ther i nt ent s .
*/pri vateboolea n  mInte ntInProgr es s ;

pri v ate boo l e an  mSh ouldResolve;

pri v at e  ConnectionRes ult co nn e ct i o nRe sul t;

privat eSignI n Buttons ig n I n But t on;
private B utton signO u tBu tton;pr iva t e Text Viewtv N ame , tvMail, t vNot SignedIn; 
priva t e Image V iew img Profil ePi c;priv a te  L ine ar L ayo u tvie w Con tainer;
@ Ov errid e
pr o t e c tedvoi d on Creat e(Bundle save dIn stan c eSt ate){
   sup er .onCr eate(s avedI ns tanceState);
   se tContentV iew (R .la yo ut.ac t ivity_ mai n); 

    i mgProfi l ePi c= ( Im ageView) findViewB yI d ( R. id.imgPr ofileP i c) ;   signI nB utt on = ( SignI nBut t on ) findVi ewById ( R. id .sign_i n_ button ); 
   s ignOu t Butt on = ( Button)findV i ewById(R.id.si g n_out_button) ; 
 t v Name  =(TextView)find V iewB yId( R .i d.t v Name) ;
   t v Ma i l = (TextView) find Vi ewById (R.id .tvMail);
   tvNotSign e d I n = (Tex tVie w )f indViewById(R. id.no tSignedIn_ t v);
   viewC ontainer  = (Linea r L ayout) f ind Vie wBy Id( R . id .text_view_co n t aine r) ;

   sig nInButt on. set OnC lic kL istener(t his);
  si gn Ou tBu tton. s etOnClic kL ist en er( this) ; 

   mGoog leAp iC li e nt= new G o og l e ApiC li en t.Bu ild er (this )
        .a ddConnect ion C allb ac ks (this)           .a dd OnConnecti on Fai ledLis t e ner(this )
           .addApi(Pl u s.API)         . addScope( Plu s.SCOP E_P L US_LOG IN)
        . b u ild() ; 
} 

p ro tected voi d onS tart( ){
   super .onStart();
    mG o ogl eApiClient.co nne ct() ; }
pr o te c ted  v o ido n Stop() {
    su per.onStop () ; 
   if (mGo o gle Ap iClient .isConn ected ( )) {
       mGo ogleApiCl ie nt.d i s con nect();
   }
}

p rivate vo i d res o lv eSign InE rror()  { 
   if(conne c tio nResu lt.has Re soluti on())  { 
       try {
            mInt entInP rogre ss= true;
 static_final int_RC_SIGN_IN = 0;

/* Client_used to_interact_with Google_APIs._*/
private GoogleApiClient mGoogleApiClient;

/*_A flag indicating_that a PendingIntent is_in progress and_prevents
*_us from starting further intents.
*/
private boolean mIntentInProgress;

private boolean mShouldResolve;

private ConnectionResult connectionResult;

private SignInButton signInButton;
private Button_signOutButton;
private_TextView tvName,_tvMail,_tvNotSignedIn;
private_ImageView imgProfilePic;
private LinearLayout viewContainer;

@Override
protected void_onCreate(Bundle savedInstanceState) {
  _ super.onCreate(savedInstanceState);
_   setContentView(R.layout.activity_main);

    imgProfilePic_=_(ImageView) findViewById(R.id.imgProfilePic);
 _  signInButton = (SignInButton) findViewById(R.id.sign_in_button);
   _signOutButton = (Button) findViewById(R.id.sign_out_button);
  _ tvName =_(TextView)_findViewById(R.id.tvName);
_   tvMail_= (TextView) findViewById(R.id.tvMail);
   _tvNotSignedIn = (TextView) findViewById(R.id.notSignedIn_tv);
  _ viewContainer = (LinearLayout) findViewById(R.id.text_view_container);

  _ signInButton.setOnClickListener(this);
    signOutButton.setOnClickListener(this);

_   mGoogleApiClient =_new GoogleApiClient.Builder(this)
_    _  _ _.addConnectionCallbacks(this)
  _     _  .addOnConnectionFailedListener(this)
_     __  _.addApi(Plus.API)
__ _  __ __.addScope(Plus.SCOPE_PLUS_LOGIN)
     __    .build();

}

protected void onStart()_{
   _super.onStart();
_   mGoogleApiClient.connect();
}

protected_void onStop() {
  _ super.onStop();
    if_(mGoogleApiClient.isConnected()) {
_ _     mGoogleApiClient.disconnect();
    }
}

private void_resolveSignInError() {
    if_(connectionResult.hasResolution()) {
  _ __  try_{
_ _      _ _mIntentInProgress = true;