Skip to content

Commit

Permalink
[mod] #8 BindingActivity, BindingFragment 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 15, 2024
1 parent 3c818f0 commit f4a3fab
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 124 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
package org.sopt.kream.presentation.ui.main

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import org.sopt.kream.databinding.ActivityMainBinding
import org.sopt.kream.util.base.BindingActivity

class MainActivity : AppCompatActivity() {
private var _binding: ActivityMainBinding? = null
private val binding: ActivityMainBinding
get() = requireNotNull(_binding)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
class MainActivity : BindingActivity<ActivityMainBinding>({ ActivityMainBinding.inflate(it) })
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
package org.sopt.kream.presentation.ui.main.home.recommend

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import org.sopt.kream.R
import org.sopt.kream.databinding.FragmentRecommendBinding
import org.sopt.kream.util.base.BindingFragment

class RecommendFragment : Fragment() {
private var _binding: FragmentRecommendBinding? = null
private val binding: FragmentRecommendBinding
get() = requireNotNull(_binding) { }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
_binding = FragmentRecommendBinding.inflate(inflater, container, false)
return binding.root
}

class RecommendFragment : BindingFragment<FragmentRecommendBinding>({ FragmentRecommendBinding.inflate(it) }) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
Expand All @@ -33,9 +18,4 @@ class RecommendFragment : Fragment() {
findNavController().navigate(R.id.releaseFragment)
}
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
package org.sopt.kream.presentation.ui.main.home.release

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.fragment.app.Fragment
import org.sopt.kream.databinding.FragmentReleaseBinding
import org.sopt.kream.util.base.BindingFragment

class ReleaseFragment : Fragment() {
private var _binding: FragmentReleaseBinding? = null
private val binding: FragmentReleaseBinding
get() = requireNotNull(_binding) { }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
_binding = FragmentReleaseBinding.inflate(inflater, container, false)
return binding.root
}

class ReleaseFragment : BindingFragment<FragmentReleaseBinding>({ FragmentReleaseBinding.inflate(it) }) {
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
Expand All @@ -33,11 +18,6 @@ class ReleaseFragment : Fragment() {
}
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}

@Composable
fun releaseScreen() {
Text(text = "Release")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
package org.sopt.kream.presentation.ui.productdetail

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.sopt.kream.databinding.FragmentProductDetailBinding
import org.sopt.kream.util.base.BindingFragment

class ProductDetailFragment : Fragment() {
private var _binding: FragmentProductDetailBinding? = null
private val binding: FragmentProductDetailBinding
get() = requireNotNull(_binding) { }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
_binding = FragmentProductDetailBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
class ProductDetailFragment : BindingFragment<FragmentProductDetailBinding>({ FragmentProductDetailBinding.inflate(it) })
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
package org.sopt.kream.presentation.ui.search

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.sopt.kream.databinding.FragmentSearchBinding
import org.sopt.kream.util.base.BindingFragment

class SearchFragment : Fragment() {
private var _binding: FragmentSearchBinding? = null
private val binding: FragmentSearchBinding
get() = requireNotNull(_binding) { }

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
_binding = FragmentSearchBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}
}
class SearchFragment : BindingFragment<FragmentSearchBinding>({ FragmentSearchBinding.inflate(it) })

0 comments on commit f4a3fab

Please sign in to comment.