-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a way to select which song will be downloaded in the song tab a…
…nd fixed ui errors This commit contains the addition of a recycler to select the exact song to be downloaded from a list and a couple of ui errors
- Loading branch information
Showing
23 changed files
with
377 additions
and
62 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
app/src/main/java/com/example/spotifydownloader/Fragments/SelectSongFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package com.example.spotifydownloader.Fragments | ||
|
||
import android.app.Activity | ||
import android.os.Bundle | ||
import android.view.View | ||
import android.view.animation.Animation | ||
import android.view.animation.AnimationUtils | ||
import androidx.activity.OnBackPressedCallback | ||
import androidx.core.view.forEach | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.NavController | ||
import androidx.navigation.Navigation | ||
import androidx.navigation.fragment.navArgs | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.example.spotifydownloader.R | ||
import com.example.spotifydownloader.databinding.FragmentSelectSongBinding | ||
import com.example.spotifydownloader.parcels.DataSearch | ||
import com.example.spotifydownloader.rvAdaptors.SongSearchRecyclerViewAdaptor | ||
import com.google.android.material.bottomnavigation.BottomNavigationView | ||
|
||
|
||
class selectSongFragment : Fragment(R.layout.fragment_select_song) { | ||
private lateinit var binding :FragmentSelectSongBinding | ||
private lateinit var navController: NavController | ||
private val args by navArgs<selectSongFragmentArgs>() | ||
private lateinit var bottomNav : BottomNavigationView | ||
|
||
|
||
|
||
|
||
|
||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding = FragmentSelectSongBinding.bind(view) | ||
navController = Navigation.findNavController(view) | ||
bottomNav = activity?.findViewById(R.id.bottomNav)!! | ||
|
||
val rV = binding.rvSongSearch | ||
|
||
val from_top : Animation by lazy { AnimationUtils.loadAnimation((context as Activity), | ||
R.anim.from_top | ||
) } | ||
val from_bottom : Animation by lazy { AnimationUtils.loadAnimation((context as Activity), | ||
R.anim.from_bottom | ||
) } | ||
|
||
|
||
val callback = object : OnBackPressedCallback(true){ | ||
override fun handleOnBackPressed() { | ||
navController.popBackStack() | ||
bottomNav.startAnimation(from_bottom) | ||
bottomNav.menu.forEach { | ||
it.isEnabled = true | ||
} | ||
|
||
|
||
} | ||
} | ||
requireActivity().onBackPressedDispatcher.addCallback(callback) | ||
|
||
|
||
bottomNav.startAnimation(from_top) | ||
bottomNav.menu.forEach { | ||
it.isEnabled = false | ||
} | ||
|
||
|
||
val adapter = SongSearchRecyclerViewAdaptor(args.ItemListData.Items) | ||
rV.adapter = adapter | ||
rV.layoutManager = LinearLayoutManager(context) | ||
adapter.setOnItemClickListener(object :SongSearchRecyclerViewAdaptor.onItemClickListener{ | ||
override fun onItemClick(position: Int) { | ||
val regex = Regex("[^A-Za-z0-9]") | ||
val songData = args.ItemListData.Items[position] | ||
|
||
|
||
val data = DataSearch( | ||
songName = songData.name, | ||
imgUrl = songData.album.images[0].url, | ||
artistName = songData.artists[0].name, | ||
filename = regex.replace(songData.name,""), | ||
albumName = songData.album.name, | ||
albumArtistName = songData.album.artists[0].name, | ||
releaseDate = songData.album.release_date, | ||
folderUri = args.ItemListData.folderUri | ||
) | ||
val action = selectSongFragmentDirections.actionSelectSongFragmentToSongDownloadFragment2(data) | ||
navController.navigate(action) | ||
|
||
|
||
|
||
} | ||
|
||
}) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
app/src/main/java/com/example/spotifydownloader/SpotifyApi/model/Search/Item.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/example/spotifydownloader/model/Data.kt → ...example/spotifydownloader/parcels/Data.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ple/spotifydownloader/model/DataSearch.kt → ...e/spotifydownloader/parcels/DataSearch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/example/spotifydownloader/parcels/ItemListData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.spotifydownloader.parcels | ||
|
||
import android.net.Uri | ||
import android.os.Parcelable | ||
import com.example.spotifydownloader.SpotifyApi.model.Search.Item | ||
import kotlinx.parcelize.Parcelize | ||
import kotlinx.parcelize.RawValue | ||
|
||
@Parcelize | ||
data class ItemListData( | ||
var Items : @RawValue List<Item>, | ||
var folderUri: Uri? | ||
):Parcelable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.