Skip to content

Commit

Permalink
Added animated gestures to ShowcaseViews class
Browse files Browse the repository at this point in the history
  • Loading branch information
nikwen committed Nov 16, 2013
1 parent 0c4f221 commit 358fa07
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion library/src/com/espian/showcaseview/ShowcaseViews.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class ShowcaseViews {

private final List<ShowcaseView> views = new ArrayList<ShowcaseView>();
private final List<float[]> animations = new ArrayList<float[]>();
private final Activity activity;
private OnShowcaseAcknowledged showcaseAcknowledgedListener = new OnShowcaseAcknowledged() {
@Override
Expand Down Expand Up @@ -51,9 +52,16 @@ public ShowcaseViews addView(ItemViewProperties properties) {
showcaseView.overrideButtonClick(createShowcaseViewDismissListener(showcaseView));
views.add(showcaseView);

animations.add(null);

return this;
}

public void addAnimatedGestureToView(int viewIndex, float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY) throws IndexOutOfBoundsException {
animations.remove(viewIndex);
animations.add(viewIndex, new float[]{offsetStartX, offsetStartY, offsetEndX, offsetEndY});
}

private boolean showcaseActionBar(ItemViewProperties properties) {
return properties.itemType > ItemViewProperties.ID_NOT_IN_ACTIONBAR;
}
Expand Down Expand Up @@ -99,6 +107,7 @@ public void show() {
// The showcase has already been shot once, so we don't need to do show it again.
view.setVisibility(View.GONE);
views.remove(0);
animations.remove(0);
view.getConfigOptions().fadeOutDuration = 0;
view.performButtonClick();
return;
Expand All @@ -107,8 +116,14 @@ public void show() {
view.setVisibility(View.INVISIBLE);
((ViewGroup) activity.getWindow().getDecorView()).addView(view);
view.show();
views.remove(0);

float[] animation = animations.get(0);
if (animation != null) {
view.animateGesture(animation[0], animation[1], animation[2], animation[3]);
}

views.remove(0);
animations.remove(0);
}

public boolean hasViews(){
Expand Down

0 comments on commit 358fa07

Please sign in to comment.