Offline App (or Offline-First App) enables user to seamlessly interact with it by using local device storage and then synchronizing the data with some remote storage (cloud database, etc) later via a background process.
With offline apps
- users no longer get error messages due to network connection problems.
- users benefit from faster loading times and conserving battery life.
- users do not see any loading bar since their actions are performed against fast local storage.
The Android app is a working sample that showcases offline commenting capability. User's comments are stored in local Room database first. A background job (implemented using Android Priority JobQueue library) is then spawned to synchronize local data with a remote database whenever Internet connection is available.
This background job is designed to be persistent--it is guaranteed to execute even after app or device restarts while waiting for the network connection.
- Patterns and frameworks
- MVVM (Model-View-ViewModel) using Google's new Architecture components
ViewModel
,LiveData
,LifecycleObserver
, etc. - Clean Architecture with
ViewModel
interacting with UseCases and the latter interacting with local database. Making each layer highly testable.
- MVVM (Model-View-ViewModel) using Google's new Architecture components
- Database
- Room Persistence Library, part of Google's new Architecture components.
- Background Job processing
- Android Priority JobQueue which uses Job Scheduler for API level Lollipop and above and GcmNetworkManager for API level below Lollipop.
- Remote Call APIs
- Retrofit 2 to perform HTTP requests.
- Fake remote database using simple JSONPlaceholder REST API.
- Dependency Injection
- Dagger Android 2.11 to manage App and Activity-scoped dependencies.
- Communication between app layers
- Other
- ButterKnife to simplify View and Listener bindings.
Copyright 2017 James Shvarts
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.