7676import java .util .Map ;
7777import java .util .TreeMap ;
7878import java .util .Map .Entry ;
79+ import java .util .concurrent .atomic .AtomicBoolean ;
80+ import java .util .concurrent .atomic .AtomicReference ;
7981
8082/**
8183 * Custom implementation of Context/Activity to handle non compiled resources.
@@ -502,11 +504,12 @@ public TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs,
502504 return null ;
503505 }
504506
505- boolean [] frameworkAttributes = new boolean [1 ];
506- TreeMap <Integer , String > styleNameMap = searchAttrs (attrs , frameworkAttributes );
507+ AtomicBoolean frameworkAttributes = new AtomicBoolean ();
508+ AtomicReference <String > attrName = new AtomicReference <String >();
509+ TreeMap <Integer , String > styleNameMap = searchAttrs (attrs , frameworkAttributes , attrName );
507510
508511 BridgeTypedArray ta = ((BridgeResources ) mSystemResources ).newTypeArray (attrs .length ,
509- isPlatformFile );
512+ isPlatformFile , frameworkAttributes . get (), attrName . get () );
510513
511514 // look for a custom style.
512515 String customStyle = null ;
@@ -597,7 +600,7 @@ public TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs,
597600 }
598601
599602 String namespace = BridgeConstants .NS_RESOURCES ;
600- if (frameworkAttributes [ 0 ] == false ) {
603+ if (frameworkAttributes . get () == false ) {
601604 // need to use the application namespace
602605 namespace = mProjectCallback .getNamespace ();
603606 }
@@ -674,10 +677,12 @@ public Looper getMainLooper() {
674677 */
675678 private BridgeTypedArray createStyleBasedTypedArray (StyleResourceValue style , int [] attrs )
676679 throws Resources .NotFoundException {
677- TreeMap <Integer , String > styleNameMap = searchAttrs (attrs , null );
680+ AtomicBoolean frameworkAttributes = new AtomicBoolean ();
681+ AtomicReference <String > attrName = new AtomicReference <String >();
682+ TreeMap <Integer , String > styleNameMap = searchAttrs (attrs , frameworkAttributes , attrName );
678683
679684 BridgeTypedArray ta = ((BridgeResources ) mSystemResources ).newTypeArray (attrs .length ,
680- false /* platformResourceFlag */ );
685+ style . isFramework (), frameworkAttributes . get (), attrName . get () );
681686
682687 // loop through all the values in the style map, and init the TypedArray with
683688 // the style we got from the dynamic id
@@ -709,10 +714,13 @@ private BridgeTypedArray createStyleBasedTypedArray(StyleResourceValue style, in
709714 * that is used to reference the attribute later in the TypedArray.
710715 *
711716 * @param attrs An attribute array reference given to obtainStyledAttributes.
717+ * @param outFrameworkFlag out value indicating if the attr array is a framework value
718+ * @param outAttrName out value for the resolved attr name.
712719 * @return A sorted map Attribute-Value to Attribute-Name for all attributes declared by the
713720 * attribute array. Returns null if nothing is found.
714721 */
715- private TreeMap <Integer ,String > searchAttrs (int [] attrs , boolean [] outFrameworkFlag ) {
722+ private TreeMap <Integer ,String > searchAttrs (int [] attrs , AtomicBoolean outFrameworkFlag ,
723+ AtomicReference <String > outAttrName ) {
716724 // get the name of the array from the framework resources
717725 String arrayName = Bridge .resolveResourceId (attrs );
718726 if (arrayName != null ) {
@@ -729,7 +737,10 @@ private TreeMap<Integer,String> searchAttrs(int[] attrs, boolean[] outFrameworkF
729737 }
730738
731739 if (outFrameworkFlag != null ) {
732- outFrameworkFlag [0 ] = true ;
740+ outFrameworkFlag .set (true );
741+ }
742+ if (outAttrName != null ) {
743+ outAttrName .set (arrayName );
733744 }
734745
735746 return attributes ;
@@ -751,7 +762,10 @@ private TreeMap<Integer,String> searchAttrs(int[] attrs, boolean[] outFrameworkF
751762 }
752763
753764 if (outFrameworkFlag != null ) {
754- outFrameworkFlag [0 ] = false ;
765+ outFrameworkFlag .set (false );
766+ }
767+ if (outAttrName != null ) {
768+ outAttrName .set (arrayName );
755769 }
756770
757771 return attributes ;
0 commit comments