[merge] Merge branch 'dev-optimize1'
This commit is contained in:
@@ -24,6 +24,7 @@ _🚀This is the client of the multimedia server Abyss, which can also be extend
|
|||||||
### High Priority
|
### High Priority
|
||||||
- [x] Fix tablet full-screen mode bug
|
- [x] Fix tablet full-screen mode bug
|
||||||
- [x] Hide private key after user input
|
- [x] Hide private key after user input
|
||||||
|
- [x] Optimize API call logic, do not create crashes
|
||||||
- [ ] Replace Android robot icon with custom design
|
- [ ] Replace Android robot icon with custom design
|
||||||
- [ ] Configure server baseURL in client settings
|
- [ ] Configure server baseURL in client settings
|
||||||
- [ ] Implement proper access control for directory queries
|
- [ ] Implement proper access control for directory queries
|
||||||
|
|||||||
@@ -13,22 +13,38 @@ object MediaManager
|
|||||||
|
|
||||||
suspend fun listVideoKlasses(): List<String>
|
suspend fun listVideoKlasses(): List<String>
|
||||||
{
|
{
|
||||||
val j = ApiClient.api.getVideoClasses(token)
|
try
|
||||||
return j.toList()
|
{
|
||||||
|
val j = ApiClient.api.getVideoClasses(token)
|
||||||
|
return j.toList()
|
||||||
|
}catch(e: Exception)
|
||||||
|
{
|
||||||
|
return listOf()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun listVideos(klass: String): List<Video>
|
suspend fun listVideos(klass: String): List<Video>
|
||||||
{
|
{
|
||||||
val j = ApiClient.api.queryVideoClasses(klass, token)
|
try {
|
||||||
return j.map{
|
val j = ApiClient.api.queryVideoClasses(klass, token)
|
||||||
queryVideo(klass, it)
|
return j.map{
|
||||||
}.toList()
|
queryVideo(klass, it)!!
|
||||||
|
}.toList()
|
||||||
|
}catch (e: Exception)
|
||||||
|
{
|
||||||
|
return listOf()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun queryVideo(klass: String, id: String): Video
|
suspend fun queryVideo(klass: String, id: String): Video?
|
||||||
{
|
{
|
||||||
val j = ApiClient.api.queryVideo(klass, id, token)
|
try {
|
||||||
return Video(klass = klass, id = id, token=token, j)
|
val j = ApiClient.api.queryVideo(klass, id, token)
|
||||||
|
return Video(klass = klass, id = id, token=token, j)
|
||||||
|
}catch (e: Exception)
|
||||||
|
{
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun listComics() : List<String>
|
suspend fun listComics() : List<String>
|
||||||
|
|||||||
@@ -50,9 +50,11 @@ object RecentManager
|
|||||||
try{
|
try{
|
||||||
val r = Json.decodeFromString<List<VideoQueryIndex>>(content)
|
val r = Json.decodeFromString<List<VideoQueryIndex>>(content)
|
||||||
|
|
||||||
_recent.value = r.map{
|
val vn = r.map{
|
||||||
MediaManager.queryVideo(it.klass, it.id)
|
MediaManager.queryVideo(it.klass, it.id)
|
||||||
}
|
}.filter { it != null }
|
||||||
|
|
||||||
|
_recent.value = vn.map { it!! }
|
||||||
return r
|
return r
|
||||||
}catch (e: Exception)
|
}catch (e: Exception)
|
||||||
{
|
{
|
||||||
@@ -82,9 +84,12 @@ object RecentManager
|
|||||||
|
|
||||||
if(o.size >= 21)
|
if(o.size >= 21)
|
||||||
o.removeAt(o.size - 1)
|
o.removeAt(o.size - 1)
|
||||||
_recent.value = o.map{
|
|
||||||
|
val vn = o.map{
|
||||||
MediaManager.queryVideo(it.klass, it.id)
|
MediaManager.queryVideo(it.klass, it.id)
|
||||||
}
|
}.filter { it != null }
|
||||||
|
_recent.value = vn.map { it!! }
|
||||||
|
|
||||||
writeFile(context, "recent.json", Json.encodeToString(o))
|
writeFile(context, "recent.json", Json.encodeToString(o))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import androidx.compose.ui.unit.sp
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.acitelight.aether.Global
|
import com.acitelight.aether.Global
|
||||||
|
import com.acitelight.aether.service.MediaManager
|
||||||
import com.acitelight.aether.service.RecentManager
|
import com.acitelight.aether.service.RecentManager
|
||||||
import com.acitelight.aether.viewModel.HomeScreenViewModel
|
import com.acitelight.aether.viewModel.HomeScreenViewModel
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ fun HomeScreen(homeScreenViewModel: HomeScreenViewModel = viewModel(), navContro
|
|||||||
.padding(horizontal = 12.dp),
|
.padding(horizontal = 12.dp),
|
||||||
i,
|
i,
|
||||||
{
|
{
|
||||||
|
Global.sameClassVideos = recent
|
||||||
val route = "video_player_route/${ "${i.klass}/${i.id}".toHex() }"
|
val route = "video_player_route/${ "${i.klass}/${i.id}".toHex() }"
|
||||||
navController.navigate(route)
|
navController.navigate(route)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -914,6 +914,7 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel)
|
|||||||
@Composable
|
@Composable
|
||||||
fun MiniVideoCard(modifier: Modifier, video: Video, onClick: () -> Unit)
|
fun MiniVideoCard(modifier: Modifier, video: Video, onClick: () -> Unit)
|
||||||
{
|
{
|
||||||
|
var isImageLoaded by remember { mutableStateOf(false) }
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.height(80.dp).fillMaxWidth(),
|
modifier = modifier.height(80.dp).fillMaxWidth(),
|
||||||
colors = CardColors(
|
colors = CardColors(
|
||||||
@@ -932,6 +933,11 @@ fun MiniVideoCard(modifier: Modifier, video: Video, onClick: () -> Unit)
|
|||||||
.data(video.getCover())
|
.data(video.getCover())
|
||||||
.memoryCacheKey("${video.klass}/${video.id}/cover")
|
.memoryCacheKey("${video.klass}/${video.id}/cover")
|
||||||
.diskCacheKey("${video.klass}/${video.id}/cover")
|
.diskCacheKey("${video.klass}/${video.id}/cover")
|
||||||
|
.listener(
|
||||||
|
onStart = { },
|
||||||
|
onSuccess = { _, _ -> isImageLoaded = true },
|
||||||
|
onError = { _, _ -> }
|
||||||
|
)
|
||||||
.build(),
|
.build(),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class VideoPlayerViewModel() : ViewModel()
|
|||||||
|
|
||||||
remember {
|
remember {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
video = MediaManager.queryVideo(v.split("/")[0], v.split("/")[1])
|
video = MediaManager.queryVideo(v.split("/")[0], v.split("/")[1])!!
|
||||||
RecentManager.Push(context, VideoQueryIndex(v.split("/")[0], v.split("/")[1]))
|
RecentManager.Push(context, VideoQueryIndex(v.split("/")[0], v.split("/")[1]))
|
||||||
_player = ExoPlayer.Builder(context).build().apply {
|
_player = ExoPlayer.Builder(context).build().apply {
|
||||||
val url = video?.getVideo() ?: ""
|
val url = video?.getVideo() ?: ""
|
||||||
|
|||||||
Reference in New Issue
Block a user