Search in sources :

Example 1 with RectLightShape

use of zhy.com.highlight.shape.RectLightShape in project Highlight by hongyangAndroid.

the class MainActivity method showTipView.

public void showTipView(View view) {
    mHightLight = //
    new HighLight(MainActivity.this).anchor(//如果是Activity上增加引导层,不需要设置anchor
    findViewById(R.id.id_container)).addHighLight(R.id.btn_rightLight, R.layout.info_gravity_left_down, new OnLeftPosCallback(45), new RectLightShape()).addHighLight(R.id.btn_light, R.layout.info_gravity_left_down, new OnRightPosCallback(5), new CircleLightShape()).addHighLight(R.id.btn_bottomLight, R.layout.info_gravity_left_down, new OnTopPosCallback(), new CircleLightShape()).addHighLight(view, R.layout.info_gravity_left_down, new OnBottomPosCallback(60), new CircleLightShape());
    mHightLight.show();
}
Also used : HighLight(zhy.com.highlight.HighLight) OnLeftPosCallback(zhy.com.highlight.position.OnLeftPosCallback) CircleLightShape(zhy.com.highlight.shape.CircleLightShape) RectLightShape(zhy.com.highlight.shape.RectLightShape) OnTopPosCallback(zhy.com.highlight.position.OnTopPosCallback) OnRightPosCallback(zhy.com.highlight.position.OnRightPosCallback) OnBottomPosCallback(zhy.com.highlight.position.OnBottomPosCallback)

Example 2 with RectLightShape

use of zhy.com.highlight.shape.RectLightShape in project Highlight by hongyangAndroid.

the class MainActivity method showNextTipView.

/**
     * 显示next模式提示布局
     * @param view
     * @author isanwenyu@163.com
     */
public void showNextTipView(View view) {
    mHightLight = //
    new HighLight(MainActivity.this).anchor(//如果是Activity上增加引导层,不需要设置anchor
    findViewById(R.id.id_container)).addHighLight(R.id.btn_rightLight, R.layout.info_gravity_left_down, new OnLeftPosCallback(45), new RectLightShape()).addHighLight(R.id.btn_light, R.layout.info_gravity_left_down, new OnRightPosCallback(5), new CircleLightShape()).addHighLight(R.id.btn_bottomLight, R.layout.info_gravity_left_down, new OnTopPosCallback(), new CircleLightShape()).addHighLight(view, R.layout.info_gravity_left_down, new OnBottomPosCallback(60), new CircleLightShape()).autoRemove(false).enableNext().setClickCallback(new HighLight.OnClickCallback() {

        @Override
        public void onClick() {
            Toast.makeText(MainActivity.this, "clicked and show next tip view by yourself", Toast.LENGTH_SHORT).show();
            mHightLight.next();
        }
    });
    mHightLight.show();
}
Also used : HighLight(zhy.com.highlight.HighLight) OnLeftPosCallback(zhy.com.highlight.position.OnLeftPosCallback) CircleLightShape(zhy.com.highlight.shape.CircleLightShape) RectLightShape(zhy.com.highlight.shape.RectLightShape) OnTopPosCallback(zhy.com.highlight.position.OnTopPosCallback) OnRightPosCallback(zhy.com.highlight.position.OnRightPosCallback) OnBottomPosCallback(zhy.com.highlight.position.OnBottomPosCallback)

Example 3 with RectLightShape

use of zhy.com.highlight.shape.RectLightShape in project Highlight by hongyangAndroid.

the class MainActivity method showNextKnownTipView.

/**
     * 显示 next模式 我知道了提示高亮布局
     * @param view id为R.id.iv_known的控件
     * @author isanwenyu@163.com
     */
public void showNextKnownTipView(View view) {
    mHightLight = //
    new HighLight(MainActivity.this).autoRemove(//设置背景点击高亮布局自动移除为false 默认为true
    false).intercept(//拦截属性默认为true 使下方callback生效
    true).enableNext().anchor(//如果是Activity上增加引导层,不需要设置anchor
    findViewById(R.id.id_container)).addHighLight(R.id.btn_rightLight, R.layout.info_known, new OnLeftPosCallback(45), new RectLightShape()).addHighLight(R.id.btn_light, R.layout.info_known, new OnRightPosCallback(5), new BaseLightShape(5, 5) {

        @Override
        protected void resetRectF4Shape(RectF viewPosInfoRectF, float dx, float dy) {
            //缩小高亮控件范围
            viewPosInfoRectF.inset(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dx, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dy, getResources().getDisplayMetrics()));
        }

        @Override
        protected void drawShape(Bitmap bitmap, HighLight.ViewPosInfo viewPosInfo) {
            //custom your hight light shape 自定义高亮形状
            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
            paint.setDither(true);
            paint.setAntiAlias(true);
            paint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
            RectF rectF = viewPosInfo.rectF;
            canvas.drawOval(rectF, paint);
        }
    }).addHighLight(R.id.btn_bottomLight, R.layout.info_known, new OnTopPosCallback(), new CircleLightShape()).addHighLight(view, R.layout.info_known, new OnBottomPosCallback(10), new RectLightShape()).setOnRemoveCallback(new //监听移除回调 intercept为true时生效
    HighLightInterface.OnRemoveCallback() {

        @Override
        public void onRemove() {
            Toast.makeText(MainActivity.this, "The HightLight view has been removed", Toast.LENGTH_SHORT).show();
        }
    }).setOnShowCallback(new //监听显示回调 intercept为true时生效
    HighLightInterface.OnShowCallback() {

        @Override
        public void onShow() {
            Toast.makeText(MainActivity.this, "The HightLight view has been shown", Toast.LENGTH_SHORT).show();
        }
    });
    mHightLight.show();
}
Also used : HighLight(zhy.com.highlight.HighLight) OnLeftPosCallback(zhy.com.highlight.position.OnLeftPosCallback) Canvas(android.graphics.Canvas) CircleLightShape(zhy.com.highlight.shape.CircleLightShape) HighLightInterface(zhy.com.highlight.interfaces.HighLightInterface) RectLightShape(zhy.com.highlight.shape.RectLightShape) Paint(android.graphics.Paint) BaseLightShape(zhy.com.highlight.shape.BaseLightShape) OnRightPosCallback(zhy.com.highlight.position.OnRightPosCallback) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) BlurMaskFilter(android.graphics.BlurMaskFilter) OnTopPosCallback(zhy.com.highlight.position.OnTopPosCallback) OnBottomPosCallback(zhy.com.highlight.position.OnBottomPosCallback)

Example 4 with RectLightShape

use of zhy.com.highlight.shape.RectLightShape in project Highlight by hongyangAndroid.

the class MainActivity method showKnownTipView.

/**
     * 显示我知道了提示高亮布局
     * @param view id为R.id.iv_known的控件
     * @author isanwenyu@163.com
     */
public void showKnownTipView(View view) {
    mHightLight = //
    new HighLight(MainActivity.this).autoRemove(//设置背景点击高亮布局自动移除为false 默认为true
    false).intercept(//设置拦截属性为false 高亮布局不影响后面布局的滑动效果 而且使下方点击回调失效
    false).setClickCallback(new HighLight.OnClickCallback() {

        @Override
        public void onClick() {
            Toast.makeText(MainActivity.this, "clicked and remove HightLight view by yourself", Toast.LENGTH_SHORT).show();
            remove(null);
        }
    }).anchor(//如果是Activity上增加引导层,不需要设置anchor
    findViewById(R.id.id_container)).addHighLight(R.id.btn_rightLight, R.layout.info_known, new OnLeftPosCallback(45), new RectLightShape()).addHighLight(R.id.btn_light, R.layout.info_known, new OnRightPosCallback(5), new CircleLightShape()).addHighLight(R.id.btn_bottomLight, R.layout.info_known, new OnTopPosCallback(), new CircleLightShape()).addHighLight(view, R.layout.info_known, new OnBottomPosCallback(10), new RectLightShape());
    mHightLight.show();
//        //added by isanwenyu@163.com 设置监听器只有最后一个添加到HightLightView的knownView响应了事件
//        //优化在布局中声明onClick方法 {@link #clickKnown(view)}响应所有R.id.iv_known的控件的点击事件
//        View decorLayout = mHightLight.getHightLightView();
//        ImageView knownView = (ImageView) decorLayout.findViewById(R.id.iv_known);
//        knownView.setOnClickListener(new View.OnClickListener()
//          {
//            @Override
//            public void onClick(View view) {
//                remove(null);
//            }
//        });
}
Also used : HighLight(zhy.com.highlight.HighLight) OnLeftPosCallback(zhy.com.highlight.position.OnLeftPosCallback) CircleLightShape(zhy.com.highlight.shape.CircleLightShape) RectLightShape(zhy.com.highlight.shape.RectLightShape) OnTopPosCallback(zhy.com.highlight.position.OnTopPosCallback) OnRightPosCallback(zhy.com.highlight.position.OnRightPosCallback) OnBottomPosCallback(zhy.com.highlight.position.OnBottomPosCallback)

Example 5 with RectLightShape

use of zhy.com.highlight.shape.RectLightShape in project Highlight by hongyangAndroid.

the class HighLight method addHighLight.

public HighLight addHighLight(View view, int decorLayoutId, OnPosCallback onPosCallback, LightShape lightShape) {
    if (onPosCallback == null && decorLayoutId != -1) {
        throw new IllegalArgumentException("onPosCallback can not be null.");
    }
    ViewGroup parent = (ViewGroup) mAnchor;
    RectF rect = new RectF(ViewUtils.getLocationInView(parent, view));
    //if RectF is empty return  added by isanwenyu 2016/10/26.
    if (rect.isEmpty())
        return this;
    ViewPosInfo viewPosInfo = new ViewPosInfo();
    viewPosInfo.layoutId = decorLayoutId;
    viewPosInfo.rectF = rect;
    viewPosInfo.view = view;
    MarginInfo marginInfo = new MarginInfo();
    onPosCallback.getPos(parent.getWidth() - rect.right, parent.getHeight() - rect.bottom, rect, marginInfo);
    viewPosInfo.marginInfo = marginInfo;
    viewPosInfo.onPosCallback = onPosCallback;
    viewPosInfo.lightShape = lightShape == null ? new RectLightShape() : lightShape;
    mViewRects.add(viewPosInfo);
    return this;
}
Also used : RectF(android.graphics.RectF) ViewGroup(android.view.ViewGroup) RectLightShape(zhy.com.highlight.shape.RectLightShape)

Aggregations

RectLightShape (zhy.com.highlight.shape.RectLightShape)5 HighLight (zhy.com.highlight.HighLight)4 OnBottomPosCallback (zhy.com.highlight.position.OnBottomPosCallback)4 OnLeftPosCallback (zhy.com.highlight.position.OnLeftPosCallback)4 OnRightPosCallback (zhy.com.highlight.position.OnRightPosCallback)4 OnTopPosCallback (zhy.com.highlight.position.OnTopPosCallback)4 CircleLightShape (zhy.com.highlight.shape.CircleLightShape)4 RectF (android.graphics.RectF)2 Bitmap (android.graphics.Bitmap)1 BlurMaskFilter (android.graphics.BlurMaskFilter)1 Canvas (android.graphics.Canvas)1 Paint (android.graphics.Paint)1 ViewGroup (android.view.ViewGroup)1 HighLightInterface (zhy.com.highlight.interfaces.HighLightInterface)1 BaseLightShape (zhy.com.highlight.shape.BaseLightShape)1