English subtitles

← The Price of Freedom

Get Embed Code
4 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. All right, you're done.
  2. Let's take a look at my solution.
  3. First, we add a function to utility to
    reset the location status to unknown.
  4. Note that we use the shared preferences
    editor apply function rather than
  5. commit, since this will be
    called from the UI thread.
  6. Next, we call that function to reset
    the location status if the user
  7. changes the location
    within settings activity.
  8. Next, we add the location
    status invalid.
  9. Remember, we have to add the constant
    and then add it to the indef annotation.
  10. Next, in get weather data from Json,
    we add the message code Json definition.
  11. Now let's check to see
    if we have an error.
  12. If the message code is 200,
  13. which happens to be the same as HTTP_OK,
    we can continue.
  14. But if the message code
    equals HTTP not found,
  15. then we set the location
    status to invalid.
  16. If it is any other error, we assume
    a server failure of some kind and
  17. set the status to server down.
  18. And then we add a string to display,
    when this case happens.
  19. Finally, we add this new
    case to update empty view.
  20. Done.
  21. Let's test this.
  22. All right, let's first of all
    run this on our emulator.
  23. All right,
    let's put an invalid location.
  24. London.
    And then we get our new message.
  25. No weather information available.
  26. The location in settings is not
    recognized by the weather server.
  27. Awesome.