<commit_before>package io.github.plastix.forage.ui.cachedetail;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.location.Location;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import javax.inject.Inject;

import butterknife.BindView;
import icepick.State;
import io.github.plastix.forage.ForageApplication;
import io.github.plastix.forage.R;
import io.github.plastix.forage.data.local.model.Cache;
import io.github.plastix.forage.ui.PresenterActivity;
import io.github.plastix.forage.ui.compass.CompassActivity;
import io.github.plastix.forage.util.ActivityUtils;

/**
 * Activity that represents the Geocache detail view screen of the app.
 */
public class CacheDetailActivity extends PresenterActivity<CacheDetailPresenter, CacheDetailView> implements CacheDetailView {

    private static final String EXTRA_CACHE_CODE = "CACHE_CODE";
    private final static String BUNDLE_KEY_MAP_STATE = "BUNDLE_KEY_MAP_STATE";

    @BindView(R.id.cachedetail_appbar)
    AppBarLayout appBarLayout;

    @BindView(R.id.cachedetail_toolbar)
    Toolbar toolbar;

    @BindView(R.id.cachedetail_collapsing_toolbar)
    CollapsingToolbarLayout collapsingToolbarLayout;

    @BindView(R.id.cachedetail_fab)
    FloatingActionButton fab;

    @BindView(R.id.cachedetail_map)
    MapView map;

    @BindView(R.id.cachedetail_description)
    TextView description;

    @BindView(R.id.cachedetail_difficulty)
    TextView difficulty;

    @BindView(R.id.cachedetail_size)
    TextView size;

    @BindView(R.id.cachedetail_terrain)
    TextView terrain;

    @BindView(R.id.cachedetail_title)
    TextView title;

    @BindView(R.id.cachedetail_type)
    TextView type;

    @Inject
    Resources resources;

    @State
    String cacheCode;

    @State
    String cacheName;

    /**
     * Static factory method that returns a new intent for opening a {@link CacheDetailActivity}.
     *
     * @param context   A context
     * @param cacheCode Cache code
     * @return A new intent.
     */
    public static Intent newIntent(Context context, String cacheCode) {
        Intent intent = new Intent(context, CacheDetailActivity.class);
        intent.putExtra(EXTRA_CACHE_CODE, cacheCode);

        return intent;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        injectDependencies();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cache_detail);

        this.cacheCode = getIntent().getStringExtra(EXTRA_CACHE_CODE);

        initializeView(savedInstanceState);

    }

    private void injectDependencies() {
        ForageApplication.getComponent(this)
                .plus(new CacheDetailModule(this)).injectTo(this);
    }

    private void initializeView(Bundle savedInstanceState) {
        setActivityActionBar();

        Bundle mapState = null;
        if (savedInstanceState != null) {
            // Load the map state bundle from the main savedInstanceState
            mapState = savedInstanceState.getBundle(BUNDLE_KEY_MAP_STATE);
        }

        map.onCreate(mapState);
    }

    private void setActivityActionBar() {
        setSupportActionBar(toolbar);

        ActivityUtils.setSupportActionBarBack(getDelegate());
    }

    @Override
    protected void onPresenterPrepared(CacheDetailPresenter presenter) {
        presenter.getGeocache(cacheCode);
    }

    @Override
    public void returnedGeocache(final Cache cache) {
        title.setText(cache.name);
        type.setText(resources.getString(R.string.cacheitem_type, cache.type));
        description.setText(cache.description);
        difficulty.setText(resources.getString(R.string.cachedetail_rating, cache.difficulty));
        terrain.setText(resources.getString(R.string.cachedetail_rating, cache.terrain));
        size.setText(cache.size);

        setFabClickListener(cache);

        MapListener mapListener = new MapListener(cache.location.toLocation());
        map.getMapAsync(mapListener);
    }

    public void setFabClickListener(final Cache cache) {
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {<commit_msg>Remove verbose method in CacheDetailActivity<commit_after>package io.github.plastix.forage.ui.cachedetail;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.location.Location;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import javax.inject.Inject;

import butterknife.BindView;
import icepick.State;
import io.github.plastix.forage.ForageApplication;
import io.github.plastix.forage.R;
import io.github.plastix.forage.data.local.model.Cache;
import io.github.plastix.forage.ui.PresenterActivity;
import io.github.plastix.forage.ui.compass.CompassActivity;
import io.github.plastix.forage.util.ActivityUtils;

/**
 * Activity that represents the Geocache detail view screen of the app.
 */
public class CacheDetailActivity extends PresenterActivity<CacheDetailPresenter, CacheDetailView> implements CacheDetailView {

    private static final String EXTRA_CACHE_CODE = "CACHE_CODE";
    private final static String BUNDLE_KEY_MAP_STATE = "BUNDLE_KEY_MAP_STATE";

    @BindView(R.id.cachedetail_appbar)
    AppBarLayout appBarLayout;

    @BindView(R.id.cachedetail_toolbar)
    Toolbar toolbar;

    @BindView(R.id.cachedetail_collapsing_toolbar)
    CollapsingToolbarLayout collapsingToolbarLayout;

    @BindView(R.id.cachedetail_fab)
    FloatingActionButton fab;

    @BindView(R.id.cachedetail_map)
    MapView map;

    @BindView(R.id.cachedetail_description)
    TextView description;

    @BindView(R.id.cachedetail_difficulty)
    TextView difficulty;

    @BindView(R.id.cachedetail_size)
    TextView size;

    @BindView(R.id.cachedetail_terrain)
    TextView terrain;

    @BindView(R.id.cachedetail_title)
    TextView title;

    @BindView(R.id.cachedetail_type)
    TextView type;

    @Inject
    Resources resources;

    @State
    String cacheCode;

    @State
    String cacheName;

    /**
     * Static factory method that returns a new intent for opening a {@link CacheDetailActivity}.
     *
     * @param context   A context
     * @param cacheCode Cache code
     * @return A new intent.
     */
    public static Intent newIntent(Context context, String cacheCode) {
        Intent intent = new Intent(context, CacheDetailActivity.class);
        intent.putExtra(EXTRA_CACHE_CODE, cacheCode);

        return intent;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        injectDependencies();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cache_detail);

        this.cacheCode = getIntent().getStringExtra(EXTRA_CACHE_CODE);

        initializeView(savedInstanceState);

    }

    private void injectDependencies() {
        ForageApplication.getComponent(this)
                .plus(new CacheDetailModule(this)).injectTo(this);
    }

    private void initializeView(Bundle savedInstanceState) {
        setSupportActionBar(toolbar);

        ActivityUtils.setSupportActionBarBack(getDelegate());

        Bundle mapState = null;
        if (savedInstanceState != null) {
            // Load the map state bundle from the main savedInstanceState
            mapState = savedInstanceState.getBundle(BUNDLE_KEY_MAP_STATE);
        }

        map.onCreate(mapState);
    }

    @Override
    protected void onPresenterPrepared(CacheDetailPresenter presenter) {
        presenter.getGeocache(cacheCode);
    }

    @Override
    public void returnedGeocache(final Cache cache) {
        title.setText(cache.name);
        type.setText(resources.getString(R.string.cacheitem_type, cache.type));
        description.setText(cache.description);
        difficulty.setText(resources.getString(R.string.cachedetail_rating, cache.difficulty));
        terrain.setText(resources.getString(R.string.cachedetail_rating, cache.terrain));
        size.setText(cache.size);

        setFabClickListener(cache);

        MapListener mapListener = new MapListener(cache.location.toLocation());
        map.getMapAsync(mapListener);
    }

    public void setFabClickListener(final Cache cache) {
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
{'fraction_non_alphanumeric': 0.09054054054054055, 'fraction_numerical': 0.0002079002079002079, 'mean_word_length': 3.762871287128713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2374215', 'n_tokens_mistral': 2847, 'n_tokens_neox': 2740, 'n_words': 508}