From 5a331659033a4503187969b5426617d4eab9789d Mon Sep 17 00:00:00 2001 From: "selim.toksal" Date: Fri, 27 Sep 2019 15:30:27 +0300 Subject: [PATCH] Add debug mode --- .../trendyol/showcase/showcase/ShowcaseManager.kt | 13 ++++++++++++- .../com/trendyol/showcase/showcase/ShowcaseModel.kt | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt index 648e338..2fda1f3 100644 --- a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt +++ b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseManager.kt @@ -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) @@ -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 @@ -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 } @@ -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!") @@ -163,7 +173,8 @@ data class ShowcaseManager private constructor( titleTextSize, descriptionTextSize, highlightPadding, - cancellableFromOutsideTouch) + cancellableFromOutsideTouch, + isDebugMode) return ShowcaseManager(showcaseModel, resId) } diff --git a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt index 03035b4..b8d1f82 100644 --- a/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt +++ b/library/src/main/java/com/trendyol/showcase/showcase/ShowcaseModel.kt @@ -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)