Program: 32202
Project: 32202
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_home);
  addSlidingMenu(mSlideMenuResourceIds,mSlideMenuTitleIds,true);
  mSession=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  if (mSession == null) {
    finish();
    return;
  }
  mMyRoomList=(ExpandableListView)findViewById(R.id.listView_myRooms);
  mMyRoomList.setGroupIndicator(null);
  mAdapter=new ConsoleRoomSummaryAdapter(mSession,this,R.layout.adapter_item_my_rooms,R.layout.adapter_room_section_header);
  if (null != savedInstanceState) {
    if (savedInstanceState.containsKey(UNREAD_MESSAGE_MAP)) {
      Serializable map=savedInstanceState.getSerializable(UNREAD_MESSAGE_MAP);
      if (null != map) {
        mAdapter.setUnreadCountMap((HashMap<String,Integer>)map);
      }
    }
    if (savedInstanceState.containsKey(PUBLIC_ROOMS_LIST)) {
      Serializable map=savedInstanceState.getSerializable(PUBLIC_ROOMS_LIST);
      if (null != map) {
        HashMap<String,PublicRoom> hash=(HashMap<String,PublicRoom>)map;
        mPublicRooms=new ArrayList<PublicRoom>(hash.values());
      }
    }
  }
  final Intent intent=getIntent();
  if (intent.hasExtra(EXTRA_JUMP_TO_ROOM_ID)) {
    mAutomaticallyOpenedRoomId=intent.getStringExtra(EXTRA_JUMP_TO_ROOM_ID);
  }
  if (intent.hasExtra(EXTRA_ROOM_INTENT)) {
    mOpenedRoomIntent=intent.getParcelableExtra(EXTRA_ROOM_INTENT);
  }
  String action=intent.getAction();
  String type=intent.getType();
  if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) && type != null) {
    this.runOnUiThread(new Runnable(){
      @Override public void run(){
        CommonActivityUtils.sendFilesTo(HomeActivity.this,mSession,intent);
      }
    }
);
  }
  mMyRoomList.setAdapter(mAdapter);
  mSession.getDataHandler().addListener(mListener);
  mMyRoomList.setOnChildClickListener(new ExpandableListView.OnChildClickListener(){
    @Override public boolean onChildClick(    ExpandableListView parent,    View v,    int groupPosition,    int childPosition,    long id){
      String roomId=null;
      if (mAdapter.isRecentsGroupIndex(groupPosition)) {
        roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
        Room room=mSession.getDataHandler().getRoom(roomId);
        if ((null == room) || room.isLeaving()) {
          roomId=null;
        }
        mAdapter.resetUnreadCount(roomId);
      }
 else       if (mAdapter.isPublicsGroupIndex(groupPosition)) {
        roomId=mAdapter.getPublicRoomAt(childPosition).roomId;
      }
      if (null != roomId) {
        CommonActivityUtils.goToRoomPage(roomId,HomeActivity.this,null);
      }
      return true;
    }
  }
);
  mMyRoomList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
    @Override public boolean onItemLongClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        long packedPos=((ExpandableListView)parent).getExpandableListPosition(position);
        int groupPosition=ExpandableListView.getPackedPositionGroup(packedPos);
        if (mAdapter.isRecentsGroupIndex(groupPosition)) {
          final int childPosition=ExpandableListView.getPackedPositionChild(packedPos);
          FragmentManager fm=HomeActivity.this.getSupportFragmentManager();
          IconAndTextDialogFragment fragment=(IconAndTextDialogFragment)fm.findFragmentByTag(TAG_FRAGMENT_ROOM_OPTIONS);
          if (fragment != null) {
            fragment.dismissAllowingStateLoss();
          }
          final Integer[] lIcons=new Integer[]{R.drawable.ic_material_exit_to_app};
          final Integer[] lTexts=new Integer[]{R.string.action_leave};
          fragment=IconAndTextDialogFragment.newInstance(lIcons,lTexts);
          fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener(){
            @Override public void onItemClick(            IconAndTextDialogFragment dialogFragment,            int position){
              Integer selectedVal=lTexts[position];
              if (selectedVal == R.string.action_leave) {
                HomeActivity.this.runOnUiThread(new Runnable(){
                  @Override public void run(){
                    String roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
                    Room room=mSession.getDataHandler().getRoom(roomId);
                    if (null != room) {
                      room.leave(new SimpleApiCallback<Void>(HomeActivity.this){
                        @Override public void onSuccess(                        Void info){
                        }
                      }
);
                    }
                  }
                }
);
              }
            }
          }
);
          fragment.show(fm,TAG_FRAGMENT_ROOM_OPTIONS);
          return true;
        }
      }
      return false;
    }
  }
);
  mMyRoomList.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener(){
    @Override public void onGroupExpand(    int groupPosition){
      if (mAdapter.isPublicsGroupIndex(groupPosition)) {
        refreshPublicRoomsList();
      }
    }
  }
);
  mMyRoomList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener(){
    @Override public boolean onGroupClick(    ExpandableListView parent,    View v,    int groupPosition,    long id){
      return mAdapter.getGroupCount() < 2;
    }
  }
);
  mSearchRoomEditText=(EditText)this.findViewById(R.id.editText_search_room);
  mSearchRoomEditText.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    android.text.Editable s){
      mAdapter.setSearchedPattern(s.toString());
      mMyRoomList.smoothScrollToPosition(0);
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_home);
  addSlidingMenu(mSlideMenuResourceIds,mSlideMenuTitleIds,true);
  mSession=Matrix.getInstance(getApplicationContext()).getDefaultSession();
  if (mSession == null) {
    finish();
    return;
  }
  mMyRoomList=(ExpandableListView)findViewById(R.id.listView_myRooms);
  mMyRoomList.setGroupIndicator(null);
  mAdapter=new ConsoleRoomSummaryAdapter(mSession,this,R.layout.adapter_item_my_rooms,R.layout.adapter_room_section_header);
  if (null != savedInstanceState) {
    if (savedInstanceState.containsKey(UNREAD_MESSAGE_MAP)) {
      Serializable map=savedInstanceState.getSerializable(UNREAD_MESSAGE_MAP);
      if (null != map) {
        mAdapter.setUnreadCountMap((HashMap<String,Integer>)map);
      }
    }
    if (savedInstanceState.containsKey(PUBLIC_ROOMS_LIST)) {
      Serializable map=savedInstanceState.getSerializable(PUBLIC_ROOMS_LIST);
      if (null != map) {
        HashMap<String,PublicRoom> hash=(HashMap<String,PublicRoom>)map;
        mPublicRooms=new ArrayList<PublicRoom>(hash.values());
      }
    }
  }
  final Intent intent=getIntent();
  if (intent.hasExtra(EXTRA_JUMP_TO_ROOM_ID)) {
    mAutomaticallyOpenedRoomId=intent.getStringExtra(EXTRA_JUMP_TO_ROOM_ID);
  }
  if (intent.hasExtra(EXTRA_ROOM_INTENT)) {
    mOpenedRoomIntent=intent.getParcelableExtra(EXTRA_ROOM_INTENT);
  }
  String action=intent.getAction();
  String type=intent.getType();
  if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) && type != null) {
    this.runOnUiThread(new Runnable(){
      @Override public void run(){
        CommonActivityUtils.sendFilesTo(HomeActivity.this,mSession,intent);
      }
    }
);
  }
  mMyRoomList.setAdapter(mAdapter);
  mSession.getDataHandler().addListener(mListener);
  mMyRoomList.setOnChildClickListener(new ExpandableListView.OnChildClickListener(){
    @Override public boolean onChildClick(    ExpandableListView parent,    View v,    int groupPosition,    int childPosition,    long id){
      String roomId=null;
      if (mAdapter.isRecentsGroupIndex(groupPosition)) {
        roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
        Room room=mSession.getDataHandler().getRoom(roomId);
        if ((null == room) || room.isLeaving()) {
          roomId=null;
        }
        mAdapter.resetUnreadCount(roomId);
      }
 else       if (mAdapter.isPublicsGroupIndex(groupPosition)) {
        roomId=mAdapter.getPublicRoomAt(childPosition).roomId;
      }
      if (null != roomId) {
        CommonActivityUtils.goToRoomPage(null,roomId,HomeActivity.this,null);
      }
      return true;
    }
  }
);
  mMyRoomList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){
    @Override public boolean onItemLongClick(    AdapterView<?> parent,    View view,    int position,    long id){
      if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        long packedPos=((ExpandableListView)parent).getExpandableListPosition(position);
        int groupPosition=ExpandableListView.getPackedPositionGroup(packedPos);
        if (mAdapter.isRecentsGroupIndex(groupPosition)) {
          final int childPosition=ExpandableListView.getPackedPositionChild(packedPos);
          FragmentManager fm=HomeActivity.this.getSupportFragmentManager();
          IconAndTextDialogFragment fragment=(IconAndTextDialogFragment)fm.findFragmentByTag(TAG_FRAGMENT_ROOM_OPTIONS);
          if (fragment != null) {
            fragment.dismissAllowingStateLoss();
          }
          final Integer[] lIcons=new Integer[]{R.drawable.ic_material_exit_to_app};
          final Integer[] lTexts=new Integer[]{R.string.action_leave};
          fragment=IconAndTextDialogFragment.newInstance(lIcons,lTexts);
          fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener(){
            @Override public void onItemClick(            IconAndTextDialogFragment dialogFragment,            int position){
              Integer selectedVal=lTexts[position];
              if (selectedVal == R.string.action_leave) {
                HomeActivity.this.runOnUiThread(new Runnable(){
                  @Override public void run(){
                    String roomId=mAdapter.getRoomSummaryAt(childPosition).getRoomId();
                    Room room=mSession.getDataHandler().getRoom(roomId);
                    if (null != room) {
                      room.leave(new SimpleApiCallback<Void>(HomeActivity.this){
                        @Override public void onSuccess(                        Void info){
                        }
                      }
);
                    }
                  }
                }
);
              }
            }
          }
);
          fragment.show(fm,TAG_FRAGMENT_ROOM_OPTIONS);
          return true;
        }
      }
      return false;
    }
  }
);
  mMyRoomList.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener(){
    @Override public void onGroupExpand(    int groupPosition){
      if (mAdapter.isPublicsGroupIndex(groupPosition)) {
        refreshPublicRoomsList();
      }
    }
  }
);
  mMyRoomList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener(){
    @Override public boolean onGroupClick(    ExpandableListView parent,    View v,    int groupPosition,    long id){
      return mAdapter.getGroupCount() < 2;
    }
  }
);
  mSearchRoomEditText=(EditText)this.findViewById(R.id.editText_search_room);
  mSearchRoomEditText.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    android.text.Editable s){
      mAdapter.setSearchedPattern(s.toString());
      mMyRoomList.smoothScrollToPosition(0);
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
}