diff --git a/app/src/main/java/org/android/go/sopt/presentation/auth/LoginActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/auth/LoginActivity.kt index 45a5665..7912126 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/auth/LoginActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/auth/LoginActivity.kt @@ -4,7 +4,6 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.content.SharedPreferences -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.inputmethod.InputMethodManager import androidx.activity.viewModels @@ -12,12 +11,12 @@ import androidx.appcompat.app.AppCompatDelegate import org.android.go.sopt.R import org.android.go.sopt.databinding.ActivityLoginBinding import org.android.go.sopt.presentation.main.MainActivity +import org.android.go.sopt.util.base.BindingActivity import org.android.go.sopt.util.extension.makeSnackBar import org.android.go.sopt.util.extension.makeToast import timber.log.Timber -class LoginActivity : AppCompatActivity() { - private lateinit var binding: ActivityLoginBinding +class LoginActivity : BindingActivity(R.layout.activity_login) { private lateinit var sharedPreferences: SharedPreferences private lateinit var editor: SharedPreferences.Editor @@ -25,7 +24,6 @@ class LoginActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding = ActivityLoginBinding.inflate(layoutInflater) setContentView(binding.root) // 야간모드 무시 diff --git a/app/src/main/java/org/android/go/sopt/presentation/auth/SignUpActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/auth/SignUpActivity.kt index 647afef..a7bf1e4 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/auth/SignUpActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/auth/SignUpActivity.kt @@ -3,7 +3,6 @@ package org.android.go.sopt.presentation.auth import android.app.Activity import android.content.Context import android.content.Intent -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.inputmethod.InputMethodManager import androidx.activity.viewModels @@ -11,18 +10,17 @@ import androidx.core.widget.doAfterTextChanged import org.android.go.sopt.R import org.android.go.sopt.databinding.ActivitySignUpBinding import org.android.go.sopt.util.KeyboardVisibilityUtils +import org.android.go.sopt.util.base.BindingActivity import org.android.go.sopt.util.extension.makeSnackBar import timber.log.Timber -class SignUpActivity : AppCompatActivity() { - private lateinit var binding: ActivitySignUpBinding +class SignUpActivity : BindingActivity(R.layout.activity_sign_up) { private lateinit var keyboardVisibilityUtils: KeyboardVisibilityUtils private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding = ActivitySignUpBinding.inflate(layoutInflater) setContentView(binding.root) // 텍스트 입력을 감지해서 조건 만족 시 버튼 활성화 @@ -45,7 +43,7 @@ class SignUpActivity : AppCompatActivity() { } // 뷰모델 observer 설정 - viewModel.signUpResult.observe(this) {signUpResult -> + viewModel.signUpResult.observe(this) { signUpResult -> binding.root.makeSnackBar(getString(R.string.snackbar_signup_success)) if (!isFinishing) { val intent = Intent(binding.root.context, LoginActivity::class.java) diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt index 3b591cb..abf6650 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt @@ -1,6 +1,5 @@ package org.android.go.sopt.presentation.main -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.MenuItem import androidx.fragment.app.Fragment @@ -12,9 +11,10 @@ import org.android.go.sopt.databinding.ActivityMainBinding import org.android.go.sopt.presentation.follower.FollowerFragment import org.android.go.sopt.presentation.playlist.ListFragment import org.android.go.sopt.presentation.search.SearchFragment +import org.android.go.sopt.util.base.BindingActivity + +class MainActivity : BindingActivity(R.layout.activity_main) { -class MainActivity : AppCompatActivity() { - private lateinit var binding: ActivityMainBinding private lateinit var listFragment: ListFragment private lateinit var albumFragment: AlbumFragment private lateinit var searchFragment: SearchFragment @@ -23,7 +23,6 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) // 시작 Fragment 설정 @@ -44,6 +43,7 @@ class MainActivity : AppCompatActivity() { ?: supportFragmentManager.beginTransaction().add(R.id.fcv_main, listFragment).commit() } + // 바텀 네비게이션 누를 때마다 새로운 프래그먼트 객체가 생성되지 않도록 설정 private fun changeFragmentByBnv() { binding.bnvMain.setOnItemSelectedListener { item -> when (item.itemId) { @@ -84,7 +84,7 @@ class MainActivity : AppCompatActivity() { } } - private fun scrollToTopForReselectedItem(item : MenuItem) { + private fun scrollToTopForReselectedItem(item: MenuItem) { if (item.itemId == R.id.menu_playlist) { when (val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_main)) { is ListFragment -> { diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index b53dfdf..15760f9 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,100 +1,108 @@ - + xmlns:tools="http://schemas.android.com/tools"> - + - + - + - + - + -