<commit_before>package com.oryanmat.trellowidget.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.RequestFuture;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.oryanmat.trellowidget.R;
import com.oryanmat.trellowidget.model.BoardList;
import com.oryanmat.trellowidget.model.CardArray;

import java.util.concurrent.ExecutionException;

import static com.oryanmat.trellowidget.TrelloWidget.INTERNAL_PREFS;
import static com.oryanmat.trellowidget.TrelloWidget.T_WIDGET;

public class TrelloAPIUtil {
    public static final String TOKEN_PREF_KEY = "com.oryanmat.trellowidget.usertoken";
    public static final String APP_KEY = "b250ef70ccf79ea5e107279a91045e6e";
    public static final String BASE_URL = "https://api.trello.com/";
    public static final String API_VERSION = "1/";
    public static final String KEY = String.format("&key=%s", APP_KEY);
    public static final String AUTH_URL = "https://trello.com/1/authorize" +
            "?name=TrelloWidget" +
            KEY +
            "&expiration=never" +
            "&callback_method=fragment" +
            "&return_url=trello-widget://callback";

    public static final String USER = "members/me?fields=fullName,username";
    public static final String BOARDS = "members/me/boards?filter=open&fields=id,name" +
            "&lists=open&list_fields=id,name";
    public static final String LIST_CARDS = "lists/%s?cards=open&card_fields=name,badges";

    public static TrelloAPIUtil instance;

    Context context;
    RequestQueue queue;
    SharedPreferences preferences;

    private TrelloAPIUtil(Context context) {
        this.context = context.getApplicationContext();
        this.preferences = context.getSharedPreferences(INTERNAL_PREFS, Context.MODE_PRIVATE);
    }

    public static void init(Context context) {
        instance = new TrelloAPIUtil(context);
    }

    public RequestQueue getRequestQueue() {
        if (queue == null) {
            queue = Volley.newRequestQueue(context);
        }
        return queue;
    }

    public String buildURL() {
        String token = preferences.getString(TrelloAPIUtil.TOKEN_PREF_KEY, "");
        return BASE_URL + API_VERSION + "%s" + KEY + "&" + token;
    }

    public String user() {
        return String.format(buildURL(), USER);
    }

    public String boards() {
        return String.format(buildURL(), BOARDS);
    }

    public CardArray getCards(BoardList list) {
        String json = get(String.format(String.format(buildURL(), LIST_CARDS), list.id));

        return Json.tryParseJson(json, CardArray.class, CardArray.oneItemList(json));
    }

    String get(String url) {
        RequestFuture<String> future = RequestFuture.newFuture();
        getRequestQueue().add(new StringRequest(Request.Method.GET, url, future, future));

        return get(future);
    }

    String get(RequestFuture<String> future) {
        try {
            return future.get();
        } catch (ExecutionException | InterruptedException e) {
            String msg = String.format(context.getString(R.string.http_fail), e);
            Log.d(T_WIDGET, msg);
            return msg;
        }
    }

    public void getAsync(String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        StringRequest request = new StringRequest(Request.Method.GET, url, listener, errorListener);
        getRequestQueue().add(request);
    }
}<commit_msg>change from d to e<commit_after>package com.oryanmat.trellowidget.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.RequestFuture;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.oryanmat.trellowidget.R;
import com.oryanmat.trellowidget.model.BoardList;
import com.oryanmat.trellowidget.model.CardArray;

import java.util.concurrent.ExecutionException;

import static com.oryanmat.trellowidget.TrelloWidget.INTERNAL_PREFS;
import static com.oryanmat.trellowidget.TrelloWidget.T_WIDGET;

public class TrelloAPIUtil {
    public static final String TOKEN_PREF_KEY = "com.oryanmat.trellowidget.usertoken";
    public static final String APP_KEY = "b250ef70ccf79ea5e107279a91045e6e";
    public static final String BASE_URL = "https://api.trello.com/";
    public static final String API_VERSION = "1/";
    public static final String KEY = String.format("&key=%s", APP_KEY);
    public static final String AUTH_URL = "https://trello.com/1/authorize" +
            "?name=TrelloWidget" +
            KEY +
            "&expiration=never" +
            "&callback_method=fragment" +
            "&return_url=trello-widget://callback";

    public static final String USER = "members/me?fields=fullName,username";
    public static final String BOARDS = "members/me/boards?filter=open&fields=id,name" +
            "&lists=open&list_fields=id,name";
    public static final String LIST_CARDS = "lists/%s?cards=open&card_fields=name,badges";

    public static TrelloAPIUtil instance;

    Context context;
    RequestQueue queue;
    SharedPreferences preferences;

    private TrelloAPIUtil(Context context) {
        this.context = context.getApplicationContext();
        this.preferences = context.getSharedPreferences(INTERNAL_PREFS, Context.MODE_PRIVATE);
    }

    public static void init(Context context) {
        instance = new TrelloAPIUtil(context);
    }

    public RequestQueue getRequestQueue() {
        if (queue == null) {
            queue = Volley.newRequestQueue(context);
        }
        return queue;
    }

    public String buildURL() {
        String token = preferences.getString(TrelloAPIUtil.TOKEN_PREF_KEY, "");
        return BASE_URL + API_VERSION + "%s" + KEY + "&" + token;
    }

    public String user() {
        return String.format(buildURL(), USER);
    }

    public String boards() {
        return String.format(buildURL(), BOARDS);
    }

    public CardArray getCards(BoardList list) {
        String json = get(String.format(String.format(buildURL(), LIST_CARDS), list.id));

        return Json.tryParseJson(json, CardArray.class, CardArray.oneItemList(json));
    }

    String get(String url) {
        RequestFuture<String> future = RequestFuture.newFuture();
        getRequestQueue().add(new StringRequest(Request.Method.GET, url, future, future));

        return get(future);
    }

    String get(RequestFuture<String> future) {
        try {
            return future.get();
        } catch (ExecutionException | InterruptedException e) {
            String msg = String.format(context.getString(R.string.http_fail), e);
            Log.e(T_WIDGET, msg);
            return msg;
        }
    }

    public void getAsync(String url, Response.Listener<String> listener, Response.ErrorListener errorListener) {
        StringRequest request = new StringRequest(Request.Method.GET, url, listener, errorListener);
        getRequestQueue().add(request);
    }
}
{'fraction_non_alphanumeric': 0.10669941328967117, 'fraction_numerical': 0.006003547550825487, 'mean_word_length': 3.4183242917420134, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6541435', 'n_tokens_mistral': 2221, 'n_tokens_neox': 2147, 'n_words': 440}