INNER CODE UNIT · Rust
Picked
jub0t/Concat · src/crates/concat-android/src/lib.rs:121
type Picked = Box<dyn FnOnce(Vec<PathBuf>) + Send>;
/// The pick in flight, waiting for Java to answer.
static PENDING: Mutex<Option<Picked>> = Mutex::new(None);
/// The fragment class, loaded once and kept.
static CLASS: OnceLock<Global<JClass<'static>>> = OnceLock::new();
/// Hands the window's crate a picker that runs on this activity.
pub fn install(app: &AndroidApp) {
let app = app.clone();
concat::install_file_picker(Box::new(move |on_picked| {
let previous = PENDING
.lock()
.map(|mut slot| slot.replace(on_picked))
.ok()
.flatten();
if let Some(previous) = previous {
// A pick was already up; the one that asked first is told