package Ġcom . example . my personal assistant . adapter Ċ Ċ import Ġandroid . annotation . Suppress Lint Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . support . v 4 . content . Context Compat . startActivity Ċ import Ġandroid . support . v 7 . widget . Card View Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Button Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġcom . example . my personal assistant . R Ċ import Ġcom . example . my personal assistant . activity . Calendar Activity Ċ import Ġcom . example . my personal assistant . activity . Weather Activity Ċ import Ġcom . example . my personal assistant . model . Weather Model Ċ import Ġjava . util .* Ċ import Ġjava . text . SimpleDateFormat Ċ Ċ class ĠWeather RecyclerView Adapter ( var Ġlist : ĠArrayList < Weather Model >) Ġ: ĠRecyclerView . Adapter < RecyclerView . ViewHolder > (){ ĊĊĠĠĠ Ġ@ Suppress Lint (" SetText I 1 8 n ", Ġ" SimpleDateFormat ") ĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠRecyclerView . ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġweather Ġ= Ġlist [ position Ġ% Ġlist . size ] ĊĊĠĠĠĠĠĠĠ Ġvar Ġday Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġval ĠcurrentTime Ġ= ĠSystem . currentTimeMillis ()/ 1 0 0 0 ĊĠĠĠĠĠĠĠ Ġif ( currentTime > weather . sun rise Ġ&& ĠcurrentTime < weather . sun set ) Ġday Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ Ġvar Ġholder Weather : ĠWeather Holder Ġ= Ġholder Ġas ĠWeather Holder ĊĊĠĠĠĠĠĠĠ Ġholder Weather . card Title View Weather . text Ġ= Ġweather . name ĊĠĠĠĠĠĠĠ Ġif ( day ) Ġholder Weather . card ImageView Title Weather . setImage Resource ( R . drawable . ic _ day ) ĊĠĠĠĠĠĠĠ Ġelse Ġholder Weather . card ImageView Title Weather . setImage Resource ( R . drawable . ic _ night ) ĊĊĠĠĠĠĠĠĠ Ġholder Weather . temp r ature Text . text Ġ= Ġweather . temp . toString () Ġ+ Ġ" ĠÂ º C " ĊĠĠĠĠĠĠĠ Ġif ( weather . temp > 1 0 ) Ġholder Weather . temp r ature Image . setImage Resource ( R . drawable . ic _ hot ) ĊĠĠĠĠĠĠĠ Ġelse Ġholder Weather . temp r ature Image . setImage Resource ( R . drawable . ic _ cold ) ĊĊĠĠĠĠĠĠĠ Ġholder Weather . humidity Text . text Ġ= Ġweather . humidity . toString ()+" Ġ% " ĊĠĠĠĠĠĠĠ Ġholder Weather . humidity Image . setImage Resource ( R . drawable . ic _ humidity ) ĊĊĠĠĠĠĠĠĠ Ġholder Weather . wind Text . text Ġ= Ġweather . wind Speed . toString () Ġ+ Ġ" Ġkm / h " ĊĠĠĠĠĠĠĠ Ġholder Weather . wind Image . setImage Resource ( R . drawable . ic _ wind ) ĊĊĠĠĠĠĠĠĠ Ġif ( weather . weather ==" Clear "){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( day ) Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ clear _ day ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ clear _ day ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġif ( weather . weather ==" Cloud s "){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( weather . description ==" f ew Ġclouds ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif ( day ) Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ cloud y _ half _ day ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ cloud y _ half _ night ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ cloud y ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġif ( weather . weather ==" Rain " Ġ|| Ġweather . weather ==" D ri zzle "){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ rain ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġif ( weather . weather ==" Th under storm "){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ storm ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse Ġif ( weather . weather ==" Snow "){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ snow y ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġelse { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġholder Weather . current Weather Main Image . setImage Resource ( R . drawable . ic _ fog ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġholder Weather . weather Condition Main . text Ġ= Ġ" ("+ weather . description +") " ĊĊĠĠĠĠĠĠĠ Ġval Ġd Ġ= ĠDate ( weather . date . to Long () Ġ* Ġ 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġf Ġ= ĠSimpleDateFormat (" dd / MM / yyyy ĠHH : mm ' h '") ĊĠĠĠĠĠĠĠ Ġholder Weather . weather Date . text Ġ= Ġf . format ( d ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġlist . size ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠRecyclerView . ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠitemView Ġ= ĠLayoutInflater . from ( parent ?. context ). inflate ( R . layout . card _ view _ weather , parent , false ) ĊĠĠĠĠĠĠĠ Ġreturn ĠWeather RecyclerView Adapter . Weather Holder ( item View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠWeather Holder ( view : ĠView ) Ġ: ĠRecyclerView . ViewHolder ( view ){ ĊĊĠĠĠĠĠĠĠ Ġvar Ġcv : ĠCard View ĊĊĠĠĠĠĠĠĠ Ġvar Ġcard Title View Weather : ĠTextView ĊĠĠĠĠĠĠĠ Ġvar Ġcard ImageView Title Weather : ĠImageView ĊĊĠĠĠĠĠĠĠ Ġvar Ġtemp r ature Text : ĠTextView ĊĠĠĠĠĠĠĠ Ġvar Ġtemp r ature Image : ĠImageView ĊĊĠĠĠĠĠĠĠ Ġvar Ġhum idity Text : ĠTextView ĊĠĠĠĠĠĠĠ Ġvar Ġhum idity Image : ĠImageView ĊĊĠĠĠĠĠĠĠ Ġvar Ġwind Text : ĠTextView ĊĠĠĠĠĠĠĠ Ġvar Ġwind Image : ĠImageView ĊĊĠĠĠĠĠĠĠ Ġvar Ġcurrent Weather Main Image : ĠImageView ĊĠĠĠĠĠĠĠ Ġvar Ġweather Condition Main : ĠTextView ĊĊĠĠĠĠĠĠĠ Ġvar Ġweather Date : ĠTextView ĊĊĠĠĠĠĠĠĠ Ġinit { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcv Ġ= Ġview . findViewById ( R . id . weather _ card _ view ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard Title View Weather Ġ= ĠitemView . findViewById ( R . id . weather Header Main Card textView ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcard ImageView Title Weather Ġ= ĠitemView . findViewById ( R . id . weather Header Main Card ImageView ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemp r ature Text Ġ= ĠitemView . findViewById ( R . id . temp r ature Main Text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemp r ature Image Ġ= ĠitemView . findViewById ( R . id . temp r ature Main Image ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġhum idity Text Ġ= ĠitemView . findViewById ( R . id . humidity Main Text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhum idity Image Ġ= ĠitemView . findViewById ( R . id . humidity Main Image ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġwind Text Ġ= ĠitemView . findViewById ( R . id . wind Main Text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwind Image Ġ= ĠitemView . findViewById ( R . id . wind Main Image ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcurrent Weather Main Image Ġ= ĠitemView . findViewById ( R . id . current Weather Main Image ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġweather Condition Main Ġ= ĠitemView . findViewById ( R . id . weather Condition Main ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġweather Date Ġ= ĠitemView . findViewById ( R . id . weather Date ) ĊĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ }