1616 * limitations under the License.
1717 */
1818
19+ import im .delight .android .ddp .db .DataStore ;
1920import android .content .Context ;
2021
2122/** Provides a single access point to the `Meteor` class that can be used across `Activity` instances */
@@ -24,21 +25,42 @@ public class MeteorSingleton extends Meteor {
2425private static MeteorSingleton mInstance ;
2526
2627public synchronized static MeteorSingleton createInstance (final Context context , final String serverUri ) {
27- return createInstance (context , serverUri , null );
28+ if (mInstance != null ) {
29+ throw new IllegalStateException ("An instance has already been created" );
30+ }
31+
32+ mInstance = new MeteorSingleton (context , serverUri );
33+
34+ return mInstance ;
2835}
2936
30- public synchronized static MeteorSingleton createInstance (final Context context , final String serverUri , final String protocolVersion ) {
37+ public synchronized static MeteorSingleton createInstance (final Context context , final String serverUri , final DataStore dataStore ) {
3138if (mInstance != null ) {
3239throw new IllegalStateException ("An instance has already been created" );
3340}
3441
35- if (protocolVersion == null ) {
36- mInstance = new MeteorSingleton (context , serverUri );
42+ mInstance = new MeteorSingleton (context , serverUri , dataStore );
43+
44+ return mInstance ;
45+ }
46+
47+ public synchronized static MeteorSingleton createInstance (final Context context , final String serverUri , final String protocolVersion ) {
48+ if (mInstance != null ) {
49+ throw new IllegalStateException ("An instance has already been created" );
3750}
38- else {
39- mInstance = new MeteorSingleton (context , serverUri , protocolVersion );
51+
52+ mInstance = new MeteorSingleton (context , serverUri , protocolVersion );
53+
54+ return mInstance ;
55+ }
56+
57+ public synchronized static MeteorSingleton createInstance (final Context context , final String serverUri , final String protocolVersion , final DataStore dataStore ) {
58+ if (mInstance != null ) {
59+ throw new IllegalStateException ("An instance has already been created" );
4060}
4161
62+ mInstance = new MeteorSingleton (context , serverUri , protocolVersion , dataStore );
63+
4264return mInstance ;
4365}
4466
@@ -68,8 +90,16 @@ private MeteorSingleton(final Context context, final String serverUri) {
6890super (context , serverUri );
6991}
7092
93+ private MeteorSingleton (final Context context , final String serverUri , final DataStore dataStore ) {
94+ super (context , serverUri , dataStore );
95+ }
96+
7197private MeteorSingleton (final Context context , final String serverUri , final String protocolVersion ) {
7298super (context , serverUri , protocolVersion );
7399}
74100
101+ private MeteorSingleton (final Context context , final String serverUri , final String protocolVersion , final DataStore dataStore ) {
102+ super (context , serverUri , protocolVersion , dataStore );
103+ }
104+
75105}
0 commit comments