private static Bundle metaDataToBundle ( Map < String , Object > meta ) { if ( meta . size ( ) == 0 ) { return null ; } Bundle bundle = new Bundle ( ) ; for ( Map . Entry < String , Object > entry : meta . entrySet ( ) ) { String key = entry . getKey ( ) ; Object value = entry . getValue ( ) ; if ( Boolean . class . isInstance ( value ) ) { bundle . putBoolean ( key , ( Boolean ) value ) ; } else if ( Float . class . isInstance ( value ) ) { bundle . putFloat ( key , ( Float ) value ) ; } else if ( Integer . class . isInstance ( value ) ) { bundle . putInt ( key , ( Integer ) value ) ; } else { bundle . putString ( key , value == null ? null : value . toString ( ) ) ; } } return bundle ; }
Goes through the meta data and puts each value in to a bundle as the correct type .