mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 13:12:09 +08:00
添加退出日志
This commit is contained in:
parent
719aeaf49f
commit
2f0beb7755
@ -52,6 +52,7 @@ public class UtilsModule extends ReactContextBaseJavaModule {
|
|||||||
|
|
||||||
// https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically
|
// https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically
|
||||||
Activity currentActivity = reactContext.getCurrentActivity();
|
Activity currentActivity = reactContext.getCurrentActivity();
|
||||||
|
Log.d("Utils", "Exit app...");
|
||||||
if (currentActivity == null) {
|
if (currentActivity == null) {
|
||||||
Log.d("Utils", "killProcess");
|
Log.d("Utils", "killProcess");
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
|
@ -49,7 +49,8 @@ export const setLanguage = (locale: Parameters<typeof applyLanguage>[0]) => {
|
|||||||
|
|
||||||
|
|
||||||
let isDestroying = false
|
let isDestroying = false
|
||||||
export const exitApp = () => {
|
export const exitApp = (reason: string) => {
|
||||||
|
console.log('Handle Exit App, Reason: ' + reason)
|
||||||
if (isDestroying) return
|
if (isDestroying) return
|
||||||
isDestroying = true
|
isDestroying = true
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
@ -17,7 +17,7 @@ const timeoutTools = {
|
|||||||
global.lx.isPlayedStop = true
|
global.lx.isPlayedStop = true
|
||||||
this.callHooks()
|
this.callHooks()
|
||||||
} else {
|
} else {
|
||||||
exitApp()
|
exitApp('Timeout Exit')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getTime() {
|
getTime() {
|
||||||
|
@ -18,9 +18,9 @@ let isInitialized = false
|
|||||||
// let isPlaying = false
|
// let isPlaying = false
|
||||||
|
|
||||||
// 销毁播放器并退出
|
// 销毁播放器并退出
|
||||||
const handleExitApp = async() => {
|
const handleExitApp = async(reason: string) => {
|
||||||
global.lx.isPlayedStop = false
|
global.lx.isPlayedStop = false
|
||||||
exitApp()
|
exitApp(reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ const registerPlaybackService = async() => {
|
|||||||
|
|
||||||
TrackPlayer.addEventListener(TPEvent.RemoteStop, () => {
|
TrackPlayer.addEventListener(TPEvent.RemoteStop, () => {
|
||||||
// console.log('remote-stop')
|
// console.log('remote-stop')
|
||||||
void handleExitApp()
|
void handleExitApp('Remote Stop')
|
||||||
})
|
})
|
||||||
|
|
||||||
// TrackPlayer.addEventListener(TPEvent.RemoteDuck, async({ permanent, paused, ducking }) => {
|
// TrackPlayer.addEventListener(TPEvent.RemoteDuck, async({ permanent, paused, ducking }) => {
|
||||||
@ -105,7 +105,7 @@ const registerPlaybackService = async() => {
|
|||||||
// console.log('playback-state', info)
|
// console.log('playback-state', info)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (global.lx.isPlayedStop) return handleExitApp()
|
if (global.lx.isPlayedStop) return handleExitApp('Timeout Exit')
|
||||||
|
|
||||||
// console.log('currentIsPlaying', currentIsPlaying, global.lx.playInfo.isPlaying)
|
// console.log('currentIsPlaying', currentIsPlaying, global.lx.playInfo.isPlaying)
|
||||||
// void updateMetaData(global.lx.store_playMusicInfo.musicInfo, currentIsPlaying)
|
// void updateMetaData(global.lx.store_playMusicInfo.musicInfo, currentIsPlaying)
|
||||||
@ -114,7 +114,7 @@ const registerPlaybackService = async() => {
|
|||||||
// console.log('PlaybackTrackChanged====>', info)
|
// console.log('PlaybackTrackChanged====>', info)
|
||||||
global.lx.playerTrackId = await getCurrentTrackId()
|
global.lx.playerTrackId = await getCurrentTrackId()
|
||||||
if (info.track == null) return
|
if (info.track == null) return
|
||||||
if (global.lx.isPlayedStop) return handleExitApp()
|
if (global.lx.isPlayedStop) return handleExitApp('Timeout Exit')
|
||||||
|
|
||||||
// console.log('global.lx.playerTrackId====>', global.lx.playerTrackId)
|
// console.log('global.lx.playerTrackId====>', global.lx.playerTrackId)
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
|
@ -115,7 +115,7 @@ export default memo(() => {
|
|||||||
confirmButtonText: global.i18n.t('list_remove_tip_button'),
|
confirmButtonText: global.i18n.t('list_remove_tip_button'),
|
||||||
}).then(isExit => {
|
}).then(isExit => {
|
||||||
if (!isExit) return
|
if (!isExit) return
|
||||||
exitApp()
|
exitApp('Exit Btn')
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
case 'back_home':
|
case 'back_home':
|
||||||
|
@ -109,7 +109,7 @@ export default memo(() => {
|
|||||||
confirmButtonText: global.i18n.t('list_remove_tip_button'),
|
confirmButtonText: global.i18n.t('list_remove_tip_button'),
|
||||||
}).then(isExit => {
|
}).then(isExit => {
|
||||||
if (!isExit) return
|
if (!isExit) return
|
||||||
exitApp()
|
exitApp('Exit Btn')
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
case 'back_home':
|
case 'back_home':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user