/** * @param context context * @param yOffset offset from top * @param minRippleSize minimum ripple size * @param maxRippleSize max ripple size */ public GuidePopupView(Context context, int yOffset, int minRippleSize, int maxRippleSize) { this.minRippleSize = Math.min(minRippleSize, maxRippleSize); this.maxRippleSize = Math.max(minRippleSize, maxRippleSize); this.yOffset = yOffset; guideLayout = new GuideLayout(context); guideLayout.setOnClickListener(null); guideLayout.setOnLongClickListener(null); }
@Override public void initAttr(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { // setWillNotDraw(false); setEnabled(false); ivTarget = new ImageView(context); addView(ivTarget, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
public void dismiss() { ViewGroup parent = (ViewGroup) guideLayout.getParent(); if (parent != null) parent.removeView(guideLayout); }
private void updateRippleLocation(@NonNull Rect targetRect, int minRippleSize, int maxRippleSize, OnRippleViewUpdateLocationCallback callback) { int size = Math.max(targetRect.width(), targetRect.height()); int min = Math.min(minRippleSize, maxRippleSize); int max = minRippleSize + maxRippleSize - min; if (min > 0) { size = Math.max(size, minRippleSize); } if (max > 0) { size = Math.min(size, maxRippleSize); } LayoutParams params = new LayoutParams(size, 0); params.leftMargin = (targetRect.left + targetRect.right - size) / 2; params.topMargin = (targetRect.top + targetRect.bottom - size) / 2; if (guideRippleViewView == null) { guideRippleViewView = new GuideRippleView(getContext()); addView(guideRippleViewView, params); } else { guideRippleViewView.setLayoutParams(params); } if (callback != null) callback.onRippleViewUpdateLocation(guideRippleViewView); }
/** * @param context context * @param yOffset offset from top * @param minRippleSize minimum ripple size * @param maxRippleSize max ripple size */ public GuidePopupWindow(Context context, int yOffset, int minRippleSize, int maxRippleSize) { this.minRippleSize = Math.min(minRippleSize, maxRippleSize); this.maxRippleSize = Math.max(minRippleSize, maxRippleSize); this.yOffset = yOffset; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); guideLayout = new GuideLayout(context); guideLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mPopupWindow = new PopupWindow(); mPopupWindow.setContentView(guideLayout); mPopupWindow.setWidth(metrics.widthPixels); mPopupWindow.setHeight(metrics.heightPixels); mPopupWindow.setFocusable(false); mPopupWindow.setOutsideTouchable(true); }
public GuideLayout(@NonNull Context context) { super(context); initAttr(context, null, 0); }
public GuidePopupWindow removeAllCustomView() { guideLayout.removeAllCustomViews(); return this; }
public GuidePopupWindow setBackgroundColor(@ColorInt int color) { guideLayout.setBackgroundColor(color); return this; }
/** * It must be called after {@link #attachTarget(View)} if necessary. * <br>And you should call it before {@link #show(Activity)}. * * @param customView custom view * @param callback initialize call back. * @param <V> custom view type */ public <V extends View> GuidePopupView addCustomView(@NonNull V customView, @NonNull GuideLayout.OnAddCustomViewCallback<V> callback) { if (target == null) throw new IllegalStateException("You need attach target first."); guideLayout.addCustomView(customView, callback); return this; }
public void removeAllCustomViews(){ if (customViewArray == null || customViewArray.isEmpty()) return; for (View v : customViewArray) { removeView(v); } customViewArray.clear(); customViewArray = null; }
/** * Before showing action, it must had attached target. */ public void show() { if (target == null) throw new IllegalStateException("You need attach target first."); mPopupWindow.showAsDropDown(target, -guideLayout.getTargetRect().left, -guideLayout.getTargetRect().bottom); }
/** * @param context context * @param yOffset offset from top * @param minRippleSize minimum ripple size * @param maxRippleSize max ripple size */ public GuideDialog(Context context, int yOffset, int minRippleSize, int maxRippleSize) { super(context); supportRequestWindowFeature(Window.FEATURE_NO_TITLE); this.minRippleSize = Math.min(minRippleSize, maxRippleSize); this.maxRippleSize = Math.max(minRippleSize, maxRippleSize); this.yOffset = yOffset; guideLayout = new GuideLayout(getContext()); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public GuideLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); initAttr(context, attrs, defStyleAttr); }
public GuidePopupView removeAllCustomView() { guideLayout.removeAllCustomViews(); return this; }
public GuidePopupView setBackgroundColor(@ColorInt int color) { guideLayout.setBackgroundColor(color); return this; }
/** * It must be called after {@link #attachTarget(View)} if necessary. * <br>And you should call it before {@link #show()}. * * @param customView custom view * @param callback initialize call back. * @param <V> custom view type */ public <V extends View> GuideDialog addCustomView(@NonNull V customView, @NonNull GuideLayout.OnAddCustomViewCallback<V> callback) { if (target == null) throw new IllegalStateException("You need attach target first."); guideLayout.addCustomView(customView, callback); return this; }
public GuideLayout(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); initAttr(context, attrs, 0); }
public GuideDialog removeAllCustomView() { guideLayout.removeAllCustomViews(); return this; }
public GuideDialog setBackgroundColor(@ColorInt int color) { guideLayout.setBackgroundColor(color); return this; }
/** * It must be called after {@link #attachTarget(View)} if necessary. * <br>And you should call it before {@link #show()}. * * @param customView custom view * @param callback initialize call back. * @param <V> custom view type */ public <V extends View> GuidePopupWindow addCustomView(@NonNull V customView, @NonNull GuideLayout.OnAddCustomViewCallback<V> callback) { if (target == null) throw new IllegalStateException("You need attach target first."); guideLayout.addCustomView(customView, callback); return this; }