Skip to content

Commit

Permalink
#11 / [ADD] BindingDialogFragment 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Jun 9, 2023
1 parent 399a7a3 commit 00e8e7a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.android.go.sopt.util.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.DialogFragment
import org.android.go.sopt.R

abstract class BindingDialogFragment<B : ViewDataBinding>(@LayoutRes private val layoutRes: Int) :
DialogFragment() {
private var _binding: B? = null
val binding get() = requireNotNull(_binding!!) { "${this::class.java.simpleName}에서 에러가 발생했습니다." }

override fun onStart() {
super.onStart()
dialog?.window?.apply {
setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
}

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

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<import type="android.view.View" />

<variable
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@
<color name="teal_A200">#64ffda</color>
<color name="teal_A400">#1de9b6</color>
<color name="teal_A700">#00bfa5</color>

<color name="transparent">#00FFFFFF</color>
</resources>

0 comments on commit 00e8e7a

Please sign in to comment.