all right so remote all our changes in
the last three videos to our top ten
downloader it's now time to check this
out does it actually work what I'm gonna
do first is put a log cat into floating
mode so we can actually see this and
we'll run our application as always I
fast forward this to get it showing
quickly
all right so so far so good the app
seems to be running but we've got a lot
of data in the logging here
I think we're logging a bit too much
here so let's comment out some of this
stuff so look at our paws applications
class so let's move tag to be consistent
outside of the class and also make it a
constant and we'll also take the
opportunity to remove the logging on
line 16 so I want to just comment that
line out again
so let's now run the up again okay so I
think there's a bit tidier and if you do
get some error or information log
entries from other parts of the system
and I've got some there now you can
filter them out what I'm going to do is
just just show debug only errors but
simple ways D capital D zap forward
slash and you can see that makes it much
easier to try and focus on just what
we've got we've got a few other things
there but it is a lot easy to see all of
our entries now right so before checking
for unnecessary downloads I want to make
sure the app still works and it's just
tab back over to that first thing I'm
going to select songs from the list then
we saw there that download our download
URL got called if you scroll over and
have a look we can see that other these
songs was actually called there the
download URL was called
doing background was in turn called and
because the URL had changed that set off
the new async task the download the
doing background was an executed from
the download data racing task have feed
view models on data available functions
getting called there as you can see and
when the live data object gets updated
main activities picking up those changes
and it's updating the data as you can
see there in the interface so that's
looking good let's try the top 25
instead of the top 10 so select top 25
you can see it clearly we've got more
songs showing up there so that's good
and in terms of our log entries with the
top 25 being downloaded they're on data
available being called again so so far
so good just before I rotate the device
I'm going to top an entry in the lock
rotating and let's try rotating it now
and see what happens
and looking at the data you can see that
data is still there clearly you've got
that there but looking at the log entry
though and accidentally scrolled in so I
go back down to the end and see what
happened so we've got our rotating it
tree that I added there firstly notice
notice how quick the data reloaded when
I did rotate into landscape and that's
because the data didn't have to be
downloaded again and we can see there
that the activities uncreate was called
so activity was destroyed and recreated
because of that that caused the download
URL function to be called again and you
can see it was called within them Anika
was 25 again but this time because of
the Euro hasn't changed and the v-model
still has all the data
there's no download needed you can see
clearly there there wasn't a call to our
download data async task as there was
previously the adapters populated with
the current data and the app appears
much slicker than it did before and
we've also saved battery life and
avoided additional data costs for our
users as well all right so that's pretty
cool and now that brings to an end this
section in our introduction to view
model and live data so keep in mind that
Google have now deprecated the lower
classes but if you use them I think
you'll agree that the view model that
replaces them is easy to use and I think
it's more flexible as well combined with
live data it's a great way to separate
your UI from other logic and also solves
many of the lifecycle problems that we
sometimes struggle with Android
development now a lot easier as a result
will be using view model again in our
data base app we originally used to
cursorloader but now that that's been
deprecated we've rewritten it to use a
view model instead so we'll see you in
the next section when we start work on
that