Skip to main content

AndroidHostBridge

Struct AndroidHostBridge 

Source
pub struct AndroidHostBridge<V: View + 'static> {
    pub root_handle: Handle<V>,
    /* private fields */
}
Expand description

泛型 Android JNI / NDK 宿主桥接器(将任意业务 View 挂载至 MobileEmbedApp 并桥接 Android 视图生命周期)。

Fields§

§root_handle: Handle<V>

Implementations§

Source§

impl<V: View + Default + 'static> AndroidHostBridge<V>

Source

pub fn new( width: i16, height: i16, status_bar_top: i16, gesture_bar_bottom: i16, ) -> Self

使用 V::default() 创建指定视口尺寸与系统状态栏/手势导航条安全区的 Android 应用宿主。

Source§

impl<V: View + 'static> AndroidHostBridge<V>

Source

pub const ACTION_DOWN: u8 = 0

Android MotionEvent.ACTION_DOWN。

Source

pub const ACTION_UP: u8 = 1

Android MotionEvent.ACTION_UP。

Source

pub const ACTION_MOVE: u8 = 2

Android MotionEvent.ACTION_MOVE。

Source

pub const ACTION_CANCEL: u8 = 3

Android MotionEvent.ACTION_CANCEL。

Source

pub fn with_root( width: i16, height: i16, status_bar_top: i16, gesture_bar_bottom: i16, root_view: V, ) -> Self

使用给定根视图实例 root_view 创建指定视口尺寸与安全区的 Android 应用宿主。

Source

pub fn set_dpi_scale(&mut self, scale: i16)

设置 Android DisplayMetrics.density 整数倍 HiDPI 缩放因子。

Source

pub fn on_surface_changed(&mut self, width: i16, height: i16)

响应屏幕旋转或分屏窗口大小改变(如竖屏 390x844 旋转为横屏 844x390)。

Source

pub fn on_window_insets(&mut self, top: i16, right: i16, bottom: i16, left: i16)

同步 Android WindowInsetsCompat.Type.systemBars() | displayCutout() 安全区内边距。

Source

pub fn on_ime_inset(&mut self, ime_bottom_px: i16)

同步 Android WindowInsetsCompat.Type.ime() 软键盘底部像素高度。

Source

pub fn on_motion_event(&mut self, pointer_id: u32, action: u8, x: i16, y: i16)

分发 Android MotionEvent(自动将 ACTION_DOWN/MOVE/UP/CANCEL 映射为 TouchPhase)。

Source

pub fn on_back_pressed(&mut self) -> bool

分发 Android OnBackInvokedCallback / onBackPressed 系统返回事件: 返回 true 表示应用内部已消费(关闭抽屉或回退二级页),返回 false 表示交由宿主 Activity 处理。

Source

pub fn do_frame(&mut self, dt_ms: u16) -> usize

响应 Android Choreographer.FrameCallback.doFrame 推进一帧,返回本帧脏矩形个数。

Source

pub fn rgba_slice(&self) -> &[u8] ⓘ

获取 RGBA8888 像素缓冲区的只读字节切片(可直接写入 ANativeWindow_Buffer.bits)。

Source

pub fn dirty_rects(&self) -> &[CDirtyRect]

获取本帧脏矩形切片(供 ANativeWindow_lock 局部脏区域刷新使用)。

Source

pub fn embed_app(&self) -> &MobileEmbedApp

访问底层 MobileEmbedApp 只读引用。

Source

pub fn embed_app_mut(&mut self) -> &mut MobileEmbedApp

访问底层 MobileEmbedApp 可变引用。

Source

pub fn is_gpu_backend(&self) -> bool

查询当前 Android 宿主实例是否启用了基于轻量 wgpu (Vulkan) 2D SDF 的硬件 GPU 渲染后端。

Source

pub fn into_raw(self) -> *mut MobileEmbedApp

取出内部裸指针供 FFI 使用(调用后不再由 Drop 自动释放)。

Trait Implementations§

Source§

impl<V: View + 'static> Drop for AndroidHostBridge<V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<V> !RefUnwindSafe for AndroidHostBridge<V>

§

impl<V> !Send for AndroidHostBridge<V>

§

impl<V> !Sync for AndroidHostBridge<V>

§

impl<V> !UnwindSafe for AndroidHostBridge<V>

§

impl<V> Forget for AndroidHostBridge<V>

§

impl<V> Freeze for AndroidHostBridge<V>
where Handle<V>: Freeze,

§

impl<V> Move for AndroidHostBridge<V>

§

impl<V> Unpin for AndroidHostBridge<V>
where Handle<V>: Unpin,

§

impl<V> UnsafeUnpin for AndroidHostBridge<V>
where Handle<V>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.