Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Week7 #5

wants to merge 11 commits into from

Conversation

lhb8106
Copy link
Contributor

@lhb8106 lhb8106 commented Dec 15, 2021

week7 과제

  • level1
  • level2 중 2-1

까지 구현했습니다~

Copy link

@l2hyunwoo l2hyunwoo left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. 리뷰 한번 확인해주시겠어요?

Comment on lines +28 to +44
<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>

Choose a reason for hiding this comment

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

exported 속성이 어떤 것인지 확인해보면 좋을 것 같습니다.

Comment on lines +9 to +19
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()
}

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에서 계속 사용되고 있는데 멤버변수로 한번 초기화 시키고 사용하는게 중복을 덜 수 있지 않을까요?

Comment on lines +21 to +26

//initTransactionEvent()
initAdapter()
initBottomNavigation()

setContentView(binding.root)

Choose a reason for hiding this comment

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

이 리뷰 한 번 참고해보시겠어요?

Comment on lines +30 to +43
// 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()
// }
// }

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)

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() {

Choose a reason for hiding this comment

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

클래스 이름은 PascalCase가 원칙입니다.

Comment on lines +15 to +17
private lateinit var OnboardingFragment3: FragmentOnboarding3Binding
private var _binding: FragmentOnboarding3Binding? = null
private val binding get() = _binding!!

Choose a reason for hiding this comment

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

Suggested change
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)

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이 발생할 가능성이 줄어듭니다.

Comment on lines +39 to +42
override fun onDestroy() {
super.onDestroy()
_binding = null
}

Choose a reason for hiding this comment

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

Suggested change
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()

Choose a reason for hiding this comment

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

Suggested change
getActivity()?.supportFragmentManager?.beginTransaction()
requireActivity()supportFragmentManager.beginTransaction()

이렇게 하면 nullable하지 않습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

많이 늦었지만 알려주신 것대로 코드 모두 수정했습니다! 덕분에 몰랐던 지식을 많이 얻어갑니다 :) 코드리뷰 정말 감사합니다!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants