<commit_before>package io.github.imsmobile.fahrplan.task;

import android.os.AsyncTask;
import android.util.Log;

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

import ch.schoeb.opendatatransport.IOpenTransportRepository;
import ch.schoeb.opendatatransport.OpenDataTransportException;
import ch.schoeb.opendatatransport.OpenTransportRepositoryFactory;
import ch.schoeb.opendatatransport.model.Connection;
import io.github.imsmobile.fahrplan.Constants;
import io.github.imsmobile.fahrplan.SearchResultActivity;

/**
 * Created by sandro on 09.02.2017.
 */
public class ConnectionSearchTask extends AsyncTask<String,Void,List<Connection>> {


    private SearchResultActivity activity;


    public ConnectionSearchTask(SearchResultActivity activity) {
        this.activity = activity;
    }

    @Override
    protected List<Connection> doInBackground(String... params) {
        String from = params[0];
        String to = params[1];
        IOpenTransportRepository repo = OpenTransportRepositoryFactory.CreateOnlineOpenTransportRepository();
        try {
            return repo.searchConnections(from, to).getConnections();
        } catch (OpenDataTransportException e) {
            Log.e(Constants.LOG, e.getMessage(), e);
            return Collections.emptyList();
        }
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        activity.startProgressDialog();
    }

    @Override
    protected void onPostExecute(List<Connection> connections) {
        super.onPostExecute(connections);
        StringBuilder text = new StringBuilder();
        for (Connection connection :connections) {
            text.append("From: " + connection.getFrom().getStation().getName()+ System.lineSeparator());
            text.append("Departure:" + connection.getFrom().getDeparture() + System.lineSeparator());
            text.append("To:" + connection.getTo().getStation().getName() + System.lineSeparator());
            text.append("Arrival:" + connection.getTo().getArrival()+ System.lineSeparator()+ System.lineSeparator());
        }
        activity.stopProcessDialog();
        activity.setResult(text.toString());
    }
}<commit_msg>Make activity variable final as it should not be reassigend in connectionserachtask<commit_after>package io.github.imsmobile.fahrplan.task;

import android.os.AsyncTask;
import android.util.Log;

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

import ch.schoeb.opendatatransport.IOpenTransportRepository;
import ch.schoeb.opendatatransport.OpenDataTransportException;
import ch.schoeb.opendatatransport.OpenTransportRepositoryFactory;
import ch.schoeb.opendatatransport.model.Connection;
import io.github.imsmobile.fahrplan.Constants;
import io.github.imsmobile.fahrplan.SearchResultActivity;

/**
 * Created by sandro on 09.02.2017.
 */
public class ConnectionSearchTask extends AsyncTask<String,Void,List<Connection>> {


    private final SearchResultActivity activity;


    public ConnectionSearchTask(SearchResultActivity activity) {
        this.activity = activity;
    }

    @Override
    protected List<Connection> doInBackground(String... params) {
        String from = params[0];
        String to = params[1];
        IOpenTransportRepository repo = OpenTransportRepositoryFactory.CreateOnlineOpenTransportRepository();
        try {
            return repo.searchConnections(from, to).getConnections();
        } catch (OpenDataTransportException e) {
            Log.e(Constants.LOG, e.getMessage(), e);
            return Collections.emptyList();
        }
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        activity.startProgressDialog();
    }

    @Override
    protected void onPostExecute(List<Connection> connections) {
        super.onPostExecute(connections);
        StringBuilder text = new StringBuilder();
        for (Connection connection :connections) {
            text.append("From: " + connection.getFrom().getStation().getName()+ System.lineSeparator());
            text.append("Departure:" + connection.getFrom().getDeparture() + System.lineSeparator());
            text.append("To:" + connection.getTo().getStation().getName() + System.lineSeparator());
            text.append("Arrival:" + connection.getTo().getArrival()+ System.lineSeparator()+ System.lineSeparator());
        }
        activity.stopProcessDialog();
        activity.setResult(text.toString());
    }
}
{'fraction_non_alphanumeric': 0.11185983827493262, 'fraction_numerical': 0.004492362982929021, 'mean_word_length': 3.6726128016789086, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1466528', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1184, 'n_words': 214}