Skip to content

Commit c78183c

Browse files
committed
Fix missing equivalents to 'Meteor' constructors in 'MeteorSingleton'
1 parent e507827 commit c78183c

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

Source/library/src/main/java/im/delight/android/ddp/MeteorSingleton.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
import im.delight.android.ddp.db.DataStore;
1920
import 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 {
2425
private static MeteorSingleton mInstance;
2526

2627
public 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) {
3138
if (mInstance != null) {
3239
throw 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+
4264
return mInstance;
4365
}
4466

@@ -68,8 +90,16 @@ private MeteorSingleton(final Context context, final String serverUri) {
6890
super(context, serverUri);
6991
}
7092

93+
private MeteorSingleton(final Context context, final String serverUri, final DataStore dataStore) {
94+
super(context, serverUri, dataStore);
95+
}
96+
7197
private MeteorSingleton(final Context context, final String serverUri, final String protocolVersion) {
7298
super(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

Comments
 (0)