This commit is contained in:
wangcongtao
2020-02-13 22:09:48 +08:00
parent 7cbe587c8c
commit 0ce54cb9c5
5 changed files with 67 additions and 13 deletions

View File

@@ -17,6 +17,11 @@ import com.mogo.service.windowview.IMogoWindowManager;
@Route( path = MogoServicePaths.PATH_WINDOW_MANAGER )
public class MogoWindowManager implements IMogoWindowManager {
@Override
public void addView( View view, int x, int y, boolean movable ) {
WindowViewHandler.addView( view, x, y, movable );
}
@Override
public void addView( int priority, View view, int x, int y, boolean movable ) {
WindowViewHandler.addView( view, priority, x, y, movable );

View File

@@ -41,6 +41,39 @@ public class WindowViewHandler {
sFloatingLayout = frameLayout;
}
/**
* 添加任意view到布局不考虑优先级
*
* @param view
* @param x
* @param y
* @param movable
*/
public static void addView( View view, int x, int y, boolean movable ) {
if ( view == null ) {
return;
}
if ( sFloatingLayout == null ) {
Logger.e( TAG, "no floating frame. " );
return;
}
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT );
params.leftMargin = x;
params.topMargin = y;
sFloatingLayout.addView( view, params );
}
/**
* 添加view到布局优先级大的展示
*
* @param view
* @param priority
* @param x
* @param y
* @param movable
*/
public static void addView( View view, int priority, int x, int y, boolean movable ) {
if ( view == null ) {
return;
@@ -71,6 +104,14 @@ public class WindowViewHandler {
addView();
}
/**
* 添加view到布局优先级大的展示
*
* @param view
* @param priority
* @param params
* @param movable
*/
public static void addView( View view, int priority, FrameLayout.LayoutParams params, boolean movable ) {
if ( view == null ) {
return;
@@ -104,19 +145,16 @@ public class WindowViewHandler {
if ( sFloatingLayout == null ) {
return;
}
if ( sView != view ) {
Logger.w( TAG, "view do not added." );
return;
}
if ( view == null ) {
return;
}
sFloatingLayout.removeView( view );
sView = null;
sPriority = Integer.MIN_VALUE;
sMovable = false;
sParams = null;
DispatchTouchEventWrapper.getInstance().release();
if ( sView == view ) {
sView = null;
sPriority = Integer.MIN_VALUE;
sMovable = false;
sParams = null;
}
}
private static void addView() {