From a2e64dbda3c200322e20dd3d3477e343c1e0924d Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 7 Aug 2021 09:57:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=8C=E8=AF=8D=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lxmusicmobile/lyric/Lyric.java | 19 +---------------- .../com/lxmusicmobile/lyric/LyricView.java | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/android/app/src/main/java/com/lxmusicmobile/lyric/Lyric.java b/android/app/src/main/java/com/lxmusicmobile/lyric/Lyric.java index 28e2963..d57abd5 100644 --- a/android/app/src/main/java/com/lxmusicmobile/lyric/Lyric.java +++ b/android/app/src/main/java/com/lxmusicmobile/lyric/Lyric.java @@ -17,13 +17,7 @@ public class Lyric extends LyricPlayer { ReactApplicationContext reactAppContext; boolean isShowLyric = false; - boolean isLock = false; - String themeColor = "#07c556"; String lastText = "LX Music ^-^"; - int lyricViewX = 0; - int lyricViewY = 0; - String textX = "LEFT"; - String textY = "TOP"; Lyric(ReactApplicationContext reactContext) { this.reactAppContext = reactContext; @@ -77,7 +71,7 @@ public class Lyric extends LyricPlayer { lyricView.runOnUiThread(new Runnable() { @Override public void run() { - lyricView.showLyricView(isLock, themeColor, lyricViewX, lyricViewY, textX, textY); + lyricView.showLyricView(); lyricView.setLyric(lastText); setTempPause(false); } @@ -87,12 +81,6 @@ public class Lyric extends LyricPlayer { public void showLyric(boolean isLock, String themeColor, int lyricViewX, int lyricViewY, String textX, String textY) { if (lyricEvent == null) lyricEvent = new LyricEvent(reactAppContext); if (lyricView == null) lyricView = new LyricView(reactAppContext, lyricEvent); - this.isLock = isLock; - this.themeColor = themeColor; - this.lyricViewX = lyricViewX; - this.lyricViewY = lyricViewY; - this.textX = textX; - this.textY = textY; lyricView.showLyricView(isLock, themeColor, lyricViewX, lyricViewY, textX, textY); isShowLyric = true; } @@ -129,13 +117,11 @@ public class Lyric extends LyricPlayer { public void lockLyric() { if (lyricView == null) return; - this.isLock = true; lyricView.lockView(); } public void unlockLyric() { if (lyricView == null) return; - this.isLock = false; lyricView.unlockView(); } @@ -145,12 +131,9 @@ public class Lyric extends LyricPlayer { public void setColor(String color) { lyricView.setColor(color); - this.themeColor = color; } public void setLyricTextPosition(String positionX, String positionY) { - this.textX = positionX; - this.textY = positionY; lyricView.setLyricTextPosition(positionX, positionY); } } diff --git a/android/app/src/main/java/com/lxmusicmobile/lyric/LyricView.java b/android/app/src/main/java/com/lxmusicmobile/lyric/LyricView.java index 82d87bd..bd3ebd4 100644 --- a/android/app/src/main/java/com/lxmusicmobile/lyric/LyricView.java +++ b/android/app/src/main/java/com/lxmusicmobile/lyric/LyricView.java @@ -43,12 +43,18 @@ public class LyricView extends Activity implements View.OnTouchListener { private float preY = 0; // private static boolean isVibrated = false; + private boolean isLock = false; + private String themeColor = "#07c556"; + private String lastText = "LX Music ^-^"; + private String textX = "LEFT"; + private String textY = "TOP"; + LyricView(ReactApplicationContext reactContext, LyricEvent lyricEvent) { this.reactContext = reactContext; this.lyricEvent = lyricEvent; } - private void sendPositionEvent(int x, int y) { + public void sendPositionEvent(int x, int y) { WritableMap params = Arguments.createMap(); params.putInt("x", x); params.putInt("y", y); @@ -76,6 +82,19 @@ public class LyricView extends Activity implements View.OnTouchListener { // } public void showLyricView(boolean isLock, String themeColor, int lyricViewX, int lyricViewY, String textX, String textY) { + this.isLock = isLock; + this.themeColor = themeColor; + this.prevViewX = lyricViewX; + this.prevViewY = lyricViewY; + this.textX = textX; + this.textY = textY; + handleShowLyric(isLock, themeColor, lyricViewX, lyricViewY, textX, textY); + } + public void showLyricView() { + handleShowLyric(isLock, themeColor, prevViewX, prevViewY, textX, textY); + } + + private void handleShowLyric(boolean isLock, String themeColor, int lyricViewX, int lyricViewY, String textX, String textY) { if (windowManager == null) { windowManager = (WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE); //设置TextView的属性