-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
[Simba/#7] feat 2주차 구현
- 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.
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,58 @@ | ||
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 | ||
|
||
class AlbumFragment : Fragment() { | ||
lateinit var binding: FragmentAlbumBinding | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = inflate(inflater,container,false) | ||
|
||
setFragmentResultListener("TitleInfo") { requestKey, bundle -> | ||
binding.albumMusicTitleTv.text = bundle.getString("title") | ||
} | ||
setFragmentResultListener("SingerInfo") { requestKey, bundle -> | ||
binding.albumSingerNameTv.text = bundle.getString("singer") | ||
} | ||
|
||
binding.albumBackIv.setOnClickListener{ | ||
(context as MainActivity).supportFragmentManager.beginTransaction().replace(R.id.main_frm,HomeFragment()).commitAllowingStateLoss() | ||
} | ||
|
||
binding.songLalacLayout.setOnClickListener{ | ||
Toast.makeText(activity,"LILAC",Toast.LENGTH_SHORT).show() | ||
} | ||
binding.songFluLayout.setOnClickListener { | ||
Toast.makeText(activity,"FLU", Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
binding.songCoinLayout.setOnClickListener { | ||
Toast.makeText(activity,"Coin", Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
binding.songSpringLayout.setOnClickListener { | ||
Toast.makeText(activity,"봄 안녕 봄", Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
binding.songCelebrityLayout.setOnClickListener { | ||
Toast.makeText(activity,"Celebrity", Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
binding.songSingLayout.setOnClickListener { | ||
Toast.makeText(activity,"돌림노래 (Feat. DEAN)", Toast.LENGTH_SHORT).show() | ||
} | ||
return binding.root | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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 androidx.core.os.bundleOf | ||
import androidx.fragment.app.setFragmentResult | ||
import com.example.umc_6th.databinding.FragmentHomeBinding | ||
|
||
class HomeFragment : Fragment() { | ||
|
||
lateinit var binding: FragmentHomeBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = FragmentHomeBinding.inflate(inflater,container,false) | ||
|
||
binding.homeAlbumImg01Iv1.setOnClickListener{ | ||
setFragmentResult("TitleInfo", bundleOf("title" to binding.titleLilac.text.toString())) | ||
setFragmentResult("SingerInfo", bundleOf("singer" to binding.singerIu.text.toString())) | ||
(context as MainActivity).supportFragmentManager.beginTransaction().replace(R.id.main_frm,AlbumFragment()).commitAllowingStateLoss() | ||
} | ||
return binding.root | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 | ||
|
||
class LockerFragment : Fragment() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_locker, container, false) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 | ||
|
||
class LookFragment : Fragment() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_look, container, false) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,95 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Toast | ||
import androidx.activity.result.ActivityResultLauncher | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import com.example.umc_6th.databinding.ActivityMainBinding | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
lateinit var binding: ActivityMainBinding | ||
lateinit var activityResultLauncher: ActivityResultLauncher<Intent> | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
setTheme(R.style.Theme_UMC_6th) | ||
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) | ||
|
||
// activityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | ||
// if (result.resultCode == RESULT_OK) { | ||
// val data = result.data | ||
// if (data != null) { | ||
// val message = data.getStringExtra("message") | ||
// Log.d("message", message!!) | ||
// Toast.makeText(this, message, Toast.LENGTH_SHORT).show() | ||
// } | ||
// } | ||
// } | ||
|
||
binding.mainPlayerCl.setOnClickListener{ | ||
val intent = Intent(this,SongActivity::class.java) | ||
// intent.putExtra("title",song.title) | ||
// intent.putExtra("singer",song.singer) | ||
startActivity(intent) | ||
} | ||
} | ||
|
||
private fun initBottomNavigation() { | ||
|
||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.main_frm, HomeFragment()) | ||
.commitNowAllowingStateLoss() | ||
|
||
binding.mainBnv.setOnItemSelectedListener { item -> | ||
when (item.itemId) { | ||
|
||
R.id.homeFragment -> { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.main_frm, HomeFragment()) | ||
.commitAllowingStateLoss() | ||
return@setOnItemSelectedListener true | ||
} | ||
|
||
R.id.lookFragment -> { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.main_frm, LookFragment()) | ||
.commitAllowingStateLoss() | ||
return@setOnItemSelectedListener true | ||
} | ||
|
||
R.id.searchFragment -> { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.main_frm, SearchFragment()) | ||
.commitAllowingStateLoss() | ||
return@setOnItemSelectedListener true | ||
} | ||
|
||
R.id.lockerFragment -> { | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.main_frm, LockerFragment()) | ||
.commitAllowingStateLoss() | ||
return@setOnItemSelectedListener true | ||
} | ||
} | ||
false | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 | ||
|
||
class SearchFragment : Fragment() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_search, container, false) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.umc_6th | ||
|
||
data class Song( | ||
val title : String = "", | ||
val singer : String = "" | ||
) |