This repository has been archived by the owner on Apr 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added special Cling implementation to show an arrow (currently showin…
…g hand until we get the assets). Fixed init method not respecting new configs and added scale of the cling to the configuration.
- Loading branch information
Martin Marconcini
committed
Feb 13, 2014
1 parent
a9ddf4a
commit 9582e68
Showing
2 changed files
with
102 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
library/src/com/espian/showcaseview/drawing/TwoArrowsClickDrawerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.espian.showcaseview.drawing; | ||
|
||
import android.content.res.Resources; | ||
import android.graphics.Canvas; | ||
import android.graphics.Matrix; | ||
import android.graphics.PorterDuff; | ||
import android.graphics.Rect; | ||
import android.graphics.drawable.Drawable; | ||
import android.util.Log; | ||
import com.github.espiandev.showcaseview.R; | ||
|
||
/** | ||
* User: martin | ||
* Date: 2/12/14 | ||
* Time: 3:03 PM | ||
*/ | ||
public class TwoArrowsClickDrawerImpl implements ClingDrawer { | ||
private Drawable mShowcaseDrawable; | ||
private Rect mShowcaseRect; | ||
public TwoArrowsClickDrawerImpl(Resources resources, int showcaseColor) { | ||
mShowcaseDrawable = resources.getDrawable(R.drawable.hand); | ||
mShowcaseDrawable.setColorFilter(showcaseColor, PorterDuff.Mode.MULTIPLY); | ||
} | ||
@Override | ||
public boolean calculateShowcaseRect(final float x, final float y) { | ||
if (mShowcaseRect == null) { | ||
mShowcaseRect = new Rect(); | ||
} | ||
int cx = (int) x, cy = (int) y; | ||
int dw = getShowcaseWidth(); | ||
int dh = getShowcaseHeight(); | ||
if (mShowcaseRect.left == cx - dw / 2) { | ||
return false; | ||
} | ||
Log.d("ShowcaseView", "Recalculated"); | ||
mShowcaseRect.left = cx - dw / 2; | ||
mShowcaseRect.top = cy - dh / 2; | ||
mShowcaseRect.right = cx + dw / 2; | ||
mShowcaseRect.bottom = cy + dh / 2; | ||
return true; | ||
} | ||
public Rect getShowcaseRect() { | ||
return mShowcaseRect; | ||
} | ||
@Override | ||
public void drawShowcase(final Canvas canvas, final float x, final float y, final float scaleMultiplier, final float radius) { | ||
Matrix mm = new Matrix(); | ||
mm.postScale(scaleMultiplier, scaleMultiplier, x, y); | ||
canvas.setMatrix(mm); | ||
mShowcaseDrawable.setBounds(mShowcaseRect); | ||
mShowcaseDrawable.draw(canvas); | ||
canvas.setMatrix(new Matrix()); | ||
} | ||
@Override | ||
public int getShowcaseWidth() { | ||
return mShowcaseDrawable.getIntrinsicWidth(); | ||
} | ||
@Override | ||
public int getShowcaseHeight() { | ||
return mShowcaseDrawable.getIntrinsicHeight(); | ||
} | ||
} |