fix: FloatyWindow.setSize() not working
This commit is contained in:
@@ -7,6 +7,7 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.stardust.autojs.R;
|
||||
import com.stardust.autojs.runtime.api.Floaty;
|
||||
import com.stardust.enhancedfloaty.FloatyService;
|
||||
import com.stardust.enhancedfloaty.ResizableFloaty;
|
||||
import com.stardust.enhancedfloaty.ResizableFloatyWindow;
|
||||
@@ -22,13 +23,19 @@ public class FloatyWindow extends ResizableFloatyWindow {
|
||||
private boolean mCreated = false;
|
||||
private View mMoveCursor;
|
||||
private View mResizer;
|
||||
private MyFloaty mFloaty;
|
||||
|
||||
|
||||
public FloatyWindow(View view) {
|
||||
super(new MyFloaty(view));
|
||||
this(new MyFloaty(view));
|
||||
mView = view;
|
||||
}
|
||||
|
||||
private FloatyWindow(MyFloaty floaty) {
|
||||
super(floaty);
|
||||
mFloaty = floaty;
|
||||
}
|
||||
|
||||
public void waitFor() {
|
||||
synchronized (LOCK) {
|
||||
if (mCreated) {
|
||||
@@ -68,10 +75,15 @@ public class FloatyWindow extends ResizableFloatyWindow {
|
||||
return mMoveCursor.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
|
||||
public View getRootView() {
|
||||
return mFloaty.mRootView;
|
||||
}
|
||||
|
||||
private static class MyFloaty implements ResizableFloaty {
|
||||
|
||||
|
||||
private View mContentView;
|
||||
private View mRootView;
|
||||
|
||||
|
||||
public MyFloaty(View view) {
|
||||
@@ -80,9 +92,9 @@ public class FloatyWindow extends ResizableFloatyWindow {
|
||||
|
||||
@Override
|
||||
public View inflateView(FloatyService floatyService, ResizableFloatyWindow resizableFloatyWindow) {
|
||||
View view = View.inflate(mContentView.getContext(), R.layout.floaty_window, null);
|
||||
((FrameLayout) view.findViewById(R.id.container)).addView(mContentView);
|
||||
return view;
|
||||
mRootView = View.inflate(mContentView.getContext(), R.layout.floaty_window, null);
|
||||
((FrameLayout) mRootView.findViewById(R.id.container)).addView(mContentView);
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Floaty {
|
||||
FloatyService.addWindow(mWindow);
|
||||
});
|
||||
mWindow.waitFor();
|
||||
setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2);
|
||||
//setSize(mWindow.getWindowBridge().getScreenWidth() / 2, mWindow.getWindowBridge().getScreenHeight() / 2);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@@ -117,11 +117,12 @@ public class Floaty {
|
||||
|
||||
public void setSize(int w, int h) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
mWindow.getWindowBridge().updateMeasure(w, h);
|
||||
ViewUtil.setViewMeasure(mWindow.getRootView(), w, h);
|
||||
// mWindow.getWindowBridge().updateMeasure(w, h);
|
||||
} else {
|
||||
mUiHandler.post(() -> {
|
||||
ViewUtil.setViewMeasure(mView, w, h);
|
||||
mWindow.getWindowBridge().updateMeasure(w, h);
|
||||
ViewUtil.setViewMeasure(mWindow.getRootView(), w, h);
|
||||
// mWindow.getWindowBridge().updateMeasure(w, h);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user