Buggy code:
public class SheeldsList extends Fragment { View v ; boolean isInflated = false ; private ListView mListView ; private static SheeldsList thisInstance ; private ShieldsListAdapter adapter ; OneSheeldEditText searchBox ; private static final String TAG = "ShieldsList" ; MainActivity activity ; public static final int REQUEST_CONNECT_DEVICE = 1 ; public static final int REQUEST_ENABLE_BT = 3 ; public static SheeldsList getInstance ( ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { } @ Override public void onStop ( ) { } @ Override public void onAttach ( Activity activity ) { } @ Override public void onResume ( ) { MainActivity . currentShieldTag = null ; this . activity = ( ( MainActivity ) ( getActivity ( ) ) ) ; if ( ( adapter ) != null ) adapter . setActivity ( activity ) ; activity . disableMenu ( ) ; activity . hideSoftKeyboard ( ) ; new Handler ( ) . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { if ( ( ( activity ) != null ) && ( ( activity . getSupportFragmentManager ( ) ) != null ) ) { activity . findViewById ( currentViewTitle ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { activity . openOptionsMenu ( ) ; } } ) ; activity . findViewById ( getAvailableDevices ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( ( getActivity ( ) . findViewById ( progressShieldInit ) . getVisibility ( ) ) != ( View . VISIBLE ) ) { activity . findViewById ( cancelConnection ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { } } ) ; activity . findViewById ( currentViewTitle ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { } } ) ; launchShieldsOperationActivity ( ) ; } } } ) ; List < Fragment > frags = activity . getSupportFragmentManager ( ) . getFragments ( ) ; for ( Fragment frag : frags ) { if ( ( frag != null ) && ( ! ( frag . getClass ( ) . getName ( ) . equals ( SheeldsList . class . getName ( ) ) ) ) ) { if ( ( ( ( activity ) != null ) && ( ( activity ) != null ) ) && ( ( activity . getSupportFragmentManager ( ) ) != null ) ) { FragmentTransaction ft = activity . getSupportFragmentManager ( ) . beginTransaction ( ) ; frag . onDestroy ( ) ; ft . remove ( frag ) ; ft . commitAllowingStateLoss ( ) ; } } } } } } , 500 ) ; ( ( ViewGroup ) ( activity . findViewById ( getAvailableDevices ) ) ) . getChildAt ( 1 ) . setBackgroundResource ( shields_list_shields_operation_button ) ; if ( ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getIsDemoMode ( ) ) && ( ! ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getAppFirmata ( ) . isOpen ( ) ) ) ) ( ( ViewGroup ) ( activity . findViewById ( cancelConnection ) ) ) . getChildAt ( 1 ) . setBackgroundResource ( scan_button ) ; else ( ( ViewGroup ) ( activity . findViewById ( cancelConnection ) ) ) . getChildAt ( 1 ) . setBackgroundResource ( bluetooth_disconnect_button ) ; new Handler ( ) . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { if ( ( ( activity ) != null ) && ( ( activity . findViewById ( cancelConnection ) ) != null ) ) activity . findViewById ( cancelConnection ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { <START_BUG> if ( ! ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getIsDemoMode ( ) ) ) { <END_BUG> if ( ( activity . getSupportFragmentManager ( ) . getBackStackEntryCount ( ) ) > 1 ) { activity . getSupportFragmentManager ( ) . popBackStack ( ) ; activity . getSupportFragmentManager ( ) . executePendingTransactions ( ) ; } activity . stopService ( ) ; } else { Log . test ( "Test" , "Cannot<seq2seq4repair_space>disconnect<seq2seq4repair_space>in<seq2seq4repair_space>demoMode" ) ; ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . setIsDemoMode ( false ) ; } if ( ! ( ArduinoConnectivityPopup . isOpened ) ) { ArduinoConnectivityPopup . isOpened = true ; new ArduinoConnectivityPopup ( activity ) . show ( ) ; } } } ) ; } } , 500 ) ; activity . getOnConnectionLostHandler ( ) . canInvokeOnCloseConnection = true ; ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . setArduinoFirmataEventHandler ( sheeldsFirmataHandler ) ; if ( ( ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getAppFirmata ( ) ) == null ) || ( ( ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getAppFirmata ( ) ) != null ) && ( ! ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getAppFirmata ( ) . isOpen ( ) ) ) ) ) { if ( ( ! ( ArduinoConnectivityPopup . isOpened ) ) && ( ! ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getIsDemoMode ( ) ) ) ) { new ArduinoConnectivityPopup ( activity ) . show ( ) ; } } CrashlyticsUtils . setString ( "Current<seq2seq4repair_space>View" , "Shields<seq2seq4repair_space>List" ) ; ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getTracker ( ) . setScreenName ( "Main<seq2seq4repair_space>Shields<seq2seq4repair_space>List" ) ;

Fix:
if ( ( ! ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getIsDemoMode ( ) ) ) || ( ( ( OneSheeldApplication ) ( activity . getApplication ( ) ) ) . getAppFirmata ( ) . isOpen ( ) ) ) {