Homework

Homework — your menu from the API

Homework — the menu from your server.

  1. Run the backend (localhost:8080) and the app. The menu should load from GET /menu (a brief Loading, then pizzas). If you see the CLEARTEXT error — remember the gotcha (usesCleartextTraffic).
  2. Check the error state. Stop the backend and reload the menu (or tap "Retry"). You should see Error with a message and a "Retry" button, not a freeze or a crash.
  3. Check the conversion. In the backend one pizza costs 850 cents. On screen it must show €8.50 (not €850). If you see cents — check toDomain().

Required tests:

  • Load test: with the backend running, the menu shows real pizzas.
  • Error test: with no backend you see Error + "Retry", not a crash.

To submit: screenshots: (1) the menu from the server, (2) the Error state with no backend.

Tip. It works! But look at that Network object and viewModel { MenuViewModel(MenuRepository(Network.api)) } — you're building the chain by hand. As lesson 6 adds more (auth, orders), this manual wiring grows and starts to tangle. Next lesson is Koin: dependency injection that turns all this assembly into a few declarations. "Feel the pain, earn the tool."