<commit_before>package net.acuttone.reddimg;

import java.util.Collections;
import java.util.List;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class UserSubredditsActivity extends Activity implements OnSharedPreferenceChangeListener {
	private ListView listView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.usersubreddits);

		listView = (ListView) findViewById(R.id.usersubreddits_listView);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				SubredditArrayAdapter adapter = (SubredditArrayAdapter) listView.getAdapter();
				String item = adapter.getItem((int) id);
				List<String> subreddits = SubredditsPickerActivity.getSubredditsFromPref();
				if(subreddits.contains(item) == false) {
					subreddits.add(item);
					SubredditsPickerActivity.saveSubreddits(subreddits);
				}
			}
		});
		
		ReddimgApp.instance().getPrefs().registerOnSharedPreferenceChangeListener(this);
		
		AsyncTask<Void, Void, List<String>> loadTask = new AsyncTask<Void, Void, List<String>>() {

			private ProgressDialog progressDialog;

			@Override
			protected void onPreExecute() {
				progressDialog = ProgressDialog.show(UserSubredditsActivity.this, "Reddimg", "Loading subreddits...");
			}
			
			@Override
			protected List<String> doInBackground(Void... params) {
				List<String> names = ReddimgApp.instance().getRedditClient().getMySubreddits();
				Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
				return names;
			}

			@Override
			protected void onPostExecute(List<String> result) {
				SubredditArrayAdapter adapter = new SubredditArrayAdapter(UserSubredditsActivity.this, result, R.drawable.plus, true);
				listView.setAdapter(adapter);
				progressDialog.dismiss();
				super.onPostExecute(result);
			}
			
		};
		loadTask.execute(null);
	}
<commit_msg>usersubreddits btn refresh<commit_after>package net.acuttone.reddimg;

import java.util.Collections;
import java.util.List;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class UserSubredditsActivity extends Activity implements OnSharedPreferenceChangeListener {
	private ListView listView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.usersubreddits);

		listView = (ListView) findViewById(R.id.usersubreddits_listView);
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				SubredditArrayAdapter adapter = (SubredditArrayAdapter) listView.getAdapter();
				String item = adapter.getItem((int) id);
				List<String> subreddits = SubredditsPickerActivity.getSubredditsFromPref();
				if(subreddits.contains(item) == false) {
					subreddits.add(item);
					SubredditsPickerActivity.saveSubreddits(subreddits);
				}
			}
		});
		
		ReddimgApp.instance().getPrefs().registerOnSharedPreferenceChangeListener(this);
		
		Button btnRefresh = (Button) findViewById(R.id.usersubreddits_btnrefresh);
		btnRefresh.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				refreshSubreddits();
			}
		});
		
		refreshSubreddits();
	}

	private void refreshSubreddits() {
		AsyncTask<Void, Void, List<String>> loadTask = new AsyncTask<Void, Void, List<String>>() {

			private ProgressDialog progressDialog;

			@Override
			protected void onPreExecute() {
				progressDialog = ProgressDialog.show(UserSubredditsActivity.this, "Reddimg", "Loading subreddits...");
			}
			
			@Override
			protected List<String> doInBackground(Void... params) {
				List<String> names = ReddimgApp.instance().getRedditClient().getMySubreddits();
				Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
				return names;
			}

			@Override
			protected void onPostExecute(List<String> result) {
				SubredditArrayAdapter adapter = new SubredditArrayAdapter(UserSubredditsActivity.this, result, R.drawable.plus, true);
				listView.setAdapter(adapter);
				progressDialog.dismiss();
				super.onPostExecute(result);
			}
			
		};
		loadTask.execute(null);
	}

{'fraction_non_alphanumeric': 0.10157682434910158, 'fraction_numerical': 0.0, 'mean_word_length': 5.596130592503023, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '3400407', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1600, 'n_words': 282}