Skip to content

Commit

Permalink
refactor: Migrate Internal Constants class to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansi-mParticle committed Sep 26, 2024
1 parent a86cd3b commit 8a4cd58
Show file tree
Hide file tree
Showing 10 changed files with 857 additions and 824 deletions.
49 changes: 23 additions & 26 deletions android-core/src/main/java/com/mparticle/identity/IdentityApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,18 @@ public class IdentityApi {
public static int THROTTLE_ERROR = 429;
public static int BAD_REQUEST = 400;
public static int SERVER_ERROR = 500;

private Context mContext;
private BaseHandler mBackgroundHandler;
private BaseHandler mMainHandler;
private MParticle.OperatingSystem mOperatingSystem;
private static final Object lock = new Object();
ConfigManager mConfigManager;
MessageManager mMessageManager;
KitManager mKitManager;
private Internal mInternal = new Internal();

MParticleUserDelegate mUserDelegate;
private MParticleIdentityClient mApiClient;

Set<IdentityStateListener> identityStateListeners = new HashSet<IdentityStateListener>();
private static Object lock = new Object();
private Context mContext;
private BaseHandler mBackgroundHandler;
private BaseHandler mMainHandler;
private MParticle.OperatingSystem mOperatingSystem;
private final Internal mInternal = new Internal();
private MParticleIdentityClient mApiClient;

protected IdentityApi() {
}
Expand All @@ -65,7 +62,7 @@ public IdentityApi(Context context, AppStateManager appStateManager, MessageMana
this.mMessageManager = messageManager;
this.mKitManager = kitManager;
this.mOperatingSystem = operatingSystem;
configManager.addMpIdChangeListener(new IdentityStateListenerManager());
ConfigManager.addMpIdChangeListener(new IdentityStateListenerManager());
setApiClient(new MParticleIdentityClientImpl(context, configManager, operatingSystem));
}

Expand Down Expand Up @@ -93,7 +90,7 @@ public MParticleUser getCurrentUser() {
*/
@Nullable
public MParticleUser getUser(@NonNull Long mpid) {
if (!Constants.TEMPORARY_MPID.equals(mpid) && mConfigManager.mpidExists(mpid)) {
if (Constants.TEMPORARY_MPID != mpid && mConfigManager.mpidExists(mpid)) {
return MParticleUserImpl.getInstance(mContext, mpid, mUserDelegate);
} else {
return null;
Expand Down Expand Up @@ -158,7 +155,7 @@ public MParticleTask<IdentityApiResult> logout() {
/**
* @return an MParticleTask<IdentityApiResult> to handle the Asynchronous results
* @see IdentityApiRequest
*
* <p>
* calls the Identity Logout endpoint
* @see MParticleTask and
* @see IdentityApiResult
Expand Down Expand Up @@ -252,7 +249,7 @@ public BaseIdentityTask modify(@NonNull final IdentityApiRequest updateRequest)
if (updateRequest.mpid == null) {
updateRequest.mpid = mConfigManager.getMpid();
}
if (Constants.TEMPORARY_MPID.equals(updateRequest.mpid)) {
if (Constants.TEMPORARY_MPID == updateRequest.mpid) {
String message = "modify() requires a non-zero MPID, please make sure a MParticleUser is present before making a modify request.";
if (devMode) {
throw new IllegalArgumentException(message);
Expand Down Expand Up @@ -417,6 +414,18 @@ public interface MpIdChangeListener {
void onMpIdChanged(long newMpid, long previousMpid);
}

public static abstract class SingleUserIdentificationCallback implements IdentityStateListener {

@Override
public void onUserIdentified(MParticleUser user, MParticleUser previousUser) {
MParticle.getInstance().Identity().removeIdentityStateListener(this);
onUserFound(user);
}

public abstract void onUserFound(MParticleUser user);

}

class IdentityStateListenerManager implements MpIdChangeListener {

@Override
Expand Down Expand Up @@ -454,18 +463,6 @@ public void run() {
}
}

public static abstract class SingleUserIdentificationCallback implements IdentityStateListener {

@Override
public void onUserIdentified(MParticleUser user, MParticleUser previousUser) {
MParticle.getInstance().Identity().removeIdentityStateListener(this);
onUserFound(user);
}

public abstract void onUserFound(MParticleUser user);

}

/**
* @hidden
*/
Expand Down
67 changes: 0 additions & 67 deletions android-core/src/main/java/com/mparticle/internal/BatchId.java

This file was deleted.

Loading

0 comments on commit 8a4cd58

Please sign in to comment.