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
34 changes: 19 additions & 15 deletions highlight/src/main/java/zhy/com/highlight/HighLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import java.util.List;

import zhy.com.highlight.util.ViewUtils;
import zhy.com.highlight.view.HightLightView;
import zhy.com.highlight.view.HighLightView;

/**
* Created by zhy on 15/10/8.
*/
public class HighLight
{
private static final String TAG = "anchorIsFrameLayout";

public static class ViewPosInfo
{
public int layoutId = -1;
Expand Down Expand Up @@ -46,7 +48,7 @@ public static interface OnPosCallback
private View mAnchor;
private List<ViewPosInfo> mViewRects;
private Context mContext;
private HightLightView mHightLightView;
private HighLightView mHighLightView;

private boolean intercept = true;
private boolean shadow = true;
Expand Down Expand Up @@ -134,15 +136,15 @@ public HighLight addHighLight(View view, int decorLayoutId, OnPosCallback onPosC
public void show()
{

if (mHightLightView != null) return;
if (mHighLightView != null) return;

HightLightView hightLightView = new HightLightView(mContext, this, maskColor, shadow, mViewRects);
HighLightView highLightView = new HighLightView(mContext, this, maskColor, shadow, mViewRects);
if (mAnchor.getClass().getSimpleName().equals("FrameLayout"))
{
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams
(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
((ViewGroup) mAnchor).addView(hightLightView, ((ViewGroup) mAnchor).getChildCount(), lp);

((ViewGroup) mAnchor).addView(highLightView, ((ViewGroup) mAnchor).getChildCount(), lp);
highLightView.setTag(TAG);
} else
{
FrameLayout frameLayout = new FrameLayout(mContext);
Expand All @@ -153,12 +155,13 @@ public void show()
(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
frameLayout.addView(mAnchor, lp);

frameLayout.addView(hightLightView);
frameLayout.addView(highLightView);
highLightView.setTag("");
}

if (intercept)
{
hightLightView.setOnClickListener(new View.OnClickListener()
highLightView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
Expand All @@ -168,25 +171,26 @@ public void onClick(View v)
});
}

mHightLightView = hightLightView;
mHighLightView = highLightView;
}

public void remove()
{
if (mHightLightView == null) return;
ViewGroup parent = (ViewGroup) mHightLightView.getParent();
if (parent instanceof RelativeLayout || parent instanceof FrameLayout)
if (mHighLightView == null) return;
ViewGroup parent = (ViewGroup) mHighLightView.getParent();
if (mHighLightView.getTag().equals(TAG))
{
parent.removeView(mHightLightView);
parent.removeView(mHighLightView);
} else
{
parent.removeView(mHightLightView);
parent.removeView(mHighLightView);
View origin = parent.getChildAt(0);
parent.removeView(origin);
ViewGroup graParent = (ViewGroup) parent.getParent();
graParent.removeView(parent);
graParent.addView(origin, parent.getLayoutParams());
}
mHightLightView = null;
mHighLightView = null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Created by zhy on 15/10/8.
*/
public class HightLightView extends FrameLayout
public class HighLightView extends FrameLayout
{
private static final int DEFAULT_WIDTH_BLUR = 15;
private static final int DEFAULT_RADIUS = 6;
Expand All @@ -36,7 +36,7 @@ public class HightLightView extends FrameLayout
private int maskColor = 0xCC000000;


public HightLightView(Context context, HighLight highLight, int maskColor, boolean isBlur, List<HighLight.ViewPosInfo> viewRects)
public HighLightView(Context context, HighLight highLight, int maskColor, boolean isBlur, List<HighLight.ViewPosInfo> viewRects)
{
super(context);
mHighLight = highLight;
Expand Down