<commit_before>package com.github.skittlesdev.kubrick.ui.fragments;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.skittlesdev.kubrick.KubrickApplication;
import com.github.skittlesdev.kubrick.MediaActivity;
import com.github.skittlesdev.kubrick.R;
import com.github.skittlesdev.kubrick.asyncs.SearchMediaTask;
import com.github.skittlesdev.kubrick.interfaces.SearchListener;
import info.movito.themoviedbapi.TmdbSearch;
import info.movito.themoviedbapi.model.MovieDb;
import info.movito.themoviedbapi.model.Multi;
import info.movito.themoviedbapi.model.core.IdElement;
import info.movito.themoviedbapi.model.tv.TvSeries;

import java.util.LinkedList;
import java.util.List;

public class MediaSearchFragment extends Fragment implements SearchListener, AdapterView.OnItemClickListener {
    private ListView view;
    private TmdbSearch.MultiListResultsPage results;
    private SearchMediaTask searchTask;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        this.view = (ListView) inflater.inflate(R.layout.fragment_media_search, container, false);
        return this.view;
    }

    public void search(String searchTerms) {
        this.searchTask = new SearchMediaTask(this);
        this.searchTask.execute(searchTerms);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (this.searchTask != null) {
            this.searchTask.cancel(true);
        }

        KubrickApplication.getRefWatcher(getActivity()).watch(this);
    }

    @Override
    public void onSearchResults(TmdbSearch.MultiListResultsPage results) {
        this.results = results;
        List<String> titles = new LinkedList<>();
        for (Multi item: results.getResults()) {
            if (item.getMediaType() == Multi.MediaType.MOVIE) {
                titles.add(((MovieDb) item).getTitle());
            }
            if (item.getMediaType() == Multi.MediaType.TV_SERIES) {
                titles.add(((TvSeries) item).getName());
            }
        }

        ArrayAdapter<String> items = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, titles);
        view.setAdapter(items);
        view.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Multi item = this.results.getResults().get(position);
        if (item.getMediaType() == Multi.MediaType.MOVIE) {
            int movieId = ((IdElement) item).getId();
            Intent intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra("MEDIA_ID", movieId);
            intent.putExtra("MEDIA_TYPE", "movie");
            startActivity(intent);
        }

        if (item.getMediaType() == Multi.MediaType.TV_SERIES) {
            int seriesId = ((IdElement) item).getId();
            Intent intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra("MEDIA_ID", seriesId);
            intent.putExtra("MEDIA_TYPE", "tv");
            startActivity(intent);
        }
    }
}
<commit_msg>search ghost fragment bug removed<commit_after>package com.github.skittlesdev.kubrick.ui.fragments;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.github.skittlesdev.kubrick.KubrickApplication;
import com.github.skittlesdev.kubrick.MediaActivity;
import com.github.skittlesdev.kubrick.R;
import com.github.skittlesdev.kubrick.asyncs.SearchMediaTask;
import com.github.skittlesdev.kubrick.interfaces.SearchListener;
import info.movito.themoviedbapi.TmdbSearch;
import info.movito.themoviedbapi.model.MovieDb;
import info.movito.themoviedbapi.model.Multi;
import info.movito.themoviedbapi.model.core.IdElement;
import info.movito.themoviedbapi.model.tv.TvSeries;

import java.util.LinkedList;
import java.util.List;

public class MediaSearchFragment extends Fragment implements SearchListener, AdapterView.OnItemClickListener {
    private ListView view;
    private TmdbSearch.MultiListResultsPage results;
    private SearchMediaTask searchTask;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        this.view = (ListView) inflater.inflate(R.layout.fragment_media_search, container, false);
        return this.view;
    }

    public void search(String searchTerms) {
        this.searchTask = new SearchMediaTask(this);
        this.searchTask.execute(searchTerms);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (this.searchTask != null) {
            this.searchTask.cancel(true);
        }

        KubrickApplication.getRefWatcher(getActivity()).watch(this);
    }

    @Override
    public void onSearchResults(TmdbSearch.MultiListResultsPage results) {
        this.results = results;
        List<String> titles = new LinkedList<>();
        for (Multi item: results.getResults()) {
            if (item.getMediaType() == Multi.MediaType.MOVIE) {
                titles.add(((MovieDb) item).getTitle());
            }
            if (item.getMediaType() == Multi.MediaType.TV_SERIES) {
                titles.add(((TvSeries) item).getName());
            }
        }

        ArrayAdapter<String> items = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, titles);
        view.setAdapter(items);
        view.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Multi item = this.results.getResults().get(position);
        if (item.getMediaType() == Multi.MediaType.MOVIE) {
            int movieId = ((IdElement) item).getId();
            Intent intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra("MEDIA_ID", movieId);
            intent.putExtra("MEDIA_TYPE", "movie");
            startActivity(intent);
        }

        if (item.getMediaType() == Multi.MediaType.TV_SERIES) {
            int seriesId = ((IdElement) item).getId();
            Intent intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra("MEDIA_ID", seriesId);
            intent.putExtra("MEDIA_TYPE", "tv");
            startActivity(intent);
        }
        getFragmentManager().beginTransaction().remove(this).commit();
    }
}

{'fraction_non_alphanumeric': 0.11031779364412712, 'fraction_numerical': 0.0002799944001119978, 'mean_word_length': 3.3481436396835056, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '423354', 'n_tokens_mistral': 2068, 'n_tokens_neox': 2033, 'n_words': 373}