<commit_before>package com.pacoapp.paco.ui;

import java.util.List;

import org.joda.time.DateTime;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.google.common.collect.Lists;
import com.pacoapp.paco.R;
import com.pacoapp.paco.model.Experiment;
import com.pacoapp.paco.model.ExperimentProviderUtil;
import com.pacoapp.paco.shared.model2.ExperimentDAO;
import com.pacoapp.paco.shared.model2.ExperimentGroup;
import com.pacoapp.paco.shared.scheduling.ActionScheduleGenerator;
import com.pacoapp.paco.utils.IntentExtraHelper;

public class ExperimentGroupPicker extends ActionBarActivity implements ExperimentLoadingActivity {

  public static final String SHOULD_GO_TO_RENDER_NEXT = "should_render_next";
  public static final int FEEDBACK_NEXT = 1;
  public static final int RENDER_NEXT = 2;
  public static final int SCHEDULE_NEXT = 3;
  private Experiment experiment;
  private ExperimentProviderUtil experimentProviderUtil;
  private List<ExperimentGroup> experimentGroups;
  private List<ExperimentGroup> choosableGroups;
  private List<String> choosableGroupNames;
  private int shouldRender;
  private ViewGroup mainLayout;
  private ListView list;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    experimentProviderUtil = new ExperimentProviderUtil(this);
    IntentExtraHelper.loadExperimentInfoFromIntent(this, getIntent(), experimentProviderUtil);
    shouldRender = getIntent().getIntExtra(SHOULD_GO_TO_RENDER_NEXT, RENDER_NEXT);
    if (experiment == null) {
      Toast.makeText(this, R.string.cannot_find_the_experiment_warning, Toast.LENGTH_SHORT).show();
      finish();
    } else {
      mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.activity_experiment_group_picker, null);
      setContentView(mainLayout);

      ActionBar actionBar = getSupportActionBar();
      actionBar.setLogo(R.drawable.ic_launcher);
      actionBar.setDisplayUseLogoEnabled(true);
      actionBar.setDisplayShowHomeEnabled(true);
      actionBar.setBackgroundDrawable(new ColorDrawable(0xff4A53B3));
      actionBar.setDisplayHomeAsUpEnabled(true);

      experimentGroups = experiment.getExperimentDAO().getGroups();
      choosableGroupNames = Lists.newArrayList();

      ExperimentDAO experimentDAO = experiment.getExperimentDAO();
      List<ExperimentGroup> groups = experimentDAO.getGroups();
      choosableGroups = Lists.newArrayList();
      for (ExperimentGroup experimentGroup : groups) {
        if (!experimentGroup.getFixedDuration() || (!ActionScheduleGenerator.isOver(new DateTime(), experimentDAO))) {
          choosableGroups.add(experimentGroup);
        }
      }

      for (ExperimentGroup eg : choosableGroups) {
        choosableGroupNames.add(eg.getName());
      }
      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
                                                              choosableGroupNames);<commit_msg>Hide experiment groups with no inputs when choosing group to respond<commit_after>package com.pacoapp.paco.ui;

import java.util.List;

import org.joda.time.DateTime;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.google.common.collect.Lists;
import com.pacoapp.paco.R;
import com.pacoapp.paco.model.Experiment;
import com.pacoapp.paco.model.ExperimentProviderUtil;
import com.pacoapp.paco.shared.model2.ExperimentDAO;
import com.pacoapp.paco.shared.model2.ExperimentGroup;
import com.pacoapp.paco.shared.scheduling.ActionScheduleGenerator;
import com.pacoapp.paco.utils.IntentExtraHelper;

public class ExperimentGroupPicker extends ActionBarActivity implements ExperimentLoadingActivity {

  public static final String SHOULD_GO_TO_RENDER_NEXT = "should_render_next";
  public static final int FEEDBACK_NEXT = 1;
  public static final int RENDER_NEXT = 2;
  public static final int SCHEDULE_NEXT = 3;
  private Experiment experiment;
  private ExperimentProviderUtil experimentProviderUtil;
  private List<ExperimentGroup> experimentGroups;
  private List<ExperimentGroup> choosableGroups;
  private List<String> choosableGroupNames;
  private int shouldRender;
  private ViewGroup mainLayout;
  private ListView list;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    experimentProviderUtil = new ExperimentProviderUtil(this);
    IntentExtraHelper.loadExperimentInfoFromIntent(this, getIntent(), experimentProviderUtil);
    shouldRender = getIntent().getIntExtra(SHOULD_GO_TO_RENDER_NEXT, RENDER_NEXT);
    if (experiment == null) {
      Toast.makeText(this, R.string.cannot_find_the_experiment_warning, Toast.LENGTH_SHORT).show();
      finish();
    } else {
      mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.activity_experiment_group_picker, null);
      setContentView(mainLayout);

      ActionBar actionBar = getSupportActionBar();
      actionBar.setLogo(R.drawable.ic_launcher);
      actionBar.setDisplayUseLogoEnabled(true);
      actionBar.setDisplayShowHomeEnabled(true);
      actionBar.setBackgroundDrawable(new ColorDrawable(0xff4A53B3));
      actionBar.setDisplayHomeAsUpEnabled(true);

      experimentGroups = experiment.getExperimentDAO().getGroups();
      choosableGroupNames = Lists.newArrayList();

      ExperimentDAO experimentDAO = experiment.getExperimentDAO();
      List<ExperimentGroup> groups = experimentDAO.getGroups();
      choosableGroups = Lists.newArrayList();
      for (ExperimentGroup experimentGroup : groups) {
        if (!experimentGroup.getFixedDuration() || (!ActionScheduleGenerator.isOver(new DateTime(), experimentDAO))) {
          if (shouldRender == RENDER_NEXT && experimentGroup.getInputs() != null && !experimentGroup.getInputs().isEmpty()) {
            choosableGroups.add(experimentGroup);
          }
        }
      }

      for (ExperimentGroup eg : choosableGroups) {
        choosableGroupNames.add(eg.getName());
      }
      ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
                                                              choosableGroupNames);
{'fraction_non_alphanumeric': 0.08946691439188223, 'fraction_numerical': 0.0037158782335286553, 'mean_word_length': 4.7360655737704915, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6983392', 'n_tokens_mistral': 2019, 'n_tokens_neox': 1968, 'n_words': 361}