-
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.
- HomeFragment에서 banner 부분 Viewpager 구현하기 - AlbumFragment 에 TabLayout + Viewpager 추가 구현하기 - AlbumFragment Viewpager 에 AlbumSongsFragment, AlbumDetailFragment, AlbumVideoFragment 구현하기 - [LockerFragment] 화면 TabLayout과 Viewpager로 구현하기 +디자인 수정 필요
- Loading branch information
1 parent
297ae20
commit a2518aa
Showing
11 changed files
with
819 additions
and
621 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
UMC_6th/app/src/main/java/com/example/umc_6th/AlbumSongsFragment.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,55 @@ | ||
package com.example.umc_6th | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.example.umc_6th.databinding.FragmentAlbumBinding | ||
import com.example.umc_6th.databinding.FragmentAlbumSongsBinding | ||
|
||
class AlbumSongsFragment : Fragment(R.layout.fragment_album_songs) { | ||
private var _binding: FragmentAlbumSongsBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = FragmentAlbumSongsBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
// 취향 mix 이미지 변경 | ||
binding.imgSongMixOffTag.setOnClickListener(){ | ||
binding.imgSongMixOffTag.visibility=View.GONE | ||
binding.imgSongMixOnTag.visibility=View.VISIBLE | ||
} | ||
binding.imgSongMixOnTag.setOnClickListener(){ | ||
binding.imgSongMixOnTag.visibility=View.GONE | ||
binding.imgSongMixOffTag.visibility=View.VISIBLE | ||
} | ||
|
||
binding.imgSongPlay01.setOnClickListener(){ | ||
goToSongActivity(binding.txSongTitle01.text.toString(), binding.txSongArtist01.text.toString()) | ||
} | ||
} | ||
|
||
private fun goToSongActivity(songTitle: String, songArtist: String) { | ||
val intent = Intent(activity, SongActivity::class.java).apply { | ||
putExtra("songTitle", songTitle) | ||
putExtra("songArtist", songArtist) | ||
} | ||
startActivity(intent) | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
// 메모리 누수를 방지하기 위해 binding 객체를 null로 설정 | ||
_binding = null | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
UMC_6th/app/src/main/java/com/example/umc_6th/adapter/AlbumPagerAdapter.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,20 @@ | ||
package com.example.umc_6th.adapter | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
import com.example.umc_6th.AlbumDetailFragment | ||
import com.example.umc_6th.AlbumSongsFragment | ||
import com.example.umc_6th.AlbumVideoFragment | ||
|
||
|
||
class AlbumPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) { | ||
private val fragments = listOf( | ||
AlbumSongsFragment(), | ||
AlbumDetailFragment(), | ||
AlbumVideoFragment() | ||
) | ||
|
||
override fun getItemCount(): Int = fragments.size | ||
|
||
override fun createFragment(position: Int): Fragment = fragments[position] | ||
} |
Oops, something went wrong.