package Ġcom . pay day bank . android . models Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . util . Attribute Set Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġcom . air bnb . e po xy . Model Prop Ċ import Ġcom . air bnb . e po xy . Model View Ċ import Ġcom . google . android . material . card . Material Card View Ċ import Ġcom . google . android . material . shape . Shape Appearance Model Ċ import Ġcom . google . android . material . text view . Material TextView Ċ import Ġcom . pay day bank . android . R Ċ import Ġcom . pay day bank . data . repository . transaction . model . Categor ized Sum Ċ Ċ @ Model View ( auto Layout Ġ= ĠModel View . Size . MATCH _ WIDTH _ WRAP _ HEIGHT ) Ċ class ĠModel View Category Ġ@ Jvm Over loads Ġconstructor ( context : ĠContext , Ġattrs : ĠAttributeSet ? Ġ= Ġnull , Ġdef Style Attr : ĠInt Ġ= Ġ 0 ) Ġ: ĠMaterial Card View ( context , Ġattrs , Ġdef Style Attr ) Ġ{ ĊĊĊĠĠĠ Ġprivate Ġval Ġcategory : ĠMaterial TextView ĊĠĠĠ Ġprivate Ġval Ġprice : ĠMaterial TextView ĊĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠInf late ĊĠĠĠĠĠĠĠ Ġinf late ( context , ĠR . layout . model _ view _ category , Ġthis ) ĊĠĠĠĠĠĠĠ Ġshape Appearance Model Ġ= Ġ ĠShape Appearance Model (). with Corner Size ( 0 f ) ĊĠĠĠĠĠĠĠ Ġ// ĠSet Ġviews ĊĠĠĠĠĠĠĠ Ġcategory Ġ= ĠfindViewById ( R . id . category ) ĊĠĠĠĠĠĠĠ Ġprice Ġ= ĠfindViewById ( R . id . price ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Model Prop ĊĠĠĠ Ġfun Ġcategor ized Sum ( categor ized Sum : ĠCategor ized Sum ? ){ ĊĠĠĠĠĠĠĠ Ġif ( categor ized Sum == null ) Ġreturn ĊĠĠĠĠĠĠĠ Ġcategory . text Ġ= Ġcategor ized Sum . title ĊĠĠĠĠĠĠĠ Ġprice . text Ġ= ĠString . format ("% . 2 f ", Ġcategor ized Sum . sum ) ĊĠĠĠĠĠĠĠ Ġ// ĠPrice Ġcolor ĊĠĠĠĠĠĠĠ Ġval Ġcl r Ġ= ĠContext Compat . getColor ( context , Ġif ( categor ized Sum . sum > 0 ) ĠR . color . balance _ green Ġelse ĠR . color . balance _ red ) ĊĠĠĠĠĠĠĠ Ġprice . setTextColor ( clr ) ĊĠĠĠ Ġ} Ċ Ċ }