66import android .content .Context ;
77import android .content .Intent ;
88import android .os .Bundle ;
9- import android .util .Log ;
109import android .view .LayoutInflater ;
1110import android .view .View ;
1211import android .widget .EditText ;
1312
1413import com .firebase .client .AuthData ;
1514import com .firebase .client .Firebase ;
1615import com .firebase .ui .R ;
17- import com .firebase .ui .auth .facebook .FacebookAuthProvider ;
1816import com .firebase .ui .auth .google .GoogleAuthProvider ;
19- import com .firebase .ui .auth .password .PasswordAuthProvider ;
20- import com .firebase .ui .auth .twitter .TwitterAuthProvider ;
2117
2218import java .util .HashMap ;
2319import java .util .Map ;
@@ -31,11 +27,6 @@ public class FirebaseLoginDialog extends DialogFragment {
3127 Context mContext ;
3228 View mView ;
3329
34- /*
35- We need to be extra aggressive about building / destroying mGoogleauthProviders so we don't
36- end up with two clients connected at the same time.
37- */
38-
3930 @ Override
4031 public void onStop () {
4132 super .onStop ();
@@ -76,7 +67,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
7667 showLoginOption (mEnabledProvidersByType .get (providerType ), providerType .getButtonId ());
7768 }
7869 else {
79- mView .findViewById (providerType .getButtonId ()).setVisibility (View .GONE );;
70+ mView .findViewById (providerType .getButtonId ()).setVisibility (View .GONE );
8071 }
8172 }
8273
@@ -86,9 +77,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
8677 }
8778
8879 mView .findViewById (R .id .loading_section ).setVisibility (View .GONE );
89-
9080 builder .setView (mView );
9181
82+ this .setRetainInstance (true );
9283 return builder .create ();
9384 }
9485
@@ -146,18 +137,18 @@ private void showLoginOption(final FirebaseAuthProvider helper, int id) {
146137 mView .findViewById (id ).setOnClickListener (new View .OnClickListener () {
147138 @ Override
148139 public void onClick (View view ) {
149- if (AuthProviderType .getTypeForProvider (helper ) == AuthProviderType .PASSWORD ) {
150- EditText emailText = (EditText ) mView .findViewById (R .id .email );
151- EditText passwordText = (EditText ) mView .findViewById (R .id .password );
152- helper .login (emailText .getText ().toString (), passwordText .getText ().toString ());
153-
154- passwordText .setText ("" );
155- } else {
156- helper .login ();
157- }
158- mActiveProvider = helper .getProviderType ();
159- mView .findViewById (R .id .login_section ).setVisibility (View .GONE );
160- mView .findViewById (R .id .loading_section ).setVisibility (View .VISIBLE );
140+ if (AuthProviderType .getTypeForProvider (helper ) == AuthProviderType .PASSWORD ) {
141+ EditText emailText = (EditText ) mView .findViewById (R .id .email );
142+ EditText passwordText = (EditText ) mView .findViewById (R .id .password );
143+ helper .login (emailText .getText ().toString (), passwordText .getText ().toString ());
144+
145+ passwordText .setText ("" );
146+ } else {
147+ helper .login ();
148+ }
149+ mActiveProvider = helper .getProviderType ();
150+ mView .findViewById (R .id .login_section ).setVisibility (View .GONE );
151+ mView .findViewById (R .id .loading_section ).setVisibility (View .VISIBLE );
161152 }
162153 });
163154 }
0 commit comments