@Test public void testAddListener() throws Exception { Context context = Mockit.setUpMock(new MockContext()); Plot plot = new MockPlot(context, "MockPlot"); ArrayList<PlotListener> listeners = Deencapsulation.getField(plot, "listeners"); assertEquals(0, listeners.size()); MockPlotListener pl1 = new MockPlotListener(); MockPlotListener pl2 = new MockPlotListener(); plot.addListener(pl1); assertEquals(1, listeners.size()); assertFalse(plot.addListener(pl1)); assertEquals(1, listeners.size()); plot.addListener(pl2); assertEquals(2, listeners.size()); }
public synchronized boolean addListener(PlotListener listener) { return !listeners.contains(listener) && listeners.add(listener); }
Plot extends View implements Resizable { public synchronized boolean addListener(PlotListener listener) { return !listeners.contains(listener) && listeners.add(listener); } }
Plot extends View implements Resizable { public synchronized boolean addListener(PlotListener listener) { return !listeners.contains(listener) && listeners.add(listener); } Plot(Context context, String title);  Plot(Context context, String title, RenderMode mode);  Plot(Context context, AttributeSet attrs);  Plot(Context context, AttributeSet attrs, int defStyle); }
Plot extends View implements Resizable { public synchronized boolean addListener(PlotListener listener) { return !listeners.contains(listener) && listeners.add(listener); } Plot(Context context, String title);  Plot(Context context, String title, RenderMode mode);  Plot(Context context, AttributeSet attrs);  Plot(Context context, AttributeSet attrs, int defStyle); DisplayDimensions getDisplayDimensions(); void setRenderMode(RenderMode mode); RenderMode getRenderMode(); synchronized boolean addListener(PlotListener listener); synchronized boolean removeListener(PlotListener listener); synchronized boolean addSeries(SeriesType series, FormatterType formatter); synchronized boolean removeSeries(SeriesType series, Class rendererClass); synchronized void removeSeries(SeriesType series); void clear(); boolean isEmpty(); FormatterType getFormatter(SeriesType series, Class rendererClass); SeriesAndFormatterList<SeriesType,FormatterType> getSeriesAndFormatterListForRenderer(Class rendererClass); Set<SeriesType> getSeriesSet(); List<SeriesType> getSeriesListForRenderer(Class rendererClass); RendererType getRenderer(Class rendererClass); List<RendererType> getRendererList(); void setMarkupEnabled(boolean enabled); void redraw(); @Override synchronized void layout(final DisplayDimensions dims); void setBorderStyle(BorderStyle style, Float radiusX, Float radiusY); String getTitle(); void setTitle(String title); LayoutManager getLayoutManager(); void setLayoutManager(LayoutManager layoutManager); TextLabelWidget getTitleWidget(); void setTitleWidget(TextLabelWidget titleWidget); Paint getBackgroundPaint(); void setBackgroundPaint(Paint backgroundPaint); void setPlotMargins(float left, float top, float right, float bottom); void setPlotPadding(float left, float top, float right, float bottom); float getPlotMarginTop(); void setPlotMarginTop(float plotMarginTop); float getPlotMarginBottom(); void setPlotMarginBottom(float plotMarginBottom); float getPlotMarginLeft(); void setPlotMarginLeft(float plotMarginLeft); float getPlotMarginRight(); void setPlotMarginRight(float plotMarginRight); float getPlotPaddingTop(); void setPlotPaddingTop(float plotPaddingTop); float getPlotPaddingBottom(); void setPlotPaddingBottom(float plotPaddingBottom); float getPlotPaddingLeft(); void setPlotPaddingLeft(float plotPaddingLeft); float getPlotPaddingRight(); void setPlotPaddingRight(float plotPaddingRight); Paint getBorderPaint(); void setBorderPaint(Paint borderPaint); }
Plot extends View implements Resizable { public synchronized boolean addListener(PlotListener listener) { return !listeners.contains(listener) && listeners.add(listener); } Plot(Context context, String title);  Plot(Context context, String title, RenderMode mode);  Plot(Context context, AttributeSet attrs);  Plot(Context context, AttributeSet attrs, int defStyle); DisplayDimensions getDisplayDimensions(); void setRenderMode(RenderMode mode); RenderMode getRenderMode(); synchronized boolean addListener(PlotListener listener); synchronized boolean removeListener(PlotListener listener); synchronized boolean addSeries(SeriesType series, FormatterType formatter); synchronized boolean removeSeries(SeriesType series, Class rendererClass); synchronized void removeSeries(SeriesType series); void clear(); boolean isEmpty(); FormatterType getFormatter(SeriesType series, Class rendererClass); SeriesAndFormatterList<SeriesType,FormatterType> getSeriesAndFormatterListForRenderer(Class rendererClass); Set<SeriesType> getSeriesSet(); List<SeriesType> getSeriesListForRenderer(Class rendererClass); RendererType getRenderer(Class rendererClass); List<RendererType> getRendererList(); void setMarkupEnabled(boolean enabled); void redraw(); @Override synchronized void layout(final DisplayDimensions dims); void setBorderStyle(BorderStyle style, Float radiusX, Float radiusY); String getTitle(); void setTitle(String title); LayoutManager getLayoutManager(); void setLayoutManager(LayoutManager layoutManager); TextLabelWidget getTitleWidget(); void setTitleWidget(TextLabelWidget titleWidget); Paint getBackgroundPaint(); void setBackgroundPaint(Paint backgroundPaint); void setPlotMargins(float left, float top, float right, float bottom); void setPlotPadding(float left, float top, float right, float bottom); float getPlotMarginTop(); void setPlotMarginTop(float plotMarginTop); float getPlotMarginBottom(); void setPlotMarginBottom(float plotMarginBottom); float getPlotMarginLeft(); void setPlotMarginLeft(float plotMarginLeft); float getPlotMarginRight(); void setPlotMarginRight(float plotMarginRight); float getPlotPaddingTop(); void setPlotPaddingTop(float plotPaddingTop); float getPlotPaddingBottom(); void setPlotPaddingBottom(float plotPaddingBottom); float getPlotPaddingLeft(); void setPlotPaddingLeft(float plotPaddingLeft); float getPlotPaddingRight(); void setPlotPaddingRight(float plotPaddingRight); Paint getBorderPaint(); void setBorderPaint(Paint borderPaint);  }