Migrated the project to Kotlin#33
Conversation
|
Thanks, @2307vivek for this PR 😃 |
@PatilShreyas My pleasure. 😀 |
| */ | ||
| fun materialDialog( | ||
| activity: Activity, | ||
| block: MaterialDialog.Builder.() -> Unit |
There was a problem hiding this comment.
We can call it builder instead of block.
| */ | ||
| fun bottomSheetMaterialDialog( | ||
| activity: Activity, | ||
| block: BottomSheetMaterialDialog.Builder.() -> Unit |
| class Builder(private val activity: Activity) : DialogBuilder() { | ||
|
|
||
| /** | ||
| * Build the {@link BottomSheetMaterialDialog}. | ||
| */ | ||
| fun build(): BottomSheetMaterialDialog = | ||
| BottomSheetMaterialDialog(activity, title, message, isCancelable, mPositiveButton, mNegativeButton, animationResId, mAnimationFile) | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
This will hide builder pattern from Java. Right?
| // /** | ||
| // * @param title Sets the Title of Dialog. | ||
| // */ | ||
| // fun setTitle(title: String) { | ||
| // mTitle = title | ||
| // } | ||
| // | ||
| // /** | ||
| // * @param message Sets the Message of Dialog. | ||
| // */ | ||
| // fun setMessage(message: String) { | ||
| // mMessage = message | ||
| // } | ||
| // | ||
| // /** | ||
| // * @param isCancelable Sets cancelable property of Dialog. | ||
| // */ | ||
| // fun isCancelable(isCancelable: Boolean) { | ||
| // cancelable = isCancelable | ||
| // } |
| class Builder(private val activity: Activity) : DialogBuilder() { | ||
|
|
||
| /** | ||
| * Build the {@link BottomSheetMaterialDialog}. | ||
| */ | ||
| fun build(): BottomSheetMaterialDialog = | ||
| BottomSheetMaterialDialog(activity, title, message, isCancelable, mPositiveButton, mNegativeButton, animationResId, mAnimationFile) | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
This will hide builder pattern from Java. Right?
You cannot create a Dialog with builder pattern with my changes, but we need something to build the MaterialDialog class. The Builder class just collects data and builds the MaterialDialog class in the materialDialog() dsl function.
| */ | ||
| fun materialDialog( | ||
| activity: Activity, | ||
| block: MaterialDialog.Builder.() -> Unit |
There was a problem hiding this comment.
We can call it
builderinstead ofblock.
Sure, calling it builder will make more sense.
| // /** | ||
| // * @param title Sets the Title of Dialog. | ||
| // */ | ||
| // fun setTitle(title: String) { | ||
| // mTitle = title | ||
| // } | ||
| // | ||
| // /** | ||
| // * @param message Sets the Message of Dialog. | ||
| // */ | ||
| // fun setMessage(message: String) { | ||
| // mMessage = message | ||
| // } | ||
| // | ||
| // /** | ||
| // * @param isCancelable Sets cancelable property of Dialog. | ||
| // */ | ||
| // fun isCancelable(isCancelable: Boolean) { | ||
| // cancelable = isCancelable | ||
| // } |
There was a problem hiding this comment.
What's purpose of this?
It can be safely deleted, I wrote that methods before the class was finalised.
Summary
Migrated the whole project to use Kotlin as the primary language. This results in reduction of the codebase size, along with improved code readability.
Resolves #32
Build Dialogs with Kotlin DSL
Building dialogs is easier than ever with kotlin dsl.
Animated Material Dialog
Animated BottomSheetMaterialDialog