public void setFromJSON ( Context context , JSONObject properties ) { String backgroundResStr = optString ( properties , Properties . background ) ; if ( backgroundResStr != null && ! backgroundResStr . isEmpty ( ) ) { final int backgroundResId = getId ( context , backgroundResStr , "drawable" ) ; setBackGround ( context . getResources ( ) . getDrawable ( backgroundResId , null ) ) ; } setBackgroundColor ( getJSONColor ( properties , Properties . background_color , getBackgroundColor ( ) ) ) ; setGravity ( optInt ( properties , TextContainer . Properties . gravity , getGravity ( ) ) ) ; setRefreshFrequency ( optEnum ( properties , Properties . refresh_freq , getRefreshFrequency ( ) ) ) ; setTextColor ( getJSONColor ( properties , Properties . text_color , getTextColor ( ) ) ) ; setText ( optString ( properties , Properties . text , ( String ) getText ( ) ) ) ; setTextSize ( optFloat ( properties , Properties . text_size , getTextSize ( ) ) ) ; final JSONObject typefaceJson = optJSONObject ( properties , Properties . typeface ) ; if ( typefaceJson != null ) { try { Typeface typeface = WidgetLib . getTypefaceManager ( ) . getTypeface ( typefaceJson ) ; setTypeface ( typeface ) ; } catch ( Throwable e ) { Log . e ( TAG , e , "Couldn't set typeface from properties: %s" , typefaceJson ) ; } } }
Set text parameters from properties