网课搜题浮窗软件实战开发一个浮窗式的安卓搜题软件
准备知识:javascript auto.js一些基础语法
打包工具:auto.js7.401
免费接口可以自己去找!网上一大堆。
学习资料领取及工具可点击领取学习工具
效果图如图所示:
功能:
1.可以移动,并且可以进行移动
2.可以最小化,点击一下又可以恢复大小
3.可以快速增贴你所复制的内容。
4.如何设置数据库,并且数据库内容随自己去监管。
//公众号:阿超程序
function 刷新屏幕方向(t) {
this.t = t || 100;
this.callBackAry = new Array;
this.Orientation = context.resources.configuration.orientation;
this.Width = this.Orientation == 1 ? device.width : device.height;
this.Height = this.Orientation == 2 ? device.width : device.height;
this.addChangeListener = (fun) => {
if (typeof (fun) == "function") {
this.callBackAry.push(fun);
};
};
setInterval(() => {
if (context.resources.configuration.orientation != this.Orientation) {
this.Orientation = context.resources.configuration.orientation;
this.Width = this.Orientation == 1 ? device.width : device.height;
this.Height = this.Orientation == 2 ? device.width : device.height;
for (let i in this.callBackAry) {
try {
if (typeof (this.callBackAry[i]) == "function") {
this.callBackAry[i](this.Width, this.Height, this.Orientation);
};
} catch (e) {
throw e;
};
};
};
}, this.t);
};
var 悬浮控制 = function (window, windowid, ar, screen_change_obj) {
this.Orientation = context.resources.configuration.orientation;
this.Width = this.Orientation == 1 ? device.width : device.height;
this.Height = this.Orientation == 2 ? device.width : device.height;
if (screen_change_obj) {
screen_change_obj.addChangeListener((Width, Height, Orientation) => {
this.Orientation = Orientation;
this.Width = Width;
this.Height = Height;
var xy = this.windowGXY(window.getX(), window.getY(), this.G(window));
this.windowyidong([
[window.getX(), window.getY()],
[xy.x, xy.y]
]);
});
};
this.isAutoIntScreen = true;
this.Click = function () { };
this.Move = function () { };
this.LongClick = function () { };
this.setClick = (fun) => {
fun = fun || function () { };
this.Click = fun;
};
this.setMove = (fun) => {
fun = fun || function () { };
this.Move = fun;
};
this.setLongClick = (fun, ji) => {
fun = fun || function () { };
this.LongClick = fun;
if (parseInt(ji)) {
this.Tjitime = parseInt(ji) / 50;
};
};
this.TX = 0;
this.TY = 0;
this.Tx = 0;
this.Ty = 0;
this.Tyidong = false;
this.Tkeep = false;
this.Tjitime = 12;
this.Ttime = 0;
setInterval(() => {
if (this.Tkeep) {
this.Ttime++;
if (!this.Tyidong && this.Ttime > this.Tjitime) {
//非移动且按下时长超过1秒判断为长按
this.Tkeep = false;
this.Ttime = 0;
this.LongClick();
};
};
}, 50);
if (windowid) {
windowid.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
this.Move(view, event);
switch (event.getAction()) {
case event.ACTION_DOWN:
this.Tx = event.getRawX();
this.Ty = event.getRawY();
this.TX = window.getX();
this.TY = window.getY();
this.Tkeep = true; //按下,开启计时
break;
case event.ACTION_MOVE:
var sx = event.getRawX() - this.Tx;
var sy = event.getRawY() - this.Ty;
if (!this.Tyidong && this.Tkeep && this.weiyi(sx, sy) >= 10) {
this.Tyidong = true;
};
if (this.Tyidong && this.Tkeep) {
window.setPosition(this.TX + sx, this.TY + sy);
};
break;
case event.ACTION_UP:
if (!this.Tyidong && this.Tkeep && this.Ttime < 7) {
this.Click();
};
this.Tkeep = false;
this.Ttime = 0;
if (this.Tyidong) {
if (this.isAutoIntScreen) {
threads.start(new java.lang.Runnable(() => {
this.windowyidong(this.IntScreen());
}));
} else {
threads.start(new java.lang.Runnable(() => {
this.windowyidong(this.ViewIntScreen());
}));
};
this.Tyidong = false;
};
break;
};
return true;
}));
};
this.G = (win, view) => {
//返回悬浮窗的坐标范围。
var K = 36, //悬浮窗的隐形边矩
H = 66; //手机通知栏的高度
var ary;
if (!ar) {
if (view) {
ary = [
[-view.getX(), -view.getY()],
[this.Width - (view.getX() + view.getWidth()), this.Height - (view.getY() + view.getHeight()) - H - K]
];
} else {
ary = [
[0, 0],
[this.Width - win.getWidth() + K * 2, this.Height - win.getHeight() - H + K * 2]
];
}
} else {
if (view) {
ary = [
[-view.getX(), H - view.getY()],
[this.Width - (view.getX() + view.getWidth()), this.Height - (view.getY() + view.getHeight())]
];
} else {
ary = [
[0, H],
[this.Width - win.getWidth(), this.Height - win.getHeight()]
];
}
};
return ary;
};
请阿超喝一杯水更有力气为你解答、点击打赏