File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
auth/src/main/java/com/firebase/ui/auth/data/remote Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change 33
33
public class TwitterSignInHandler extends ProviderSignInBase <Void > {
34
34
static {
35
35
if (ProviderAvailability .IS_TWITTER_AVAILABLE ) {
36
- initializeTwitter ();
36
+ Context context = AuthUI .getApplicationContext ();
37
+
38
+ // Note: this has no effect if Twitter is already initialized so it's safe to call
39
+ // multiple times.
40
+ Twitter .initialize (new TwitterConfig .Builder (context )
41
+ .twitterAuthConfig (new TwitterAuthConfig (
42
+ context .getString (R .string .twitter_consumer_key ),
43
+ context .getString (R .string .twitter_consumer_secret )))
44
+ .build ());
37
45
}
38
46
}
39
47
@@ -46,15 +54,11 @@ public TwitterSignInHandler(Application application) {
46
54
}
47
55
48
56
public static void initializeTwitter () {
49
- Context context = AuthUI .getApplicationContext ();
50
-
51
- // Note: this has no effect if Twitter is already initialized so it's safe to call
52
- // multiple times.
53
- Twitter .initialize (new TwitterConfig .Builder (context )
54
- .twitterAuthConfig (new TwitterAuthConfig (
55
- context .getString (R .string .twitter_consumer_key ),
56
- context .getString (R .string .twitter_consumer_secret )))
57
- .build ());
57
+ // This method is intentionally empty, but calling it forces the static {} block of this
58
+ // class to be executed (if it wasn't already).
59
+ //
60
+ // Even though it's currently safe to initialize Twitter more than once, this protects
61
+ // against a future behavior change and gives a small efficiency gain.
58
62
}
59
63
60
64
private static IdpResponse createIdpResponse (
You can’t perform that action at this time.
0 commit comments