mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-30 14:49:47 +02:00
This commit is contained in:
parent
9d6a467517
commit
b72aba36b8
2 changed files with 5 additions and 28 deletions
|
@ -26,7 +26,6 @@ class MainActivity : BridgeActivity() {
|
||||||
private lateinit var mConnection : ServiceConnection
|
private lateinit var mConnection : ServiceConnection
|
||||||
|
|
||||||
lateinit var pluginCallback : () -> Unit
|
lateinit var pluginCallback : () -> Unit
|
||||||
lateinit var downloaderCallback : (String, Long) -> Unit
|
|
||||||
|
|
||||||
val storageHelper = SimpleStorageHelper(this)
|
val storageHelper = SimpleStorageHelper(this)
|
||||||
val storage = SimpleStorage(this)
|
val storage = SimpleStorage(this)
|
||||||
|
@ -36,21 +35,6 @@ class MainActivity : BridgeActivity() {
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
)
|
)
|
||||||
|
|
||||||
val broadcastReceiver = object: BroadcastReceiver() {
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
|
||||||
when (intent?.action) {
|
|
||||||
DownloadManager.ACTION_DOWNLOAD_COMPLETE -> {
|
|
||||||
var thisdlid = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0L)
|
|
||||||
downloaderCallback("complete", thisdlid)
|
|
||||||
}
|
|
||||||
DownloadManager.ACTION_NOTIFICATION_CLICKED -> {
|
|
||||||
var thisdlid = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0L)
|
|
||||||
downloaderCallback("clicked", thisdlid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// TODO: Optimize using strict mode logs
|
// TODO: Optimize using strict mode logs
|
||||||
// StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
|
// StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
|
||||||
|
@ -85,17 +69,11 @@ class MainActivity : BridgeActivity() {
|
||||||
registerPlugin(AbsFileSystem::class.java)
|
registerPlugin(AbsFileSystem::class.java)
|
||||||
registerPlugin(AbsDatabase::class.java)
|
registerPlugin(AbsDatabase::class.java)
|
||||||
|
|
||||||
var filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE).apply {
|
|
||||||
addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED)
|
|
||||||
}
|
|
||||||
registerReceiver(broadcastReceiver, filter)
|
|
||||||
|
|
||||||
Paper.init(applicationContext)
|
Paper.init(applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
unregisterReceiver(broadcastReceiver)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -138,10 +116,6 @@ class MainActivity : BridgeActivity() {
|
||||||
stopService(stopIntent)
|
stopService(stopIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerBroadcastReceiver(cb: (String, Long) -> Unit) {
|
|
||||||
downloaderCallback = cb
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
storageHelper.onSaveInstanceState(outState)
|
storageHelper.onSaveInstanceState(outState)
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
|
|
|
@ -54,13 +54,16 @@ export default {
|
||||||
updatedAt() {
|
updatedAt() {
|
||||||
return this._author.updatedAt
|
return this._author.updatedAt
|
||||||
},
|
},
|
||||||
|
serverAddres() {
|
||||||
|
return this.$store.getters['user/getServerAddress']
|
||||||
|
},
|
||||||
imgSrc() {
|
imgSrc() {
|
||||||
if (!this.imagePath) return null
|
if (!this.imagePath || !this.serverAddres) return null
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
// Testing
|
// Testing
|
||||||
return `http://localhost:3333/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}`
|
return `http://localhost:3333/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}`
|
||||||
}
|
}
|
||||||
return `/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}`
|
return `${this.serverAddres}/api/authors/${this.authorId}/image?token=${this.userToken}&ts=${this.updatedAt}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue