Tina Tang's Blog

在哪裡跌倒了,就在哪裡躺下來

0%

瞭解如何在 debugging 時使用中斷點(breakpoints),並留意特定變數。

到目前為止,大多數的新手 developers 可能已經會使用 Log statements 進行 debugging。完成單元 1 後,您將學到如何解讀 stack traces 和研究 error messages。雖然這兩種工具都是功能強大的 debugging 工具,但現代 IDE 提供更多功能,讓您的 debugging 流程更有效率。

在本課程中,您將瞭解 Android Studio 整合的 debugger、如何暫停執行 app,以及一次執行單行程式碼,找出 bug 的確切來源。此外,您將學會如何使用一項稱為 Watches 的功能以及如何追蹤特定變數,而不必新增特定的 log statements。

學習目標

  • 如何將 debugger 附加到運作中的 app。
  • 使用中斷點(breakpoints)來暫停執行中的 app,逐行檢查程式碼。
  • 條件運算式加入中斷點(breakpoints)以節省 debugging 時間。
  • 在 Watches 窗格中新增變數,以輔助 debugging。
Read more »

了解如何使用 Coil library 從 URL 載入並顯示網路上的圖片。

學習目標

  • 如何使用 Coil library 從 URL 載入及顯示 image
  • 如何使用 RecyclerViewgrid adapter 顯示格狀(grid) images
  • 如何處理 images 下載及顯示時出現的潛在 errors

建構項目

  • 修改 MarsPhotos app 以取得 Mars data 中的 image URL,並使用 Coil 載入並顯示該 image
  • 在 app 中加入 loading animationerror icon
  • 使用 RecyclerView 顯示格狀(grid) Mars images。
  • RecyclerView 加入狀態和錯誤處理機制(status and error handling)
Read more »

使用第三方 library Retrofit 將 app 連線至後端 server,並瞭解 REST web service。

使用以 open source 開發的 libraries 建構網路層(network layer),並從後端 server 取得 data。這樣可大幅簡化資料擷取作業,還可讓 app 符合 Android 最佳做法,例如在背景執行緒(background thread)上執行作業。若網際網路(internet)連線速度緩慢或無法使用,您也可更新 app 的 UI,以讓使用者隨時掌握任何網路連線問題。

學習目標

  • 什麼是 REST web service。
  • 使用 Retrofit library 連線至 internet 上的 REST web service 並取得 response(回應)。
  • 使用 Moshi library 將 JSON response 解析(parse)成 data object

建構項目

  • 修改 starter app,以發出 web service API要求(request)處理回應(response)
  • 使用 Retrofit library 為 app 實作網路層(network layer)
  • 使用 Moshi library,將 web service 中的 JSON response 解析(parse)成 app 的 LiveData objects
  • 使用 Retrofit 提供的 coroutines(協程)來簡化程式碼。
Read more »

瞭解關於執行緒(threads)的資訊,以及如何使用稱為協程(coroutines)的 Kotlin 功能撰寫乾淨(clear)非阻塞(non-blocking)並行(concurrent)程式碼。

學習目標

  • 何謂並行(concurrency),以及其重要性
  • 如何使用協程(coroutines)執行緒(threads),撰寫非阻塞(non-blocking)並行(concurrent)程式碼
  • 如何在 background 工作(performing tasks)時存取 main thread,安全地更新UI
  • 不同並行模式(concurrency pattern) 範圍(Scope) / 調度工具(Dispatchers) / 延遲(Deferred) 」的使用方式與使用時機
  • 如何撰寫與網路資源(network resources)互動(interacts)的程式碼
Read more »