Homework

Homework — the menu, offline

Homework — prove the menu works offline.

  1. The cache works. Run online, wait for the menu to load. Then turn on airplane mode, fully close the app and reopen it. The menu must appear immediately, with no Loading and no Error — straight from the cache.
  2. Refresh updates. Go back online. If you change a pizza's name in the backend and reopen the app, refresh() quietly overwrites the cache and the screen updates.
  3. Inspect the DB. Android Studio → App Inspection → Database Inspector. You should see a menu_items table with the pizza rows. That's your cache on disk.

Required tests:

  • Offline test: in airplane mode (after the first load) the menu still shows.
  • Cold-start test: uninstall the app (clears the cache), launch offline → now you get Error "Could not load menu" (empty cache, no network — refresh() throws and nothing is cached). Turn the network on → the menu loads and is cached again.

To submit: screenshots: (1) the menu in airplane mode, (2) the menu_items table in the Database Inspector.

Next. The menu is now solid: fast, works offline. But everything we've seen is public — anyone can call GET /menu. In lesson 8a we add accounts — register and log in by email. The server issues a session token (JWT) that we store securely. That token contract is the foundation for orders (lesson 9) and Google sign-in (8b).