2222import  android .content .Intent ;
2323import  android .net .Uri ;
2424import  android .os .Bundle ;
25+ import  android .support .annotation .Nullable ;
26+ import  android .util .Log ;
2527import  android .view .WindowManager ;
2628
2729import  java .util .ArrayList ;
30+ import  java .util .Arrays ;
2831import  java .util .Collection ;
32+ import  java .util .List ;
2933import  java .util .UUID ;
3034
3135import  io .fabric .sdk .android .Fabric ;
@@ -148,6 +152,31 @@ public void setup(
148152            String  subdomain ,
149153            String  twitterConsumerKey ,
150154            String  twitterSecret ) {
155+         setup (context , subdomain , null , twitterConsumerKey , twitterSecret );
156+     }
157+ 
158+     /** 
159+      * setup manager instance. should be called before using the manager. Otherwise the manager will 
160+      * not function. 
161+      * 
162+      * @param context            context 
163+      * @param subdomain          subdomain of your OneAll application 
164+      * @param defaultProviders   The list of default providers used to immediately 
165+      *                           populate the accepted providers list while we don't get a response 
166+      *                           from the server (async) or cache (sync). 
167+      * @param twitterConsumerKey (optional) Twitter consumer key from 
168+      *                           {@link <a href="https://apps.twitter.com/">https://apps.twitter.com/</a>} 
169+      * @param twitterSecret      (optional) Twitter secret key from 
170+      *                           {@link <a href="https://apps.twitter.com/">https://apps.twitter.com/</a>} 
171+      * @throws java.lang.NullPointerException     if {@code context} is null 
172+      * @throws java.lang.IllegalArgumentException if {@code subdomain} is null or empty 
173+      */ 
174+     public  void  setup (
175+             Context  context ,
176+             String  subdomain ,
177+             @ Nullable  List <Provider > defaultProviders ,
178+             String  twitterConsumerKey ,
179+             String  twitterSecret ) {
151180
152181        if  (context  == null ) {
153182            throw  new  NullPointerException ("context cannot be null" );
@@ -167,11 +196,11 @@ public void setup(
167196
168197        // if the parent app already initialized Fabric for some of its other modules 
169198        // make sure it includes the required TwitterCore. Otherwise, init it ourselves 
170-         if (!Fabric .isInitialized ()) {
199+         if   (!Fabric .isInitialized ()) {
171200            TwitterAuthConfig  authConfig  = new  TwitterAuthConfig (twitterConsumerKey , twitterSecret );
172201            Fabric .with (this .mAppContext , new  TwitterCore (authConfig ));
173202        } else  {
174-             if (Fabric .getKit (TwitterCore .class ) == null ) {
203+             if   (Fabric .getKit (TwitterCore .class ) == null ) {
175204                OALog .error ("Twitter's Fabric is already init but it doesn't include TwitterCore kit which is required for Auth calls" );
176205            } else  {
177206                OALog .warn ("Twitter's Fabric was already init with a TwitterCore kit. Reusing existing kit" );
@@ -181,6 +210,12 @@ public void setup(
181210        OALog .info (String .format ("SDK init with subdomain %s" , subdomain ));
182211
183212        Settings .getInstance ().setSubdomain (subdomain );
213+ 
214+         if (defaultProviders  != null ) {
215+             // init ProviderManager with default providers 
216+             ProviderManager .getInstance ().updateProviders (defaultProviders );
217+         }
218+ 
184219        ProviderManager .getInstance ().refreshProviders (mAppContext );
185220    }
186221
0 commit comments