Realm

How Realm has reconciliated me with mobile databases

Realms of Chaos

I’ve been developing Android apps for few years now, and even if I’m a huge fan of what the platform offers to developers, one thing has always bothered me: Databases.

I come from the web world, where you have very powerful ORMs (like Hibernate, Entity Framework…). And when you arrive to Android, what you have is… SQLite. Hard to use, painful to work with… It’s such a mess that I’ve avoided it as much as possible. Then came ORMs for Android, like ORMLite, GreenDAO, ActiveAndroid…

I had the occasion to work with most of them, and even if some are better than others, globally, they’re really, really not efficient enough. At least in my opinion. Models generation, data migrations, APIs… Most of these things are hard to work with when it comes to Android ORMs.

Here comes Realm

Then came Realm. A promising database with a nice APIs and a SQLite-like performance (or even better). It’s actually a whole new DBMS, written in C++, and available on iOS (Swif/Objective C) and Android. Besides being really fast, Realm offers an API so nice it reminds me my good old Entity Framework.

They present their product better than me, so go visit heir website: http://realm.io

It’s pretty easy to setup, and you can start making your entities in a minute. And if you doubt about speed, know that not so long ago, your data manipulation and reading had to be done on the same thread. But from what I’ve experienced, it had no major performance impact (and Joaquim Verges, creator of Falcon Pro, has the same conclusion: https://realm.io/news/joaquim-verges-making-falcon-pro-3/). Don’t worry, if you still want to read data in a background thread and display them in the UI thread (which is probably a good idea, or an absolute requirement, depending on how you see things), Realm is now offering async methods for data manipulation!

Why is it so great?

Even if Realm has been around for several years, I haven’t tried it until recently (even if I was keeping an eye on it). After all, the Android version hasn’t reached the 1.0 version!

I’ve started to use it on Condor, a Twitter client app I’ve made last summer, and to be honest, I was impressed. Since then, I’ve used it on Astonishing Comic Reader, powering some very, very huge collections of books, without any problem. And I’m basically planning to add it to use it in all my future projects.

So it’s just the most perfect library in the world?
Actually not. It has some flaws. After all, it’s still in beta.
The brand new async methods seems not that stable, at least for now ( One of my colleagues had a severe bug which stucked him for a day or so). Some parts are also a bit tedious to use, like the Realm migration API. It’s changed recently, and it’s much better, but I feel like there’s still room for improvement. But anyway, I still consider it’s one of the best libraries you can find on Android.

What are you waiting for?

Seriously, go try it. Copy/paste the Gradle dependency line, and start to play with those RealmObject. I’m sure you’ll be quickly convinced!

Share Button
droidconfr

From Nice To Astonishing

I was in Paris two weeks ago for the 2015 edition of the Droidcon Paris. As usual, I’ve met great people and assisted to some very nice conferences.

I also had the opportunity to present a new talk, focused on app design. Mainly inspired by the great book About Face by Alan Cooper, it’s full of advices about how to make your app even better.

Slides are available on Slideshare, so enjoy, and make your apps astonishing!


Share Button
material-design

Building the astonishing: useful Android libraries for developers

When you’re developing an Android app, you can of course build everything from scratch, or use some of the thousands available open-source libraries. It’ll save you a lot of time, and often let you use complex UI animations, components, or algorithms, which you wouldn’t be able to code from scratch (or not without a lot of time). I even know some people who’d like to use nothing but libraries to build their app.

Since I’ve used a lot of libraries for Astonishing Comic Reader, I’ve decided to write this article, and talk about some of the most useful ones.

 

Support libraries

First of all, I’d like to quickly talk about support libraries. There are a lot of them out there, and even if new releases often come with bugs (especially Appcompat, or the brand new design support library), you have to use (some of) them. Even if you don’t require an API level 4 support, the support v4 library contains very useful stuff like fragments or retro-compatible animations. Just take a look at the revisions list.

 

 

Android annotations

Android annotations (AA) is one of my favorite Android libraries since I’ve started to develop on this platform. It simplifies your code by generating a lot of boilerplate code, like views injection, background threads, intents building, custom views, preferences, Rest API calls… Well, it does it almost all. Just take a look at the official cookbook, you’ll see what I mean.

AA actually generates subclasses from annotations, where all the code you don’t want to write is. For example, if you want to use AA on a specific activity class called MyActivity, you’re using annotations like @EActivity (to declare that your class will use AA annotations) and @ViewById (to avoid the boring findViewById). At compilation, a class called MyActivity_ (notice the “_” symbol) is generated. This is this class that you’ll declare in your manifest, and use to build intents.

AA really makes your life easier, on a lot of things. Maybe too much things, and that’s one of its flaws. It quickly creates a very strong dependency between your code and the library, and removing it might be a pain. But if you want to replace all these features with other libraries, you can start with things like Dagger and Butterknife.

The other major flaw is that it creates a lot of new subclasses (actually, one per annotated classes). Then, it almost doubles the number of methods in your code, which might dramatically lead you to the unpopular multidex error. Keep it in mind if you want to use it.

 

Square one

Square is an American company specialized in mobile payments. But their talented developers have developed some of the most popular Android libraries, including Otto, Dagger, Retrofit, Picasso… I’ll talk about some of them here, but you can check the complete list here.

 

Otto

Otto is an event bus library. Basically, it allows you to send messages across the different components of your application. And trust me, that’s sometimes very, very useful. You can for example send objects from a fragment to another or notify an activity from a custom view. It’s not a must-have in all your projects, and you should be careful about overusing it.

In ACR, I use Otto to synchronize the zoom level between the pager’s page, or to notify the view that suggestions have been loaded. You can also use it to send events about network operations, or database data retrieving.

There is a very good alternative to Otto called EventBus. I’m not very fond of it, but it has some very convenient features, like managing events trough inheritance, which Otto doesn’t.

 

Retrofit

Retrofit is a REST client library for Android which clearly eases your work with web services.

The only things you have to do is to declare an interface, containing all your API endpoints (annotated with things like @GET or @Query), and use this interface to declare a RestAdapter and a service class, which is basically your interface implementation.

What I like with Retrofit is that it’s very, very easy to use, and it’ll clearly change your life. It allows you to simply declare your endpoints, or customize them with annotations. It automatically parses you results using Gson, but you can use a custom converter if you want (XML parser for example). Easy setup, great default behaviour, and advanced customization if needed. What else?

 

Picasso

I’ll probably write another article about image libraries, since image processing is at the core of ACR, but I got to talk about Picasso. Yes, it’s another library by Square, designed to ease image downloading and manipulation. The goal is to let developers easily display images from the Internet, and automatically handle things like cache, network failures, placeholders etc.

I’ve seen on a Google + poll that a lot of developers don’t use any library to manage images. If you don’t, do it. Right now.  Even if you’ve your own library for that. If you don’t want Picasso, you can pick something like Universal Image Loader, Glide or even Fresco. Each of these libraries have been developed, tested and improved by thousands of fellow developers. And they clearly ease your life!

 

JSON processing

JSON processing is nowadays a very easy task in most cases. You probably all know Gson, the Google library to parse JSON. There are alternatives like Jackson, or the new player in town: Moshi (also by Square).

 

Finding new libraries

Finding new Android libraries is easy: just use Google. But if you want to do it the right way, there are a lot of websites out there which are referencing new libraries each day. My favorite one is Android arsenal, but you can also visit AndroidLibs or directly test libraries on your mobile with Libraries for developers.

 

Share Button
techblock

Astonishing Comic Reader: Year One

A bit more than a year ago, I’ve published a comic book reader app for Android, called Astonishing Comic Reader. And last week I’ve published the 100th release. Time to summarize the experience.

The first version was very basic. There was no gestures, no fullscreen mode, and had a lot of bugs (mainly due to some devices, like Samsung tablets). But after only a week-end of work, you couldn’t expect much more. Now the app offers tons of features, like cloud integration, a nice screenshots system called Snapshots, Material Design, intelligent suggestions, Muzei and Chromecast support… There is also a web version and a Windows 8 version.

The Android app has almost 65K downloads, with more than 1400 users each day. Of course, some people are busy reading comics each week-end! More than 2500 users have rated the app, with a 4.08 global rating (and increasing). With the coming 101th release, there is more than an update each 5 days. Yes, I have a full-time job, and also have the time to work on other apps (and do other stuff as well, like reading comics 😉 ).

The app has also been featured on several websites, including several Android news websites, and LifeHacker, which describes it as “The best comic reader app for Android”. How nice is that?

 

As I’m writing this article, our Google+ community has 499 members (come on, 500th member!). And they are very active, giving me a lot of feedback, which is an absolute necessity when you’re working on an application. No feedback means you’re the only one making decisions, but maybe they’re the wrong ones. When you add a feature, you’re not sure if it’s really needed by your users. Of course, you can be on your own for a lot of things. But after a time, you need to know whan your users think. That’s why my G+ community is so important to me.

I also receive a lot of emails about the app. I don’t have numbers for that, but I generally receive at least one each day. Most of the time, it’s a bug report or some suggestions. Sometimes it’s just a “thank you for making this app”. And that’s awesome!

There is more astonishing stuff coming soon. If you don’t read comic books yet, there is no better time to start!

Download Android app

Google Plus community

 

Share Button
Devoxx

Holo to material design – Devoxx France 2015

I was this week at Devoxx France. Apart of the amazing conferences, I was myself doing an updated talk about Material Design. Since the Droidcon Paris (where I first did this presentation), a lot of libraries have been created to achieve various parts of the design specifications, and many apps have adopted this new approach.

I’ll update this article when the video will be available on Parleys. You can however get the slides on Slideshare:

 

 

Share Button