package com.jungle.apps.photos.base.manager;

import android.database.sqlite.SQLiteDatabase;
import com.jungle.apps.photos.module.favorite.data.pic.FavoriteEntity;
import com.jungle.apps.photos.module.favorite.data.tag.FavoriteTagEntity;
import com.jungle.base.app.AppCore;
import com.jungle.base.manager.AppManager;
import com.jungle.simpleorm.supporter.ORMDatabaseListener;
import com.jungle.simpleorm.supporter.ORMSupporter;
import com.jungle.simpleorm.supporter.SimpleORMDatabaseListener;

public class PhotosEntityManager implements AppManager {

    public static PhotosEntityManager getInstance() {
        return AppCore.getInstance().getManager(PhotosEntityManager.class);
    }


    protected ORMDatabaseListener getDBListener() {
        return new SimpleORMDatabaseListener() {

            @Override
            public void onCreated(ORMSupporter supporter, SQLiteDatabase db) {
                super.onCreated(supporter, db);

                supporter.createTable(FavoriteEntity.class);
                supporter.createTable(FavoriteTagEntity.class);
            }

            @Override
            public void onUpgrade(ORMSupporter supporter, SQLiteDatabase db,
                    int oldVersion, int newVersion) {

                super.onUpgrade(supporter, db, oldVersion, newVersion);
            }
        };
    }

    public ORMSupporter getGlobalORMSupporter() {
        return null;
    }

    @Override
    public void onCreate() {

    }

    @Override
    public void onTerminate() {

    }
}

@@ -306,24 +306,64 @@
 AppManager;%0A
+import com.jungle.base.utils.FileUtils;%0A
 import com.j
@@ -457,24 +457,82 @@
 MSupporter;%0A
+import com.jungle.simpleorm.supporter.SQLiteORMSupporter;%0A
 import com.j
@@ -780,16 +780,105 @@
 %0A    %7D%0A%0A
+    private static final int DB_VERSION = 1;%0A    private ORMSupporter mGlobalSupporter;%0A%0A
 %0A    pro
@@ -1589,12 +1589,24 @@
 urn 
-null
+mGlobalSupporter
 ;%0A  
@@ -1649,24 +1649,233 @@
 nCreate() %7B%0A
+        String filePath = FileUtils.getDatabaseFilePath(%22entity.db%22);%0A        mGlobalSupporter = new SQLiteORMSupporter(%0A                AppCore.getApplicationContext(), filePath, DB_VERSION, getDBListener());
 %0A    %7D%0A%0A    
@@ -1912,21 +1912,54 @@
 rminate() %7B%0A
+        mGlobalSupporter.close();
 %0A    %7D%0A%7D%0A

fix module. step 2. add Volley for Http requests.