<commit_before>package symdroid.sample.uitutorials;

/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


public class RadioGroup1 extends Activity implements RadioGroup.OnCheckedChangeListener,
    View.OnClickListener {

  private TextView mChoice;
  private RadioGroup mRadioGroup;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_radio_group1);
    mRadioGroup = (RadioGroup) findViewById(R.id.menu);

    // test adding a radio button programmatically
    RadioButton newRadioButton = new RadioButton(this);
    newRadioButton.setText("Snack");
    newRadioButton.setId(R.id.snack);
    LinearLayout.LayoutParams layoutParams = new RadioGroup.LayoutParams(
        RadioGroup.LayoutParams.WRAP_CONTENT,
        RadioGroup.LayoutParams.WRAP_CONTENT);
    mRadioGroup.addView(newRadioButton, 0, layoutParams);

    // test listening to checked change events
    String selection = "You have selected: ";
    mRadioGroup.setOnCheckedChangeListener(this);
    mChoice = (TextView) findViewById(R.id.choice);
    mChoice.setText(selection + mRadioGroup.getCheckedRadioButtonId());

    // test clearing the selection
    Button clearButton = (Button) findViewById(R.id.clear);
    clearButton.setOnClickListener(this);
  }

  public void onCheckedChanged(RadioGroup group, int checkedId) {
    String selection = "You have selected: ";
    String none = "(none)";
    mChoice.setText(selection +
        (checkedId == View.NO_ID ? none : checkedId));
  }

  public void onClick(View v) {
    mRadioGroup.clearCheck();
  }

  @Override
  @SuppressWarnings("unused")
  public void setContentView(int id) {
    ViewGroup.LayoutParams mpwc = new ViewGroup.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.WRAP_CONTENT<commit_msg>desugaring conditional expression<commit_after>package symdroid.sample.uitutorials;

/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;


public class RadioGroup1 extends Activity implements RadioGroup.OnCheckedChangeListener,
    View.OnClickListener {

  private TextView mChoice;
  private RadioGroup mRadioGroup;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_radio_group1);
    mRadioGroup = (RadioGroup) findViewById(R.id.menu);

    // test adding a radio button programmatically
    RadioButton newRadioButton = new RadioButton(this);
    newRadioButton.setText("Snack");
    newRadioButton.setId(R.id.snack);
    LinearLayout.LayoutParams layoutParams = new RadioGroup.LayoutParams(
        RadioGroup.LayoutParams.WRAP_CONTENT,
        RadioGroup.LayoutParams.WRAP_CONTENT);
    mRadioGroup.addView(newRadioButton, 0, layoutParams);

    // test listening to checked change events
    String selection = "You have selected: ";
    mRadioGroup.setOnCheckedChangeListener(this);
    mChoice = (TextView) findViewById(R.id.choice);
    mChoice.setText(selection + mRadioGroup.getCheckedRadioButtonId());

    // test clearing the selection
    Button clearButton = (Button) findViewById(R.id.clear);
    clearButton.setOnClickListener(this);
  }

  public void onCheckedChanged(RadioGroup group, int checkedId) {
    String selection = "You have selected: ";
    String none = "(none)";
    String msg;
    if (checkedId == View.NO_ID) {
      msg = selection + none;
    } else {
      msg = selection + checkedId;
    }
    mChoice.setText(msg);
  }

  public void onClick(View v) {
    mRadioGroup.clearCheck();
  }

  @Override
  @SuppressWarnings("unused")
  public void setContentView(int id) {
    ViewGroup.LayoutParams mpwc = new ViewGroup.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.WRAP_CONTENT
{'fraction_non_alphanumeric': 0.08626313881841247, 'fraction_numerical': 0.003986951794128307, 'mean_word_length': 4.157943925233645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7492186', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1473, 'n_words': 435}