I try to convert code Kotlin to java and I could not find run function in java. This is Kotlin code :
private val resumeArElementsTask = Runnable {
locationScene?.resume()
arSceneView!!.resume()
}
And I use resumeArElementsTask like
resumeArElementsTask.run {
computeNewScaleModifierBasedOnDistance(locationMarker, locationNode.distance)
}
When I convert to java
private final Runnable resumeArElementsTask = new Runnable() {
@Override
public void run() {
locationScene.resume();
try {
arSceneView.resume();
} catch (CameraNotAvailableException e) {
e.printStackTrace();
}
}
};
How can I use run function in java and convert this code to java
resumeArElementsTask.run {
computeNewScaleModifierBasedOnDistance(locationMarker, locationNode.distance)
}
Thanks
CodePudding user response:
The following Java code is exactly equivalent to what your Kotlin code actually does:
computeNewScaleModifierBasedOnDistance(locationMarker, locationNode.getDistance());
Note that it doesn't resume anything. Your Kotlin code doesn't, either. It looks like it does, but it doesn't.
It sounds like you just want to write
runnable.run();
computeNewScaleModifierBasedOnDistance(locationMarker, locationNode.getDistance());