-
Notifications
You must be signed in to change notification settings - Fork 0
mission3_miles (1) #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: miles-flo-clone
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 나중에 Fragment의 생명주기에서 다룰 내용이긴 하지만 Fragment의 생성 단계가 onCreateView -> onViewCreated가 있습니다. onCreateView에서는 View가 처음 생성되고 초기화되는 부분을 담당하고 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| 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 com.google.android.material.tabs.TabLayoutMediator | ||
| import com.jihyun.floclonecoding.databinding.FragmentAlbumBinding | ||
|
|
||
| class AlbumFragment : Fragment() { | ||
| lateinit var binding : FragmentAlbumBinding | ||
|
|
||
| private val information = arrayListOf("수록곡", "상세정보", "영상") | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = FragmentAlbumBinding.inflate(inflater, container, false) | ||
|
|
||
| binding.albumAlbumIv.setOnClickListener { | ||
| (context as MainActivity).supportFragmentManager.beginTransaction(). | ||
| replace(R.id.main_frm,HomeFragment()). | ||
| commitAllowingStateLoss() | ||
| } | ||
|
|
||
| val albumAdapter = AlbumVPAdapter(this) | ||
| binding.albumContentVp.adapter = albumAdapter | ||
| TabLayoutMediator(binding.albumContentTb, binding.albumContentVp) { | ||
| tab, position -> | ||
| tab.text = information[position] | ||
| }.attach() | ||
|
|
||
| // Toast 코드 | ||
| // binding.songLalacLayout.setOnClickListener { | ||
| // Toast.makeText(activity,"LILAC",Toast.LENGTH_SHORT).show() | ||
| // } | ||
| return binding.root | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| 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,24 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import com.jihyun.floclonecoding.databinding.FragmentBannerBinding | ||
|
|
||
| class BannerFragment(val imgRes : Int) : Fragment() { | ||
|
|
||
| lateinit var binding : FragmentBannerBinding | ||
|
|
||
| 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,18 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import androidx.fragment.app.Fragment | ||
| import androidx.viewpager2.adapter.FragmentStateAdapter | ||
|
|
||
| class BannerVPAdapter(fragment: Fragment) :FragmentStateAdapter(fragment) { | ||
|
|
||
| private val fragmentlist : ArrayList<Fragment> = ArrayList() | ||
| //private: 외부에서 쓰는 거 방지! | ||
| override fun getItemCount(): Int = fragmentlist.size | ||
|
|
||
| override fun createFragment(position: Int): Fragment = 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.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import com.jihyun.floclonecoding.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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import androidx.viewpager2.widget.ViewPager2 | ||
| import com.jihyun.floclonecoding.databinding.FragmentHomeBinding | ||
|
|
||
| class HomeFragment : Fragment() { | ||
|
|
||
| lateinit var binding: FragmentHomeBinding | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = FragmentHomeBinding.inflate(inflater, container, false) | ||
|
|
||
| binding.homeAlbumImgIv1.setOnClickListener { | ||
|
|
||
| } | ||
|
|
||
| val bannerAdapter = BannerVPAdapter(this) | ||
| bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_viewpager_exp)) | ||
| bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_viewpager_exp2)) | ||
| bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_viewpager_exp)) | ||
| bannerAdapter.addFragment(BannerFragment(R.drawable.img_home_viewpager_exp2)) | ||
|
|
||
| binding.homeBannerVp.adapter = bannerAdapter | ||
| binding.homeBannerVp.orientation = ViewPager2.ORIENTATION_HORIZONTAL | ||
|
|
||
| return binding.root | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| class LockerFragment { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| class LookFragment { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,40 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import androidx.activity.enableEdgeToEdge | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.core.view.ViewCompat | ||
| import androidx.core.view.WindowInsetsCompat | ||
| import com.jihyun.floclonecoding.databinding.ActivityMainBinding | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
|
|
||
| lateinit var binding: ActivityMainBinding | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| enableEdgeToEdge() | ||
| setContentView(R.layout.activity_main) | ||
| ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> | ||
| val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||
| v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) | ||
| insets | ||
| binding = ActivityMainBinding.inflate(layoutInflater) | ||
| setContentView(binding.root) | ||
|
|
||
| val song = Song(binding.mainMiniplayerTitleTv.text.toString(), binding.mainMiniplayerSingerTv.text.toString()) | ||
|
|
||
|
|
||
| binding.mainPlayerCl.setOnClickListener { | ||
| //startActivity(Intent(this, SongActivity::class.java)) | ||
| val intent = Intent(this, SongActivity::class.java) | ||
| intent.putExtra("title", song.title) | ||
| intent.putExtra("singer", song.singer) | ||
| startActivity(intent) | ||
| } | ||
| initBottomNavigation() | ||
|
|
||
| Log.d("Song", song.title + song.singer) | ||
|
|
||
| } | ||
| } | ||
|
|
||
| private fun initBottomNavigation() { | ||
| TODO("Not yet implemented") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| class SearchFragment { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| data class Song( | ||
| val title : String = "", | ||
| val singer : String = "" | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.View | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import com.jihyun.floclonecoding.databinding.ActivitySongBinding | ||
|
|
||
| class SongActivity : | ||
| AppCompatActivity() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 줄바꿈은 안하시는 것이 가독성이 좋아보입니다! |
||
|
|
||
| lateinit var binding : ActivitySongBinding | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| binding = ActivitySongBinding.inflate(layoutInflater) | ||
| setContentView(binding.root) | ||
| binding.songDownIb.setOnClickListener { | ||
| finish() | ||
| } | ||
| binding.songMiniplayerIv.setOnClickListener { | ||
| setPlayerStatus(false) | ||
| } | ||
| binding.songPauseIv.setOnClickListener { | ||
| setPlayerStatus(true) | ||
|
|
||
| } | ||
| if (intent.hasExtra("title") && intent.hasExtra("singer")){ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. intent에 들어있는 변수의 존재 여부를 판별하고 저장하는 것보다는 if문에서는 null 체크만 하고 값을 사용하는 편이 더 좋아보입니다! |
||
| binding.songMusicTitleTv.text=intent.getStringExtra("title") | ||
| binding.songSingerNameTv.text=intent.getStringExtra("singer") | ||
| } | ||
| } | ||
| private fun setPlayerStatus(isPlaying: Boolean) { | ||
| if(isPlaying){ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if문 판별식은 띄워쓰는 것이 일반적입니다~ |
||
| binding.songMiniplayerIv.visibility = View.VISIBLE | ||
| binding.songPauseIv.visibility = View.GONE | ||
| } | ||
| else { | ||
| binding.songMiniplayerIv.visibility = View.GONE | ||
| binding.songPauseIv.visibility = View.VISIBLE | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import com.jihyun.floclonecoding.databinding.FragmentDetailBinding | ||
| import com.jihyun.floclonecoding.databinding.FragmentSongBinding | ||
|
|
||
| class SongFragment : Fragment() { | ||
|
|
||
| lateinit var binding: FragmentSongBinding | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = FragmentSongBinding.inflate(inflater,container, false) | ||
|
|
||
| return binding.root | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.jihyun.floclonecoding | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.Fragment | ||
| import com.jihyun.floclonecoding.databinding.FragmentDetailBinding | ||
| import com.jihyun.floclonecoding.databinding.FragmentVideoBinding | ||
|
|
||
| class VideoFragment : Fragment() { | ||
|
|
||
| lateinit var binding: FragmentVideoBinding | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = FragmentVideoBinding.inflate(inflater,container, false) | ||
|
|
||
| return binding.root | ||
| } | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이미지 파일을 png로 많이 갖고 오신 것 같은데 Chapter 1에 png 말고 svg로 다운로드받고 다시 xml 형식으로 변환하는 과정을 다시 한 번 정독해주세요~ 물론 Udemy 강의의 이미지 파일들이 너무 많은 관계로 일일이 못하신 것 같지만 실제 프로젝트에서는 png로 할 경우 이미지의 해상도가 깨지는 경우들이 많아서 방법 정도만 숙지해놓으셔도 됩니다! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <item android:color="#3f3fff" android:state_checked="true" /> | ||
| <item android:color="#a8a8a8" /> | ||
| </selector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:shape="rectangle"> | ||
|
|
||
| <solid android:color="@color/black"/> | ||
|
|
||
| <stroke | ||
| android:width="1dp" | ||
| android:color="@color/black"/> | ||
| </shape> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:shape="rectangle"> | ||
|
|
||
| <solid android:color="@color/flo"/> | ||
|
|
||
| <stroke | ||
| android:width="1dp" | ||
| android:color="@color/flo"/> | ||
| </shape> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultConfig랑 같은 라인에 buildFeatures 안에 viewBinding을 선언하면 가독성이 더 좋습니다!