(
&self,
env: &mut JNIEnv,
host: &JObject,
id_map: &mut NodeIdMap,
node_info: &JObject,
)
| 175 | } |
| 176 | |
| 177 | pub(crate) fn populate_node_info( |
| 178 | &self, |
| 179 | env: &mut JNIEnv, |
| 180 | host: &JObject, |
| 181 | id_map: &mut NodeIdMap, |
| 182 | node_info: &JObject, |
| 183 | ) { |
| 184 | for child in self.0.filtered_children(&filter) { |
| 185 | env.call_method( |
| 186 | node_info, |
| 187 | "addChild", |
| 188 | "(Landroid/view/View;I)V", |
| 189 | &[host.into(), id_map.get_or_create_java_id(&child).into()], |
| 190 | ) |
| 191 | .unwrap(); |
| 192 | } |
| 193 | if let Some(parent) = self.0.filtered_parent(&filter) { |
| 194 | if parent.is_root() { |
| 195 | env.call_method( |
| 196 | node_info, |
| 197 | "setParent", |
| 198 | "(Landroid/view/View;)V", |
| 199 | &[host.into()], |
| 200 | ) |
| 201 | .unwrap(); |
| 202 | } else { |
| 203 | env.call_method( |
| 204 | node_info, |
| 205 | "setParent", |
| 206 | "(Landroid/view/View;I)V", |
| 207 | &[host.into(), id_map.get_or_create_java_id(&parent).into()], |
| 208 | ) |
| 209 | .unwrap(); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | if let Some(rect) = self.0.bounding_box() { |
| 214 | let location = env.new_int_array(2).unwrap(); |
| 215 | env.call_method(host, "getLocationOnScreen", "([I)V", &[(&location).into()]) |
| 216 | .unwrap(); |
| 217 | let mut location_buf = [0; 2]; |
| 218 | env.get_int_array_region(&location, 0, &mut location_buf) |
| 219 | .unwrap(); |
| 220 | let host_screen_x = location_buf[0]; |
| 221 | let host_screen_y = location_buf[1]; |
| 222 | let android_rect_class = env.find_class("android/graphics/Rect").unwrap(); |
| 223 | let android_rect = env |
| 224 | .new_object( |
| 225 | &android_rect_class, |
| 226 | "(IIII)V", |
| 227 | &[ |
| 228 | ((rect.x0 as jint) + host_screen_x).into(), |
| 229 | ((rect.y0 as jint) + host_screen_y).into(), |
| 230 | ((rect.x1 as jint) + host_screen_x).into(), |
| 231 | ((rect.y1 as jint) + host_screen_y).into(), |
| 232 | ], |
| 233 | ) |
| 234 | .unwrap(); |
no test coverage detected