diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000..eca030f Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ diff --git a/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt b/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt index db781b2..ec402a8 100644 --- a/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt +++ b/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt @@ -11,12 +11,13 @@ import android.support.v4.app.ActivityCompat import android.support.v4.content.ContextCompat import android.support.v7.app.AppCompatActivity import android.view.View -import io.github.jeffshee.visualizer.painters.fft.FftCircle -import io.github.jeffshee.visualizer.painters.fft.FftWave -import io.github.jeffshee.visualizer.painters.misc.Background +import android.widget.Toast +import io.github.jeffshee.visualizer.painters.fft.* import io.github.jeffshee.visualizer.painters.misc.SimpleIcon +import io.github.jeffshee.visualizer.painters.modifier.Beat +import io.github.jeffshee.visualizer.painters.modifier.Move +import io.github.jeffshee.visualizer.painters.modifier.Rotate import io.github.jeffshee.visualizer.painters.modifier.Shake -import io.github.jeffshee.visualizer.painters.modifier.Zoom import io.github.jeffshee.visualizer.painters.waveform.Waveform import io.github.jeffshee.visualizer.utils.Preset import io.github.jeffshee.visualizer.utils.VisualizerHelper @@ -28,6 +29,7 @@ class MainActivity : AppCompatActivity() { private lateinit var background: Bitmap private lateinit var bitmap: Bitmap private lateinit var circleBitmap: Bitmap + private var current = 0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -72,13 +74,33 @@ class MainActivity : AppCompatActivity() { circleBitmap = SimpleIcon.getCircledBitmap(bitmap) helper = VisualizerHelper(0) - visual.setPainterList( - helper, listOf( + val painterLists = listOf( + listOf(FftBar(), Move(FftWave(), yR = .5f)), + listOf(FftLine(), Move(FftWaveRgb(), yR = .5f)), + listOf(Rotate(SimpleIcon(circleBitmap).apply { radiusR = .5f }).apply { rpm = 2f }), + listOf(Preset.getPresetWithBitmap("cIcon", circleBitmap)), + listOf(Beat(Preset.getPresetWithBitmap("cIcon", circleBitmap))), + listOf( + Waveform().apply { paint.alpha = 150 }, + Shake(Preset.getPresetWithBitmap("cWaveRgbIcon", circleBitmap)).apply { + animX.duration = 1000 + animY.duration = 2000 + }), + listOf( Preset.getPresetWithBitmap("liveBg", background), - FftCircle().apply { paint.strokeWidth = 8f;paint.strokeCap = Paint.Cap.ROUND } ) ) + visual.setPainterList( + helper, painterLists[current] + ) + visual.setOnLongClickListener { + if (current < painterLists.lastIndex) current++ else current = 0 + visual.setPainterList(helper, painterLists[current]) + true + } + + Toast.makeText(this, "Try long-click \ud83d\ude09", Toast.LENGTH_LONG).show() } override fun onDestroy() { diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 898f3ed..0d01c2a 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 64ba76f..cf64194 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index e5ed465..5f8d840 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index b0907ca..68188e9 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 2c18de9..925eceb 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/visualizer/src/main/java/io/github/jeffshee/visualizer/views/VisualizerView.kt b/visualizer/src/main/java/io/github/jeffshee/visualizer/views/VisualizerView.kt index b23cde9..6bbe36a 100644 --- a/visualizer/src/main/java/io/github/jeffshee/visualizer/views/VisualizerView.kt +++ b/visualizer/src/main/java/io/github/jeffshee/visualizer/views/VisualizerView.kt @@ -54,15 +54,17 @@ class VisualizerView : View { override fun onDraw(canvas: Canvas?) { super.onDraw(canvas) - setLayerType(LAYER_TYPE_HARDWARE, paint) - canvas?.apply { - painterList.forEach { - it.calc(helper) - it.draw(canvas, helper) } - simpleText.text = "FPS: ${frameManager.fps()}" - if (fps) simpleText.draw(canvas, helper) + if(this::painterList.isInitialized && this::helper.isInitialized){ + setLayerType(LAYER_TYPE_HARDWARE, paint) + canvas?.apply { + painterList.forEach { + it.calc(helper) + it.draw(canvas, helper) } + simpleText.text = "FPS: ${frameManager.fps()}" + if (fps) simpleText.draw(canvas, helper) + } + frameManager.tick() + if (anim) invalidate() } - frameManager.tick() - if (anim) invalidate() } } \ No newline at end of file