<commit_before>package fr.utc.assos.uvweb.io;

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

import java.util.ArrayList;
import java.util.List;

import fr.tkeunebr.androidlazyasync.acl.AsyncFragment;
import fr.utc.assos.uvweb.data.UVwebContent;
import fr.utc.assos.uvweb.util.HttpHelper;

/**
 * A UI-less fragment that loads the comments of the corresponding {@code mUvId}.
 */
public class CommentsTaskFragment extends AsyncFragment {
	private String mUvId;

	public CommentsTaskFragment() {
	}

	// Public API
	public String getUvId() {
		return mUvId;
	}

	public void setUvId(String uvId) {
		mUvId = uvId;
	}

	@Override
	protected void execute() {
		new LoadUvCommentsTask().exec(mUvId);
	}

	private final class LoadUvCommentsTask extends FragmentTask<String, Void, List<UVwebContent.UVComment>> {
		private static final String URL = "http://s370803768.onlinehome.fr/uvweb/uvdetail.json";

		@Override
		protected List<UVwebContent.UVComment> doInBackground(String... params) {
			final JSONArray uvCommentsArray = HttpHelper.loadJSON(URL);
			if (uvCommentsArray == null || isCancelled()) return null;
			final int nUvComments = uvCommentsArray.length();

			final List<UVwebContent.UVComment> uvComments = new ArrayList<UVwebContent.UVComment>(nUvComments);

			try {
				for (int i = 0; !isCancelled() && i < nUvComments; i++) {
					final JSONObject uvCommentsInfo = (JSONObject) uvCommentsArray.get(i);
					String email; // Fake data to display images
					if ((i + 1) % 4 == 0) {
						email = "<EMAIL>";
					} else if ((i + 1) % 3 == 0) {
						email = "<EMAIL>";
					} else {
						email = "<EMAIL>";
					}
					uvComments.add(new UVwebContent.UVComment(
							uvCommentsInfo.getString("authorName"),
							email,
							"21/03/2012",
							uvCommentsInfo.getString("comment"),
							uvCommentsInfo.getInt("globalRate"),
							uvCommentsInfo.getString("semester")
					));
				}
			} catch (JSONException ignored) {
			}

			//SystemClock.sleep(4000);

			return uvComments;
		}
	}
}<commit_msg>Adapt UV detail comments to new UVweb public API<commit_after>package fr.utc.assos.uvweb.io;

import android.util.Log;

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

import java.util.ArrayList;
import java.util.List;

import fr.tkeunebr.androidlazyasync.acl.AsyncFragment;
import fr.utc.assos.uvweb.data.UVwebContent;
import fr.utc.assos.uvweb.util.HttpHelper;

/**
 * A UI-less fragment that loads the comments of the corresponding {@code mUvId}.
 */
public class CommentsTaskFragment extends AsyncFragment {
    private static final String TAG = "CommentsTaskFragment";
    private String mUvId;

	public CommentsTaskFragment() {
	}

	// Public API
	public String getUvId() {
		return mUvId;
	}

	public void setUvId(String uvId) {
		mUvId = uvId;
	}

	@Override
	protected void execute() {
		new LoadUvCommentsTask().exec(mUvId);
	}

	private final class LoadUvCommentsTask extends FragmentTask<String, Void, List<UVwebContent.UVComment>> {
		private static final String URL = "https://assos.utc.fr/uvweb/uv/app/details/";

		@Override
		protected List<UVwebContent.UVComment> doInBackground(String... params) {
			final String uvCommentsString = HttpHelper.loadJSONString(URL + params[0]);
			if (uvCommentsString == null || isCancelled()) return null;

			final List<UVwebContent.UVComment> uvComments = new ArrayList<UVwebContent.UVComment>();

			try {
                JSONObject root = new JSONObject(uvCommentsString);
                JSONObject details = root.getJSONObject("details");
                JSONArray uvCommentsArray = details.getJSONArray("comments");


				for (int i = 0; !isCancelled() && i < uvCommentsArray.length(); i++) {
					final JSONObject uvCommentsInfo = (JSONObject) uvCommentsArray.get(i);
					String email = "<EMAIL>"; // Fake data to display images
					uvComments.add(new UVwebContent.UVComment(
							uvCommentsInfo.getString("identity"),
							email,
							"21/03/2012",
							uvCommentsInfo.getString("comment"),
							uvCommentsInfo.getInt("globalRate"),
							uvCommentsInfo.getString("semester")
					));
				}
			} catch (JSONException ignored) {
                Log.e(TAG, ignored.toString());
			}

			return uvComments;
		}
	}
}
{'fraction_non_alphanumeric': 0.11873104735246093, 'fraction_numerical': 0.008864007464427339, 'mean_word_length': 3.6608695652173915, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '7833', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1335, 'n_words': 307}