Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map
This commit is contained in:
@@ -39,6 +39,10 @@ class DialogImpl implements IWindowManagerView {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(WindowManagerView.WMViewParams params) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
/*
|
||||
|
||||
@@ -27,6 +27,12 @@ interface IWindowManagerView {
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* 更新界面位置或大小
|
||||
* @param params 具体参数
|
||||
*/
|
||||
void update(WindowManagerView.WMViewParams params);
|
||||
|
||||
/**
|
||||
* 隐藏
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
@@ -16,6 +17,8 @@ class WindowManagerImpl implements IWindowManagerView {
|
||||
private WindowManagerView.WMViewParams mParams;
|
||||
private boolean isShowing;
|
||||
|
||||
private View rootView;
|
||||
|
||||
private float mLastX, mLastY;
|
||||
private int mOldOffsetX, mOldOffsetY;
|
||||
|
||||
@@ -23,6 +26,10 @@ class WindowManagerImpl implements IWindowManagerView {
|
||||
public void init( WindowManagerView.WMViewParams params ) {
|
||||
mParams = params;
|
||||
mWindowManager = ( WindowManager ) mParams.mContext.getApplicationContext().getSystemService( Context.WINDOW_SERVICE );
|
||||
generateLayoutParams();
|
||||
}
|
||||
|
||||
private void generateLayoutParams(){
|
||||
mLayoutParams = new WindowManager.LayoutParams();
|
||||
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) {
|
||||
mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
@@ -80,10 +87,20 @@ class WindowManagerImpl implements IWindowManagerView {
|
||||
public void show() {
|
||||
if ( !isShowing ) {
|
||||
isShowing = true;
|
||||
rootView = mParams.mContentView;
|
||||
mWindowManager.addView( mParams.mContentView, mLayoutParams );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(WindowManagerView.WMViewParams params) {
|
||||
if (isShowing) {
|
||||
mParams = params;
|
||||
generateLayoutParams();
|
||||
mWindowManager.updateViewLayout(rootView,mLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
if ( isShowing && mParams != null ) {
|
||||
|
||||
@@ -116,4 +116,15 @@ public class WindowManagerView {
|
||||
public int mY;
|
||||
public int mGravity;
|
||||
}
|
||||
|
||||
public void exchangeSizeAndPosition(int width, int height, int x, int y) {
|
||||
if (isShowing()) {
|
||||
mParams.mX = x;
|
||||
mParams.mY = y;
|
||||
mParams.mWidth = width;
|
||||
mParams.mHeight = height;
|
||||
mManagerView.update(mParams);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user