Fix switching Gerrit instance

Previously, DatabaseFactory.changeGerrit was not called so changing the
 Gerrit instance in the preferences would not change the database. This
 adds an Application-wide shared preference listener, so wherever the
 sharedPreferences are modified, the lister code is guarenteed to be
 called.

Added Application class (and modified manifest accordingly).
 This class will help to fix loosing broadcasts.
Implemented locking mechanism in DatabaseFactory to not disturb
 CRUD operations, switch the database after they are finished.

This fixes the menu option for the Gerrit instance switcher (the cloud
 button).

PS5: Mildly fix changing Gerrit instances via cloud button
PS6: Fix a sort-of race condition where the activity would
 refresh with old data before the application had loaded the
 new database.

Change-Id: I6c6b2fc40fb82a07969a261ca36eef0ab072eec3