package Ġedu . uw . min h 2 8 0 4 . res ift . fragments Ċ Ċ import Ġandroid . graphics . Bitmap Factory Ċ import Ġandroid . graphics . drawable . Gradient Drawable Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Typed Value Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Image Button Ċ import Ġandroid . widget . LinearLayout Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġcom . google . android . material . image view . Shape able ImageView Ċ import Ġcom . ms . square . android . expand able text view . Expand able TextView Ċ import Ġedu . uw . min h 2 8 0 4 . res ift . R Ċ import Ġedu . uw . min h 2 8 0 4 . res ift . view models . S ift ViewModel Ċ import Ġjava . util .* Ċ Ċ class ĠPublisher Overview Card Body Fragment Ġ: ĠFragment ( R . layout . fragment _ publisher _ overview _ card _ body ) Ġ{ Ċ ĉ private Ġval ĠviewModel : ĠS ift ViewModel Ġby Ġactivity ViewModels () ĊĊ ĉ override Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . on View Created ( view , ĠsavedInstanceState ) ĊĊĉ ĉ val Ġcred ibility Rating View Ġ= Ġview . findViewById < TextView >( R . id . text _ view _ publisher _ overview _ card _ body _ cred ibility _ rating ) Ċĉ ĉ val Ġbias Rating View Ġ= Ġview . findViewById < TextView >( R . id . text _ view _ publisher _ overview _ card _ body _ bias _ rating ) ĊĊĉ ĉ val Ġhistory View Ġ= Ġview . findViewById < Expand able TextView >( R . id . expand able _ text _ view _ publisher _ overview _ card _ body _ history ) Ċĉ ĉ val Ġexpand Toggle View Ġ= Ġhistory View . findViewById < Image Button >( com . ms . square . android . expand able text view . R . id . expand _ collapse ) Ċĉ ĉ expand Toggle View . apply Ġ{ Ċĉĉ ĉ val Ġsurface Color Ġ= ĠTyped Value () Ċĉĉ ĉ require Context (). theme . resolve Attribute ( com . google . android . material . R . attr . color Surface , Ġsurface Color , Ġtrue ) Ċĉĉ ĉ background Ġ= ĠGradient Drawable ( Gradient Drawable . Orientation . BOTTOM _ TOP , Ġint ArrayOf ( surface Color . data , Ġ 0 xFF F )) Ċĉĉ ĉ layout Params Ġ= ĠLinearLayout . LayoutParams ( LinearLayout . LayoutParams . MATCH _ PARENT , ĠLinearLayout . LayoutParams . WRAP _ CONTENT ). apply Ġ{ Ċĉĉĉ ĉ set Margins ( 0 , Ġ- resources . get Dimension ( R . dim en . margin _ small ). toInt (), Ġ 0 , Ġ 0 ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ viewModel . publisher . observe ( view Lifecycle Owner ) Ġ{ Ġpublisher Ġ-> Ċĉĉ ĉ if Ġ( publisher Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ bias Rating View . text Ġ= Ġpublisher . bias Rating Ġ?: ĠgetString ( R . string . publisher _ overview _ card _ body _ bias _ rating _ not _ found ) Ċĉĉĉ ĉ history View . text Ġ= Ġpublisher . history ?. let Ġ{ Ġit Ġ+ Ġ'\ n ' Ġ} Ġ?: ĠgetString ( R . string . publisher _ overview _ card _ body _ history _ not _ found ) Ċĉĉĉ ĉ if Ġ( publisher . cred ibility Rating Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉ ĉ val Ġcred ibility Rating Ġ= Ġpublisher . cred ibility Rating . toString () Ġ+ Ġ" Ġ/ Ġ 5 " Ċĉĉĉĉ ĉ cred ibility Rating View . text Ġ= Ġcred ibility Rating Ċĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉ ĉ cred ibility Rating View . text Ġ= ĠgetString ( R . string . publisher _ overview _ card _ body _ cred ibility _ rating _ not _ found ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ val Ġfav icon View Ġ= Ġview . findViewById < Shape able ImageView >( R . id . shape able _ image _ view _ publisher _ overview _ card _ body _ favicon ) Ċĉ ĉ viewModel . article . observe ( view Lifecycle Owner ) Ġ{ Ċĉĉ ĉ val Ġstatus Color Ġ= ĠTyped Value () Ċĉĉ ĉ if Ġ( it ?. favicon Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ val Ġbase 6 4 Image Ġ= Ġit . favicon . slice ( Int Range ( 2 , Ġit . favicon . length Ġ- Ġ 2 )) Ċĉĉĉ ĉ val Ġdecoded Image Ġ= ĠBase 6 4 . get Decoder (). decode ( base 6 4 Image ) Ċĉĉĉ ĉ favicon View . setImage Bitmap ( Bitmap Factory . decode ByteArray ( decoded Image , Ġ 0 , Ġdecoded Image . size )) Ċĉĉĉ ĉ require Context (). theme . resolve Attribute ( com . google . android . material . R . attr . color Secondary , Ġstatus Color , Ġtrue ) Ċĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉ ĉ favicon View . setImage Resource ( R . drawable . ic _ all _ error _ image _ not _ found ) Ċĉĉĉ ĉ require Context (). theme . resolve Attribute ( com . google . android . material . R . attr . color Error , Ġstatus Color , Ġtrue ) Ċĉĉ ĉ } Ċĉĉ ĉ favicon View . set BackgroundColor ( status Color . data ) Ċĉ ĉ } Ċ ĉ } Ċ } Ċ