Skip to content

Commit

Permalink
refactor: BaseActivity 생성 및 메인액티비티에 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
s9hn committed Nov 4, 2023
1 parent b2c9d9a commit ec8fdd9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.created.team201.presentation.common

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding

abstract class BindingViewActivity<VB : ViewBinding>(
private val bindingInflater: (LayoutInflater) -> VB,
) : AppCompatActivity() {
private var _binding: VB? = null
val binding get() = _binding!!

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = bindingInflater(layoutInflater)
setContentView(binding.root)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.fragment.app.commit
import com.created.team201.R
import com.created.team201.databinding.ActivityMainBinding
import com.created.team201.presentation.chat.ChatFragment
import com.created.team201.presentation.common.BindingActivity
import com.created.team201.presentation.common.BindingViewActivity
import com.created.team201.presentation.guest.GuestFragment
import com.created.team201.presentation.guest.GuestViewModel
import com.created.team201.presentation.guest.bottomSheet.LoginBottomSheetFragment
Expand All @@ -32,7 +32,7 @@ import com.created.team201.presentation.studyList.StudyListFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main) {
class MainActivity : BindingViewActivity<ActivityMainBinding>(ActivityMainBinding::inflate) {
private val mainViewModel: MainViewModel by viewModels()
private val guestViewModel: GuestViewModel by viewModels()

Expand Down
61 changes: 27 additions & 34 deletions android/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.main.MainActivity">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.main.MainActivity">

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="match_parent"
android:layout_height="68dp"
app:backgroundTint="@color/black02_181B21"
app:itemActiveIndicatorStyle="@color/transparent"
app:itemBackground="@color/transparent"
app:itemIconTint="@color/btn_bnv_selector"
app:itemTextAppearanceActive="@style/navi_bar_m12"
app:itemTextAppearanceInactive="@style/navi_bar_m12"
app:itemTextColor="@color/btn_bnv_selector"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="@menu/menu_main_bnv"
tools:menu="@menu/menu_main_bnv" />
android:layout_height="68dp"
app:backgroundTint="@color/black02_181B21"
app:itemActiveIndicatorStyle="@color/transparent"
app:itemBackground="@color/transparent"
app:itemIconTint="@color/btn_bnv_selector"
app:itemTextAppearanceActive="@style/navi_bar_m12"
app:itemTextAppearanceInactive="@style/navi_bar_m12"
app:itemTextColor="@color/btn_bnv_selector"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="@menu/menu_main_bnv"
tools:menu="@menu/menu_main_bnv" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_main"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/bnv_main"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_main"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/bnv_main"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit ec8fdd9

Please sign in to comment.