Tina Tang's Blog

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

0%

Privacy Policy

Last updated: February 09, 2024

This Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your information when You use the Service and tells You about Your privacy rights and how the law protects You.

We use Your Personal data to provide and improve the Service. By using the Service, You agree to the collection and use of information in accordance with this Privacy Policy. This Privacy Policy has been created with the help of the Privacy Policy Generator.

Read more »

瞭解如何使用 WorkManager 編寫 simple work,然後執行設有限制條件(constraints)的複雜鏈結(chaining) work。

建構項目
使用 Blur-O-Matic,該 app 可對照片進行模糊處理,並將處理後的照片保存在檔案中。

學習目標

  • WorkManager 添加到您的 project 中
  • 安排(scheduling) 一個 simple task
  • Input 和 output 參數
  • 鏈結(chaining) work
  • 唯一(unique) work
  • 在 UI 中顯示 work status
  • 取消(cancel) work
  • work 限制條件(constraints)
Read more »

建構一款名為「Forage」的 app。本程式碼研究室將引導您逐步完成 Forage app project,包括在 Android Studio 中設定和測試 project。

完成後的 Forage app 可讓使用者追蹤他們在自然界中搜尋到的物品,例如食物。通過使用 Room,可使這些資料在會話間持久保存(persisted)下來。運用您掌握的 Room 知識以及對 database 進行讀取、寫入、更新和刪除,以在 Forage app 中實現資料的持久保留(persisted)

建構項目
實作 entityDAOViewModeldatabase class,以便透過 Room 在 app 中加入持續性機制(persistence)

Read more »

學習如何使用 Jetpack DataStore 在 app 中儲存 key-value 組合。

在先前的程式碼研究室中,我們已說明如何使用 Room (database 抽象層) 將資料儲存在 SQLite database 中。本程式碼研究室會介紹 Jetpack DataStoreDataStore 以 Kotlin coroutineFlow 為基礎而設計,共提供兩種不同的實作方式,一種是專門儲存 typed objects 的 Proto DataStore,另一種則是專門儲存 key-value 組合的 Preferences DataStore

本程式碼研究室會說明如何使用 Preferences DataStore,Proto DataStore 則不在本程式碼研究室的說明範圍內。

學習目標

  • DataStore 是什麼?您應使用 DataStore 的原因及時機為何?
  • 如何將 Preference DataStore 新增至 app。
Read more »

在本程式碼研究室中,您將使用離線快取(offline caching)功能來改善 app 的使用者體驗。許多 app 都依賴來自網路的 data。如果 app 在每次啟動時都從 server 擷取 data,並顯示 loading 畫面,可能會造成使用者體驗不佳,導致使用者解除安裝 app。

使用者啟動 app 時,會希望 app 能快速顯示 data。實作離線快取(offline caching)功能就能實現這個目標。離線快取(offline caching)是指 app 將從網路擷取的 data 儲存到裝置的本機儲存空間(local storage),進而加快存取速度

由於 app 將可從網路取得 data,並且保留先前下載結果的離線快取(offline cache),因此您需要讓 app 透過某種方式彙整來自多個來源的 data。做法是實作repository class,做為 app data 的單一可靠資料來源,並從 view model 中提取資料來源 (例如網路(network)、快取(cache)等)。

學習目標

  • 如何實作 repository,以便從 app 的其他部分提取 data layer。
  • 如何使用 repository 載入快取資料(cached data)
Read more »