Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot fix 0.1.4-beta #116

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
//material design3
implementation("com.google.android.material:material:1.9.0")
implementation("com.google.android.material:material:1.10.0")
//runtime
implementation("androidx.startup:startup-runtime:1.1.1")
implementation(project(mapOf("path" to ":kotlinYtmusicScraper")))
Expand Down Expand Up @@ -93,8 +93,8 @@ dependencies {
//Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
//Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.7.3")
implementation("androidx.navigation:navigation-ui-ktx:2.7.3")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.4")
implementation("androidx.navigation:navigation-ui-ktx:2.7.4")

implementation("com.google.code.gson:gson:2.10.1")

Expand All @@ -113,8 +113,8 @@ dependencies {
//fragment ktx
implementation("androidx.fragment:fragment-ktx:1.6.1")
//Hilt
implementation("com.google.dagger:hilt-android:2.48")
ksp("com.google.dagger:hilt-compiler:2.48")
implementation("com.google.dagger:hilt-android:2.48.1")
ksp("com.google.dagger:hilt-compiler:2.48.1")
ksp("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.7.0")
//DataStore
implementation("androidx.datastore:datastore-preferences:1.0.0")
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>

<application
android:name=".SimpMusicApplication"
Expand Down Expand Up @@ -133,9 +134,6 @@
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService"/>
</intent-filter>
</service>
<service android:name=".service.test.source.FetchQueue">

</service>
<service android:name=".service.test.download.MusicDownloadService"
android:exported="false">
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/maxrave/simpmusic/SimpMusicApplication.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.maxrave.simpmusic

import android.app.Application
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.media3.common.util.UnstableApi
import cat.ereza.customactivityoncrash.config.CaocConfig
Expand All @@ -26,4 +27,15 @@ class SimpMusicApplication: Application(){
.restartActivity(MainActivity::class.java) //default: null (your app's launch activity)
.apply()
}

override fun onLowMemory() {
super.onLowMemory()
Log.w("Low Memory", "Checking")
}

override fun onTerminate() {
super.onTerminate()

Log.w("Terminate", "Checking")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import com.maxrave.simpmusic.data.model.explore.mood.genre.ItemsPlaylist
import com.maxrave.simpmusic.databinding.ItemMoodMomentPlaylistBinding

class GenreItemAdapter(private var genreList: ArrayList<ItemsPlaylist>, val context: Context, val navController: NavController): RecyclerView.Adapter<GenreItemAdapter.ViewHolder>() {
inner class ViewHolder(val binding: ItemMoodMomentPlaylistBinding): RecyclerView.ViewHolder(binding.root) {
inner class ViewHolder(val binding: ItemMoodMomentPlaylistBinding): RecyclerView.ViewHolder(binding.root)

}
fun updateData(newList: ArrayList<ItemsPlaylist>){
genreList.clear()
genreList.addAll(newList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import com.maxrave.simpmusic.data.model.explore.mood.moodmoments.Item
import com.maxrave.simpmusic.databinding.ItemMoodMomentPlaylistBinding

class MoodItemAdapter(private var itemList: ArrayList<Item>, val context: Context, val navController: NavController): RecyclerView.Adapter<MoodItemAdapter.ViewHolder>() {
inner class ViewHolder(val binding: ItemMoodMomentPlaylistBinding): RecyclerView.ViewHolder(binding.root) {
inner class ViewHolder(val binding: ItemMoodMomentPlaylistBinding): RecyclerView.ViewHolder(binding.root)

}
fun updateData(newList: ArrayList<Item>){
itemList.clear()
itemList.addAll(newList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.maxrave.simpmusic.adapter.playlist
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.ImageLoader
import coil.request.ImageRequest
import com.maxrave.simpmusic.R
import com.maxrave.simpmusic.data.db.entities.SongEntity
import com.maxrave.simpmusic.data.model.browse.album.Track
Expand Down Expand Up @@ -59,18 +61,16 @@ class PlaylistItemAdapter(private var playlistItemList: ArrayList<Any>): Recycle
binding.tvSongArtist.text = song.artistName?.connectArtists()
binding.tvSongTitle.isSelected = true
binding.tvSongArtist.isSelected = true
binding.ivThumbnail.load(song.thumbnails) {
placeholder(R.drawable.holder)
}
binding.ivThumbnail.load(song.thumbnails)
}
}
fun updateList(newList: ArrayList<Any>){
Log.d("PlaylistItemAdapter", "updateList: ${newList.toString()}")
Log.d("PlaylistItemAdapter", "updateList: $newList")
playlistItemList.clear()
newList.forEach {
playlistItemList.add(it)
}
Log.d("PlaylistItemAdapter", "updateList: ${playlistItemList.toString()}")
Log.d("PlaylistItemAdapter", "updateList: $playlistItemList")
notifyDataSetChanged()
}

Expand Down Expand Up @@ -113,4 +113,17 @@ class PlaylistItemAdapter(private var playlistItemList: ArrayList<Any>): Recycle
private const val VIEW_TYPE_TRACK = 0
private const val VIEW_TYPE_LOCAL_PLAYLIST_TRACK = 1
}

fun ImageView.load(url: String?) {
if (url != null) {
ImageLoader(context).enqueue(
ImageRequest.Builder(context)
.placeholder(R.drawable.holder)
.data(url)
.diskCacheKey(url)
.target(this)
.build()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.maxrave.simpmusic.data.dataStore

import android.content.Context
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
Expand All @@ -10,7 +9,6 @@ import androidx.media3.common.Player
import com.maxrave.simpmusic.common.SELECTED_LANGUAGE
import com.maxrave.simpmusic.common.SPONSOR_BLOCK
import com.maxrave.simpmusic.common.SUPPORTED_LANGUAGE
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
Expand All @@ -19,7 +17,7 @@ import kotlinx.coroutines.withContext
import javax.inject.Inject
import com.maxrave.simpmusic.common.QUALITY as COMMON_QUALITY

class DataStoreManager @Inject constructor(@ApplicationContext appContext: Context, private val settingsDataStore: DataStore<Preferences>) {
class DataStoreManager @Inject constructor(private val settingsDataStore: DataStore<Preferences>) {

val location: Flow<String> = settingsDataStore.data.map { preferences ->
preferences[LOCATION] ?: "VN"
Expand Down Expand Up @@ -234,6 +232,7 @@ class DataStoreManager @Inject constructor(@ApplicationContext appContext: Conte
preferences[RECENT_SONG_POSITION_KEY] ?: "0"
}
suspend fun saveRecentSong (mediaId: String, position: Long) {
Log.w("saveRecentSong", "$mediaId $position")
withContext(Dispatchers.IO) {
settingsDataStore.edit { settings ->
settings[RECENT_SONG_MEDIA_ID_KEY] = mediaId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ data class HomeResponse(
val homeItem: Resource<ArrayList<HomeItem>>,
val exploreMood: Resource<Mood>,
val exploreChart: Resource<Chart>
) {
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun parseSongChart(contents: List<MusicCarouselShelfRenderer.Content>): ArrayLis
var view = ""
val artists: ArrayList<Artist> = arrayListOf()
val albums: ArrayList<Album> = arrayListOf()
if (runs != null) {
if (runs != null) {
for (i in runs.indices) {
if (i.rem(2) == 0) {
if (i == runs.size -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fun parseMixedContent(data: List<SectionListRenderer.Content>?): List<HomeItem>
if (ytItem != null) {
listContent.add(
Content(
album = Album( id = musicTwoRowItemRenderer.navigationEndpoint.browseEndpoint?.browseId ?: "", name = title ?: ""),
album = Album( id = musicTwoRowItemRenderer.navigationEndpoint.browseEndpoint?.browseId ?: "", name = title),
artists = listOf(),
description = null,
isExplicit = false,
Expand Down Expand Up @@ -214,7 +214,7 @@ fun parseMixedContent(data: List<SectionListRenderer.Content>?): List<HomeItem>
if (ytItemAlbum != null) {
listContent.add(
Content(
album = Album( id = musicTwoRowItemRenderer.navigationEndpoint.browseEndpoint?.browseId ?: "", name = title ?: ""),
album = Album( id = musicTwoRowItemRenderer.navigationEndpoint.browseEndpoint?.browseId ?: "", name = title),
artists = listOf(),
description = null,
isExplicit = false,
Expand Down Expand Up @@ -264,8 +264,8 @@ fun parseMixedContent(data: List<SectionListRenderer.Content>?): List<HomeItem>
playlistId = null,
browseId = null,
thumbnails = result1.musicResponsiveListItemRenderer!!.thumbnail?.musicThumbnailRenderer?.thumbnail?.thumbnails?.toListThumbnail() ?: listOf(),
title = ytItem.title ?: "",
videoId = ytItem.id ?: "",
title = ytItem.title,
videoId = ytItem.id,
views = "",
radio = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ fun parseMoodsMomentObject(data: BrowseResponse?): MoodsMomentObject? {
val contentTitle =
content.musicTwoRowItemRenderer?.title?.runs?.get(0)?.text
val playlistBrowseId = content.musicTwoRowItemRenderer?.navigationEndpoint?.browseEndpoint?.browseId
listContent.add(
Content(
playlistBrowseId = playlistBrowseId ?: "",
subtitle = subtitle,
thumbnails = thumbnails ?: listOf(),
title = contentTitle ?: ""
)
listContent.add(
Content(
playlistBrowseId = playlistBrowseId ?: "",
subtitle = subtitle,
thumbnails = thumbnails ?: listOf(),
title = contentTitle ?: ""
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class MainRepository @Inject constructor(private val localDataSource: LocalDataS
withContext(Dispatchers.IO) { localDataSource.insertFormat(format) }

suspend fun getFormat(videoId: String): Flow<FormatEntity?> =
flow { emit(localDataSource.getFormat(videoId)) }.flowOn(Dispatchers.IO)
flow { emit(localDataSource.getFormat(videoId)) }.flowOn(Dispatchers.Main)


suspend fun recoverQueue(temp: List<Track>) {
Expand Down Expand Up @@ -1166,7 +1166,7 @@ class MainRepository @Inject constructor(private val localDataSource: LocalDataS

suspend fun removeYouTubePlaylistItem(youtubePlaylistId: String, videoId: String) = flow {
runCatching {
getSetVideoId(videoId).collect() { setVideoId ->
getSetVideoId(videoId).collect { setVideoId ->
if (setVideoId?.setVideoId != null) {
YouTube.removeItemYouTubePlaylist(youtubePlaylistId, videoId, setVideoId.setVideoId).onSuccess {
emit(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ object LocalServiceModule {

@Provides
@Singleton
fun provideDatastoreManager(@ApplicationContext context: Context, settingsDataStore: DataStore<Preferences>): DataStoreManager = DataStoreManager(context, settingsDataStore)
fun provideDatastoreManager(settingsDataStore: DataStore<Preferences>): DataStoreManager = DataStoreManager(
settingsDataStore
)
}
Loading