Skip to content

Commit

Permalink
[Maro/#13] feat :: 3주차 구현 완료 (#15)
Browse files Browse the repository at this point in the history
* [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
leesumin0526 authored Apr 24, 2024
1 parent 4eca112 commit 2267c18
Show file tree
Hide file tree
Showing 150 changed files with 2,530 additions and 23 deletions.
1 change: 1 addition & 0 deletions .idea/.name

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

6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

7 changes: 7 additions & 0 deletions .idea/misc.xml

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.

95 changes: 87 additions & 8 deletions .idea/workspace.xml

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

6 changes: 6 additions & 0 deletions UMC_6th/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ android {
viewBinding = true
}

buildFeatures {
dataBinding = true
}

defaultConfig {
applicationId = "com.example.umc_6th"
minSdk = 24
Expand Down Expand Up @@ -44,7 +48,9 @@ dependencies {

implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.fragment:fragment-ktx:1.3.0")
implementation ("androidx.viewpager2:viewpager2:1.0.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation ("me.relex:circleindicator:2.1.6")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
Expand Down
49 changes: 49 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumFragment.kt
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
}
}
16 changes: 16 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/AlbumVPAdpter.kt
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()
}
}
}
27 changes: 27 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/BannerFragment.kt
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
}
}
22 changes: 22 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/BannerVPAdapter.kt
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)
}

}
23 changes: 23 additions & 0 deletions UMC_6th/app/src/main/java/com/example/umc_6th/DetailFragment.kt
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
}
}
Loading

0 comments on commit 2267c18

Please sign in to comment.