<commit_before>package com.asafge.newsblurplus;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;

import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus;

public class APICall {
	
	public JSONObject Json;
	public AjaxStatus Status;
	private AjaxCallback<JSONObject> callback;
	private AQuery aquery;
	private String callbackUrl;
	
	// Empty constructor
	public APICall(Context c) {
		aquery = new AQuery(c);
	}
	
	// Constructor
	public APICall(String url,  Context c) {
		aquery = new AQuery(c);
		// Create the callback object
		createCallback(url, c);
	}

	// Create a callback object, before running sync
	public void createCallback(String url, Context c) {
		callbackUrl = url;
		callback = new AjaxCallback<JSONObject>();
		callback.header("User-Agent", Prefs.USER_AGENT);
		String[] sessionID = Prefs.getSessionID(c);
		callback.cookie(sessionID[0], sessionID[1]);
		callback.url(callbackUrl).type(JSONObject.class);
	}
	
	// Add a parameter to the call
	public void addParam(String key, Object value) {
		if (callback != null)
			callback.param(key, value);
	}
	
	// Run synchronous HTTP request and check for valid response
	public boolean sync() {
		if (callback == null)
			return false;
		try {
			aquery.sync(callback);
			Json = callback.getResult();
			Status = callback.getStatus();
			if (Json == null)
				return false;
			if (Json.getString("authenticated") != "true") {
				// TODO: LoginActivity.logout();
				return false;
			}
			return (Status.getCode() == 200);
		}
		catch (JSONException e) {
			return false;
		}
	}
	
	// Run synchronous HTTP request, check valid response + successful operation 
	public boolean syncGetBool() {
		boolean result = true;
		try {<commit_msg>Add param now returns feedback<commit_after>package com.asafge.newsblurplus;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;

import com.androidquery.AQuery;
import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus;

public class APICall {
	
	public JSONObject Json;
	public AjaxStatus Status;
	private AjaxCallback<JSONObject> callback;
	private AQuery aquery;
	private String callbackUrl;
	
	// Empty constructor
	public APICall(Context c) {
		aquery = new AQuery(c);
	}
	
	// Constructor
	public APICall(String url,  Context c) {
		aquery = new AQuery(c);
		// Create the callback object
		createCallback(url, c);
	}

	// Create a callback object, before running sync
	public void createCallback(String url, Context c) {
		callbackUrl = url;
		callback = new AjaxCallback<JSONObject>();
		callback.header("User-Agent", Prefs.USER_AGENT);
		String[] sessionID = Prefs.getSessionID(c);
		callback.cookie(sessionID[0], sessionID[1]);
		callback.url(callbackUrl).type(JSONObject.class);
	}
	
	// Add a parameter to the call
	public boolean addParam(String key, Object value) {
		if (callback == null)
			return false;
		callback.param(key, value);
		return true;
	}
	
	// Run synchronous HTTP request and check for valid response
	public boolean sync() {
		if (callback == null)
			return false;
		try {
			aquery.sync(callback);
			Json = callback.getResult();
			Status = callback.getStatus();
			if (Json == null)
				return false;
			if (Json.getString("authenticated") != "true") {
				// TODO: LoginActivity.logout();
				return false;
			}
			return (Status.getCode() == 200);
		}
		catch (JSONException e) {
			return false;
		}
	}
	
	// Run synchronous HTTP request, check valid response + successful operation 
	public boolean syncGetBool() {
		boolean result = true;
		try {
{'fraction_non_alphanumeric': 0.11047619047619048, 'fraction_numerical': 0.0027210884353741495, 'mean_word_length': 3.9742895805142084, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1222281', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1110, 'n_words': 322}