-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into improve_javadoc
- Loading branch information
Showing
2 changed files
with
76 additions
and
57 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
example/src/main/java/com/example/InternalDebugOnlyData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.example; | ||
|
||
import com.parsely.parselyandroid.ParselyTrackerInternal; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* The InternalDebugOnlyData class is designed to provide access to internal data for debugging | ||
* purposes through reflection. The methods within this class are intended for internal use only | ||
* and should *not* be utilized within the SDK user's code. | ||
* @noinspection KotlinInternalInJava | ||
*/ | ||
class InternalDebugOnlyData { | ||
private final ParselyTrackerInternal parselyTracker; | ||
|
||
InternalDebugOnlyData(ParselyTrackerInternal parselyTracker) { | ||
this.parselyTracker = parselyTracker; | ||
} | ||
|
||
boolean engagementIsActive() { | ||
return (boolean) invokePrivateMethod("engagementIsActive"); | ||
} | ||
|
||
@Nullable | ||
Double getEngagementInterval() { | ||
return (Double) invokePrivateMethod("getEngagementInterval"); | ||
} | ||
|
||
@Nullable | ||
Double getVideoEngagementInterval() { | ||
return (Double) invokePrivateMethod("getVideoEngagementInterval"); | ||
} | ||
|
||
long getFlushInterval() { | ||
return (long) invokePrivateMethod("getFlushInterval"); | ||
} | ||
|
||
boolean videoIsActive() { | ||
return (boolean) invokePrivateMethod("videoIsActive"); | ||
} | ||
|
||
boolean flushTimerIsActive() { | ||
return (boolean) invokePrivateMethod("flushTimerIsActive"); | ||
} | ||
|
||
private Object invokePrivateMethod(String methodName) { | ||
try { | ||
Method method = ParselyTrackerInternal.class.getDeclaredMethod(methodName); | ||
method.setAccessible(true); | ||
return method.invoke(parselyTracker); | ||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters