Program: 167588
Project: 167588
Buggy source:
/** 
 * On create
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FacebookSdk.sdkInitialize(getApplicationContext());
  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();
  }
  String key="String_Node_Str";
  iap inAppPayments=new iap();
  bp=inAppPayments.getBilling(this,key);
  bp.loadOwnedPurchasesFromGoogle();
  if (!bp.isPurchased("String_Node_Str")) {
    mInterstitialAd=new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("String_Node_Str");
    requestNewInterstitial();
    mInterstitialAd.setAdListener(new AdListener(){
      @Override public void onAdClosed(){
        requestNewInterstitial();
      }
    }
);
  }
  try {
    setTitle(server.getTitle());
  }
 catch (  Exception e) {
  }
  isFirstTimeStarred=tinydb.getBoolean("String_Node_Str",true);
  isFirstTimeRefresh=tinydb.getBoolean("String_Node_Str",true);
  setContentView(R.layout.conversations);
  boolean isLandscape=(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
  final ImageView sendButton=(ImageView)findViewById(R.id.send_button);
  sendButton.setVisibility(View.GONE);
  input=(AutoCompleteTextView)findViewById(R.id.input);
  input.setOnKeyListener(inputKeyListener);
  input.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (input.getText().toString().equals("String_Node_Str")) {
        sendButton.setVisibility(View.GONE);
      }
 else {
        sendButton.setVisibility(View.VISIBLE);
      }
    }
  }
);
  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);
  }
  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);
      updateAutoComplete();
    }
  }
);
  conversationLayout=(FrameLayout)findViewById(R.id.conversationFragment);
  conversationLayout.setVisibility(LinearLayout.INVISIBLE);
  roomsLayout=(FrameLayout)findViewById(R.id.roomsLayout);
  scrollback=new Scrollback();
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  swipeRefresh=(SwipeRefreshLayout)findViewById(R.id.swipeRefresh);
  swipeRefresh.setColorSchemeResources(R.color.refresh_progress_1,R.color.refresh_progress_2,R.color.refresh_progress_3);
  swipeRefresh.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener(){
    @Override public void onScrollChanged(){
      Rect scrollBounds=new Rect();
      swipeRefresh.getHitRect(scrollBounds);
      TextView firstItem=(TextView)findViewById(R.id.firstItem);
      if (firstItem.getLocalVisibleRect(scrollBounds)) {
        if (conversationLayout.getVisibility() != View.VISIBLE) {
          swipeRefresh.setEnabled(true);
        }
 else {
          swipeRefresh.setEnabled(false);
        }
      }
 else {
        swipeRefresh.setEnabled(false);
      }
    }
  }
);
  swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener(){
    @Override public void onRefresh(){
      if (swipeRefresh.getScrollY() == 0) {
        refreshActivity();
      }
    }
  }
);
  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();
      if (Math.random() * 100 < 30) {
        showAd();
      }
    }
  }
);
  roomsList.setOnTouchListener(touchListener);
  roomsList.setOnScrollListener(touchListener.makeScrollListener());
  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){
      invalidateOptionsMenu();
      swipeRefresh.setEnabled(false);
      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);
      showConversationLayout();
    }
  }
);
  CardView otherCard=(CardView)findViewById(R.id.card_view_other);
  otherCard.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      invalidateOptionsMenu();
      swipeRefresh.setEnabled(false);
      pager.setCurrentItem(0);
      showConversationLayout();
    }
  }
);
  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) {
        invalidateOptionsMenu();
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        recentList.remove(position);
        saveRecentItems();
        refreshActivity();
      }
 else {
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        saveRecentItems();
        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();
      if (Math.random() * 100 < 10) {
        showAd();
      }
    }
  }
);
  recentView.setOnTouchListener(touchListenerRecent);
  recentView.setOnScrollListener(touchListenerRecent.makeScrollListener());
}

Fixed version (ground truth):
/** 
 * On create
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  FacebookSdk.sdkInitialize(getApplicationContext());
  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();
  }
  String key="String_Node_Str";
  inAppPayments=new iap();
  bp=inAppPayments.getBilling(this,key);
  bp.loadOwnedPurchasesFromGoogle();
  if (!inAppPayments.isPurchased()) {
    mInterstitialAd=new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("String_Node_Str");
    requestNewInterstitial();
    mInterstitialAd.setAdListener(new AdListener(){
      @Override public void onAdClosed(){
        requestNewInterstitial();
      }
    }
);
  }
  try {
    setTitle(server.getTitle());
  }
 catch (  Exception e) {
  }
  isFirstTimeStarred=tinydb.getBoolean("String_Node_Str",true);
  isFirstTimeRefresh=tinydb.getBoolean("String_Node_Str",true);
  setContentView(R.layout.conversations);
  boolean isLandscape=(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
  final ImageView sendButton=(ImageView)findViewById(R.id.send_button);
  sendButton.setVisibility(View.GONE);
  input=(AutoCompleteTextView)findViewById(R.id.input);
  input.setOnKeyListener(inputKeyListener);
  input.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (input.getText().toString().equals("String_Node_Str")) {
        sendButton.setVisibility(View.GONE);
      }
 else {
        sendButton.setVisibility(View.VISIBLE);
      }
    }
  }
);
  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);
  }
  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);
      updateAutoComplete();
    }
  }
);
  conversationLayout=(FrameLayout)findViewById(R.id.conversationFragment);
  conversationLayout.setVisibility(LinearLayout.INVISIBLE);
  roomsLayout=(FrameLayout)findViewById(R.id.roomsLayout);
  scrollback=new Scrollback();
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  swipeRefresh=(SwipeRefreshLayout)findViewById(R.id.swipeRefresh);
  swipeRefresh.setColorSchemeResources(R.color.refresh_progress_1,R.color.refresh_progress_2,R.color.refresh_progress_3);
  swipeRefresh.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener(){
    @Override public void onScrollChanged(){
      Rect scrollBounds=new Rect();
      swipeRefresh.getHitRect(scrollBounds);
      TextView firstItem=(TextView)findViewById(R.id.firstItem);
      if (firstItem.getLocalVisibleRect(scrollBounds)) {
        if (conversationLayout.getVisibility() != View.VISIBLE) {
          swipeRefresh.setEnabled(true);
        }
 else {
          swipeRefresh.setEnabled(false);
        }
      }
 else {
        swipeRefresh.setEnabled(false);
      }
    }
  }
);
  swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener(){
    @Override public void onRefresh(){
      if (swipeRefresh.getScrollY() == 0) {
        refreshActivity();
      }
    }
  }
);
  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();
      if (Math.random() * 100 < 30) {
        showAd();
      }
    }
  }
);
  roomsList.setOnTouchListener(touchListener);
  roomsList.setOnScrollListener(touchListener.makeScrollListener());
  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){
      invalidateOptionsMenu();
      swipeRefresh.setEnabled(false);
      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);
      showConversationLayout();
    }
  }
);
  CardView otherCard=(CardView)findViewById(R.id.card_view_other);
  otherCard.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      invalidateOptionsMenu();
      swipeRefresh.setEnabled(false);
      pager.setCurrentItem(0);
      showConversationLayout();
    }
  }
);
  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) {
        invalidateOptionsMenu();
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        recentList.remove(position);
        saveRecentItems();
        refreshActivity();
      }
 else {
        new Thread(){
          @Override public void run(){
            try {
              binder.getService().getConnection(serverId).joinChannel(room);
            }
 catch (            Exception E) {
            }
          }
        }
.start();
        saveRecentItems();
        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();
      if (Math.random() * 100 < 10) {
        showAd();
      }
    }
  }
);
  recentView.setOnTouchListener(touchListenerRecent);
  recentView.setOnScrollListener(touchListenerRecent.makeScrollListener());
}