<commit_before>package me.masterejay.testapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;

import android.widget.Toast;
import me.masterejay.testapp.widget.UITableView;
import me.masterejzz.testapp.R;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class Forum extends Activity{
	UITableView tableView;
	List<ForumEntry> entries = new ArrayList<ForumEntry>();
	Document doc = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

		StrictMode.setThreadPolicy(policy);
		setContentView(R.layout.forum);
		Toast.makeText(Forum.this, "Please wait while we fetch the latest news!", Toast.LENGTH_SHORT).show();

		tableView = (UITableView) findViewById(R.id.tableView);

		parsePage();
		Log.d("Forum","total items: "+ tableView.getCount());
	}

	private void createList() {
		CustomClickListener listener = new CustomClickListener();
		tableView.setClickListener(listener);
		tableView.clear();
		int index = 0;
		for (ForumEntry e : entries){
			tableView.addBasicItem(e.getTopicName(), e.getPoster() + " posted " + e.getDate());
			e.setIndex(index);
			index++;
		}
		tableView.commit();

	}


	public ForumEntry getEntryFromId(int id){
		for (ForumEntry e : entries){
			if (id == e.getIndex()){
				return e;
			}
		}
		return null;
	}

	private class CustomClickListener implements UITableView.ClickListener{
		@Override
		public void onClick(int index) {
			Toast.makeText(Forum.this, "item clicked: " + getEntryFromId(index).getLink(), Toast.LENGTH_SHORT).show();
		}
	}


	public void parsePage(){
				try {
					doc = Jsoup.connect("http://oc.tc/forums").userAgent("Mozilla").get();
				} catch (IOException e) {
					e.printStackTrace();
					Toast.makeText(Forum.this, "Something went wrong! Are you sure you're online?", Toast.LENGTH_LONG).show();
					return;
					}

					Elements topics = doc.getElementsByClass("topic");
					for (int i = 0; i < topics.size(); i++){
						Element e = topics.get(i);
						Elements td = e.getElementsByClass("td");
						for (int i2 = 0; i2 <= td.size(); i2++){
							Elements titleElement = e.getElementsByAttributeValueContaining("href", "topics");
							Elements authorElement = e.getElementsByAttributeValueContaining("style", "color");
							String author = authorElement.text().split(" ")[0];
							String title = titleElement.text();
							String link = "https://oc.tc/" + titleElement.attr("href").split("/unread")[0];
							Elements dateElement = e.getElementsByTag("span");
							String date = dateElement.text();
							entries.add(new ForumEntry(author, date, title, link));

						}
					}
					createList();
					Elements startedBy = topics.addClass("started-by");
			}
	}


<commit_msg>Async, kinda...<commit_after>package me.masterejay.testapp;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;

import android.widget.Toast;
import me.masterejay.testapp.widget.UITableView;
import me.masterejzz.testapp.R;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class Forum extends Activity{
	UITableView tableView;
	List<ForumEntry> entries = new ArrayList<ForumEntry>();
	Document doc = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

		StrictMode.setThreadPolicy(policy);
		setContentView(R.layout.forum);
		Toast.makeText(Forum.this, "Please wait while we fetch the latest news!", Toast.LENGTH_SHORT).show();

		tableView = (UITableView) findViewById(R.id.tableView);

		 sendAsyncTask();

		Log.d("Forum","total items: "+ tableView.getCount());
	}

	private void createList() {
		CustomClickListener listener = new CustomClickListener();
		tableView.setClickListener(listener);
		tableView.clear();
		int index = 0;
		for (ForumEntry e : entries){
			tableView.addBasicItem(e.getTopicName(), e.getPoster() + " posted " + e.getDate());
			e.setIndex(index);
			index++;
		}
		tableView.commit();

	}

	public void sendAsyncTask(){
		ParseTask task = new ParseTask();
		task.doInBackground(null);
	}


	public ForumEntry getEntryFromId(int id){
		for (ForumEntry e : entries){
			if (id == e.getIndex()){
				return e;
			}
		}
		return null;
	}

	private class CustomClickListener implements UITableView.ClickListener{
		@Override
		public void onClick(int index) {
			Toast.makeText(Forum.this, "item clicked: " + getEntryFromId(index).getLink(), Toast.LENGTH_SHORT).show();
		}
	}


	protected class ParseTask extends AsyncTask<String, String, String> {
		public void parsePage(){
			try {
				doc = Jsoup.connect("http://oc.tc/forums").userAgent("Mozilla").get();
			} catch (IOException e) {
				e.printStackTrace();
				Toast.makeText(Forum.this, "Something went wrong! Are you sure you're online?", Toast.LENGTH_LONG).show();
				return;
			}

			Elements topics = doc.getElementsByClass("topic");
			for (int i = 0; i < topics.size(); i++){
				Element e = topics.get(i);
				Elements td = e.getElementsByClass("td");
				for (int i2 = 0; i2 <= td.size(); i2++){
					Elements titleElement = e.getElementsByAttributeValueContaining("href", "topics");
					Elements authorElement = e.getElementsByAttributeValueContaining("style", "color");
					String author = authorElement.text().split(" ")[0];
					String title = titleElement.text();
					String link = "https://oc.tc/" + titleElement.attr("href").split("/unread")[0];
					Elements dateElement = e.getElementsByTag("span");
					String date = dateElement.text();
					entries.add(new ForumEntry(author, date, title, link));

				}
			}
			createList();
		}

		@Override
		protected String doInBackground(String... params){
		   parsePage();
			return null;
		}
	}


	}



{'fraction_non_alphanumeric': 0.1394658753709199, 'fraction_numerical': 0.002498828674059035, 'mean_word_length': 4.2234910277324635, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 2, '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': '5034036', 'n_tokens_mistral': 2317, 'n_tokens_neox': 1974, 'n_words': 439}