@@ -0,0 +1,2820 @@
+package de.metalmatze.krautreporter.api;%0A%0Aimport com.google.gson.ExclusionStrategy;%0Aimport com.google.gson.FieldAttributes;%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0A%0Aimport de.metalmatze.krautreporter.models.Article;%0Aimport de.metalmatze.krautreporter.models.Author;%0Aimport io.realm.Realm;%0Aimport io.realm.RealmObject;%0Aimport retrofit.Callback;%0Aimport retrofit.RestAdapter;%0Aimport retrofit.RetrofitError;%0Aimport retrofit.client.Response;%0Aimport retrofit.converter.GsonConverter;%0A%0Apublic class Api %7B%0A%0A    public static final String URL = %22http://krautreporter.metalmatze.de%22;%0A%0A    protected Realm realm;%0A%0A    private static ApiInterface singleton;%0A%0A    public static ApiInterface request() %7B%0A%0A        if (singleton == null) %7B%0A%0A            Gson gson = new GsonBuilder()%0A                    .setExclusionStrategies(new ExclusionStrategy() %7B%0A                        @Override%0A                        public boolean shouldSkipField(FieldAttributes f) %7B%0A                            return f.getDeclaringClass().equals(RealmObject.class);%0A                        %7D%0A%0A                        @Override%0A                        public boolean shouldSkipClass(Class%3C?%3E clazz) %7B%0A                            return false;%0A                        %7D%0A                    %7D)%0A                    .create();%0A%0A            RestAdapter restAdapter = new RestAdapter.Builder()%0A                    .setEndpoint(URL)%0A                    .setConverter(new GsonConverter(gson))%0A                    .build();%0A%0A            singleton = restAdapter.create(ApiInterface.class);%0A        %7D%0A%0A        return singleton;%0A    %7D%0A%0A    public static Api with(Realm realm) %7B%0A        return new Api(realm);%0A    %7D%0A%0A    public Api(Realm realm) %7B%0A        this.realm = realm;%0A    %7D%0A%0A    public void updateArticles() %7B%0A        Api.request().articles(new Callback%3CJsonArray%3CArticle%3E%3E() %7B%0A            @Override%0A            public void success(JsonArray%3Cde.metalmatze.krautreporter.models.Article%3E articles, Response response) %7B%0A                realm.beginTransaction();%0A                realm.copyToRealmOrUpdate(articles.data);%0A                realm.commitTransaction();%0A            %7D%0A%0A            @Override%0A            public void failure(RetrofitError error) %7B%0A                error.printStackTrace();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public void updateAuthors() %7B%0A        Api.request().authors(new Callback%3CJsonArray%3CAuthor%3E%3E() %7B%0A            @Override%0A            public void success(JsonArray%3CAuthor%3E authors, Response response) %7B%0A                realm.beginTransaction();%0A                realm.copyToRealmOrUpdate(authors.data);%0A                realm.commitTransaction();%0A            %7D%0A%0A            @Override%0A            public void failure(RetrofitError error) %7B%0A                error.printStackTrace();%0A            %7D%0A        %7D);%0A    %7D%0A%7D%0A

Create the Api class with all api logic