Skip to content

Commit 152c63c

Browse files
author
lemon
committed
feature:show guidevew with condition setting;detech the guideView hide event
1 parent 677dcf7 commit 152c63c

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/src/main/java/easily/tech/guideview/MainActivity.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class MainActivity : AppCompatActivity() {
5656
.setTargetView(tvContent)
5757
.setHintView(hintViewLeft)
5858
.setDismissOnClicked(false)
59+
.condition(false)
5960
.setHintViewMargin(0, -160, 0, 0)
6061
.setTransparentSpace(space, space, space, space)
6162
.setOutlineType(TYPE_RECT)
@@ -68,6 +69,9 @@ class MainActivity : AppCompatActivity() {
6869
.setHintView(hintViewTop)
6970
.setDismissOnClicked(false)
7071
.setHintViewParams(params)
72+
.setGuideViewHideListener {
73+
Toast.makeText(this,"dismissed",Toast.LENGTH_SHORT).show()
74+
}
7175
.setHintViewMargin(-dp2px(this, 55f), 0, 0, 0)
7276
.setTransparentSpace(space, space, space, space)
7377
.setHintViewDirection(TOP)

lib/src/main/java/easily/tech/guideview/lib/GuideView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,8 @@ public void hide() {
244244
if (getParent() != null && getParent() instanceof ViewGroup) {
245245
((ViewGroup) getParent()).removeView(this);
246246
}
247+
if (bundle != null && bundle.getGuideViewHideListener() != null) {
248+
bundle.getGuideViewHideListener().onGuideViewHide();
249+
}
247250
}
248251
}

lib/src/main/java/easily/tech/guideview/lib/GuideViewBundle.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public interface Direction {
3636
int BOTTOM = 0x0004;
3737
}
3838

39+
public interface GuideViewHideListener {
40+
void onGuideViewHide();
41+
}
42+
43+
3944
/**
4045
* Transparent focus area outline type
4146
*/
@@ -123,6 +128,14 @@ public boolean isDismissOnTouchInTargetView() {
123128
return config.isDismissOnClickTargetView;
124129
}
125130

131+
public boolean condition() {
132+
return config.condition;
133+
}
134+
135+
public GuideViewHideListener getGuideViewHideListener() {
136+
return config.guideViewHideListener;
137+
}
138+
126139
public static class Builder {
127140

128141
private static int MASK_LAYER_COLOR = 0xd9000000;
@@ -147,6 +160,11 @@ public static class Builder {
147160
// whether click the whole screen can dismissed the guideView.If false,you need to handle the click and dismiss event yourself
148161
private boolean isDismissOnClicked = true;
149162

163+
// set a condition,whether the added GuideViewBundle can be shown,default is true
164+
private boolean condition = true;
165+
166+
private GuideViewHideListener guideViewHideListener;
167+
150168

151169
private boolean isDismissOnClickTargetView=true;
152170

@@ -225,6 +243,18 @@ public Builder setDismissOnTouchInTargetView(boolean dismissOnTouchInTargetView)
225243
}
226244

227245

246+
247+
public Builder condition(boolean condition) {
248+
this.condition = condition;
249+
return this;
250+
}
251+
252+
public Builder setGuideViewHideListener(GuideViewHideListener guideViewHideListener) {
253+
this.guideViewHideListener = guideViewHideListener;
254+
return this;
255+
}
256+
257+
228258
public GuideViewBundle build() {
229259
return new GuideViewBundle(this);
230260
}

lib/src/main/java/easily/tech/guideview/lib/GuideViewFragment.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,15 @@ private void showGuideView() {
9191
flContainer.setBackgroundColor(currentBundle == null ? Color.TRANSPARENT : currentBundle.getMaskColor());
9292
currentGuideView.hide();
9393
}
94-
// if there is no available guideView,just dismiss the whole dialogFragment
95-
if (guideViewBundles == null || guideViewBundles.isEmpty()) {
96-
dismiss();
97-
return;
98-
}
99-
currentBundle = guideViewBundles.remove(0);
94+
// loop to get the available guideView bundle data
95+
do {
96+
if (guideViewBundles == null || guideViewBundles.isEmpty()) {
97+
currentBundle = null;
98+
} else {
99+
currentBundle = guideViewBundles.remove(0);
100+
}
101+
} while (currentBundle != null && !currentBundle.condition());
102+
100103
if (currentBundle == null) {
101104
dismiss();
102105
return;
@@ -107,7 +110,7 @@ private void showGuideView() {
107110
@Override
108111
public void onGuideViewClicked() {
109112
if (currentBundle != null && currentBundle.isDismissOnTouchInTargetView()) {
110-
dismiss();
113+
onNext();
111114
}
112115
}
113116
});

0 commit comments

Comments
 (0)