Program: 142227
Project: 142227
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.createDataSetObserver();
  EntitySelectActivity oldActivity=(EntitySelectActivity)this.getDestroyedActivityState();
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  try {
    asw=CommCareApplication._().getCurrentSessionWrapper();
    session=asw.getSession();
  }
 catch (  SessionUnavailableException sue) {
    this.setResult(Activity.RESULT_CANCELED);
    this.finish();
    return;
  }
  selectDatum=session.getNeededDatum();
  shortSelect=session.getDetail(selectDatum.getShortDetail());
  mNoDetailMode=selectDatum.getLongDetail() == null;
  if (this.getString(R.string.panes).equals("String_Node_Str") && !mNoDetailMode) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      setContentView(R.layout.screen_compound_select);
      View.inflate(this,R.layout.entity_select_layout,(ViewGroup)findViewById(R.id.screen_compound_select_left_pane));
      inAwesomeMode=true;
      rightFrame=(FrameLayout)findViewById(R.id.screen_compound_select_right_pane);
      TextView message=(TextView)findViewById(R.id.screen_compound_select_prompt);
      message.setText(Localization.get("String_Node_Str",new String[]{Localization.get("String_Node_Str")}));
    }
 else {
      setContentView(R.layout.entity_select_layout);
      if (oldActivity != null) {
        Intent intent=this.getIntent();
        TreeReference selectedRef=SerializationUtil.deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
        if (selectedRef != null) {
          intent.removeExtra(EntityDetailActivity.CONTEXT_REFERENCE);
          Intent detailIntent=getDetailIntent(selectedRef,null);
          startOther=true;
          startActivityForResult(detailIntent,CONFIRM_SELECT);
        }
      }
    }
  }
 else {
    setContentView(R.layout.entity_select_layout);
  }
  ((ListView)this.findViewById(R.id.screen_entity_select_list)).setOnItemClickListener(this);
  TextView searchLabel=(TextView)findViewById(R.id.screen_entity_select_search_label);
  searchLabel.setText(Localization.get("String_Node_Str"));
  searchLabel.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      searchbox.performClick();
      InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.showSoftInput(searchbox,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  searchbox=(EditText)findViewById(R.id.searchbox);
  searchbox.setMaxLines(3);
  searchbox.setHorizontallyScrolling(false);
  searchResultStatus=(TextView)findViewById(R.id.no_search_results);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  mViewMode=session.isViewCommand(session.getCommand());
  Callout callout=shortSelect.getCallout();
  if (callout == null) {
    calloutButton=(ImageButton)findViewById(R.id.barcodeButton);
    calloutButton.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        Intent i=new Intent("String_Node_Str");
        try {
          startActivityForResult(i,BARCODE_FETCH);
        }
 catch (        ActivityNotFoundException anfe) {
          Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str" + "String_Node_Str",Toast.LENGTH_LONG);
          noReader.show();
        }
      }
    }
);
  }
 else {
    CalloutData calloutData=callout.evaluate();
    if (calloutData.getImage() != null) {
      setupImageLayout(calloutButton,calloutData.getImage());
    }
    final String actionName=calloutData.getActionName();
    final Hashtable<String,String> extras=calloutData.getExtras();
    calloutButton.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        Intent i=new Intent(actionName);
        for (        String key : extras.keySet()) {
          i.putExtra(key,extras.get(key));
        }
        try {
          startActivityForResult(i,CALLOUT);
        }
 catch (        ActivityNotFoundException anfe) {
          Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str" + actionName,Toast.LENGTH_LONG);
          noReader.show();
        }
      }
    }
);
  }
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
  if (oldActivity != null) {
    adapter=oldActivity.adapter;
    if (adapter != null) {
      adapter.setController(this);
      ((ListView)this.findViewById(R.id.screen_entity_select_list)).setAdapter(adapter);
      findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
      adapter.unregisterDataSetObserver(oldActivity.mListStateObserver);
      adapter.registerDataSetObserver(this.mListStateObserver);
    }
  }
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.createDataSetObserver();
  EntitySelectActivity oldActivity=(EntitySelectActivity)this.getDestroyedActivityState();
  if (savedInstanceState != null) {
    mResultIsMap=savedInstanceState.getBoolean(EXTRA_IS_MAP,false);
  }
  try {
    asw=CommCareApplication._().getCurrentSessionWrapper();
    session=asw.getSession();
  }
 catch (  SessionUnavailableException sue) {
    this.setResult(Activity.RESULT_CANCELED);
    this.finish();
    return;
  }
  selectDatum=session.getNeededDatum();
  shortSelect=session.getDetail(selectDatum.getShortDetail());
  mNoDetailMode=selectDatum.getLongDetail() == null;
  if (this.getString(R.string.panes).equals("String_Node_Str") && !mNoDetailMode) {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      setContentView(R.layout.screen_compound_select);
      View.inflate(this,R.layout.entity_select_layout,(ViewGroup)findViewById(R.id.screen_compound_select_left_pane));
      inAwesomeMode=true;
      rightFrame=(FrameLayout)findViewById(R.id.screen_compound_select_right_pane);
      TextView message=(TextView)findViewById(R.id.screen_compound_select_prompt);
      message.setText(Localization.get("String_Node_Str",new String[]{Localization.get("String_Node_Str")}));
    }
 else {
      setContentView(R.layout.entity_select_layout);
      if (oldActivity != null) {
        Intent intent=this.getIntent();
        TreeReference selectedRef=SerializationUtil.deserializeFromIntent(intent,EntityDetailActivity.CONTEXT_REFERENCE,TreeReference.class);
        if (selectedRef != null) {
          intent.removeExtra(EntityDetailActivity.CONTEXT_REFERENCE);
          Intent detailIntent=getDetailIntent(selectedRef,null);
          startOther=true;
          startActivityForResult(detailIntent,CONFIRM_SELECT);
        }
      }
    }
  }
 else {
    setContentView(R.layout.entity_select_layout);
  }
  ((ListView)this.findViewById(R.id.screen_entity_select_list)).setOnItemClickListener(this);
  TextView searchLabel=(TextView)findViewById(R.id.screen_entity_select_search_label);
  searchLabel.setText(Localization.get("String_Node_Str"));
  searchLabel.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      searchbox.performClick();
      InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.showSoftInput(searchbox,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  searchbox=(EditText)findViewById(R.id.searchbox);
  searchbox.setMaxLines(3);
  searchbox.setHorizontallyScrolling(false);
  searchResultStatus=(TextView)findViewById(R.id.no_search_results);
  header=(LinearLayout)findViewById(R.id.entity_select_header);
  mViewMode=session.isViewCommand(session.getCommand());
  Callout callout=shortSelect.getCallout();
  calloutButton=(ImageButton)findViewById(R.id.barcodeButton);
  if (callout == null) {
    calloutButton.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        Intent i=new Intent("String_Node_Str");
        try {
          startActivityForResult(i,BARCODE_FETCH);
        }
 catch (        ActivityNotFoundException anfe) {
          Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str" + "String_Node_Str",Toast.LENGTH_LONG);
          noReader.show();
        }
      }
    }
);
  }
 else {
    CalloutData calloutData=callout.evaluate();
    if (calloutData.getImage() != null) {
      setupImageLayout(calloutButton,calloutData.getImage());
    }
    final String actionName=calloutData.getActionName();
    final Hashtable<String,String> extras=calloutData.getExtras();
    calloutButton.setOnClickListener(new OnClickListener(){
      public void onClick(      View v){
        Intent i=new Intent(actionName);
        for (        String key : extras.keySet()) {
          i.putExtra(key,extras.get(key));
        }
        try {
          startActivityForResult(i,CALLOUT);
        }
 catch (        ActivityNotFoundException anfe) {
          Toast noReader=Toast.makeText(EntitySelectActivity.this,"String_Node_Str" + actionName,Toast.LENGTH_LONG);
          noReader.show();
        }
      }
    }
);
  }
  searchbox.addTextChangedListener(this);
  searchbox.requestFocus();
  if (oldActivity != null) {
    adapter=oldActivity.adapter;
    if (adapter != null) {
      adapter.setController(this);
      ((ListView)this.findViewById(R.id.screen_entity_select_list)).setAdapter(adapter);
      findViewById(R.id.entity_select_loading).setVisibility(View.GONE);
      adapter.unregisterDataSetObserver(oldActivity.mListStateObserver);
      adapter.registerDataSetObserver(this.mListStateObserver);
    }
  }
}