Program: 167594
Project: 167594
Buggy source:
/** 
 * On create
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  key="String_Node_Str";
  iap inAppPayments=new iap();
  bp=inAppPayments.getBilling(this,key);
  bp.loadOwnedPurchasesFromGoogle();
  tinydb=new TinyDB(getApplicationContext());
  serverId=getIntent().getExtras().getInt("String_Node_Str");
  server=Hermes.getInstance().getServerById(serverId);
  if (server.autoConnectStarred()) {
    server.setAutoJoinChannels(pinnedRooms);
  }
  loadPinnedItems();
  loadRecentItems();
  HashSet hs=new HashSet();
  hs.addAll(recentList);
  recentList.clear();
  recentList.addAll(hs);
  saveRecentItems();
  Settings settings=new Settings(this);
  if (server == null) {
    this.finish();
  }
  try {
    setTitle(server.getTitle());
  }
 catch (  Exception e) {
  }
  isFirstTimeStarred=tinydb.getBoolean("String_Node_Str",true);
  setContentView(R.layout.conversations);
  boolean isLandscape=(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
  LinearLayout ads=(LinearLayout)findViewById(R.id.ads_card_conversation);
  if (bp.isPurchased("String_Node_Str")) {
    ads.setVisibility(LinearLayout.GONE);
  }
 else {
    AdView mAdView=(AdView)findViewById(R.id.adView);
    AdRequest adRequest=new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    ads.setVisibility(LinearLayout.VISIBLE);
  }
  EditText input=(EditText)findViewById(R.id.input);
  input.setOnKeyListener(inputKeyListener);
  pager=(ViewPager)findViewById(R.id.pager);
  pagerAdapter=new ConversationPagerAdapter(this,server);
  pager.setAdapter(pagerAdapter);
  final float density=getResources().getDisplayMetrics().density;
  indicator=(ConversationIndicator)findViewById(R.id.titleIndicator);
  indicator.setServer(server);
  indicator.setViewPager(pager);
  indicator.setFooterColor(Color.parseColor("String_Node_Str"));
  indicator.setFooterLineHeight(1);
  indicator.setPadding(10,10,10,10);
  indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
  indicator.setFooterIndicatorHeight(2 * density);
  indicator.setSelectedColor(0xFF222222);
  indicator.setSelectedBold(false);
  indicator.setBackgroundColor(Color.parseColor("String_Node_Str"));
  historySize=settings.getHistorySize();
  if (server.getStatus() == Status.PRE_CONNECTING) {
    server.clearConversations();
    pagerAdapter.clearConversations();
    server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
  }
  float fontSize=settings.getFontSize();
  indicator.setTextSize(TypedValue.COMPLEX_UNIT_SP,35);
  input.setTypeface(Typeface.SANS_SERIF);
  Collection<Conversation> mConversations=server.getConversations();
  for (  Conversation conversation : mConversations) {
    if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
      onNewConversation(conversation.getName());
    }
 else {
      createNewConversation(conversation.getName());
    }
  }
  input.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      openSoftKeyboard(v);
    }
  }
);
  int setInputTypeFlags=0;
  setInputTypeFlags|=InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
  if (settings.autoCapSentences()) {
    setInputTypeFlags|=InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
  }
  if (isLandscape && settings.imeExtract()) {
    setInputTypeFlags|=InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
  }
  if (!settings.imeExtract()) {
    input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  }
  input.setInputType(input.getInputType() | setInputTypeFlags);
  scrollback=new Scrollback();
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  conversationLayout=(FrameLayout)findViewById(R.id.conversationFragment);
  conversationLayout.setVisibility(LinearLayout.INVISIBLE);
  roomsList=(ExpandableHeightListView)findViewById(R.id.roomsActivityList);
  roomsList.setExpanded(true);
  SwipeDismissListViewTouchListener touchListener=new SwipeDismissListViewTouchListener(roomsList,new SwipeDismissListViewTouchListener.DismissCallbacks(){
    @Override public boolean canDismiss(    int position){
      return true;
    }
    @Override public void onDismiss(    ListView listView,    int[] reverseSortedPositions){
      for (      int position : reverseSortedPositions) {
        roomAdapter.remove(position);
      }
      roomAdapter.notifyDataSetChanged();
    }
  }
);
  roomsList.setOnTouchListener(touchListener);
  roomsList.setOnScrollListener(touchListener.makeScrollListener());
  RoomsList=new ArrayList<String>();
  ArrayList<Integer> MentionsList=new ArrayList<Integer>();
  ArrayList<String> channels=new ArrayList<String>();
  ArrayList<String> query=new ArrayList<String>();
  channels=server.getCurrentChannelNames();
  query=server.getCurrentQueryNames();
  for (int i=0; i < channels.size(); i++) {
    try {
      Conversation conversation=server.getConversation(channels.get(i));
      int Mentions=conversation.getNewMentions();
      RoomsList.add(channels.get(i));
      MentionsList.add(Mentions);
    }
 catch (    Exception E) {
    }
  }
  fab=(FloatingActionButton)findViewById(R.id.room_fab);
  fab.setOnTouchListener(new View.OnTouchListener(){
    public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        joinRoom(v);
      }
      return true;
    }
  }
);
  roomAdapter=new mentionsAdapter(RoomsList,MentionsList);
  roomsList.setAdapter(roomAdapter);
  roomsList.setEmptyView(findViewById(R.id.roomsActivityList_empty));
  roomsList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      showConversationLayout();
      invalidateOptionsMenu();
      int pagerPosition;
      String name;
      TextView roomName=(TextView)view.findViewById(R.id.room_name);
      name=roomName.getText().toString();
      pagerPosition=pagerAdapter.getPositionByName(name);
      pager.setCurrentItem(pagerPosition,true);
    }
  }
);
  CardView otherCard=(CardView)findViewById(R.id.card_view_other);
  otherCard.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      showConversationLayout();
      invalidateOptionsMenu();
      pager.setCurrentItem(0);
    }
  }
);
  int counter;
  for (counter=0; counter < recentList.size(); counter++) {
    if (RoomsList.contains(recentList.get(counter))) {
      recentList.remove(counter);
      saveRecentItems();
    }
  }
  LinearLayout recentLabel=(LinearLayout)findViewById(R.id.recentName);
  if (recentList.size() != 0) {
    recentLabel.setVisibility(View.VISIBLE);
  }
 else {
    recentLabel.setVisibility(View.GONE);
  }
  recentView=(ExpandableHeightListView)findViewById(R.id.recentList);
  loadLastItems();
  int k;
  for (k=0; k < lastRooms.size(); k++) {
    String lastRoom=lastRooms.get(k);
    if (RoomsList.contains(lastRoom)) {
    }
 else {
      recentList.add(lastRoom);
    }
  }
  lastRooms.clear();
  saveLastItems();
  saveRecentItems();
  recentAdapter=new recentAdapter(recentList);
  recentView.setAdapter(recentAdapter);
  recentView.setExpanded(true);
  recentView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> adapter,    View v,    int position,    long arg3){
      final String room=(String)recentAdapter.getRoomAtPosition(position);
      if (RoomsList.size() != 0) {
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        recentList.remove(position);
        saveRecentItems();
        refreshActivity();
      }
 else {
        Toast toast=Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_SHORT);
        toast.show();
        refreshActivity();
      }
    }
  }
);
  SwipeDismissListViewTouchListener touchListenerRecent=new SwipeDismissListViewTouchListener(recentView,new SwipeDismissListViewTouchListener.DismissCallbacks(){
    @Override public boolean canDismiss(    int position){
      return true;
    }
    @Override public void onDismiss(    ListView listView,    int[] reverseSortedPositions){
      for (      int position : reverseSortedPositions) {
        recentAdapter.remove(position);
        saveRecentItems();
      }
      recentAdapter.notifyDataSetChanged();
    }
  }
);
  recentView.setOnTouchListener(touchListenerRecent);
  recentView.setOnScrollListener(touchListenerRecent.makeScrollListener());
}

Fixed version (ground truth):
/** 
 * On create
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  key="String_Node_Str";
  iap inAppPayments=new iap();
  bp=inAppPayments.getBilling(this,key);
  bp.loadOwnedPurchasesFromGoogle();
  tinydb=new TinyDB(getApplicationContext());
  serverId=getIntent().getExtras().getInt("String_Node_Str");
  server=Hermes.getInstance().getServerById(serverId);
  loadPinnedItems();
  loadRecentItems();
  server.setAutoJoinChannels(pinnedRooms);
  HashSet hs=new HashSet();
  hs.addAll(recentList);
  recentList.clear();
  recentList.addAll(hs);
  saveRecentItems();
  Settings settings=new Settings(this);
  if (server == null) {
    this.finish();
  }
  try {
    setTitle(server.getTitle());
  }
 catch (  Exception e) {
  }
  isFirstTimeStarred=tinydb.getBoolean("String_Node_Str",true);
  setContentView(R.layout.conversations);
  boolean isLandscape=(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
  LinearLayout ads=(LinearLayout)findViewById(R.id.ads_card_conversation);
  if (bp.isPurchased("String_Node_Str")) {
    ads.setVisibility(LinearLayout.GONE);
  }
 else {
    AdView mAdView=(AdView)findViewById(R.id.adView);
    AdRequest adRequest=new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    ads.setVisibility(LinearLayout.VISIBLE);
  }
  EditText input=(EditText)findViewById(R.id.input);
  input.setOnKeyListener(inputKeyListener);
  pager=(ViewPager)findViewById(R.id.pager);
  pagerAdapter=new ConversationPagerAdapter(this,server);
  pager.setAdapter(pagerAdapter);
  final float density=getResources().getDisplayMetrics().density;
  indicator=(ConversationIndicator)findViewById(R.id.titleIndicator);
  indicator.setServer(server);
  indicator.setViewPager(pager);
  indicator.setFooterColor(Color.parseColor("String_Node_Str"));
  indicator.setFooterLineHeight(1);
  indicator.setPadding(10,10,10,10);
  indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);
  indicator.setFooterIndicatorHeight(2 * density);
  indicator.setSelectedColor(0xFF222222);
  indicator.setSelectedBold(false);
  indicator.setBackgroundColor(Color.parseColor("String_Node_Str"));
  historySize=settings.getHistorySize();
  if (server.getStatus() == Status.PRE_CONNECTING) {
    server.clearConversations();
    pagerAdapter.clearConversations();
    server.getConversation(ServerInfo.DEFAULT_NAME).setHistorySize(historySize);
  }
  float fontSize=settings.getFontSize();
  indicator.setTextSize(TypedValue.COMPLEX_UNIT_SP,35);
  input.setTypeface(Typeface.SANS_SERIF);
  Collection<Conversation> mConversations=server.getConversations();
  for (  Conversation conversation : mConversations) {
    if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
      onNewConversation(conversation.getName());
    }
 else {
      createNewConversation(conversation.getName());
    }
  }
  input.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      openSoftKeyboard(v);
    }
  }
);
  int setInputTypeFlags=0;
  setInputTypeFlags|=InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
  if (settings.autoCapSentences()) {
    setInputTypeFlags|=InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
  }
  if (isLandscape && settings.imeExtract()) {
    setInputTypeFlags|=InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
  }
  if (!settings.imeExtract()) {
    input.setImeOptions(input.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
  }
  input.setInputType(input.getInputType() | setInputTypeFlags);
  scrollback=new Scrollback();
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  conversationLayout=(FrameLayout)findViewById(R.id.conversationFragment);
  conversationLayout.setVisibility(LinearLayout.INVISIBLE);
  roomsList=(ExpandableHeightListView)findViewById(R.id.roomsActivityList);
  roomsList.setExpanded(true);
  SwipeDismissListViewTouchListener touchListener=new SwipeDismissListViewTouchListener(roomsList,new SwipeDismissListViewTouchListener.DismissCallbacks(){
    @Override public boolean canDismiss(    int position){
      return true;
    }
    @Override public void onDismiss(    ListView listView,    int[] reverseSortedPositions){
      for (      int position : reverseSortedPositions) {
        roomAdapter.remove(position);
      }
      roomAdapter.notifyDataSetChanged();
    }
  }
);
  roomsList.setOnTouchListener(touchListener);
  roomsList.setOnScrollListener(touchListener.makeScrollListener());
  RoomsList=new ArrayList<String>();
  ArrayList<Integer> MentionsList=new ArrayList<Integer>();
  ArrayList<String> channels=new ArrayList<String>();
  ArrayList<String> query=new ArrayList<String>();
  channels=server.getCurrentChannelNames();
  query=server.getCurrentQueryNames();
  for (int i=0; i < channels.size(); i++) {
    try {
      Conversation conversation=server.getConversation(channels.get(i));
      int Mentions=conversation.getNewMentions();
      RoomsList.add(channels.get(i));
      MentionsList.add(Mentions);
    }
 catch (    Exception E) {
    }
  }
  fab=(FloatingActionButton)findViewById(R.id.room_fab);
  fab.setOnTouchListener(new View.OnTouchListener(){
    public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_UP) {
        joinRoom(v);
      }
      return true;
    }
  }
);
  roomAdapter=new mentionsAdapter(RoomsList,MentionsList);
  roomsList.setAdapter(roomAdapter);
  roomsList.setEmptyView(findViewById(R.id.roomsActivityList_empty));
  roomsList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      showConversationLayout();
      invalidateOptionsMenu();
      int pagerPosition;
      String name;
      TextView roomName=(TextView)view.findViewById(R.id.room_name);
      name=roomName.getText().toString();
      pagerPosition=pagerAdapter.getPositionByName(name);
      pager.setCurrentItem(pagerPosition,true);
    }
  }
);
  CardView otherCard=(CardView)findViewById(R.id.card_view_other);
  otherCard.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      showConversationLayout();
      invalidateOptionsMenu();
      pager.setCurrentItem(0);
    }
  }
);
  int counter;
  for (counter=0; counter < recentList.size(); counter++) {
    if (RoomsList.contains(recentList.get(counter))) {
      recentList.remove(counter);
      saveRecentItems();
    }
  }
  LinearLayout recentLabel=(LinearLayout)findViewById(R.id.recentName);
  if (recentList.size() != 0) {
    recentLabel.setVisibility(View.VISIBLE);
  }
 else {
    recentLabel.setVisibility(View.GONE);
  }
  recentView=(ExpandableHeightListView)findViewById(R.id.recentList);
  loadLastItems();
  int k;
  for (k=0; k < lastRooms.size(); k++) {
    String lastRoom=lastRooms.get(k);
    if (RoomsList.contains(lastRoom)) {
    }
 else {
      recentList.add(lastRoom);
    }
  }
  lastRooms.clear();
  saveLastItems();
  saveRecentItems();
  recentAdapter=new recentAdapter(recentList);
  recentView.setAdapter(recentAdapter);
  recentView.setExpanded(true);
  recentView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    @Override public void onItemClick(    AdapterView<?> adapter,    View v,    int position,    long arg3){
      final String room=(String)recentAdapter.getRoomAtPosition(position);
      if (RoomsList.size() != 0) {
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        recentList.remove(position);
        saveRecentItems();
        refreshActivity();
      }
 else {
        Toast toast=Toast.makeText(getApplicationContext(),"String_Node_Str",Toast.LENGTH_SHORT);
        toast.show();
        refreshActivity();
      }
    }
  }
);
  SwipeDismissListViewTouchListener touchListenerRecent=new SwipeDismissListViewTouchListener(recentView,new SwipeDismissListViewTouchListener.DismissCallbacks(){
    @Override public boolean canDismiss(    int position){
      return true;
    }
    @Override public void onDismiss(    ListView listView,    int[] reverseSortedPositions){
      for (      int position : reverseSortedPositions) {
        recentAdapter.remove(position);
        saveRecentItems();
      }
      recentAdapter.notifyDataSetChanged();
    }
  }
);
  recentView.setOnTouchListener(touchListenerRecent);
  recentView.setOnScrollListener(touchListenerRecent.makeScrollListener());
}