@Test public void testAddToWindow() throws Exception { final View iconMock = mock(View.class); setInternalState(magnet, "iconView", iconMock); magnet.addToWindow(); verify(windowManagerMock).addView(iconMock, paramsMock); }
protected void addToWindow() { int overlayFlag; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { overlayFlag = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { overlayFlag = WindowManager.LayoutParams.TYPE_PHONE; } WindowManager.LayoutParams params = new WindowManager.LayoutParams( iconWidth > 0 ? iconWidth : WindowManager.LayoutParams.WRAP_CONTENT, iconHeight > 0 ? iconHeight : WindowManager.LayoutParams.WRAP_CONTENT, overlayFlag, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSPARENT); params.gravity = Gravity.TOP | Gravity.START; windowManager.addView(iconView, layoutParams = params); addedToWindow = true; }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { protected void addToWindow() { int overlayFlag; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { overlayFlag = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { overlayFlag = WindowManager.LayoutParams.TYPE_PHONE; } WindowManager.LayoutParams params = new WindowManager.LayoutParams( iconWidth > 0 ? iconWidth : WindowManager.LayoutParams.WRAP_CONTENT, iconHeight > 0 ? iconHeight : WindowManager.LayoutParams.WRAP_CONTENT, overlayFlag, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSPARENT); params.gravity = Gravity.TOP | Gravity.START; windowManager.addView(iconView, layoutParams = params); addedToWindow = true; } }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { protected void addToWindow() { int overlayFlag; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { overlayFlag = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { overlayFlag = WindowManager.LayoutParams.TYPE_PHONE; } WindowManager.LayoutParams params = new WindowManager.LayoutParams( iconWidth > 0 ? iconWidth : WindowManager.LayoutParams.WRAP_CONTENT, iconHeight > 0 ? iconHeight : WindowManager.LayoutParams.WRAP_CONTENT, overlayFlag, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSPARENT); params.gravity = Gravity.TOP | Gravity.START; windowManager.addView(iconView, layoutParams = params); addedToWindow = true; } Magnet(Context context); }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { protected void addToWindow() { int overlayFlag; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { overlayFlag = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { overlayFlag = WindowManager.LayoutParams.TYPE_PHONE; } WindowManager.LayoutParams params = new WindowManager.LayoutParams( iconWidth > 0 ? iconWidth : WindowManager.LayoutParams.WRAP_CONTENT, iconHeight > 0 ? iconHeight : WindowManager.LayoutParams.WRAP_CONTENT, overlayFlag, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSPARENT); params.gravity = Gravity.TOP | Gravity.START; windowManager.addView(iconView, layoutParams = params); addedToWindow = true; } Magnet(Context context); static Builder<Magnet> newBuilder(Context context); void show(); @Deprecated void setPosition(int x, int y, boolean animate); void setPosition(int x, int y); void setIconSize(int width, int height); void goToWall(); void destroy(); @Override void onGlobalLayout(); @Override boolean onTouch(View view, MotionEvent event); @Override void onClick(View view); @Override void onSpringUpdate(Spring spring); @Override void onSpringAtRest(Spring spring); @Override void onSpringActivate(Spring spring); @Override void onSpringEndStateChange(Spring spring); }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { protected void addToWindow() { int overlayFlag; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { overlayFlag = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { overlayFlag = WindowManager.LayoutParams.TYPE_PHONE; } WindowManager.LayoutParams params = new WindowManager.LayoutParams( iconWidth > 0 ? iconWidth : WindowManager.LayoutParams.WRAP_CONTENT, iconHeight > 0 ? iconHeight : WindowManager.LayoutParams.WRAP_CONTENT, overlayFlag, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSPARENT); params.gravity = Gravity.TOP | Gravity.START; windowManager.addView(iconView, layoutParams = params); addedToWindow = true; } Magnet(Context context); static Builder<Magnet> newBuilder(Context context); void show(); @Deprecated void setPosition(int x, int y, boolean animate); void setPosition(int x, int y); void setIconSize(int width, int height); void goToWall(); void destroy(); @Override void onGlobalLayout(); @Override boolean onTouch(View view, MotionEvent event); @Override void onClick(View view); @Override void onSpringUpdate(Spring spring); @Override void onSpringAtRest(Spring spring); @Override void onSpringActivate(Spring spring); @Override void onSpringEndStateChange(Spring spring);  }