<commit_before>package com.cloudycrew.cloudycar.search;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ProgressBar;

import com.cloudycrew.cloudycar.BaseActivity;
import com.cloudycrew.cloudycar.Constants;
import com.cloudycrew.cloudycar.R;
import com.cloudycrew.cloudycar.RequestAdapter;
import com.cloudycrew.cloudycar.driversummary.DriverSummaryFragment;
import com.cloudycrew.cloudycar.models.requests.PendingRequest;
import com.cloudycrew.cloudycar.models.requests.Request;
import com.cloudycrew.cloudycar.requestdetails.DriverRequestDetailsActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by George on 2016-11-05.
 */

public class SearchActivity extends BaseActivity implements ISearchView {
    @BindView(R.id.toolbar)
    protected Toolbar toolbar;
    @BindView(R.id.search_loading_progress_bar)
    protected ProgressBar searchProgressBar;
    @BindView(R.id.search_results_recycler_view)
    protected RecyclerView searchRecyclerView;

    private RequestAdapter requestAdapter;
    private SearchController searchController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        ButterKnife.bind(this);

        setSupportActionBar(toolbar);
        resolveDependencies();
        setUpRecyclerView();
    }

    @Override
    protected void onResume() {
        super.onResume();
        searchController.attachView(this);
        searchController.searchByPoint(null);
    }

    @Override
    protected void onPause() {
        super.onPause();
        searchController.detachView();
    }

    private void resolveDependencies() {
        searchController = getCloudyCarApplication().getSearchController();
    }

    private void setUpRecyclerView() {
        requestAdapter = new RequestAdapter(true);
        searchRecyclerView.setAdapter(requestAdapter);
        searchRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        requestAdapter.setClickListener((v, r) -> {
            Intent intent = new Intent(SearchActivity.this, DriverRequestDetailsActivity.class);
            intent.putExtra(Constants.EXTRA_REQUEST_ID, r.getId());
            startActivity(intent);
        });
    }

    @Override
    public void showLoading() {
        searchProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void showSearchResults(List<PendingRequest> searchResults) {
        searchProgressBar.setVisibility(View.GONE);
        requestAdapter.setPendingRequests(searchResults);
    }
}<commit_msg>Use ViewCellAdapter in the search view<commit_after>package com.cloudycrew.cloudycar.search;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ProgressBar;

import com.cloudycrew.cloudycar.BaseActivity;
import com.cloudycrew.cloudycar.Constants;
import com.cloudycrew.cloudycar.R;
import com.cloudycrew.cloudycar.RequestAdapter;
import com.cloudycrew.cloudycar.driversummary.DriverSummaryFragment;
import com.cloudycrew.cloudycar.models.requests.PendingRequest;
import com.cloudycrew.cloudycar.models.requests.Request;
import com.cloudycrew.cloudycar.requestdetails.DriverRequestDetailsActivity;
import com.cloudycrew.cloudycar.requestdetails.RiderRequestDetailsActivity;
import com.cloudycrew.cloudycar.viewcells.BaseRequestViewCell;
import com.cloudycrew.cloudycar.viewcells.HeaderViewCell;
import com.cloudycrew.cloudycar.viewcells.PendingRequestViewCell;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import ca.antonious.viewcelladapter.SectionViewCell;
import ca.antonious.viewcelladapter.SectionWithHeaderViewCell;
import ca.antonious.viewcelladapter.ViewCellAdapter;
import rx.Observable;

/**
 * Created by George on 2016-11-05.
 */

public class SearchActivity extends BaseActivity implements ISearchView {
    @BindView(R.id.toolbar)
    protected Toolbar toolbar;
    @BindView(R.id.search_loading_progress_bar)
    protected ProgressBar searchProgressBar;
    @BindView(R.id.search_results_recycler_view)
    protected RecyclerView searchRecyclerView;

    private ViewCellAdapter viewCellAdapter;
    private SectionViewCell searchResultsSection;

    private SearchController searchController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        ButterKnife.bind(this);

        setSupportActionBar(toolbar);
        resolveDependencies();
        setUpRecyclerView();
    }

    @Override
    protected void onResume() {
        super.onResume();
        searchController.attachView(this);
        searchController.searchByPoint(null);
    }

    @Override
    protected void onPause() {
        super.onPause();
        searchController.detachView();
    }

    private void resolveDependencies() {
        searchController = getCloudyCarApplication().getSearchController();
    }

    private void setUpRecyclerView() {
        viewCellAdapter = new ViewCellAdapter();
        viewCellAdapter.setHasStableIds(true);

        searchResultsSection = new SectionViewCell();

        viewCellAdapter.add(searchResultsSection);

        searchRecyclerView.setAdapter(viewCellAdapter);
        searchRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    }

    @Override
    public void showLoading() {
        searchProgressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void showSearchResults(List<PendingRequest> searchResults) {
        searchProgressBar.setVisibility(View.GONE);

        searchResultsSection.setAll(getPendingRequestViewCells(searchResults));
        viewCellAdapter.notifyDataSetChanged();
    }

    private void launchRequestDetailsActivity(String requestId) {
        Intent intent = new Intent(this, RiderRequestDetailsActivity.class);
        intent.putExtra(Constants.EXTRA_REQUEST_ID, requestId);
        startActivity(intent);
    }

    private BaseRequestViewCell.OnRequestClickedListener onRequestClickedListener = request -> {
        launchRequestDetailsActivity(request.getId());
    };

    private List<PendingRequestViewCell> getPendingRequestViewCells(List<? extends PendingRequest> pendingRequests) {
        return Observable.from(pendingRequests)
                         .map(PendingRequestViewCell::new)
                         .doOnNext(viewCell -> viewCell.setOnRequestClickedListener(onRequestClickedListener))
                         .toList()
                         .toBlocking()
                         .firstOrDefault(new ArrayList<>());
    }
}
{'fraction_non_alphanumeric': 0.08505844247289114, 'fraction_numerical': 0.003098155189409942, 'mean_word_length': 4.0226308345120225, 'pattern_counts': {'":': 0, '<': 8, '<?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': '5631671', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1934, 'n_words': 312}