Skip to content

Commit

Permalink
修复进入播放详情歌词界面后的屏幕常亮不会被取消的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed May 22, 2021
1 parent aac3f05 commit 57e57f3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
10 changes: 1 addition & 9 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
### 新增

- 新增通过歌单链接打开歌单的功能

### 优化

- 切换到播放详情歌词界面时将阻止屏幕息屏

### 修复

- 修复一个导致崩溃日志写入文件前会导致APP崩溃的莫名其妙问题
- 修复进入播放详情歌词界面后的屏幕常亮不会被取消的问题
2 changes: 2 additions & 0 deletions src/config/globalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ global.allList = null
global.globalObj = null
global.listScrollPosition = {}
global.listSort = {}

global.isScreenKeepAwake = false
6 changes: 0 additions & 6 deletions src/screens/PlayDetail/Portrait/Player/Lyric.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,13 @@ export default memo(() => {

// const imgWidth = useMemo(() => layout.width * 0.75, [layout.width])
const handleScrollToActive = useCallback((index = lineRef.current) => {
screenkeepAwake()

if (scrollViewRef.current && linesRef.current.length) {
scrollViewRef.current.scrollToIndex({
index,
animated: true,
viewPosition: 0.4,
})
}

return () => {
screenUnkeepAwake()
}
}, [])

const handleScrollBeginDrag = () => {
Expand Down
7 changes: 7 additions & 0 deletions src/screens/PlayDetail/Portrait/Player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ import { useGetter, useDispatch } from '@/store'
import PagerView from 'react-native-pager-view'
import Pic from './Pic'
import Lyric from './Lyric'
import { screenkeepAwake, screenUnkeepAwake } from '@/utils/utils'

// global.iskeep = false
export default memo(() => {
const theme = useGetter('common', 'theme')
const [pageIndex, setPageIndex] = useState(0)

const onPageSelected = useCallback(({ nativeEvent }) => {
setPageIndex(nativeEvent.position)
if (nativeEvent.position == 1) {
screenkeepAwake()
} else {
screenUnkeepAwake()
}
}, [])

const pic = useMemo(() => <Pic />, [])
Expand Down
15 changes: 11 additions & 4 deletions src/store/modules/common/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { compareVer } from '@/utils'
// import { setMaxCache } from '@/plugins/player/utils'
import { showVersionModal } from '@/navigation'
import { VERSION_STATUS } from '@/config/constant'
import { screenUnkeepAwake } from '@/utils/utils'

export const TYPES = {
updateSetting: null,
Expand Down Expand Up @@ -107,10 +108,16 @@ export const setComponentId = data => ({
type: TYPES.setComponentId,
payload: data,
})
export const removeComponentId = id => ({
type: TYPES.removeComponentId,
payload: id,
})
export const removeComponentId = id => (dispatch, getState) => {
const { common } = getState()
if (common.componentIds.playDetail == id) {
screenUnkeepAwake()
}
dispatch({
type: TYPES.removeComponentId,
payload: id,
})
}

export const setNavActiveIndex = index => ({
type: TYPES.setNavActiveIndex,
Expand Down
13 changes: 11 additions & 2 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ export const getSupportedAbis = UtilsModule.getSupportedAbis
export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority)


export const screenkeepAwake = UtilsModule.screenkeepAwake
export const screenUnkeepAwake = UtilsModule.screenUnkeepAwake
export const screenkeepAwake = () => {
if (global.isScreenKeepAwake) return
global.isScreenKeepAwake = true
UtilsModule.screenkeepAwake()
}
export const screenUnkeepAwake = () => {
// console.log('screenUnkeepAwake')
if (!global.isScreenKeepAwake) return
global.isScreenKeepAwake = false
UtilsModule.screenUnkeepAwake()
}

0 comments on commit 57e57f3

Please sign in to comment.