<commit_before>package org.nguyenhuy.buffer.activity;

import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import com.path.android.jobqueue.JobManager;
import com.squareup.otto.Subscribe;
import org.nguyenhuy.buffer.R;
import org.nguyenhuy.buffer.adapter.ProfilesAdapter;
import org.nguyenhuy.buffer.controller.AccessTokenController;
import org.nguyenhuy.buffer.controller.ConfigurationController;
import org.nguyenhuy.buffer.controller.ProfilesController;
import org.nguyenhuy.buffer.controller.UpdatesController;
import org.nguyenhuy.buffer.event.*;
import org.nguyenhuy.buffer.fragment.UpdatesFragment;
import org.nguyenhuy.buffer.model.configuration.Service;
import org.nguyenhuy.buffer.model.user.Profile;
import org.nguyenhuy.buffer.module.ForActivity;
import org.nguyenhuy.buffer.module.MainActivityModule;

import javax.inject.Inject;
import javax.inject.Provider;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends BaseActivity implements ActionBar.OnNavigationListener,
        UpdatesFragment.Delegate {

    /**
     * The serialization (saved instance state) Bundle key representing the
     * current dropdown position.
     */
    private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";

    @Inject
    ConfigurationController configurationController;
    @Inject
    @ForActivity
    JobManager jobManager;
    @Inject
    AccessTokenController accessTokenController;
    @Inject
    ProfilesController profilesController;
    @Inject
    Provider<ProfilesAdapter> profileAdapterProvider;
    @Inject
    PagerAdapter pagerAdapter;
    @Inject
    UpdatesController updatesController;
    private int loadingCounter;
    private ProfilesAdapter profilesAdapter;
    private Map<String, String> serviceIcons;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.activity_main);

        ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
        viewPager.setAdapter(pagerAdapter);
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        // Restore the previously serialized current dropdown position.
        if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
            getActionBar().setSelectedNavigationItem(
                    savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        jobManager.start();
        configurationController.onStart();
        profilesController.onStart();
        updatesController.onStart();
        configurationController.load();
        profilesController.load();
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        // Serialize the current dropdown position.
        ActionBar actionBar = getActionBar();
        if (actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) {
            outState.putInt(STATE_SELECTED_NAVIGATION_ITEM,
                    actionBar.getSelectedNavigationIndex());
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        jobManager.stop();
        configurationController.onStop();<commit_msg>Only refresh cache data if main activity is newly created.<commit_after>package org.nguyenhuy.buffer.activity;

import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import com.path.android.jobqueue.JobManager;
import com.squareup.otto.Subscribe;
import org.nguyenhuy.buffer.R;
import org.nguyenhuy.buffer.adapter.ProfilesAdapter;
import org.nguyenhuy.buffer.controller.AccessTokenController;
import org.nguyenhuy.buffer.controller.ConfigurationController;
import org.nguyenhuy.buffer.controller.ProfilesController;
import org.nguyenhuy.buffer.controller.UpdatesController;
import org.nguyenhuy.buffer.event.*;
import org.nguyenhuy.buffer.fragment.UpdatesFragment;
import org.nguyenhuy.buffer.model.configuration.Service;
import org.nguyenhuy.buffer.model.user.Profile;
import org.nguyenhuy.buffer.module.ForActivity;
import org.nguyenhuy.buffer.module.MainActivityModule;

import javax.inject.Inject;
import javax.inject.Provider;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends BaseActivity implements ActionBar.OnNavigationListener,
        UpdatesFragment.Delegate {

    /**
     * The serialization (saved instance state) Bundle key representing the
     * current dropdown position.
     */
    private static final String STATE_SELECTED_NAVIGATION_ITEM = "selected_navigation_item";

    @Inject
    ConfigurationController configurationController;
    @Inject
    @ForActivity
    JobManager jobManager;
    @Inject
    AccessTokenController accessTokenController;
    @Inject
    ProfilesController profilesController;
    @Inject
    Provider<ProfilesAdapter> profileAdapterProvider;
    @Inject
    PagerAdapter pagerAdapter;
    @Inject
    UpdatesController updatesController;
    private int loadingCounter;
    private ProfilesAdapter profilesAdapter;
    private Map<String, String> serviceIcons;
    private boolean isCreated;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.activity_main);

        ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
        viewPager.setAdapter(pagerAdapter);

        isCreated = true;
    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        // Restore the previously serialized current dropdown position.
        if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
            getActionBar().setSelectedNavigationItem(
                    savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        jobManager.start();
        configurationController.onStart();
        profilesController.onStart();
        updatesController.onStart();

        // Only load user data if this activity is newly created.
        // Otherwise the data is still in memory.
        if (isCreated) {
            configurationController.load();
            profilesController.load();
            isCreated = false;
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        // Serialize the current dropdown position.
        ActionBar actionBar = getActionBar();
        if (actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) {
            outState.putInt(STATE_SELECTED_NAVIGATION_ITEM,
                    actionBar.getSelectedNavigationIndex());
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        jobManager.stop();
        configurationController.onStop();
{'fraction_non_alphanumeric': 0.08125331917153479, 'fraction_numerical': 0.0005310674455655868, 'mean_word_length': 3.722884012539185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5452271', 'n_tokens_mistral': 2037, 'n_tokens_neox': 2010, 'n_words': 396}