-
Notifications
You must be signed in to change notification settings - Fork 1
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
Week7 #5
base: main
Are you sure you want to change the base?
Conversation
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.
수고하셨습니다. 리뷰 한번 확인해주시겠어요?
<activity | ||
android:name=".view.profile.RepositoryFragment" | ||
android:exported="true" | ||
tools:ignore="Instantiatable" /> | ||
<activity | ||
android:name=".view.profile.FollowerFragment" | ||
android:exported="true" | ||
tools:ignore="Instantiatable" /> | ||
<activity | ||
android:name=".view.login.SignUpActivity" | ||
android:exported="true" /> | ||
<activity | ||
android:name=".view.home.HomeActivity" | ||
android:exported="true" /> | ||
<activity | ||
android:name=".view.login.SignInActivity" | ||
android:exported="true"></activity> |
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.
exported 속성이 어떤 것인지 확인해보면 좋을 것 같습니다.
fun getAutoLogin(context: Context) : Boolean{ | ||
val preferences = context.getSharedPreferences(USER_AUTH, Context.MODE_PRIVATE) | ||
return preferences.getBoolean(AUTO_LOGIN, false) | ||
} | ||
|
||
fun setAutoLogin(context: Context, auto : Boolean) { | ||
val preferences = context.getSharedPreferences(USER_AUTH, Context.MODE_PRIVATE) | ||
preferences.edit() | ||
.putBoolean(AUTO_LOGIN,auto) | ||
.apply() | ||
} |
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.
val preferences = context.getSharedPreferences(USER_AUTH, Context.MODE_PRIVATE)가 SOPTSharedPreferences에서 계속 사용되고 있는데 멤버변수로 한번 초기화 시키고 사용하는게 중복을 덜 수 있지 않을까요?
|
||
//initTransactionEvent() | ||
initAdapter() | ||
initBottomNavigation() | ||
|
||
setContentView(binding.root) |
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.
이 리뷰 한 번 참고해보시겠어요?
// fun initTransactionEvent() { | ||
// val followerFragment = FollowerFragment() | ||
// val repositstoryFragment = RepositoryFragment() | ||
// | ||
// supportFragmentManager.beginTransaction().add(R.id.container_rv, followerFragment).commit() | ||
// | ||
// binding.btnFollower.setOnClickListener { | ||
// supportFragmentManager.beginTransaction().replace(R.id.container_rv, followerFragment) .commit() | ||
// } | ||
// | ||
// binding.btnRepository.setOnClickListener { | ||
// supportFragmentManager.beginTransaction().replace(R.id.container_rv, repositstoryFragment) .commit() | ||
// } | ||
// } |
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.
주석은 지워주는 것이 좋을 것 같습니다.
private fun initAdapter() { | ||
val fragmentList = listOf(ProfileFragment(), HomeFragment(), CameraFragment()) | ||
|
||
SampleViewPagerAdapter = SampleViewPagerAdapter(this) |
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.
- 변수명은 camelCase가 원칙입니다
- 변수명과 클래스명이 동일하면 다른 협업하는 사람의 입장에서 혼란을 야기할 수 있을 것 같습니다.
import android.view.ViewGroup | ||
import com.example.myapplication.R | ||
|
||
class home_following_Fragment : Fragment() { |
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.
클래스 이름은 PascalCase가 원칙입니다.
private lateinit var OnboardingFragment3: FragmentOnboarding3Binding | ||
private var _binding: FragmentOnboarding3Binding? = null | ||
private val binding get() = _binding!! |
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.
private lateinit var OnboardingFragment3: FragmentOnboarding3Binding | |
private var _binding: FragmentOnboarding3Binding? = null | |
private val binding get() = _binding!! | |
private var _binding: FragmentOnboarding3Binding? = null | |
private val binding get() = _binding!! |
이거 지우셔도 되겠죠?
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = FragmentOnboarding3Binding.inflate(layoutInflater, container, false) |
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.
_binding 객체를 inflate 했으면 onDestroyView에서 null로 해제를 시켜야 memeory leak이 발생할 가능성이 줄어듭니다.
override fun onDestroy() { | ||
super.onDestroy() | ||
_binding = null | ||
} |
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.
override fun onDestroy() { | |
super.onDestroy() | |
_binding = null | |
} | |
override fun onDestroyView() { | |
_binding = null | |
super.onDestroyView() | |
} |
- Fragment에서 객체의 생명주기와 View의 생명주기는 서로 다릅니다
- super.onDestroyView는 부모의 클래스 소멸자 함수이기에 이후에 호출하는 로직들은 예상치 못하는 결과를 발생시킬 수 있습니다(이걸 개발할 때 Side Effect라고 부릅니다). 그래서 먼저 로직을 실행하고 super.onDestroyView를 호출하는 것이 더 좋습니다.
?.add(R.id.container_rv, followerFragment)?.commit() | ||
|
||
binding.btnFollower.setOnClickListener { | ||
getActivity()?.supportFragmentManager?.beginTransaction() |
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.
getActivity()?.supportFragmentManager?.beginTransaction() | |
requireActivity()supportFragmentManager.beginTransaction() |
이렇게 하면 nullable하지 않습니다.
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.
많이 늦었지만 알려주신 것대로 코드 모두 수정했습니다! 덕분에 몰랐던 지식을 많이 얻어갑니다 :) 코드리뷰 정말 감사합니다!!!
week7 과제
까지 구현했습니다~