Skip to content

Commit

Permalink
Merge pull request #5 from selimtoksal/debugMode
Browse files Browse the repository at this point in the history
debugMode
  • Loading branch information
bilgehankalkan authored Sep 27, 2019
2 parents ad59c9b + 5a33165 commit a0fc2c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ data class ShowcaseManager private constructor(
) {

fun show(activity: Activity, requestCode: Int? = null) {
if(showcaseModel.isDebugMode) return

val intent = Intent(activity, ShowcaseActivity::class.java)
val model = if (resId != null) readFromStyle(activity, resId) else showcaseModel
intent.putExtra(ShowcaseActivity.BUNDLE_KEY, model)
Expand All @@ -36,6 +38,8 @@ data class ShowcaseManager private constructor(
}

fun show(fragment: Fragment, requestCode: Int? = null) {
if(showcaseModel.isDebugMode) return

fragment.activity?.let { activity ->
val intent = Intent(activity, ShowcaseActivity::class.java)
val model = if (resId != null) readFromStyle(activity, resId) else showcaseModel
Expand Down Expand Up @@ -91,6 +95,7 @@ data class ShowcaseManager private constructor(
@StyleRes
private var resId: Int? = null
private var cancellableFromOutsideTouch: Boolean = Constants.DEFAULT_CANCELLABLE_FROM_OUTSIDE_TOUCH
private var isDebugMode: Boolean = false

fun view(view: View) = apply { focusView = view }
fun titleText(title: String) = apply { titleText = title }
Expand Down Expand Up @@ -136,6 +141,11 @@ data class ShowcaseManager private constructor(
fun resId(@StyleRes res: Int) = apply { resId = res }
fun cancellableFromOutsideTouch(cancellable: Boolean) = apply { cancellableFromOutsideTouch = cancellable }

/**
* Running in debug mode or not
*/
fun isDebugMode(isDebug: Boolean) = apply { isDebugMode = isDebug }

fun build(): ShowcaseManager {
if (focusView == null) {
throw Exception("view should not be null!")
Expand Down Expand Up @@ -163,7 +173,8 @@ data class ShowcaseManager private constructor(
titleTextSize,
descriptionTextSize,
highlightPadding,
cancellableFromOutsideTouch)
cancellableFromOutsideTouch,
isDebugMode)

return ShowcaseManager(showcaseModel, resId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ data class ShowcaseModel(val rectF: RectF,
val titleTextSize: Float,
val descriptionTextSize: Float,
val highlightPadding: Float,
val cancellableFromOutsideTouch: Boolean
val cancellableFromOutsideTouch: Boolean,
val isDebugMode: Boolean
) : Parcelable {

fun horizontalCenter() = rectF.left + ((rectF.right - rectF.left) / 2)
Expand Down

0 comments on commit a0fc2c1

Please sign in to comment.