Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mobile Apps That Work Offline-Online

Mobile Apps That Work Offline-Online

putrabangga

March 24, 2019
Tweet

More Decks by putrabangga

Other Decks in Technology

Transcript

  1. We live in a disconnected & battery powered world, but

    our technology and best practices are a leftover from the always connected & steadily powered past. http://offlinefirst.org/
  2. Offline First! an approach to software development in which developers

    build an application’s core features to function with or without an internet connection. With an offline first approach, data is written locally on the end user’s device and periodically uploaded and replicated in the cloud.
  3. Research Time! • Realm? • Firebase? • Yigit Job Queue

    + Our Craft :) • Retrofit • MVP-Clean
  4. Yigit Job Queue • Free! • API < 21 •

    Easy to customize https://github.com/yigit/android-priority-jobqueue
  5. Yigit Configuration .minConsumerCount(1)//always keep at least one consumer alive .maxConsumerCount(3)//up

    to 3 consumers at a time .loadFactor(3)//3 jobs per consumer .consumerKeepAlive(120) .networkUtil(new NetworkUtilImpl(this));//wait 2 minute
  6. Create • Presenter -> Create Local -> STATE_NOT_SYNC, ID_REMOTE=0 ->

    Done • Run Job -> High Priority, group By • When Internet Found • Create Remote • Update id_remote & STATE_SYNC
  7. Update • Presenter -> Update Local -> Done • Run

    Job -> High Priority, group By • When Internet Found • Get Local • Update Remote • Update id_remote & STATE_SYNC
  8. Delete • Presenter -> Delete Local -> Done • Run

    Job -> Mid Priority, group By • When Internet Found • Get Local • Delete Remote • Update id_remote=0 & STATE_SYNC
  9. Read • Presenter -> Get Local -> View • Run

    Job -> Mid Priority, group By, singleInstance • When Internet Found • Get Local • Get Remote • Delete Local Data -> Local.isSync() & Local.notFound(remote) • Create Remote Data -> Local.isAllSync() & remote.notFound(local) • Get Local
  10. So What The Result After New Stack? • User So

    Happy -> Not Blocking Anymore • Apps Run Smooth •
  11. Our Next Challenge • Offline Design • UUID • TimeStamp

    • Conflict Data • Storage • Memory • https://github.com/evernote/android-job