<commit_before>package se.nelio.slicker;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import se.nelio.slicker.flickr.PhotosApi;
import se.nelio.slicker.flickr.ServiceGenerator;

/**
 * An activity representing a list of Photos. This activity
 * has different presentations for handset and tablet-size devices. On
 * handsets, the activity presents a list of items, which when touched,
 * lead to a {@link PhotoDetailActivity} representing
 * item details. On tablets, the activity presents the list of items and
 * item details side-by-side using two vertical panes.
 */
public class PhotoListActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_list);

        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setTitle(getTitle());

        final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.photo_list);
        recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                // https://github.com/square/picasso/issues/457https://github.com/square/picasso/issues/457
                // Remove self
                recyclerView.removeOnLayoutChangeListener(this);

                final PhotosApi photosApi = ServiceGenerator.createService(PhotosApi.class);
                final int recyclerViewWidth = recyclerView.getWidth();
                final PhotoRecyclerViewAdapter recyclerAdapter = new PhotoRecyclerViewAdapter(PhotoListActivity.this, photosApi, recyclerViewWidth);
                recyclerView.setAdapter(recyclerAdapter);

                final SearchView searchView = (SearchView) findViewById(R.id.searchView);
                final SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
                    @Override
                    public boolean onQueryTextSubmit(String query) {
                        recyclerAdapter.loadMore(true, query);
                        return false;
                    }

                    @Override
                    public boolean onQueryTextChange(String newText) {
                        return false;
                    }
                };
                searchView.setOnQueryTextListener(queryTextListener);

                // TODO: only load initially, not on rotation.
                recyclerAdapter.loadMore(true);
            }
        });
    }
}<commit_msg>PhotoListActivity: collapse search view on submit #31<commit_after>package se.nelio.slicker;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import se.nelio.slicker.flickr.PhotosApi;
import se.nelio.slicker.flickr.ServiceGenerator;

/**
 * An activity representing a list of Photos. This activity
 * has different presentations for handset and tablet-size devices. On
 * handsets, the activity presents a list of items, which when touched,
 * lead to a {@link PhotoDetailActivity} representing
 * item details. On tablets, the activity presents the list of items and
 * item details side-by-side using two vertical panes.
 */
public class PhotoListActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo_list);

        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setTitle(getTitle());

        final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.photo_list);
        recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                // https://github.com/square/picasso/issues/457https://github.com/square/picasso/issues/457
                // Remove self
                recyclerView.removeOnLayoutChangeListener(this);

                final PhotosApi photosApi = ServiceGenerator.createService(PhotosApi.class);
                final int recyclerViewWidth = recyclerView.getWidth();
                final PhotoRecyclerViewAdapter recyclerAdapter = new PhotoRecyclerViewAdapter(PhotoListActivity.this, photosApi, recyclerViewWidth);
                recyclerView.setAdapter(recyclerAdapter);

                final SearchView searchView = (SearchView) findViewById(R.id.searchView);
                final SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
                    @Override
                    public boolean onQueryTextSubmit(String query) {
                        recyclerAdapter.loadMore(true, query);
                        searchView.clearFocus();
                        return false;
                    }

                    @Override
                    public boolean onQueryTextChange(String newText) {
                        return false;
                    }
                };
                searchView.setOnQueryTextListener(queryTextListener);

                // TODO: only load initially, not on rotation.
                recyclerAdapter.loadMore(true);
            }
        });
    }
}
{'fraction_non_alphanumeric': 0.07703902193937363, 'fraction_numerical': 0.0036844749623178696, 'mean_word_length': 2.5568790946992257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '6813128', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1437, 'n_words': 361}