From 131ba8813fe13f745d98fcf89f90aea6b9ec3a82 Mon Sep 17 00:00:00 2001 From: hyeumm <20221159@sungshin.ac.kr> Date: Fri, 12 Apr 2024 00:23:21 +0900 Subject: [PATCH] =?UTF-8?q?mod/#5:=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80<->=ED=99=88=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/sopt/now/Friend.kt | 5 ++ .../main/java/com/sopt/now/HomeFragment.kt | 38 +++++++-- .../main/java/com/sopt/now/LoginActivity.kt | 15 +++- .../main/java/com/sopt/now/MyPageFragment.kt | 41 +++------ app/src/main/res/layout/fragment_home.xml | 10 ++- app/src/main/res/layout/fragment_my_page.xml | 83 ++++++++++++++++--- 6 files changed, 139 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/com/sopt/now/Friend.kt b/app/src/main/java/com/sopt/now/Friend.kt index f6d3ea0..5a7c81c 100644 --- a/app/src/main/java/com/sopt/now/Friend.kt +++ b/app/src/main/java/com/sopt/now/Friend.kt @@ -2,6 +2,11 @@ package com.sopt.now import androidx.annotation.DrawableRes +data class User( + @DrawableRes val profileImage: Int, + val name: String, + val selfDescription: String +) data class Friend( @DrawableRes val profileImage: Int, val name: String, diff --git a/app/src/main/java/com/sopt/now/HomeFragment.kt b/app/src/main/java/com/sopt/now/HomeFragment.kt index 9a29d1f..2917642 100644 --- a/app/src/main/java/com/sopt/now/HomeFragment.kt +++ b/app/src/main/java/com/sopt/now/HomeFragment.kt @@ -5,18 +5,44 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager +import com.sopt.now.databinding.FragmentHomeBinding class HomeFragment : Fragment() { + private lateinit var binding: FragmentHomeBinding - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - } - + private val mockFriendList = listOf( + Friend( + profileImage = R.drawable.ic_home_white_24, + name = "이의경", + selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^", + ), + Friend( + profileImage = R.drawable.ic_home_white_24, + name = "우상욱", + selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐", + ), + Friend( + profileImage = R.drawable.ic_home_white_24, + name = "배지현", + selfDescription = "표정 풀자 ^^", + ), + ) override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_home, container, false) + binding=FragmentHomeBinding.inflate(inflater) + return binding.root } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + val friendAdapter = FriendAdapter() + binding.rvFriends.run { + adapter = friendAdapter + layoutManager = LinearLayoutManager(requireContext()) + } + friendAdapter.setFriendList(mockFriendList) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/sopt/now/LoginActivity.kt b/app/src/main/java/com/sopt/now/LoginActivity.kt index f9b649f..23c1d48 100644 --- a/app/src/main/java/com/sopt/now/LoginActivity.kt +++ b/app/src/main/java/com/sopt/now/LoginActivity.kt @@ -37,6 +37,7 @@ class LoginActivity : AppCompatActivity() { } } binding.btnLogin.setOnClickListener { + startMainActivity() sendData(id,pw,nick) } } @@ -61,12 +62,18 @@ class LoginActivity : AppCompatActivity() { Toast.makeText(this,message,Toast.LENGTH_SHORT).show() return loginBool } + private fun startMainActivity(){ + val intent = Intent(this, MainActivity::class.java) + startActivity(intent) + } private fun sendData(id:String,pw:String,nick:String){ if (isLoginAvailable(id, pw)) { - val intent = Intent(this, MainActivity::class.java) - //메인 액티비티로 데이터를 보냄 - intent.putExtra("id", id).putExtra("pw", pw).putExtra("nick", nick) - startActivity(intent) + var mypagefragment = MyPageFragment() + var bundle = Bundle() + bundle.putString("id",id) + bundle.putString("pw",pw) + bundle.putString("nick",nick) + mypagefragment.arguments = bundle } } } diff --git a/app/src/main/java/com/sopt/now/MyPageFragment.kt b/app/src/main/java/com/sopt/now/MyPageFragment.kt index bb34054..527dc24 100644 --- a/app/src/main/java/com/sopt/now/MyPageFragment.kt +++ b/app/src/main/java/com/sopt/now/MyPageFragment.kt @@ -5,44 +5,29 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager import com.sopt.now.databinding.FragmentMyPageBinding class MyPageFragment : Fragment() { - private lateinit var binding:FragmentMyPageBinding + private lateinit var binding: FragmentMyPageBinding + + private var param1: String? = null + private var param2: String? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + } - private val mockFriendList = listOf( - Friend( - profileImage = R.drawable.ic_home_white_24, - name = "이의경", - selfDescription = "다들 빨리 끝내고 뒤풀이 가고 싶지? ㅎㅎ 아직 반도 안왔어 ^&^", - ), - Friend( - profileImage = R.drawable.ic_home_white_24, - name = "우상욱", - selfDescription = "나보다 안드 잘하는 사람 있으면 나와봐", - ), - Friend( - profileImage = R.drawable.ic_home_white_24, - name = "배지현", - selfDescription = "표정 풀자 ^^", - ), - ) override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding=FragmentMyPageBinding.inflate(inflater) + getUserInfo() return binding.root } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val friendAdapter = FriendAdapter() - binding.rvFriends.run { - adapter = friendAdapter - layoutManager = LinearLayoutManager(requireContext()) - } - friendAdapter.setFriendList(mockFriendList) + private fun getUserInfo() { + binding.tvMainNick.text = arguments?.getString("nick") + binding.tvMainId.text = arguments?.getString("id") + binding.tvMainPw.text = arguments?.getString("pw") } - } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 7eb0b33..5815c2f 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -3,12 +3,16 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".HomeFragment"> - - + android:orientation="vertical" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:listitem="@layout/item_friend" + android:paddingVertical="5dp"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_my_page.xml b/app/src/main/res/layout/fragment_my_page.xml index 30979a5..a323054 100644 --- a/app/src/main/res/layout/fragment_my_page.xml +++ b/app/src/main/res/layout/fragment_my_page.xml @@ -1,18 +1,77 @@ - + + + + + + - - - \ No newline at end of file + \ No newline at end of file