From: drizea Date: Thu, 9 Aug 2012 14:55:44 +0000 (+0300) Subject: add bootreceiver to reinitialize the notifications + notification code X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1636669f304055c0c206cb8ec9d058dd42dde704;p=working%2FEvergreen.git add bootreceiver to reinitialize the notifications + notification code --- diff --git a/Open-ILS/src/Android/.classpath b/Open-ILS/src/Android/.classpath index 3c525784df..ace0184986 100644 --- a/Open-ILS/src/Android/.classpath +++ b/Open-ILS/src/Android/.classpath @@ -9,5 +9,6 @@ + diff --git a/Open-ILS/src/Android/AndroidManifest.xml b/Open-ILS/src/Android/AndroidManifest.xml index 1558a74b42..a64c282a64 100644 --- a/Open-ILS/src/Android/AndroidManifest.xml +++ b/Open-ILS/src/Android/AndroidManifest.xml @@ -16,7 +16,7 @@ - + - + + + + + + + + records) { + + DefaultDAO daoNotifications = DatabaseManager.getDAOInstance(context, NotificationAlert.class, NotificationAlert.tableName); + daoNotifications.open(); + + // Fetch all alarms + List alarms = daoNotifications.fetchAll(""); + + System.out.println(" Alarms " + alarms.size()); + + for(int i=0;i daoNotifications = DatabaseManager.getDAOInstance(context, NotificationAlert.class, NotificationAlert.tableName); + daoNotifications.open(); + + // Fetch all alarms + List alarms = daoNotifications.fetchAll(""); + + System.out.println(" Alarms " + alarms.size()); + + for(int i=0;i rmMap = new HashMap(); + + @SuppressWarnings("rawtypes") + private static HashMap daoMap = new HashMap(); + + /** + * Gets the Singleton database helper. + * + * @return the dB helper + */ + public static DefaultDatabaseHelper getDBHelper(Context context) { + if (dbHelper == null) + dbHelper = new DefaultDatabaseHelper(context, DATABASE_NAME, DATABASE_VERSION, new Class[] { NotificationAlert.class}, new String[] { + NotificationAlert.tableName}); + return dbHelper; + } + + /** + * Gets a singleton instance of a reflection manager corresponding to a class. + * + * @param cls the class + * @return the reflection manager instance + */ + public static ReflectionManager getReflectionManagerInstance(Class cls) { + if (rmMap.containsKey(cls)) + return rmMap.get(cls); + try { + ReflectionManager rm = new ReflectionManager(cls); + rmMap.put(cls, rm); + return rm; + } catch (IllegalClassStructureException ex) { + ex.printStackTrace(); + Log.d(TAG, "Illegal Class Structure for class " + cls + ": " + ex.getMessage()); + return null; + } + } + + /** + * Gets a singleton instance of a DefaultDAO object corresponding to a class. + * + * @param the generic type + * @param cls the class + * @param tableName the table name + * @return the DAO instance + */ + @SuppressWarnings("unchecked") + public static synchronized DefaultDAO getDAOInstance(Context context, Class cls, String tableName) { + if (daoMap.containsKey(cls)) + return daoMap.get(cls); + DefaultDAO dao = new DefaultDAO(cls, DatabaseManager.getDBHelper(context), + DatabaseManager.getReflectionManagerInstance(cls), tableName); + daoMap.put(cls, dao); + return dao; + } +}