Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultConfig {
}

buildFeatures {
    viewBinding = true
}

defaultConfig랑 같은 라인에 buildFeatures 안에 viewBinding을 선언하면 가독성이 더 좋습니다!

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ android {
namespace = "com.jihyun.floclonecoding"
compileSdk = 34

viewBinding {
enable = true
}
defaultConfig {
applicationId = "com.jihyun.floclonecoding"
minSdk = 24
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SongActivity"
android:exported="true"/>
</application>

</manifest>
43 changes: 43 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/AlbumFragment.kt
Copy link
Contributor

@tristanjung1006 tristanjung1006 Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 Fragment의 생명주기에서 다룰 내용이긴 하지만 Fragment의 생성 단계가 onCreateView -> onViewCreated가 있습니다.

onCreateView에서는 View가 처음 생성되고 초기화되는 부분을 담당하고
onViewCreated에서는 View와의 상호작용이 이루어지는 곳이라서 onCreateView 말고
onViewCreated를 override 받아서 setOnClickListener 메서드를 선언하는 것이 좋습니다!

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
}
}
16 changes: 16 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/AlbumVPAdapter.kt
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()
}
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/BannerFragment.kt
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
}
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/BannerVPAdapter.kt
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)
}
}
23 changes: 23 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/DetailFragment.kt
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
}
}
38 changes: 38 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/HomeFragment.kt
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
}

}
4 changes: 4 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/LockerFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.jihyun.floclonecoding

class LockerFragment {
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/LookFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.jihyun.floclonecoding

class LookFragment {
}
34 changes: 27 additions & 7 deletions app/src/main/java/com/jihyun/floclonecoding/MainActivity.kt
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")
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/SearchFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.jihyun.floclonecoding

class SearchFragment {
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/Song.kt
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 = ""
)
44 changes: 44 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/SongActivity.kt
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() {
Copy link
Contributor

Choose a reason for hiding this comment

The 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")){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val title = intent.getStringExtra("title")
val singer = intent.getStringExtra("singer")

if (title != null && singer != null) {
    binding.songMusicTitleTv.text = title
    binding.songSingerNameTv.text = singer
}

intent에 들어있는 변수의 존재 여부를 판별하고 저장하는 것보다는 if문에서는 null 체크만 하고 값을 사용하는 편이 더 좋아보입니다!

binding.songMusicTitleTv.text=intent.getStringExtra("title")
binding.songSingerNameTv.text=intent.getStringExtra("singer")
}
}
private fun setPlayerStatus(isPlaying: Boolean) {
if(isPlaying){
Copy link
Contributor

Choose a reason for hiding this comment

The 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
}
}
}


24 changes: 24 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/SongFragment.kt
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
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/jihyun/floclonecoding/VideoFragment.kt
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
}
}
Binary file added app/src/main/res/drawable/apple_44.png
Copy link
Contributor

@tristanjung1006 tristanjung1006 Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미지 파일을 png로 많이 갖고 오신 것 같은데 Chapter 1에 png 말고 svg로 다운로드받고 다시 xml 형식으로 변환하는 과정을 다시 한 번 정독해주세요~ 물론 Udemy 강의의 이미지 파일들이 너무 많은 관계로 일일이 못하신 것 같지만 실제 프로젝트에서는 png로 할 경우 이미지의 해상도가 깨지는 경우들이 많아서 방법 정도만 숙지해놓으셔도 됩니다!

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/btm_color_selector.xml
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>
Binary file added app/src/main/res/drawable/btn_actionbar_close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_arrow_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_arrow_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_input_password.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_main_arrow_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_main_mike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_main_setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_main_ticket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplay_mvpause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplay_mvplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplay_pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplayer_go_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplayer_next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplayer_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_miniplayer_previous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_nugu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_eq_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_go_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_related.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/btn_player_setting.png
Binary file added app/src/main/res/drawable/btn_playlist_select_on.png
Binary file added app/src/main/res/drawable/btn_setting_phone.png
Binary file added app/src/main/res/drawable/btn_textbox_close.png
Binary file added app/src/main/res/drawable/btn_titlebar_close.png
Binary file added app/src/main/res/drawable/btn_toggle_off.png
Binary file added app/src/main/res/drawable/btn_toggle_on.png
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/button_background_black_color.xml
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>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/button_background_flo_color.xml
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>
Loading