mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
#2821 added null check
This commit is contained in:
parent
4b1c8ae1b0
commit
74e7212067
@ -36,14 +36,22 @@ inline fun <reified T : BaseRobot> T.applyWithViewHierarchyPrinting(
|
|||||||
} catch (runtimeException: RuntimeException) {
|
} catch (runtimeException: RuntimeException) {
|
||||||
uiDevice.takeScreenshot(File(context.filesDir, "${System.currentTimeMillis()}.png"))
|
uiDevice.takeScreenshot(File(context.filesDir, "${System.currentTimeMillis()}.png"))
|
||||||
InstrumentationRegistry.getInstrumentation().runOnMainSync {
|
InstrumentationRegistry.getInstrumentation().runOnMainSync {
|
||||||
|
// During the Pause state, it can't any state or since it may not hold strong reference it
|
||||||
|
// may garbage collected in the low memory stage or may not return an instance of particular
|
||||||
|
// activity
|
||||||
|
val activity =
|
||||||
|
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED).lastOrNull()
|
||||||
|
if (activity != null) {
|
||||||
throw RuntimeException(
|
throw RuntimeException(
|
||||||
combineMessages(
|
combineMessages(
|
||||||
runtimeException,
|
runtimeException = runtimeException,
|
||||||
ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED).last()
|
activity = activity
|
||||||
),
|
),
|
||||||
runtimeException
|
runtimeException
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
throw RuntimeException()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user