mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 03:32:10 +08:00
切换到播放详情歌词界面时将阻止屏幕息屏
This commit is contained in:
parent
d1a558248a
commit
0a6a6d9243
@ -1,9 +1,11 @@
|
|||||||
package com.lxmusicmobile.utils;
|
package com.lxmusicmobile.utils;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
@ -96,5 +98,35 @@ public class UtilsModule extends ReactContextBaseJavaModule {
|
|||||||
promise.resolve(null);
|
promise.resolve(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void screenkeepAwake() {
|
||||||
|
// https://github.com/corbt/react-native-keep-awake/blob/master/android/src/main/java/com/corbt/keepawake/KCKeepAwake.java
|
||||||
|
final Activity activity = getCurrentActivity();
|
||||||
|
|
||||||
|
if (activity != null) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void screenUnkeepAwake() {
|
||||||
|
// https://github.com/corbt/react-native-keep-awake/blob/master/android/src/main/java/com/corbt/keepawake/KCKeepAwake.java
|
||||||
|
final Activity activity = getCurrentActivity();
|
||||||
|
|
||||||
|
if (activity != null) {
|
||||||
|
activity.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
activity.getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
### 新增
|
### 优化
|
||||||
|
|
||||||
- 新增竖屏下的播放详情页
|
- 切换到播放详情歌词界面时将阻止屏幕息屏
|
||||||
|
@ -3,6 +3,7 @@ import { View, Text, StyleSheet, FlatList } from 'react-native'
|
|||||||
import { useGetter, useDispatch } from '@/store'
|
import { useGetter, useDispatch } from '@/store'
|
||||||
import { useLayout } from '@/utils/hooks'
|
import { useLayout } from '@/utils/hooks'
|
||||||
import { useLrcPlay, useLrcSet } from '@/plugins/lyric'
|
import { useLrcPlay, useLrcSet } from '@/plugins/lyric'
|
||||||
|
import { screenkeepAwake, screenUnkeepAwake } from '@/utils/utils'
|
||||||
|
|
||||||
const LrcLine = memo(({ text, line, activeLine }) => {
|
const LrcLine = memo(({ text, line, activeLine }) => {
|
||||||
const theme = useGetter('common', 'theme')
|
const theme = useGetter('common', 'theme')
|
||||||
@ -41,12 +42,19 @@ export default memo(() => {
|
|||||||
|
|
||||||
// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
|
// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
|
||||||
const handleScrollToActive = useCallback((index = lineRef.current) => {
|
const handleScrollToActive = useCallback((index = lineRef.current) => {
|
||||||
if (!scrollViewRef.current || !linesRef.current.length) return
|
screenkeepAwake()
|
||||||
scrollViewRef.current.scrollToIndex({
|
|
||||||
index,
|
if (scrollViewRef.current && linesRef.current.length) {
|
||||||
animated: true,
|
scrollViewRef.current.scrollToIndex({
|
||||||
viewPosition: 0.4,
|
index,
|
||||||
})
|
animated: true,
|
||||||
|
viewPosition: 0.4,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
screenUnkeepAwake()
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleScrollBeginDrag = () => {
|
const handleScrollBeginDrag = () => {
|
||||||
|
@ -7,3 +7,7 @@ export const exitApp = UtilsModule.exitApp
|
|||||||
export const getSupportedAbis = UtilsModule.getSupportedAbis
|
export const getSupportedAbis = UtilsModule.getSupportedAbis
|
||||||
|
|
||||||
export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority)
|
export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority)
|
||||||
|
|
||||||
|
|
||||||
|
export const screenkeepAwake = UtilsModule.screenkeepAwake
|
||||||
|
export const screenUnkeepAwake = UtilsModule.screenUnkeepAwake
|
||||||
|
Loading…
x
Reference in New Issue
Block a user