<commit_before>package org.pocketcampus.plugin.transport;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import org.pocketcampus.core.communication.DataRequest;
import org.pocketcampus.shared.plugin.transport.Location;
import org.pocketcampus.shared.plugin.transport.LocationType;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

abstract class AutoCompleteStationRequest extends DataRequest {
	private ArrayList<Location> locations;

	public AutoCompleteStationRequest() {
		locations = new ArrayList<Location>();
	}
	
	@Override
	protected int expirationDelay() {
		// Location list is not likely to change.
		return 6 * 60 * 60;
	}

	@Override
	final protected void doInUiThread(String result) {
		// Extracts the result.
		Gson gson = new Gson();
		Type AutocompleteType = new TypeToken<List<Location>>(){}.getType();
		locations = gson.fromJson(result, AutocompleteType);
		
		// Keeps only the stations (no POIs etc)
		ArrayList<Location> stations = new ArrayList<Location>();
		
		for(Location location : locations) {
			if(location.type == LocationType.STATION) {
				stations.add(location);
			}
		}
		
		handleLocations(locations);
	}

	protected abstract void handleLocations(ArrayList<Location> locations);
}



<commit_msg><transport> fixes bug when you put a % in the search field<commit_after>package org.pocketcampus.plugin.transport;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import org.pocketcampus.core.communication.DataRequest;
import org.pocketcampus.shared.plugin.transport.Location;
import org.pocketcampus.shared.plugin.transport.LocationType;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

abstract class AutoCompleteStationRequest extends DataRequest {
	private ArrayList<Location> locations;

	public AutoCompleteStationRequest() {
		locations = new ArrayList<Location>();
	}
	
	@Override
	protected int expirationDelay() {
		// Location list is not likely to change.
		return 6 * 60 * 60;
	}

	@Override
	final protected void doInUiThread(String result) {
		// Extracts the result.
		Gson gson = new Gson();
		Type AutocompleteType = new TypeToken<List<Location>>(){}.getType();
		locations = gson.fromJson(result, AutocompleteType);
		
		if(locations == null) {
			handleLocations(null);
			return;
		}
		
		// Keeps only the stations (no POIs etc)
		ArrayList<Location> stations = new ArrayList<Location>();
		
		for(Location location : locations) {
			if(location.type == LocationType.STATION) {
				stations.add(location);
			}
		}
		
		handleLocations(locations);
	}

	protected abstract void handleLocations(ArrayList<Location> locations);
}




{'fraction_non_alphanumeric': 0.10594315245478036, 'fraction_numerical': 0.0036913990402362494, 'mean_word_length': 4.69327731092437, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '3960521', 'n_tokens_mistral': 888, 'n_tokens_neox': 773, 'n_words': 192}