Skip to content

Commit

Permalink
make if fast,make it better
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTFtrue committed Feb 5, 2024
1 parent 4b43e38 commit 94f13ed
Show file tree
Hide file tree
Showing 28 changed files with 684 additions and 935 deletions.
19 changes: 9 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId = "com.ztftrue.music"
minSdk = 30
targetSdk = 34
versionCode = 8
versionName = "0.1.6"
versionCode = 10
versionName = "0.1.10"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -46,13 +46,13 @@ android {
signingConfig = signingConfigs.getByName("debug")
}
getByName("debug") {
isMinifyEnabled = true
isShrinkResources = true
isMinifyEnabled = false
isShrinkResources = false

proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
// proguardFiles(
// getDefaultProguardFile("proguard-android-optimize.txt"),
// "proguard-rules.pro"
// )
signingConfig = signingConfigs.getByName("debug")
}
}
Expand Down Expand Up @@ -98,11 +98,10 @@ dependencies {
implementation("androidx.compose.material3:material3-window-size-class:1.1.2")

// splash
implementation("androidx.core:core-splashscreen")
implementation ("androidx.core:core-splashscreen:1.0.1")
// implementation("androidx.compose.material:material:1.5.4")
implementation ("androidx.constraintlayout:constraintlayout-compose:1.0.1")
//
implementation ("androidx.core:core-splashscreen:1.0.1")

// load image
implementation("io.coil-kt:coil-compose:2.5.0")
Expand Down
603 changes: 11 additions & 592 deletions app/src/main/java/com/ztftrue/music/MainActivity.kt

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/src/main/java/com/ztftrue/music/effects/DelayEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setDecay(float newDecay) {
this.decay = newDecay;
}

public boolean process(float[] floatBuffer) {
public void process(float[] floatBuffer) {
for (int i = 0; i < floatBuffer.length; i++) {
if (position >= echoBuffer.length) {
position = 0;
Expand All @@ -80,7 +80,6 @@ public boolean process(float[] floatBuffer) {
position++;
}
applyNewEchoLength();
return true;
}

public boolean isWithFeedBack() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ztftrue.music.sqlData

import androidx.room.TypeConverter
import com.google.gson.reflect.TypeToken;
import com.google.gson.reflect.TypeToken
import com.google.gson.Gson
import java.lang.reflect.Type

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/ztftrue/music/ui/home/AlbumGridView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@ import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.zIndex
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.media3.common.util.UnstableApi
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import coil.compose.rememberAsyncImagePainter
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.trackManager.ArtistManager
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.enumToStringForPlayListType
import com.ztftrue.music.utils.model.AlbumList
import com.ztftrue.music.utils.trackManager.ArtistManager


@Composable
fun AlbumGridView(
modifier: Modifier = Modifier,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
albumListDefault: SnapshotStateList<AlbumList>? = null,
type: PlayListType = PlayListType.Albums,
scrollDirection: ScrollDirectionType? = null
Expand Down Expand Up @@ -185,7 +185,7 @@ fun AlbumGridView(
fun AlbumItemView(
item: AlbumList,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Albums,
) {
val number = item.trackNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import coil.compose.rememberAsyncImagePainter
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.model.ArtistList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.enumToStringForPlayListType
import com.ztftrue.music.utils.model.ArtistList


@Composable
fun ArtistsGridView(
modifier: Modifier = Modifier,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
artistListDefault: SnapshotStateList<ArtistList>? = null,
type: PlayListType = PlayListType.Artists,
scrollDirection: ScrollDirectionType? = null
Expand Down Expand Up @@ -187,7 +187,7 @@ fun ArtistsGridView(
fun ArtistItemView(
item: ArtistList,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Artists
) {
val context = LocalContext.current
Expand Down
125 changes: 125 additions & 0 deletions app/src/main/java/com/ztftrue/music/ui/home/BaseLayout.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.ztftrue.music.ui.home

import androidx.compose.runtime.Composable
import androidx.compose.runtime.key
import androidx.media3.common.util.UnstableApi
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.ztftrue.music.MainActivity
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.Router
import com.ztftrue.music.ui.other.EditTrackPage
import com.ztftrue.music.ui.other.SearchPage
import com.ztftrue.music.ui.other.SettingsPage
import com.ztftrue.music.ui.other.TracksSelectPage
import com.ztftrue.music.ui.play.PlayingPage
import com.ztftrue.music.ui.public.QueuePage
import com.ztftrue.music.ui.public.TracksListPage
import com.ztftrue.music.utils.stringToEnumForPlayListType

@androidx.annotation.OptIn(UnstableApi::class)
@Composable
fun BaseLayout(
musicViewModel: MusicViewModel,
activity: MainActivity
) {
val navController: NavHostController = rememberNavController()
musicViewModel.navController = navController
NavHost(
navController = navController, startDestination = Router.MainView.route,
) {
composable(route = Router.MainView.route) {
key(Unit) {
if(musicViewModel.mainTabList.isNotEmpty()){
MainView(musicViewModel, activity, navController)
}
}
}
composable(
route = Router.MusicPlayerView.route,
) { _ ->
key(Unit) {
PlayingPage(navController, viewModel = musicViewModel)
}
}
composable(
route = Router.PlayListView.withArgs("{id}", "{itemType}"), arguments = listOf(),
) { backStackEntry ->
val arg = backStackEntry.arguments
key(Unit) {
if (arg != null) {
TracksListPage(
musicViewModel = musicViewModel,
navController,
stringToEnumForPlayListType(arg.getString("itemType") ?: ""),
arg.getString("id")?.toLong() ?: 0
)
}
}
}
composable(
route = Router.TracksSelectPage.withArgs("{id}", "{name}"), arguments = listOf(),
) { backStackEntry ->
val arg = backStackEntry.arguments
key(Unit) {
if (arg != null) {
TracksSelectPage(
musicViewModel = musicViewModel,
navController,
arg.getString("name"),
arg.getString("id")?.toLong()
)
}
}
}
composable(
route = Router.EditTrackPage.withArgs("{id}"), arguments = listOf(),
) { backStackEntry ->
val arg = backStackEntry.arguments
key(Unit) {
if (arg != null) {
val id = arg.getString("id")?.toLong()
if (id != null) {
EditTrackPage(
musicViewModel = musicViewModel,
navController,
id
)
}
}
}
}
composable(
route = Router.SettingsPage.route, arguments = listOf(),
) { _ ->
key(Unit) {
SettingsPage(
musicViewModel = musicViewModel,
navController,
)
}
}
composable(
route = Router.QueuePage.route, arguments = listOf(),
) { _ ->
key(Unit) {
QueuePage(
musicViewModel = musicViewModel,
navController,
)
}
}
composable(
route = Router.SearchPage.route, arguments = listOf(),
) { _ ->
key(Unit) {
SearchPage(
musicViewModel = musicViewModel,
navController,
)
}
}
}
}
8 changes: 4 additions & 4 deletions app/src/main/java/com/ztftrue/music/ui/home/FolderListView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.model.FolderList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.enumToStringForPlayListType
import com.ztftrue.music.utils.model.FolderList


@Composable
fun FolderListView(
modifier: Modifier = Modifier,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Folders
) {

Expand Down Expand Up @@ -133,7 +133,7 @@ fun FolderItemView(
item: FolderList,
musicViewModel: MusicViewModel,
modifier: Modifier,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Folders,
) {
val context = LocalContext.current
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/ztftrue/music/ui/home/GenreGridView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.zIndex
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import com.ztftrue.music.MusicViewModel
import com.ztftrue.music.R
import com.ztftrue.music.Router
import com.ztftrue.music.ui.public.AddMusicToPlayListDialog
import com.ztftrue.music.ui.public.CreatePlayListDialog
import com.ztftrue.music.utils.model.GenresList
import com.ztftrue.music.utils.OperateType
import com.ztftrue.music.utils.PlayListType
import com.ztftrue.music.utils.ScrollDirectionType
import com.ztftrue.music.utils.Utils
import com.ztftrue.music.utils.Utils.addTracksToPlayList
import com.ztftrue.music.utils.Utils.createPlayListAddTracks
import com.ztftrue.music.utils.enumToStringForPlayListType
import com.ztftrue.music.utils.model.GenresList


@Composable
fun GenreGridView(
modifier: Modifier = Modifier,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Genres,
scrollDirection: ScrollDirectionType? = null
) {
Expand Down Expand Up @@ -176,7 +176,7 @@ fun GenreGridView(
fun GenreItemView(
item: GenresList,
musicViewModel: MusicViewModel,
navController: NavController,
navController: NavHostController,
type: PlayListType = PlayListType.Genres
) {
val context = LocalContext.current
Expand Down
Loading

0 comments on commit 94f13ed

Please sign in to comment.