Skip to content

Instantly share code, notes, and snippets.

@cbedoy
Created June 9, 2021 18:33
Show Gist options
  • Save cbedoy/4721c15e7cfcc9452cc695c54549e8ca to your computer and use it in GitHub Desktop.
Save cbedoy/4721c15e7cfcc9452cc695c54549e8ca to your computer and use it in GitHub Desktop.
Dialgo
open class BaseDialog : DialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
setStyle(STYLE_NO_TITLE, R.style.DialogTheme)
super.onCreate(savedInstanceState)
}
override fun onStart() {
super.onStart()
dialog?.window?.setWindowAnimations(R.style.DialogAnimation)
}
}
<style name="DialogTheme" parent="AppTheme">
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@color/black_opaque</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:gravity">center</item>
</style>
<style name="DialogAnimation" parent="@style/AppTheme">
<item name="android:windowEnterAnimation">@anim/anim_in</item>
<item name="android:windowExitAnimation">@anim/anim_out</item>
</style>
@cbedoy
Copy link
Author

cbedoy commented Jun 9, 2021

companion object {
    const val TAG = "CancelServiceDialog"
    fun newInstance(): CancelServiceDialog {
        return CancelServiceDialog()
    }
}

override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? = binding.root


private val binding by lazy {
    DialogCancelServiceBinding.inflate(LayoutInflater.from(context))
}

@cbedoy
Copy link
Author

cbedoy commented Jun 9, 2021

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    arguments?.let {
        isFirstAttempt = it.getBoolean(FIRST_ATTEMPT, false)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment