Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions app/src/main/java/me/toptas/fancyshowcasesample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.graphics.Color
import android.os.Bundle
import android.text.Html
import android.text.Spanned
import android.util.Log
import android.util.TypedValue
import android.view.Gravity
import android.view.Menu
Expand Down Expand Up @@ -124,25 +125,21 @@ class MainActivity : BaseActivity() {

//Shows a FancyShowCaseView that focus on a view
btn_focus_dismiss_on_focus_area.setOnClickListener {
if (FancyShowCaseView.isVisible(this)) {
Toast.makeText(this, "Clickable button", Toast.LENGTH_SHORT).show()
FancyShowCaseView.hideCurrent(this)
} else {
FancyShowCaseView.Builder(this)
Toast.makeText(this, "Clickable button", Toast.LENGTH_SHORT).show()

FancyShowCaseView.Builder(this)
.focusOn(findViewById(R.id.btn_focus_dismiss_on_focus_area))
.enableTouchOnFocusedView(true)
.title("Focus on View \n(dismiss on focus area)")
.build()
.show()
}

}

//Shows a FancyShowCaseView with rounded rect focus shape
btn_rounded_rect_dismiss_on_focus_area.setOnClickListener {
if (FancyShowCaseView.isVisible(this)) {
Toast.makeText(this, "Clickable button", Toast.LENGTH_SHORT).show()
FancyShowCaseView.hideCurrent(this)
} else {
Toast.makeText(this, "Clickable button", Toast.LENGTH_SHORT).show()

FancyShowCaseView.Builder(this)
.focusOn(it)
.focusShape(FocusShape.ROUNDED_RECTANGLE)
Expand All @@ -151,7 +148,7 @@ class MainActivity : BaseActivity() {
.title("Focus on View \n(dismiss on focus area)")
.build()
.show()
}

}

//Shows FancyShowCaseView with focusCircleRadiusFactor 1.5 and title gravity
Expand Down Expand Up @@ -271,6 +268,7 @@ class MainActivity : BaseActivity() {
})
.closeOnTouch(false)
.build()

mFancyShowCaseView?.show()

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,9 @@ class FancyShowCaseView @JvmOverloads constructor(context: Context, attrs: Attri
* @return [FancyShowCaseView] with given parameters
*/
fun build(): FancyShowCaseView {
if(isVisible(activity)){
hideCurrent(activity)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I like the idea of auto-hiding, yet shouldn't this be done in the show() function. The build() function would also be used to prepare show cases to be enqueued e.g..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I do agree this should be done inside show() function instead of the build method.

return FancyShowCaseView(activity, focusedView, clickableView, mId, mTitle, mSpannedTitle, mTitleGravity, mTitleStyle, mTitleSize, mTitleSizeUnit,
focusCircleRadiusFactor, mBackgroundColor, mFocusBorderColor, mFocusBorderSize, mCustomViewRes, viewInflateListener,
mEnterAnimation, mExitAnimation, mAnimationListener, mCloseOnTouch, mEnableTouchOnFocusedView, fitSystemWindows, mFocusShape, mDismissListener, mRoundRectRadius,
Expand Down