Program: 141906
Project: 141906
Buggy source:
private void Initialize(){
  this.setOrientation(LinearLayout.VERTICAL);
  setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
  int height=Context.getResources().getDisplayMetrics().heightPixels;
  int max=Math.max(Context.getResources().getDisplayMetrics().widthPixels,height) / 8;
  textView=new TextView(Context);
  textView.setMaxWidth(max);
  textView.setMinWidth(max);
  textView.setMaxLines(1);
  textView.setSingleLine();
  textView.setTextColor(getResources().getColor(R.color.dark_white_smoke));
  textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  textView.setText(mExecutor.getName());
  textView.setLongClickable(true);
  textView.setOnLongClickListener(new View.OnLongClickListener(){
    @Override public boolean onLongClick(    final View v){
      final AlertDialog.Builder alert=new AlertDialog.Builder(v.getContext());
      alert.setTitle(getContext().getResources().getString(R.string.executor_settings_title));
      final View view=View.inflate(v.getContext(),R.layout.executor_setting_dialog,null);
      final EditText input=(EditText)view.findViewById(R.id.editName);
      input.setText(textView.getText());
      final RadioGroup dropdown=(RadioGroup)view.findViewById(R.id.radioButtonGroup);
      final RadioButton intensity_btn=(RadioButton)view.findViewById(R.id.radioButton_Intensity);
      final RadioButton timing_btn=(RadioButton)view.findViewById(R.id.radioButton_Timing);
      final RadioButton speed_btn=(RadioButton)view.findViewById(R.id.radioButton_EffectSpeed);
switch (mExecutor.getFaderMode()) {
case 0:
        intensity_btn.setChecked(true);
      break;
case 1:
    timing_btn.setChecked(true);
  break;
case 2:
speed_btn.setChecked(true);
break;
}
final ToggleButton toggle_btn=(ToggleButton)view.findViewById(R.id.toggleButton_flash);
toggle_btn.setChecked(mExecutor.getToggle());
alert.setView(view);
alert.setPositiveButton(getContext().getResources().getString(android.R.string.ok),new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int whichButton){
String str=input.getEditableText().toString();
mExecutor.setName(str,false);
mExecutor.setToggle(toggle_btn.isChecked(),false);
if (intensity_btn.isChecked()) {
mExecutor.setFaderMode(0,false);
}
 else if (timing_btn.isChecked()) {
mExecutor.setFaderMode(1,false);
}
 else if (speed_btn.isChecked()) {
mExecutor.setFaderMode(2,false);
}
textView.setText(mExecutor.getName());
Toast.makeText(alert.getContext(),str,Toast.LENGTH_LONG).show();
}
}
);
AlertDialog alertDialog=alert.create();
alertDialog.show();
return true;
}
}
);
mExecutor.setNameChangedListener(new Entity.NameChangedListener(){
@Override public void onNameChanged(String name){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
textView.setText(mExecutor.getName());
instance.Resize();
instance.invalidate();
}
}
);
}
}
}
);
int margin=10;
LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
layoutParams.leftMargin=margin;
layoutParams.rightMargin=margin;
fader=new FaderVerticalControl(Context);
fader.setValue(mExecutor.getValue(),0);
fader.setBackgroundResource(R.drawable.border_normal_layer_transperent);
mExecutor.setValueChangedListener(new EntityExecutor.ValueChangedListener(){
@Override public void onValueChanged(float value){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
fader.setValue(mExecutor.getValue(),0);
}
}
);
}
}
}
);
fader.setValueChangedListener(new FaderVerticalControl.ValueChangedListener(){
@Override public void onValueChanged(float value,boolean isMoving){
mExecutor.setValue(value,false);
}
}
);
fader.setLayoutParams(layoutParams);
faderLayout=new FrameLayout(Context);
faderLayout.addView(fader);
layoutParams=new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,(height / 2) + (height / 16)));
layoutParams.leftMargin=margin;
layoutParams.rightMargin=margin;
faderLayout.setLayoutParams(layoutParams);
flashbtn=new Button(Context);
flashbtn.setEnabled(false);
flashbtn.setBackgroundResource(R.drawable.btn_normal_selector);
flashbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
flashbtn.setTextSize(18);
flashbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
flashbtn.setText(getContext().getResources().getString(R.string.char_flash));
flashbtn.setTag(flashbtn.getText() + "String_Node_Str" + mExecutor.getName());
flashbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,height / 8));
flashbtn.setEnabled(false);
flashbtn.setClickable(false);
mExecutor.setFlashChangedListener(new EntityExecutor.FlashChangedListener(){
@Override public void onFlashChanged(float value){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
if (!lockflash) {
  flashbtn.setPressed(mExecutor.getFlash());
}
}
}
);
}
}
}
);
breakbtn=new Button(Context);
breakbtn.setBackgroundResource(R.drawable.btn_normal_selector);
breakbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
breakbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
breakbtn.setText(getContext().getResources().getString(R.string.char_breakback));
breakbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,height / 16));
breakbtn.setTag(breakbtn.getText() + "String_Node_Str" + mExecutor.getName());
breakbtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.BreakBack();
}
}
);
gobtn=new Button(Context);
gobtn.setBackgroundResource(R.drawable.btn_normal_selector);
gobtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
gobtn.setTextSize(18);
gobtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
gobtn.setText(getContext().getResources().getString(R.string.char_go));
gobtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,height / 8));
gobtn.setTag(gobtn.getText() + "String_Node_Str" + mExecutor.getName());
gobtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.GO();
}
}
);
stopbtn=new Button(Context);
stopbtn.setBackgroundResource(R.drawable.btn_normal_selector);
stopbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
stopbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
stopbtn.setText(getContext().getResources().getString(R.string.char_stop));
stopbtn.setTag(stopbtn.getText() + "String_Node_Str" + mExecutor.getName());
stopbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,height / 16));
stopbtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.Stop();
}
}
);
Resize();
this.addView(textView);
this.addView(stopbtn);
this.addView(breakbtn);
this.addView(gobtn);
this.addView(faderLayout);
this.addView(flashbtn);
}

Fixed version (ground truth):
private void Initialize(){
  this.setOrientation(LinearLayout.VERTICAL);
  setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
  int height=Context.getResources().getDisplayMetrics().heightPixels;
  int max=Math.max(Context.getResources().getDisplayMetrics().widthPixels,height) / 8;
  textView=new TextView(Context);
  textView.setMaxWidth(max);
  textView.setMinWidth(max);
  textView.setMaxLines(1);
  textView.setSingleLine();
  textView.setTextColor(getResources().getColor(R.color.dark_white_smoke));
  textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  textView.setText(mExecutor.getName());
  textView.setLongClickable(true);
  textView.setOnLongClickListener(new View.OnLongClickListener(){
    @Override public boolean onLongClick(    final View v){
      final AlertDialog.Builder alert=new AlertDialog.Builder(v.getContext());
      alert.setTitle(getContext().getResources().getString(R.string.executor_settings_title));
      final View view=View.inflate(v.getContext(),R.layout.executor_setting_dialog,null);
      final EditText input=(EditText)view.findViewById(R.id.editName);
      input.setText(textView.getText());
      final RadioGroup dropdown=(RadioGroup)view.findViewById(R.id.radioButtonGroup);
      final RadioButton intensity_btn=(RadioButton)view.findViewById(R.id.radioButton_Intensity);
      final RadioButton timing_btn=(RadioButton)view.findViewById(R.id.radioButton_Timing);
      final RadioButton speed_btn=(RadioButton)view.findViewById(R.id.radioButton_EffectSpeed);
switch (mExecutor.getFaderMode()) {
case 0:
        intensity_btn.setChecked(true);
      break;
case 1:
    timing_btn.setChecked(true);
  break;
case 2:
speed_btn.setChecked(true);
break;
}
final ToggleButton toggle_btn=(ToggleButton)view.findViewById(R.id.toggleButton_flash);
toggle_btn.setChecked(mExecutor.getToggle());
alert.setView(view);
alert.setPositiveButton(getContext().getResources().getString(android.R.string.ok),new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int whichButton){
String str=input.getEditableText().toString();
mExecutor.setName(str,false);
mExecutor.setToggle(toggle_btn.isChecked(),false);
if (intensity_btn.isChecked()) {
mExecutor.setFaderMode(0,false);
}
 else if (timing_btn.isChecked()) {
mExecutor.setFaderMode(1,false);
}
 else if (speed_btn.isChecked()) {
mExecutor.setFaderMode(2,false);
}
textView.setText(mExecutor.getName());
Toast.makeText(alert.getContext(),str,Toast.LENGTH_LONG).show();
}
}
);
AlertDialog alertDialog=alert.create();
alertDialog.show();
return true;
}
}
);
mExecutor.setNameChangedListener(new Entity.NameChangedListener(){
@Override public void onNameChanged(String name){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
textView.setText(mExecutor.getName());
instance.Resize();
instance.invalidate();
}
}
);
}
}
}
);
int margin=10;
LinearLayout.LayoutParams layoutParams;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
layoutParams=new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
 else {
layoutParams=new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
}
layoutParams.leftMargin=margin;
layoutParams.rightMargin=margin;
fader=new FaderVerticalControl(Context);
fader.setValue(mExecutor.getValue(),0);
fader.setBackgroundResource(R.drawable.border_normal_layer_transperent);
mExecutor.setValueChangedListener(new EntityExecutor.ValueChangedListener(){
@Override public void onValueChanged(float value){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
fader.setValue(mExecutor.getValue(),0);
}
}
);
}
}
}
);
fader.setValueChangedListener(new FaderVerticalControl.ValueChangedListener(){
@Override public void onValueChanged(float value,boolean isMoving){
mExecutor.setValue(value,false);
}
}
);
fader.setLayoutParams(layoutParams);
faderLayout=new FrameLayout(Context);
faderLayout.addView(fader);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
layoutParams=new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,(height / 2) + (height / 16)));
}
 else {
layoutParams=new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,(height / 2) + (height / 16)));
}
layoutParams.leftMargin=margin;
layoutParams.rightMargin=margin;
faderLayout.setLayoutParams(layoutParams);
flashbtn=new Button(Context);
flashbtn.setEnabled(false);
flashbtn.setBackgroundResource(R.drawable.btn_normal_selector);
flashbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
flashbtn.setTextSize(18);
flashbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
flashbtn.setText(getContext().getResources().getString(R.string.char_flash));
flashbtn.setTag(flashbtn.getText() + "String_Node_Str" + mExecutor.getName());
flashbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height / 8));
flashbtn.setEnabled(false);
flashbtn.setClickable(false);
mExecutor.setFlashChangedListener(new EntityExecutor.FlashChangedListener(){
@Override public void onFlashChanged(float value){
if (parentActivity != null) {
parentActivity.runOnUiThread(new Runnable(){
@Override public void run(){
if (!lockflash) {
  flashbtn.setPressed(mExecutor.getFlash());
}
}
}
);
}
}
}
);
breakbtn=new Button(Context);
breakbtn.setBackgroundResource(R.drawable.btn_normal_selector);
breakbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
breakbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
breakbtn.setText(getContext().getResources().getString(R.string.char_breakback));
breakbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height / 16));
breakbtn.setTag(breakbtn.getText() + "String_Node_Str" + mExecutor.getName());
breakbtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.BreakBack();
}
}
);
gobtn=new Button(Context);
gobtn.setBackgroundResource(R.drawable.btn_normal_selector);
gobtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
gobtn.setTextSize(18);
gobtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
gobtn.setText(getContext().getResources().getString(R.string.char_go));
gobtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height / 8));
gobtn.setTag(gobtn.getText() + "String_Node_Str" + mExecutor.getName());
gobtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.GO();
}
}
);
stopbtn=new Button(Context);
stopbtn.setBackgroundResource(R.drawable.btn_normal_selector);
stopbtn.setTextColor(getResources().getColor(R.color.dark_white_smoke));
stopbtn.setTypeface(Typeface.createFromAsset(Context.getAssets(),"String_Node_Str"));
stopbtn.setText(getContext().getResources().getString(R.string.char_stop));
stopbtn.setTag(stopbtn.getText() + "String_Node_Str" + mExecutor.getName());
stopbtn.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,height / 16));
stopbtn.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
mExecutor.Stop();
}
}
);
Resize();
this.addView(textView);
this.addView(stopbtn);
this.addView(breakbtn);
this.addView(gobtn);
this.addView(faderLayout);
this.addView(flashbtn);
}