NEW RadzDroid Android 15 Emulator for Coding & AI Agents is live! Explore RadzDroid →
Android Case Study ·

Huayomi’s Offline Chapter Downloads

How Huayomi stores chapters for offline reading, tracks progress, and tells an interrupted download from a complete one.

When a chapter counts as downloaded

A reader can have a chapter cover in memory, a page in the image cache, and two pages already written to disk. Those are three different states. In Huayomi, the chapter download store records the complete page list separately from whatever an image loader has cached. That lets the reader make a better decision when someone taps a chapter on a train or opens it after restarting the app.

Write pages in reading order

The chapter store asks the selected source for its page list and sorts it by page index. Each page streams to a file, with a numbered name and an extension derived from the response type or URL. Once every page has been written, the store records the chapter ID, manga ID, source ID and ordered file paths. The source ID matters because chapter numbers and titles can repeat across different sources.

File names alone do not tell the app whether the download completed. A connection can fail while the first file is being written or after the first several files succeeded. The download store returns failure in those cases and skips publishing a new completed entry. That makes progress a useful status for the download screen while the completed entry remains the signal the reader can use.

Separate progress from recovery

Progress and download speed are useful while a job is active. After the process exits, the durable record is what matters. Huayomi writes chapter metadata to the chapter folder and persists its download list. The current implementation attempts the per-folder metadata write after publishing the entry, so it leaves a narrow window for interruption. Any design that needs stronger crash guarantees can stage the data in a temporary directory and commit the completion record only when both the files and metadata are durable.

The best recovery test is to interrupt the app near the end, when the UI can look finished even though the last file or index write is still pending. Reopening the chapter should either use the last known complete copy or show that the download needs to be retried. An empty or incomplete chapter should never open as if it were ready.

A practical offline test

  1. Download a chapter you have permission to use. Enable airplane mode, force-stop the app, and reopen it. Check the first, middle and last pages.
  2. Start a different chapter download and turn off connectivity partway through. Reopen the downloads list and verify that the incomplete chapter is distinguishable from a completed one.
  3. Restore connectivity and retry. Open the completed chapter in airplane mode and check that the pages still appear in order.

This case study describes the chapter download implementation. The checklist is for device verification, where source behavior, Android version and storage permissions can affect the result.

Explore Huayomi or read the offline Android architecture guide for the broader design.

OrangeVPN Engineering

IT Specialist, Systems Architect, and Full-Stack Developer. Building resilient web infrastructure, zero-trust mesh networks, and AI-accelerated developer tooling.