// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
//     private Realm realm;
//     private Context context;
//     @Inject
//     public RealmBookmarksHelper(Context context) {
//         Realm.init(context);
//         this.context = context;
//     }
// 
//     public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
//        try {
//            realm = Realm.getDefaultInstance();
//            realm.executeTransaction(transactionRealm -> {
//                BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
//                if (bookmark == null)
//                    bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
//                bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
// 
//            });
//        } finally {
//            realm.close();
//        }
//     }
// 
// 
//     public BookmarkDbEntity findInRealm(Realm realm, String title) {
//         return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
//     }
// 
//     public List<BookmarkDbEntity> findAllBookmarks() {
//         realm = Realm.getDefaultInstance();
//         return realm.where(BookmarkDbEntity.class).findAll();
//     }
// 
//     public void deleteBookmark(String title) {
//         try {
//             realm = Realm.getDefaultInstance();
// 
//             realm.executeTransaction(transactionRealm -> {
//                 BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
//                 if (bookmark!=null) bookmark.deleteFromRealm();
//             });
//         } finally {
//             realm.close();
//         }
//     }
// 
//     public boolean isInDatabase(String title) {
//         realm = Realm.getDefaultInstance();
//         BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
//         realm.close();
//         return entity != null;
//     }
// }


import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import dagger.Module;
import dagger.Provides;
package com.projects.elad.hacklist.injection.modules;




/**
 * Created by EladKeyshawn on 25/02/2017.
 */
@Module
public class AppModule {
    protected final Application application;
    public AppModule(Application application) {
        this.application = application;
    }

    @Provides
    Application provideApplication(){
        return application;
    }

    @Provides
    Context provideContext(){
        return application;
    }

    @Provides
    @HacklistApplicationScope
// Path: app/src/main/java/com/projects/elad/hacklist/data/db/RealmBookmarksHelper.java
// public class RealmBookmarksHelper {
//     private Realm realm;
//     private Context context;
//     @Inject
//     public RealmBookmarksHelper(Context context) {
//         Realm.init(context);
//         this.context = context;
//     }
// 
//     public void writeToRealm(BookmarkDbEntity bookmarkToSave) {
//        try {
//            realm = Realm.getDefaultInstance();
//            realm.executeTransaction(transactionRealm -> {
//                BookmarkDbEntity bookmark = findInRealm(transactionRealm, bookmarkToSave.getEventTitle());
//                if (bookmark == null)
//                    bookmark = transactionRealm.createObject(BookmarkDbEntity.class, bookmarkToSave.getEventTitle());
//                bookmark.setFacebookUrl(bookmarkToSave.getFacebookUrl());
// 
//            });
//        } finally {
//            realm.close();
//        }
//     }
// 
// 
//     public BookmarkDbEntity findInRealm(Realm realm, String title) {
//         return realm.where(BookmarkDbEntity.class).equalTo("eventTitle",title).findFirst();
//     }
// 
//     public List<BookmarkDbEntity> findAllBookmarks() {
//         realm = Realm.getDefaultInstance();
//         return realm.where(BookmarkDbEntity.class).findAll();
//     }
// 
//     public void deleteBookmark(String title) {
//         try {
//             realm = Realm.getDefaultInstance();
// 
//             realm.executeTransaction(transactionRealm -> {
//                 BookmarkDbEntity bookmark = findInRealm(transactionRealm, title);
//                 if (bookmark!=null) bookmark.deleteFromRealm();
//             });
//         } finally {
//             realm.close();
//         }
//     }
// 
//     public boolean isInDatabase(String title) {
//         realm = Realm.getDefaultInstance();
//         BookmarkDbEntity entity = realm.where(BookmarkDbEntity.class).equalTo("eventTitle", title).findFirst();
//         realm.close();
//         return entity != null;
//     }
// }


// Path: app/src/main/java/com/projects/elad/hacklist/injection/modules/AppModule.java
import android.app.Application;
import android.content.Context;
import com.projects.elad.hacklist.data.db.RealmBookmarksHelper;
import com.projects.elad.hacklist.injection.scopes.HacklistApplicationScope;
import dagger.Module;
import dagger.Provides;

package com.projects.elad.hacklist.injection.modules;




/**
 * Created by EladKeyshawn on 25/02/2017.
 */
@Module
public class AppModule {
    protected final Application application;
    public AppModule(Application application) {
        this.application = application;
    }

    @Provides
    Application provideApplication(){
        return application;
    }

    @Provides
    Context provideContext(){
        return application;
    }

    @Provides
    @HacklistApplicationScope
    public RealmBookmarksHelper provideRealmBookmarksHelper(Context context){