Skip to content

Commit

Permalink
Preventing re-initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldestlivingboy committed Mar 25, 2024
1 parent 5e9ee6b commit 7842c30
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ dependencies {
implementation 'androidx.preference:preference:1.2.1'
implementation 'org.apache.maven:maven-artifact:3.8.1'
implementation 'com.github.kittinunf.fuel:fuel:1.6.0'
implementation 'com.massive:sdk:0.7.0'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
implementation 'com.dtx12:actions:0.1.4'
implementation 'com.wbrawner.plausible:plausible-android:0.1.0-SNAPSHOT'
implementation 'com.massive:sdk:0.7.0'
implementation 'com.google.firebase:firebase-functions:20.4.0'
implementation 'com.onesignal:OneSignal:5.1.6'
implementation 'com.wbrawner.plausible:plausible-android:0.1.0-SNAPSHOT'
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import com.massive.sdk.MassiveServiceType;
import com.massive.sdk.State;

import com.wbrawner.plausible.android.Plausible;

import com.onesignal.OneSignal;

import com.wbrawner.plausible.android.Plausible;

import com.rocketshipapps.adblockfast.utils.Ruleset;

public class AdblockFastApplication extends Application {
Expand Down Expand Up @@ -140,36 +140,40 @@ public static void dumpPrefs() {
}

public static void initMassive(Context context) {
MassiveClient.Companion.getInstance(context, (client) -> {
massiveClient = client;

if (client.getState() == State.NotInitialized) {
client.initAsync(
BuildConfig.MASSIVE_API_TOKEN,
new MassiveOptions(
MassiveServiceType.Foreground,
new MassiveNotificationOptions(
context.getString(R.string.name),
context.getString(R.string.foreground_text),
R.drawable.icon
)
),
new InitCallback() {
@Override
public void onSuccess() {
if (Ruleset.isUpgraded()) client.start();
Plausible.INSTANCE.event("Succeed", "/massive", "", null);
if (massiveClient == null) {
MassiveClient.Companion.getInstance(context, (client) -> {
massiveClient = client;

if (client.getState() == State.NotInitialized) {
client.initAsync(
BuildConfig.MASSIVE_API_TOKEN,
new MassiveOptions(
MassiveServiceType.Foreground,
new MassiveNotificationOptions(
context.getString(R.string.name),
context.getString(R.string.foreground_text),
R.drawable.icon
)
),
new InitCallback() {
@Override
public void onSuccess() {
if (Ruleset.isUpgraded()) client.start();
Plausible.INSTANCE.event("Succeed", "/massive", "", null);
}

@Override
public void onFailure(@NonNull String message) {
Plausible.INSTANCE.event("Fail", "/massive", "", null);
}
}
);
}

@Override
public void onFailure(@NonNull String message) {
Plausible.INSTANCE.event("Fail", "/massive", "", null);
}
}
);
}

return Unit.INSTANCE;
});
return Unit.INSTANCE;
});
} else if (massiveClient.getState() != State.NotInitialized && Ruleset.isUpgraded()) {
massiveClient.start();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
import io.github.inflationx.viewpump.ViewPump;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;

import com.wbrawner.plausible.android.Plausible;
import com.massive.sdk.State;

import com.onesignal.Continue;
import com.onesignal.OneSignal;

import com.wbrawner.plausible.android.Plausible;

import com.rocketshipapps.adblockfast.utils.Ruleset;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -114,7 +116,10 @@ protected void onResume() {

if (AdblockFastApplication.massiveClient == null) {
AdblockFastApplication.initMassive(this);
} else if (Ruleset.isUpgraded()) {
} else if (
AdblockFastApplication.massiveClient.getState() != State.NotInitialized &&
Ruleset.isUpgraded()
) {
AdblockFastApplication.massiveClient.start();
}

Expand Down

0 comments on commit 7842c30

Please sign in to comment.