@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (!active) { return; } DownloadService downloadService = DownloadServiceImpl.getInstance(); if (downloadService != null && downloadService.getPlayerState() != PlayerState.STARTED) { return; } if (data == null) { return; } if (points == null || points.length < data.length * 4) { points = new float[data.length * 4]; } int w = getWidth(); int h = getHeight(); for (int i = 0; i < data.length - 1; i++) { points[i * 4] = w * i / (data.length - 1); points[i * 4 + 1] = h / 2 + ((byte) (data[i] + 128)) * (h / 2) / 128; points[i * 4 + 2] = w * (i + 1) / (data.length - 1); points[i * 4 + 3] = h / 2 + ((byte) (data[i + 1] + 128)) * (h / 2) / 128; } canvas.drawLines(points, paint); }
private Visualizer getVizualiser() { DownloadService downloadService = DownloadServiceImpl.getInstance(); VisualizerController visualizerController = downloadService == null ? null : downloadService.getVisualizerController(); return visualizerController == null ? null : visualizerController.getVisualizer(); }