-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* [maro/#13] feat : ViewPager Banner * [maro/#13] feat : ViewPager Background * [maro/#13] feat : ViewPager Indicator, CircleIndicator, Auto Slide * [maro/#13] feat : 3주차 완성 * [maro/#13] fix : AlbumFragment.kt 수정
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.example.umc_6th | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.setFragmentResultListener | ||
import com.example.umc_6th.databinding.FragmentAlbumBinding | ||
import com.example.umc_6th.databinding.FragmentAlbumBinding.inflate | ||
import com.example.umc_6th.databinding.FragmentSongBinding | ||
import com.google.android.material.tabs.TabLayoutMediator | ||
|
||
class AlbumFragment : Fragment() { | ||
lateinit var binding: FragmentAlbumBinding | ||
|
||
private val information = arrayListOf("수록곡","상세정보","영상") | ||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = inflate(inflater,container,false) | ||
binding.albumBackIv.setOnClickListener{ | ||
(context as MainActivity).supportFragmentManager.beginTransaction(). | ||
replace(R.id.main_frm,HomeFragment()). | ||
commitAllowingStateLoss() | ||
} | ||
|
||
val albumAdapter = AlbumVPAdapter(this) | ||
binding.albumContentVp.adapter = albumAdapter | ||
|
||
|
||
setFragmentResultListener("TitleInfo") { requestKey, bundle -> | ||
binding.albumTitleTv.text = bundle.getString("title") | ||
} | ||
setFragmentResultListener("SingerInfo") { requestKey, bundle -> | ||
binding.albumSingerTv.text = bundle.getString("singer") | ||
} | ||
|
||
TabLayoutMediator(binding.albumContentTb,binding.albumContentVp){ | ||
tab, position -> | ||
tab.text = information[position] | ||
}.attach() | ||
|
||
return binding.root | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
|
||
class AlbumVPAdapter(fragment : Fragment) : FragmentStateAdapter(fragment) { | ||
override fun getItemCount(): Int = 3 | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
return when(position) { | ||
0 -> SongFragment() | ||
1 -> DetailFragment() | ||
else -> VideoFragment() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.example.umc_6th | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.example.umc_6th.databinding.FragmentBannerBinding | ||
|
||
class BannerFragment(val imgRes : Int) : Fragment() { | ||
|
||
lateinit var binding : FragmentBannerBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = FragmentBannerBinding.inflate(inflater, container, false) | ||
binding.bannerImageIv.setImageResource(imgRes) | ||
return binding.root | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.viewpager2.adapter.FragmentStateAdapter | ||
|
||
class BannerVPAdapter(fragment : Fragment) : FragmentStateAdapter(fragment) { | ||
private val fragmentList : ArrayList<Fragment> = ArrayList() | ||
|
||
override fun getItemCount(): Int { | ||
return fragmentList.size | ||
} | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
return fragmentList[position] | ||
} | ||
|
||
fun addFragment(fragment: Fragment) { | ||
fragmentList.add(fragment) | ||
notifyItemInserted(fragmentList.size-1) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.example.umc_6th | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.example.umc_6th.databinding.FragmentDetailBinding | ||
|
||
class DetailFragment : Fragment() { | ||
|
||
lateinit var binding: FragmentDetailBinding | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = FragmentDetailBinding.inflate(inflater,container,false) | ||
|
||
return binding.root | ||
} | ||
} |