commit
c14a5854c7
8 changed files with 28 additions and 41 deletions
|
@ -93,7 +93,7 @@ dependencies {
|
|||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation "androidx.preference:preference-ktx:$preference_version"
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||
|
|
|
@ -35,7 +35,7 @@ import kotlinx.coroutines.withContext
|
|||
import java.io.File
|
||||
|
||||
class LibraryViewModel(
|
||||
private val repository: RealRepository
|
||||
private val repository: RealRepository,
|
||||
) : ViewModel(), IMusicServiceEventListener {
|
||||
|
||||
private val _paletteColor = MutableLiveData<Int>()
|
||||
|
@ -144,12 +144,11 @@ class LibraryViewModel(
|
|||
suggestions.postValue(repository.suggestions())
|
||||
}
|
||||
|
||||
fun search(query: String?, filter: Filter) {
|
||||
fun search(query: String?, filter: Filter) =
|
||||
viewModelScope.launch(IO) {
|
||||
val result = repository.search(query, filter)
|
||||
val result =repository.search(query, filter)
|
||||
searchResults.postValue(result)
|
||||
}
|
||||
}
|
||||
|
||||
fun forceReload(reloadType: ReloadType) = viewModelScope.launch(IO) {
|
||||
when (reloadType) {
|
||||
|
@ -380,6 +379,14 @@ class LibraryViewModel(
|
|||
createPlaylist(PlaylistEntity(playlistName = playlistName))
|
||||
insertSongs(songs.map { it.toSongEntity(playlistId) })
|
||||
forceReload(Playlists)
|
||||
withContext(Main) {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext()
|
||||
.getString(R.string.playlist_created_sucessfully, playlistName),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
} else {
|
||||
val playlist = playlists.firstOrNull()
|
||||
if (playlist != null) {
|
||||
|
@ -389,34 +396,11 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
withContext(Main) {
|
||||
when {
|
||||
playlists.isEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext()
|
||||
.getString(R.string.playlist_created_sucessfully, playlistName),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
checkPlaylistExists(playlistName).isNotEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext().getString(R.string.playList_already_exits),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
playlists.isNotEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext().getString(
|
||||
R.string.added_song_count_to_playlist,
|
||||
songs.size,
|
||||
playlistName
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
Toast.makeText(App.getContext(), App.getContext().getString(
|
||||
R.string.added_song_count_to_playlist,
|
||||
songs.size,
|
||||
playlistName
|
||||
), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,10 @@ package code.name.monkey.retromusic.fragments.other
|
|||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.doOnPreDraw
|
||||
|
@ -43,7 +46,6 @@ import code.name.monkey.retromusic.interfaces.ICabCallback
|
|||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.google.android.material.chip.ChipGroup
|
|||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.transition.MaterialFadeThrough
|
||||
import kotlinx.coroutines.Job
|
||||
import net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEvent
|
||||
import java.util.*
|
||||
|
||||
|
@ -63,6 +64,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
private lateinit var searchAdapter: SearchAdapter
|
||||
private var query: String? = null
|
||||
|
||||
private var job: Job? = null
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
enterTransition = MaterialFadeThrough().addTarget(view)
|
||||
|
@ -184,7 +187,8 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
binding.voiceSearch.isGone = query.isNotEmpty()
|
||||
binding.clearText.isVisible = query.isNotEmpty()
|
||||
val filter = getFilter()
|
||||
libraryViewModel.search(query, filter)
|
||||
job?.cancel()
|
||||
job = libraryViewModel.search(query, filter)
|
||||
}
|
||||
|
||||
private fun getFilter(): Filter {
|
||||
|
|
|
@ -49,7 +49,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils;
|
||||
import code.name.monkey.retromusic.App;
|
||||
|
||||
public class RetroUtil {
|
||||
|
|
|
@ -17,12 +17,10 @@ package code.name.monkey.retromusic.util
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Adaptive" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Dark</item>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
|
||||
<style name="Theme.RetroMusic.Base.Adaptive" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue