Realm Mobile Platform: Offline-first TaskManager app – Intro

This article is the first one in a series of five. Each part will describe the steps of building offline-first TaskManager app with realtime synchronization. Part one is devoted to defining the technology stack and the UI of the app.

Part 2: REALM MOBILE PLATFORM: OFFLINE-FIRST TASKMANAGER APP – BASICS OF REALM
Part 3: REALM MOBILE PLATFORM: ANDROID “TASKMANAGER” – REALM OBJECT SERVER
Part 4: REALM MOBILE PLATFORM: OFFLINE-FIRST TASKMANAGER APP – AUTHENTICATION
Part 5: Coming soon

Here is the preview of the app that we are going to develop during the series.

apka_final

1. Technology stack

Realm Mobile Platform

A flexible platform for creating offline-first, reactive mobile apps effortlessly.

This platform integrates two technologies we are going to use:

Realm Object Server
Realm Object Server (released around September 2016) is basically a backend responsible for realtime data synchronization, resolving conflicts in data changes, handling various events and authentication. In can be deployed on servers or in the cloud.

Realm Mobile Database
Realm Mobile Database is a cross-platform database, supporting both iOS and Android and it’s open source. For those who are familiar with SQLite database (default choice of persistence in Android) or ORM libraries like ORMLite/ActiveAndroid/GreenDao, you should know that in Realm gives no SQLite at all. Realm Mobile Database is a Zero-copy object store. Sounds familiar? Probably not (I had not known that before attending the Droidcon NYC 2015 – Realm: Building a mobile database).

In this article we are going to use the Developer Edition of RPM.

Ubuntu 16.04. hosted on Amazon EC2

The instance of our Realm Object Server backend will be available through the Ubuntu instance.

2. Useful links

3. TaskManager UI

Before getting to the “cool” stuff, we are going to prepare some basic UI for the app. However, if you are impatient (like I am), you can just checkout to commit 09adf4d in the TaskManager github repository and start from there.

3.1 Gradle

Core dependencies for UI.

3.2 Main screen UI

Screenshot_20160718-205804

activity_main.xml

toolbar.xml
Basic toolbar with a title.

fab.xml
Custom implementation of fab button (copied from this sample)

Fab.java

sheet.xml
Sheet for adding new tasks in our application.

3.3 MainActivity

Finally, let’s connect everything in our MainActivity.

Result
nkbewtfk2z

3.4 Managing tasks

Since our basic UI of the main screen is done, we can now proceed to implement one of our main functionalities. To do that, we are going to define the Task model, corresponding TaskRowHolder, and finally the TaskAdapter. These classes are very simple, so I guess that no explanation is needed.

Task

TaskRowHolder

TaskAdapter

view_task_row.xml

Now we need to connect our code to MainActivity.

Result

nkbewtfk2z

3.5 Login screen UI

We need some kind of authentication since our data will be connected to particular users. Therefore, in one of the incoming posts we are going to implement the auth logic using Realm (yes, Realm provides this feature :)).
However, we will also need the UI part of login to collect the user data.

A pretty simple layout of the login screen. It will have two fields (username + password) and two actions (register + login).

login_activity.xml

Out Login Screen implementation is also really basic, but we will come back to it later.

LoginActivity

Don’t forget to update AndroidManifest!

Result

nkbewtfk2z

Thanks for reading!

The next part of the series is already available!
Part 2: REALM MOBILE PLATFORM: OFFLINE-FIRST TASKMANAGER APP – BASICS OF REALM

Subscribe to our newsletter
Menu