// Path: app/src/main/java/de/stephanlindauer/criticalmaps/App.java
// public class App extends Application {
// 
//     private static AppComponent appComponent;
// 
//     public static AppComponent components() {
//         return appComponent;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         if (BuildConfig.DEBUG) {
//             Timber.plant(new Timber.DebugTree());
//         } else {
//             Timber.plant(new NoOpTree());
//         }
// 
//         appComponent = DaggerAppComponent.builder().app(this).build();
//     }
// 
//     private static class NoOpTree extends Timber.Tree {
//         @Override
//         protected void log(int priority, String tag, @NotNull String message, Throwable t) {
//         }
//     }
// }
// 
// Path: app/src/main/java/de/stephanlindauer/criticalmaps/model/TwitterModel.java
// @Singleton
// public class TwitterModel {
// 
//     private final List<Tweet> tweets = new ArrayList<>();
// 
//     @Inject
//     public TwitterModel() {
//     }
// 
//     public void setTweetsFromJsonString(String tweetsString) throws JSONException, ParseException {
//         tweets.clear();
//         JSONObject jsonObject = new JSONObject(tweetsString);
//         JSONArray statusesArray = jsonObject.getJSONArray("statuses");
// 
//         for (int i = 0, statusesArrayLength = statusesArray.length(); i < statusesArrayLength; i++) {
//             JSONObject currentStatus = statusesArray.getJSONObject(i);
//             final JSONObject user = currentStatus.getJSONObject("user");
//             Tweet tweet = new Tweet()
//                     .setUserName(user.getString("name"))
//                     .setUserScreenName(user.getString("screen_name"))
//                     .setTweetId(currentStatus.getString("id_str"))
//                     .setText(currentStatus.getString("text"))
//                     .setTimestamp(TwitterUtils.getTwitterDate(currentStatus.getString("created_at")))
//                     .setProfileImageUrl(user.getString("profile_image_url_https"));
// 
//             tweets.add(tweet);
//         }
//     }
// 
//     public List<Tweet> getTweets() {
//         return tweets;
//     }
// }
// 
// Path: app/src/main/java/de/stephanlindauer/criticalmaps/vo/Endpoints.java
// public class Endpoints {
//     public static final String MAIN_POST = "https://api.criticalmaps.net/";
//     public static final String IMAGE_POST = "https://api.criticalmaps.net/gallery/";
//     public static final String GET_TWITTER = "https://api.criticalmaps.net/twitter/";
// }


import android.os.AsyncTask;
import org.json.JSONException;
import java.text.ParseException;
import de.stephanlindauer.criticalmaps.App;
import de.stephanlindauer.criticalmaps.fragments.TwitterFragment;
import de.stephanlindauer.criticalmaps.model.TwitterModel;
import de.stephanlindauer.criticalmaps.vo.Endpoints;
import de.stephanlindauer.criticalmaps.vo.ResultType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;
package de.stephanlindauer.criticalmaps.handler;





public class TwitterGetHandler extends AsyncTask<Void, Void, ResultType> {

    //dependencies
    private final TwitterModel twitterModel = App.components().twitterModel();
    private final TwitterFragment twitterFragment;

    private String responseString = "";

    public TwitterGetHandler(TwitterFragment twitterFragment) {
        this.twitterFragment = twitterFragment;
    }

    @Override
    protected void onPreExecute() {
        twitterFragment.setRefreshing(true);
    }

    @Override
    protected ResultType doInBackground(Void... params) {
        final Request request = new Request.Builder().url(Endpoints.GET_TWITTER).get().build();

        final OkHttpClient httpClient = App.components().okHttpClient();
// Path: app/src/main/java/de/stephanlindauer/criticalmaps/App.java
// public class App extends Application {
// 
//     private static AppComponent appComponent;
// 
//     public static AppComponent components() {
//         return appComponent;
//     }
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         if (BuildConfig.DEBUG) {
//             Timber.plant(new Timber.DebugTree());
//         } else {
//             Timber.plant(new NoOpTree());
//         }
// 
//         appComponent = DaggerAppComponent.builder().app(this).build();
//     }
// 
//     private static class NoOpTree extends Timber.Tree {
//         @Override
//         protected void log(int priority, String tag, @NotNull String message, Throwable t) {
//         }
//     }
// }
// 
// Path: app/src/main/java/de/stephanlindauer/criticalmaps/model/TwitterModel.java
// @Singleton
// public class TwitterModel {
// 
//     private final List<Tweet> tweets = new ArrayList<>();
// 
//     @Inject
//     public TwitterModel() {
//     }
// 
//     public void setTweetsFromJsonString(String tweetsString) throws JSONException, ParseException {
//         tweets.clear();
//         JSONObject jsonObject = new JSONObject(tweetsString);
//         JSONArray statusesArray = jsonObject.getJSONArray("statuses");
// 
//         for (int i = 0, statusesArrayLength = statusesArray.length(); i < statusesArrayLength; i++) {
//             JSONObject currentStatus = statusesArray.getJSONObject(i);
//             final JSONObject user = currentStatus.getJSONObject("user");
//             Tweet tweet = new Tweet()
//                     .setUserName(user.getString("name"))
//                     .setUserScreenName(user.getString("screen_name"))
//                     .setTweetId(currentStatus.getString("id_str"))
//                     .setText(currentStatus.getString("text"))
//                     .setTimestamp(TwitterUtils.getTwitterDate(currentStatus.getString("created_at")))
//                     .setProfileImageUrl(user.getString("profile_image_url_https"));
// 
//             tweets.add(tweet);
//         }
//     }
// 
//     public List<Tweet> getTweets() {
//         return tweets;
//     }
// }
// 
// Path: app/src/main/java/de/stephanlindauer/criticalmaps/vo/Endpoints.java
// public class Endpoints {
//     public static final String MAIN_POST = "https://api.criticalmaps.net/";
//     public static final String IMAGE_POST = "https://api.criticalmaps.net/gallery/";
//     public static final String GET_TWITTER = "https://api.criticalmaps.net/twitter/";
// }


// Path: app/src/main/java/de/stephanlindauer/criticalmaps/handler/TwitterGetHandler.java
import android.os.AsyncTask;
import org.json.JSONException;
import java.text.ParseException;
import de.stephanlindauer.criticalmaps.App;
import de.stephanlindauer.criticalmaps.fragments.TwitterFragment;
import de.stephanlindauer.criticalmaps.model.TwitterModel;
import de.stephanlindauer.criticalmaps.vo.Endpoints;
import de.stephanlindauer.criticalmaps.vo.ResultType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;

package de.stephanlindauer.criticalmaps.handler;





public class TwitterGetHandler extends AsyncTask<Void, Void, ResultType> {

    //dependencies
    private final TwitterModel twitterModel = App.components().twitterModel();
    private final TwitterFragment twitterFragment;

    private String responseString = "";

    public TwitterGetHandler(TwitterFragment twitterFragment) {
        this.twitterFragment = twitterFragment;
    }

    @Override
    protected void onPreExecute() {
        twitterFragment.setRefreshing(true);
    }

    @Override
    protected ResultType doInBackground(Void... params) {
        final Request request = new Request.Builder().url(Endpoints.GET_TWITTER).get().build();

        final OkHttpClient httpClient = App.components().okHttpClient();
        try {