Skip to content

Commit 1779177

Browse files
VSpotView2
1 parent 0f4d1ca commit 1779177

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

library/src/main/java/com/developer/spoti/vspoti/VSpotView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ public void show() {
277277
startAnimation.setFillAfter(true);
278278
this.startAnimation(startAnimation);
279279
mIsShowing = true;
280-
281280
}
282281

283282
public void setTitle(String str) {

library/src/main/java/com/developer/spoti/vspoti/VSpotView2.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.graphics.*;
66
import android.view.*;
7+
import android.view.animation.AlphaAnimation;
78
import android.widget.FrameLayout;
89

910
import java.util.ArrayList;
@@ -32,6 +33,8 @@ public class VSpotView2 extends FrameLayout {
3233
private static final float ARROW_WIDTH = 20;
3334
private static final float ARROW_HEIGHT = 12;
3435

36+
final int ANIMATION_DURATION = 400;
37+
3538
public interface VSpotListener {
3639
void onDismiss(View view);
3740
}
@@ -198,6 +201,19 @@ public void previousTarget() {
198201
}
199202
}
200203

204+
public void show() {
205+
this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
206+
ViewGroup.LayoutParams.MATCH_PARENT));
207+
this.setClickable(false);
208+
209+
((ViewGroup) ((Activity) getContext()).getWindow().getDecorView()).addView(this);
210+
AlphaAnimation startAnimation = new AlphaAnimation(0.0f, 1.0f);
211+
startAnimation.setDuration(ANIMATION_DURATION);
212+
startAnimation.setFillAfter(true);
213+
this.startAnimation(startAnimation);
214+
mIsShowing = true;
215+
}
216+
201217
public boolean isShowing() {
202218
return mIsShowing;
203219
}
@@ -267,6 +283,7 @@ public static class Builder {
267283
private final List<View> targetViews = new ArrayList<>();
268284
private final Context context;
269285
private String title, contentText;
286+
private Gravity gravity;
270287
private VSpotListener vSpotListener;
271288
private DismissType dismissType = DismissType.outside;
272289

@@ -289,6 +306,11 @@ public Builder setContentText(String contentText) {
289306
return this;
290307
}
291308

309+
public Builder setGravity(Gravity gravity) {
310+
this.gravity = gravity;
311+
return this;
312+
}
313+
292314
public Builder setVSpotListener(VSpotListener listener) {
293315
this.vSpotListener = listener;
294316
return this;

sample/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<activity
1212
android:exported="true"
1313
android:windowSoftInputMode="stateHidden"
14-
android:name="com.developer.spoti.vspot.MainActivity">
14+
android:name="com.developer.spoti.vspot.MainActivity2">
1515
<intent-filter>
1616
<action android:name="android.intent.action.MAIN" />
1717

sample/src/main/java/com/developer/spoti/vspot/MainActivity2.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import androidx.appcompat.app.AppCompatActivity;
77

8-
import com.developer.spoti.vspoti.VSpotView;
98
import com.developer.spoti.vspoti.VSpotView2;
109

1110
public class MainActivity2 extends AppCompatActivity {
@@ -24,23 +23,23 @@ protected void onCreate(Bundle savedInstanceState) {
2423
final View view4 = findViewById(R.id.view4);
2524
final View view5 = findViewById(R.id.view5);
2625

27-
2826
builder = new VSpotView2.Builder(MainActivity2.this)
2927
.setTitle("Guide Title Text")
3028
.setContentText("Spoti Description Text\n .....Spoti Description Text\n .....Spoti Description Text .....")
31-
.setGravity(VSpotView.Gravity.center)
32-
.setDismissType(VSpotView.DismissType.outside)
33-
.setTargetView(view1)
29+
30+
.setGravity(VSpotView2.Gravity.center)
31+
.setDismissType(VSpotView2.DismissType.outside)
32+
.addTargetView(view1)
3433
.setVSpotListener(view -> {
3534
int id = view.getId();
3635
if (id == R.id.view1) {
37-
builder.setTargetView(view2).build();
36+
builder.addTargetView(view2).build();
3837
} else if (id == R.id.view2) {
39-
builder.setTargetView(view3).build();
38+
builder.addTargetView(view3).build();
4039
} else if (id == R.id.view3) {
41-
builder.setTargetView(view4).build();
40+
builder.addTargetView(view4).build();
4241
} else if (id == R.id.view4) {
43-
builder.setTargetView(view5).build();
42+
builder.addTargetView(view5).build();
4443
} else if (id == R.id.view5) {
4544
return;
4645
}
@@ -50,20 +49,11 @@ protected void onCreate(Bundle savedInstanceState) {
5049

5150
mVSpotView = builder.build();
5251
mVSpotView.show();
53-
54-
// builder2 = new VSpotView2.Builder(MainActivity.this, view1)
55-
// .setDismissType(VSpotView2.DismissType.anywhere)
56-
// .setGravity(VSpotView2.Gravity.center);
57-
//
58-
// vSpotView2 = builder2.build();
59-
// vSpotView2.show();
60-
6152
}
6253

6354

6455
@Override
6556
protected void onDestroy() {
6657
super.onDestroy();
67-
6858
}
6959
}

0 commit comments

Comments
 (0)