// Path: app/src/main/java/me/ccrama/rssslide/BaseApplication.java
// public class BaseApplication extends Application {
// 
//     public static RealmConfiguration config;
//     private static ImageLoader defaultImageLoader;
//     public static ImageLoader getImageLoader(Context context) {
//         if (defaultImageLoader == null || !defaultImageLoader.isInited()) {
//             ImageLoaderUtils.initImageLoader(context.getApplicationContext());
//             defaultImageLoader = ImageLoaderUtils.imageLoader;
//         }
// 
//         return defaultImageLoader;
//     }
// 
// 
//     @Override
//     public void onLowMemory() {
//         super.onLowMemory();
//         getImageLoader(this).clearMemoryCache();
//     }
// 
// 
//     public void onCreate() {
//         super.onCreate();
//         Realm.init(this);
// 
//         config = new RealmConfiguration.Builder().name("posts").deleteRealmIfMigrationNeeded().build();
//         Realm.setDefaultConfiguration(config);
//     }
// }
// 
// Path: app/src/main/java/me/ccrama/rssslide/Util/ConversionCallback.java
// public interface ConversionCallback{
//     public void onCompletion(int size);
// }


import android.app.Activity;
import com.rometools.rome.feed.synd.SyndEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import io.realm.Realm;
import me.ccrama.rssslide.BaseApplication;
import me.ccrama.rssslide.Util.ConversionCallback;
                ArrayList<Article> toAdd = new ArrayList<>();
                for (SyndEntry i : items) {
                    if (realm.where(Article.class).equalTo("title", i.getTitle()).findFirst() == null) {
                        Article a = new Article();
                        a.setAll(i, f);
                        realm.copyToRealmOrUpdate(a);
                        toAdd.add(a);
                    }
                }
                Collections.reverse(toAdd);
                c.onCompletion(toAdd.size());
            }
        });
    }

    public static void convertInTransaction(final Realm realm, final Feed feed, final List<SyndEntry> items, final ConversionCallback c) {
        ArrayList<Article> toAdd = new ArrayList<>();
        for (SyndEntry i : items) {
            if (realm.where(Article.class).equalTo("title", i.getTitle()).findFirst() == null) {
                Article a = new Article();
                a.setAll(i, feed);
                realm.copyToRealmOrUpdate(a);
                toAdd.add(a);
            }
        }
        Collections.reverse(toAdd);
        c.onCompletion(toAdd.size());
    }


// Path: app/src/main/java/me/ccrama/rssslide/BaseApplication.java
// public class BaseApplication extends Application {
// 
//     public static RealmConfiguration config;
//     private static ImageLoader defaultImageLoader;
//     public static ImageLoader getImageLoader(Context context) {
//         if (defaultImageLoader == null || !defaultImageLoader.isInited()) {
//             ImageLoaderUtils.initImageLoader(context.getApplicationContext());
//             defaultImageLoader = ImageLoaderUtils.imageLoader;
//         }
// 
//         return defaultImageLoader;
//     }
// 
// 
//     @Override
//     public void onLowMemory() {
//         super.onLowMemory();
//         getImageLoader(this).clearMemoryCache();
//     }
// 
// 
//     public void onCreate() {
//         super.onCreate();
//         Realm.init(this);
// 
//         config = new RealmConfiguration.Builder().name("posts").deleteRealmIfMigrationNeeded().build();
//         Realm.setDefaultConfiguration(config);
//     }
// }
// 
// Path: app/src/main/java/me/ccrama/rssslide/Util/ConversionCallback.java
// public interface ConversionCallback{
//     public void onCompletion(int size);
// }


// Path: app/src/main/java/me/ccrama/rssslide/Realm/XMLToRealm.java
import android.app.Activity;
import com.rometools.rome.feed.synd.SyndEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import io.realm.Realm;
import me.ccrama.rssslide.BaseApplication;
import me.ccrama.rssslide.Util.ConversionCallback;

                ArrayList<Article> toAdd = new ArrayList<>();
                for (SyndEntry i : items) {
                    if (realm.where(Article.class).equalTo("title", i.getTitle()).findFirst() == null) {
                        Article a = new Article();
                        a.setAll(i, f);
                        realm.copyToRealmOrUpdate(a);
                        toAdd.add(a);
                    }
                }
                Collections.reverse(toAdd);
                c.onCompletion(toAdd.size());
            }
        });
    }

    public static void convertInTransaction(final Realm realm, final Feed feed, final List<SyndEntry> items, final ConversionCallback c) {
        ArrayList<Article> toAdd = new ArrayList<>();
        for (SyndEntry i : items) {
            if (realm.where(Article.class).equalTo("title", i.getTitle()).findFirst() == null) {
                Article a = new Article();
                a.setAll(i, feed);
                realm.copyToRealmOrUpdate(a);
                toAdd.add(a);
            }
        }
        Collections.reverse(toAdd);
        c.onCompletion(toAdd.size());
    }


    public static void convertSync(final Feed feed, final List<SyndEntry> items, final ConversionCallback c, Activity baseActivity) {