-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrated the project to Kotlin #33
base: dev/kotlin
Are you sure you want to change the base?
Conversation
Thanks, @2307vivek for this PR 😃 |
@PatilShreyas My pleasure. 😀 |
*/ | ||
fun materialDialog( | ||
activity: Activity, | ||
block: MaterialDialog.Builder.() -> Unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can call it builder
instead of block
.
*/ | ||
fun bottomSheetMaterialDialog( | ||
activity: Activity, | ||
block: BottomSheetMaterialDialog.Builder.() -> Unit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
class Builder(private val activity: Activity) : DialogBuilder() { | ||
|
||
/** | ||
* Build the {@link BottomSheetMaterialDialog}. | ||
*/ | ||
fun build(): BottomSheetMaterialDialog = | ||
BottomSheetMaterialDialog(activity, title, message, isCancelable, mPositiveButton, mNegativeButton, animationResId, mAnimationFile) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's purpose of this?
class Builder(private val activity: Activity) : DialogBuilder() { | ||
|
||
/** | ||
* Build the {@link BottomSheetMaterialDialog}. | ||
*/ | ||
fun build(): BottomSheetMaterialDialog = | ||
BottomSheetMaterialDialog(activity, title, message, isCancelable, mPositiveButton, mNegativeButton, animationResId, mAnimationFile) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can call it
builder
instead 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's purpose of this?
It can be safely deleted, I wrote that methods before the class was finalised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍🏻
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