@Test public void addOnConsoleListenerInstanceShouldNotStartSecondListener() { OnConsoleStatusListener ocl0 = new OnConsoleStatusListener(); OnConsoleStatusListener ocl1 = new OnConsoleStatusListener(); StatusListenerConfigHelper.addOnConsoleListenerInstance(context, ocl0); { List<StatusListener> listeners = sm.getCopyOfStatusListenerList(); assertEquals(1, listeners.size()); assertTrue(ocl0.isStarted()); } StatusListenerConfigHelper.addOnConsoleListenerInstance(context, ocl1); { List<StatusListener> listeners = sm.getCopyOfStatusListenerList(); assertEquals(1, listeners.size()); assertFalse(ocl1.isStarted()); } }
static public void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener) { onConsoleStatusListener.setContext(context); boolean effectivelyAdded = context.getStatusManager().add(onConsoleStatusListener); if (effectivelyAdded) { onConsoleStatusListener.start(); } }
StatusListenerConfigHelper { static public void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener) { onConsoleStatusListener.setContext(context); boolean effectivelyAdded = context.getStatusManager().add(onConsoleStatusListener); if (effectivelyAdded) { onConsoleStatusListener.start(); } } }
StatusListenerConfigHelper { static public void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener) { onConsoleStatusListener.setContext(context); boolean effectivelyAdded = context.getStatusManager().add(onConsoleStatusListener); if (effectivelyAdded) { onConsoleStatusListener.start(); } }  }
StatusListenerConfigHelper { static public void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener) { onConsoleStatusListener.setContext(context); boolean effectivelyAdded = context.getStatusManager().add(onConsoleStatusListener); if (effectivelyAdded) { onConsoleStatusListener.start(); } }  static void installIfAsked(Context context); static void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener); }
StatusListenerConfigHelper { static public void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener) { onConsoleStatusListener.setContext(context); boolean effectivelyAdded = context.getStatusManager().add(onConsoleStatusListener); if (effectivelyAdded) { onConsoleStatusListener.start(); } }  static void installIfAsked(Context context); static void addOnConsoleListenerInstance(Context context, OnConsoleStatusListener onConsoleStatusListener);  }