generated from GO-SOPT-ANDROID/android-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#11 / [ADD] BindingDialogFragment 추가
- Loading branch information
1 parent
399a7a3
commit 00e8e7a
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
app/src/main/java/org/android/go/sopt/util/base/BindingDialogFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters