import { simpleUiObject } from './ui-object' ; importClass ( android . widget . Toast ) ; const showToast = ( ( ) => { let myToast ; let lastTimer ; return ( msg , duration = 3500 ) => { if ( myToast ) { myToast . cancel ( ) ; } if ( lastTimer ) { clearTimeout ( lastTimer ) ; } lastTimer = setTimeout ( ( ) => { if ( myToast ) { myToast . cancel ( ) ; } } , duration ) ; ui . run ( ( ) => { const Toast = new android . widget . Toast ( context ) ; myToast = Toast . makeText ( context , msg , Toast . LENGTH_LONG ) ; myToast . show ( ) ; } ) ; } ; } ) ( ) ; function tl ( ... msg ) { console . info ( ... msg ) ; const text = msg . map ( ( item ) => { try { if ( typeof item === 'object' ) { return JSON . stringify ( item ) ; } return item ; } catch ( e ) { return '|-格式化失败-|' ; } } ) . join ( ' ' ) ; showToast ( text ) ; } function toastUiObject ( ele ? , extra ? ) { tl ( { ... extra , ... simpleUiObject ( ele ) , } ) ; } export { showToast , tl , toastUiObject } ;