整合代码

master
CYZ 2 years ago
parent afb3b38039
commit 8bd735be4a

@ -1,129 +0,0 @@
` java:S112m"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
` java:S112x"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112ƒ"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112Ž"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112¤"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112¯"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
a java:S112º"FDefine and throw a dedicated exception instead of using a generic one.(Ò‚Òéüÿÿÿÿ
g java:S117˜"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(×àÿÅ
>
java:S1604Y"(Make this anonymous inner class a lambda(Æ·»°
>
java:S1604g"(Make this anonymous inner class a lambda(êáÇñ
C
java:S1604r"(Make this anonymous inner class a lambda(Ëݳ­ûÿÿÿÿ
C
java:S1604}"(Make this anonymous inner class a lambda(ßó¤—ùÿÿÿÿ
D
java:S1604ˆ"(Make this anonymous inner class a lambda(‰‘¼“ÿÿÿÿÿ
D
java:S1604"(Make this anonymous inner class a lambda(÷³¿­úÿÿÿÿ
?
java:S1604ž"(Make this anonymous inner class a lambda(Ÿ…³Á
?
java:S1604©"(Make this anonymous inner class a lambda(ÚŠõ¨
?
java:S1604´"(Make this anonymous inner class a lambda(¶±»ù
?
java:S1604¿"(Make this anonymous inner class a lambda(±ë¦þ
V
java:S2184"@Cast one of the operands of this integer division to a "double".(—­½[
X
java:S2184œ"ACast one of the operands of this division operation to a "float".(ÒÏ“×
]
java:S2184¢"ACast one of the operands of this division operation to a "float".(‹öÚÈùÿÿÿÿ
[
java:S2184£"DCast one of the operands of this subtraction operation to a "float".(¸õÀ½
]
java:S2184¯"ACast one of the operands of this division operation to a "float".(‹öÚÈùÿÿÿÿ
[
java:S2184°"DCast one of the operands of this subtraction operation to a "float".(¸õÀ½
[
java:S2184±"DCast one of the operands of this subtraction operation to a "float".(¬Óé<C393>
]
java:S2184À"ACast one of the operands of this addition operation to a "float".(•‹öƒýÿÿÿÿ
`
java:S2184À"DCast one of the operands of this subtraction operation to a "float".(•‹öƒýÿÿÿÿ
]
java:S2184Á"ACast one of the operands of this division operation to a "float".(ÝÒŒÑþÿÿÿÿ
\
java:S2184×"@Cast one of the operands of this integer division to a "double".(ÂÀ‰öùÿÿÿÿ
c
java:S2095Ž"LUse try-with-resources or close this "DatagramSocket" in a "finally" clause.(©Áá‚
o java:S115-"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(ƴư
t java:S115."ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(¨Öܶüÿÿÿÿ
t java:S116:"ZRename this field "Trans_to_Detect" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¾¥Âöûÿÿÿÿ
k java:S116="VRename this field "Forward_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¸ÂÑ•
m java:S116>"SRename this field "Back_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ÛÇãôþÿÿÿÿ
h java:S116?"SRename this field "Left_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¥÷œë
i java:S116@"TRename this field "Right_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(<28>Οƒ
m java:S116A"SRename this field "Down_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ß缎øÿÿÿÿ
k java:S116B"QRename this field "Up_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ŒÑ„›ùÿÿÿÿ
q java:S116C"WRename this field "TurnLeft_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ëÝŽ–þÿÿÿÿ
l java:S116D"XRename this field "TurnRight_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(€‡p
k java:S116E"VRename this field "Setting_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(à°úö
p java:S116F"VRename this field "TakeOff_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(€‚òœüÿÿÿÿ
p java:S116G"VRename this field "Landing_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ÅÔ““þÿÿÿÿ
u
java:S1450F"ZRemove the "TakeOff_btn" field and declare it as a local variable in the relevant methods.(€‚òœüÿÿÿÿ
o
java:S1450H"TRemove the "angle" field and declare it as a local variable in the relevant methods.(§úþóþÿÿÿÿ
r
java:S1450I"WRemove the "distance" field and declare it as a local variable in the relevant methods.(×¾¶Ðøÿÿÿÿ
[
java:S1124-"EReorder the modifiers to comply with the Java Language Specification.(ƴư
`
java:S1124."EReorder the modifiers to comply with the Java Language Specification.(¨Öܶüÿÿÿÿ
[
java:S1124/"EReorder the modifiers to comply with the Java Language Specification.(ß×á
[
java:S11240"EReorder the modifiers to comply with the Java Language Specification.(Ó¾þá
h java:S100f"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ü™âîùÿÿÿÿ
m
java:S3776f"RRefactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.(ü™âîùÿÿÿÿ
D
java:S1185Ñ"(Remove this method to simply inherit it.(ñ‰ÿÜýÿÿÿÿ
L
java:S2696á"6Make the enclosing method "static" or remove this set.(èª
W java:S125â"<This block of commented-out lines of code should be removed.(<28>­éäøÿÿÿÿ
W java:S125ç"<This block of commented-out lines of code should be removed.(çéŸþÿÿÿÿ
R
java:S2696ï"6Make the enclosing method "static" or remove this set.(Ôø±üûÿÿÿÿ
W java:S125÷"<This block of commented-out lines of code should be removed.(ÏúˆÃýÿÿÿÿ
F
java:S2093Þ"*Change this "try" to a try-with-resources.(ç£ê<C2A3>úÿÿÿÿ
d java:S100˜"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(×àÿÅ
i java:S116¿"SRename this field "BG_COLOR" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(þ¨ò‘
k
java:S1450Í"TRemove the "mPath" field and declare it as a local variable in the relevant methods.(ä“<C3A4>Â
R java:S125¥"<This block of commented-out lines of code should be removed.(Ê蘋
\
java:S1610Ø"@Convert the abstract class "OnUnlockListener" into an interface.(׋›Îøÿÿÿÿ
= java:S131""Add a default case to this switch.(<28>äÃùÿÿÿÿÿ
= java:S131Ë""Add a default case to this switch.(ãÁð™øÿÿÿÿ
9
java:S1128*"Remove this duplicated import.(°þÊóøÿÿÿÿ
C
java:S1068/"-Remove this unused "SEND_PORT" private field.(ß×á
B
java:S10683"'Remove this unused "buf" private field.(ÅØè<C398>þÿÿÿÿ
D
java:S10686".Remove this unused "sendSocket" private field.(éêÖé
J
java:S10688"/Remove this unused "sendHandler" private field.(ã¹Ð«þÿÿÿÿ
N
java:S1068:"3Remove this unused "Trans_to_Detect" private field.(¾¥Âöûÿÿÿÿ
B
java:S1068<"'Remove this unused "btn" private field.(ãȧ<C388>üÿÿÿÿ
J
java:S1068G"/Remove this unused "Landing_btn" private field.(ÅÔ““þÿÿÿÿ
D
java:S1068H")Remove this unused "angle" private field.(§úþóþÿÿÿÿ
G
java:S1068I",Remove this unused "distance" private field.(×¾¶Ðøÿÿÿÿ
@
java:S1068Í")Remove this unused "mPath" private field.(ä“<C3A4>Â
F
java:S1068Ó"/Remove this unused "mIsUnlocked" private field.(ˆø•ö

@ -1,84 +0,0 @@
l java:S117Û"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ÓÔÒÞùÿÿÿÿ
p
java:S1104D"[Make mLocationClient a static final constant or non-public and provide accessors if needed.(òó•L
q
java:S1104F"[Make mLocationOption a static final constant or non-public and provide accessors if needed.(ÈÀ‚§
d
java:S2259<18>"MA "NullPointerException" could be thrown; "mLocationClient" is nullable here.(Ô¹¤<C2B9>
c
java:S2095ó"LUse try-with-resources or close this "DatagramSocket" in a "finally" clause.(ù<>Èö
o java:S115d"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(ë¿§Ï
s java:S116I"YRename this field "Current_latlng" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(æàÁÆÿÿÿÿÿ
o java:S116["ZRename this field "ClearMarker_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ëþ¥È
r java:S116]"XRename this field "ChangeAct_btn" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ÂîœÃúÿÿÿÿ
d java:S116i"PRename this field "Angle" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ÒáÒD
q java:S116j"WRename this field "MonitorAngle" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(þ‰Ô€ûÿÿÿÿ
o java:S116l"ZRename this field "MonitorDistance" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ƒæ¬Ê
˜
java:S1186ã"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(±€¿ë
i
java:S1450i"TRemove the "Angle" field and declare it as a local variable in the relevant methods.(ÒáÒD
w
java:S1450]"\Remove the "ChangeAct_btn" field and declare it as a local variable in the relevant methods.(ÂîœÃúÿÿÿÿ
i
java:S1450H"SRemove the "city" field and declare it as a local variable in the relevant methods.(“øÌà
m
java:S1450W"WRemove the "cityCode" field and declare it as a local variable in the relevant methods.(êýð†
r
java:S1450k"WRemove the "distance" field and declare it as a local variable in the relevant methods.(×¾¶Ðøÿÿÿÿ
G
java:S1874S"1Remove this use of "PoiSearch"; it is deprecated.(–ƒëÖ
L
java:S1874U"1Remove this use of "PoiSearch"; it is deprecated.(²¹·‘ÿÿÿÿÿ
[
java:S1124d"EReorder the modifiers to comply with the Java Language Specification.(ë¿§Ï
`
java:S1124e"EReorder the modifiers to comply with the Java Language Specification.(<28>”µÆüÿÿÿÿ
Q java:S125h"<This block of commented-out lines of code should be removed.(‡µÍ”
V java:S125x"<This block of commented-out lines of code should be removed.(¤¯¿Îúÿÿÿÿ
f
java:S1874·"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(Ó»×¶þÿÿÿÿ
R java:S125í"<This block of commented-out lines of code should be removed.(©áèè
Y
java:S1854 "=Remove this useless assignment to local variable "longitude".(ËàÅ€ûÿÿÿÿ
X
java:S1854ž"<Remove this useless assignment to local variable "latitude".(û‘áäùÿÿÿÿ
I
java:S1481ž"-Remove this unused "latitude" local variable.(û‘áäùÿÿÿÿ
J
java:S1481 ".Remove this unused "longitude" local variable.(ËàÅ€ûÿÿÿÿ
R java:S125ß"<This block of commented-out lines of code should be removed.(É–Ö­
G
java:S1172"+Remove this unused method parameter "view".(çÑ¢‰ýÿÿÿÿ
U
java:S1155">Use isEmpty() to check whether the collection is empty or not.(”ó±’
G
java:S1172<18>"+Remove this unused method parameter "view".(•É‘Îûÿÿÿÿ
Q java:S125 "<This block of commented-out lines of code should be removed.(Ÿ…¦Q
U
java:S1117Ï"9Rename "query" which hides the field declared at line 83.(˜Ž“áûÿÿÿÿ
\
java:S2147Š"ECombine this catch with the one at line 520, which has the same body.(<28>”ý¾
n
java:S3776š"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(—´¸…øÿÿÿÿ
O java:S106·"9Replace this use of System.out or System.err by a logger.(éÃÇâ
W java:S125¹"<This block of commented-out lines of code should be removed.(×ûÂÚÿÿÿÿÿ
>
java:S1068H"(Remove this unused "city" private field.(“øÌà
?
java:S1068S")Remove this unused "query" private field.(–ƒëÖ
H
java:S1068U"-Remove this unused "poiSearch" private field.(²¹·‘ÿÿÿÿÿ
B
java:S1068W",Remove this unused "cityCode" private field.(êýð†
I
java:S1068c".Remove this unused "reveSocket" private field.(éÛþ§ýÿÿÿÿ
K
java:S1068e"0Remove this unused "RECEIVE_PORT" private field.(<28>”µÆüÿÿÿÿ
K
java:S1068f"0Remove this unused "listenStatus" private field.(ì㋸ûÿÿÿÿ
I
java:S1068g".Remove this unused "serverAddr" private field.(<28>§±ùÿÿÿÿ
E
java:S1068ë".Remove this unused "mReceiveIp" private field.(úúÛò

@ -1,33 +0,0 @@
o
java:S2293Z"YReplace the type specification in this constructor call with the diamond operator ("<>").(œœÕ¼
K
java:S1066<18>"/Merge this if statement with the enclosing one.(¦­Üˆûÿÿÿÿ
K
java:S1066"/Merge this if statement with the enclosing one.(þÆÅ÷üÿÿÿÿ
>
java:S1604"(Make this anonymous inner class a lambda(ô§ê
i
java:S1104%"SMake TV_show a static final constant or non-public and provide accessors if needed.(úÀŸõ
>
java:S2189""Add an end condition to this loop.(˜ïˆžÿÿÿÿÿ
>
java:S2189±""Add an end condition to this loop.(˜ïˆžÿÿÿÿÿ
k java:S116!"VRename this field "receive_Msg" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ŒßÙú
g java:S116%"RRename this field "TV_show" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(úÀŸõ
^
java:S1659#"CDeclare "total1" and all following declarations on a separate line.(Æ‘ç¡üÿÿÿÿ
c java:S100<"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Íš“è
h
java:S3776~"RRefactor this method to reduce its Cognitive Complexity from 50 to the 15 allowed.(“–ýþ
u
java:S2142Œ"^Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.(<>í†
W java:S125"<This block of commented-out lines of code should be removed.(‹ãà‘úÿÿÿÿ
R java:S125"<This block of commented-out lines of code should be removed.(çÓ®Ë
U
java:S1155·">Use isEmpty() to check whether the collection is empty or not.(†”“”
u
java:S2142È"^Either re-interrupt this method or rethrow the "InterruptedException" that can be caught here.(ä ¹€
V java:S106Õ"9Replace this use of System.out or System.err by a logger.(ŒŸÍÞ8¬ª<C2AC>‰1
A
java:S1068$"+Remove this unused "button0" private field.(Îÿæ¡

@ -16,8 +16,4 @@ i
j j
:app/src/main/java/com/example/sixaunyi/SecondFragment.java,1\2\12963d86ac5c2888cc2a9ae459de5665bc06b01f :app/src/main/java/com/example/sixaunyi/SecondFragment.java,1\2\12963d86ac5c2888cc2a9ae459de5665bc06b01f
j j
:app/src/main/java/com/example/sixaunyi/MapApplication.java,7\7\776a4b5f215e52628a4164ac15ef90fa338360ce :app/src/main/java/com/example/sixaunyi/MapApplication.java,7\7\776a4b5f215e52628a4164ac15ef90fa338360ce
j
:app/src/main/java/com/example/sixaunyi/DetectActivity.java,9\6\9668392b13e33166876f2a7d3f10eb5405e757ad
k
;app/src/main/java/com/example/sixaunyi/ControlActivity.java,c\9\c99a584c2117ed2df42496451bb97ac1147f5ea0

@ -29,10 +29,7 @@
android:exported="false" android:exported="false"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:theme="@style/TransparentTheme"/> android:theme="@style/TransparentTheme"/>
<activity <!-- 定位service -->
android:name=".ControlActivity"
android:exported="false"
android:screenOrientation="landscape" /> <!-- 定位service -->
<service android:name="com.amap.api.location.APSService" /> <!-- 设置高德Key --> <service android:name="com.amap.api.location.APSService" /> <!-- 设置高德Key -->
<meta-data <meta-data
android:name="com.amap.api.v2.apikey" android:name="com.amap.api.v2.apikey"
@ -43,17 +40,12 @@
android:exported="false" android:exported="false"
android:screenOrientation="landscape" android:screenOrientation="landscape"
/> />
<activity
android:name=".DetectActivity"
android:exported="false"
android:label="@string/title_activity_detect"
android:theme="@style/Theme.Sixaunyi.NoActionBar" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
android:launchMode="singleInstance" android:launchMode="singleTop"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.AppCompat"> android:theme="@style/Theme.AppCompat.NoActionBar">
</activity> </activity>
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"

@ -1,14 +0,0 @@
package com.example.sixaunyi;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class ControlActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);
}
}

@ -1,218 +0,0 @@
package com.example.sixaunyi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.ArrayList;
public class DetectActivity extends AppCompatActivity {
/*接收发送定义的常量*/
private String mIp= "192.168.79.46"; //这里是NodeMCU的IP Address我们可以通过打开Arduino的串口监视器获取IP Address
private int mPort = 80; //WiFiServer server(80);建立网络服务器对象监听端口80这里的80是自定义的只要与Android中的socket一致就好。
private SendThread sendthread;
String receive_Msg;
String l;
String total0,total1,total2,total3;
private Button button0;
public TextView TV_show;
private DataHandler mHandler = new DataHandler();
/*****************************/
@Override
protected void onCreate(Bundle savedInstanceState) {
//onCreate必做事情继承父类super.onCreate设置当前试图setContentView
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detect);
TV_show = findViewById(R.id.show);
/***************连接*****************/
sendthread = new SendThread(mIp, mPort, mHandler);
create_Thread();
new Thread().start();
/**********************************/
}
/*接收线程*******************************************************************************/
/**
* socket线
*/
void create_Thread(){
new Thread(sendthread).start();//创建一个新线程
}
class DataHandler extends Handler {
@Override
public void handleMessage(Message msg)
{
super.handleMessage(msg);
if (msg.what == 0x00) {
Log.i("mr_收到的数据 ", msg.obj.toString());
receive_Msg = msg.obj.toString();
if(receive_Msg.indexOf("Humidity:")!=-1) {
String[] strArray = receive_Msg.split(" "); //处理接受到的数据并将他们显示在TextView中
TV_show.setText(strArray[3]);
}
}
}
}
class SendThread implements Runnable {
private String ip;
private int port;
BufferedReader in;
PrintWriter out; //打印流
Handler mainHandler;
Socket s;
private String receiveMsg;
ArrayList<String> list = new ArrayList<String>();
public SendThread(String ip,int port, Handler mainHandler) { //IP端口数据
this.ip = ip;
this.port=port;
this.mainHandler = mainHandler;
}
/**
*
*/
void open(){
try {
s = new Socket(ip, port);
//in收单片机发的数据
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
s.getOutputStream())), true);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
*/
void close(){
try {
s.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
//创建套接字
open();
//BufferedReader
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(200);
close();
open();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
if (!s.isClosed()) {
if (s.isConnected()) {
if (!s.isInputShutdown()) {
try {
Log.i("mr", "等待接收信息");
Message msg=mainHandler.obtainMessage();
char[] chars = new char[1024]; //byte[] bys = new byte[1024];
int len = 0; //int len = 0;
while((len = in.read(chars)) != -1){
receiveMsg = new String(chars, 0, len);
msg.what=0x00;
msg.obj=receiveMsg;
mainHandler.sendMessage(msg);
}
} catch (IOException e) {
Log.i("mr", e.getMessage());
try {
s.shutdownInput();
s.shutdownOutput();
s.close();
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
}
}
}
}
});
thread.start();
while (true) {
//连接中
if (!s.isClosed()&&s.isConnected()&&!s.isInputShutdown()) {
// 如果消息集合有东西,并且发送线程在工作。
if (list.size() > 0 && !s.isOutputShutdown()) {
out.println(list.get(0));
list.remove(0);
}
Message msg=mainHandler.obtainMessage();
msg.what=0x01;
mainHandler.sendMessage(msg);
} else {
//连接中断了
Log.i("mr", "连接断开了");
Message msg=mainHandler.obtainMessage();
msg.what=0x02;
mainHandler.sendMessage(msg);
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
try {
out.close();
in.close();
s.close();
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
}
public void send(String msg) {
System.out.println("msg的值为 " + msg);
list.add(msg);
}
}
}

@ -3,6 +3,9 @@ package com.example.sixaunyi;
import static androidx.constraintlayout.motion.utils.Oscillator.TAG; import static androidx.constraintlayout.motion.utils.Oscillator.TAG;
import static java.lang.Math.PI; import static java.lang.Math.PI;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -19,6 +22,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.animation.Animator; import android.animation.Animator;
@ -92,14 +96,17 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
//浮动按钮 清空地图标点 //浮动按钮 清空地图标点
private FloatingActionButton ClearMarker_btn; private FloatingActionButton ClearMarker_btn;
//浮动按钮 更换活动 //浮动按钮 更换活动
private FloatingActionButton ChangeAct_btn; private ImageButton ChangeAct_btn;
//标点列表 //标点列表
private List<Marker> markerList = new ArrayList<>(); private List<Marker> markerList = new ArrayList<>();
//标识参数类 //标识参数类
private MarkerOptions markerOption = new MarkerOptions(); private MarkerOptions markerOption = new MarkerOptions();
// //
private DatagramSocket reveSocket; private DatagramSocket reveSocket;
private String value;
private ExecutorService mThreadPool = Executors.newCachedThreadPool(); private ExecutorService mThreadPool = Executors.newCachedThreadPool();
//private ActivityResultLauncher<Intent> launcher;
////////////////////////////可修改部分///////////////////////////// ////////////////////////////可修改部分/////////////////////////////
private final LatLng Monitorlatlng = new LatLng(28.258348849051746,113.04552182879037); private final LatLng Monitorlatlng = new LatLng(28.258348849051746,113.04552182879037);
private final static String Recieve_IP = "192.168.39.46"; private final static String Recieve_IP = "192.168.39.46";
@ -119,14 +126,19 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
fabPOI = findViewById(R.id.fab_poi); if (savedInstanceState != null) {
// 从保存的状态数据中恢复状态
value = savedInstanceState.getString("key");
}
ClearMarker_btn = findViewById(R.id.clearMarker_btn); ClearMarker_btn = findViewById(R.id.clearMarker_btn);
ChangeAct_btn = findViewById(R.id.change_btn); ChangeAct_btn = findViewById(R.id.change_btn);
ChangeAct_btn.show(); ChangeAct_btn.setOnClickListener(new View.OnClickListener() {
//tvContent = findViewById(R.id.tv_content); @Override
/*, public void onClick(View v) {
* changeAct();
*/ }
});
initLocation(); initLocation();
//初始化地图 //初始化地图
initMap(savedInstanceState); initMap(savedInstanceState);
@ -235,6 +247,8 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
aMap.setLocationSource(this); aMap.setLocationSource(this);
// 设置为true表示显示定位层并可触发定位false表示隐藏定位层并不可触发定位默认是false // 设置为true表示显示定位层并可触发定位false表示隐藏定位层并不可触发定位默认是false
aMap.setMyLocationEnabled(true); aMap.setMyLocationEnabled(true);
//设置最小缩放等级为16 ,缩放级别范围为[3, 20]
aMap.setMinZoomLevel(18);
//设置地图标志点击事件 //设置地图标志点击事件
aMap.setOnMarkerClickListener(this); aMap.setOnMarkerClickListener(this);
//设置地图标志拖拽事件 //设置地图标志拖拽事件
@ -288,7 +302,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
city = aMapLocation.getCity(); city = aMapLocation.getCity();
//当前位置经纬度坐标 //当前位置经纬度坐标
Current_latlng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()); Current_latlng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
MonitorDistance = AMapUtils.calculateLineDistance(Current_latlng,Monitorlatlng);
//获取纬度 //获取纬度
double latitude = aMapLocation.getLatitude(); double latitude = aMapLocation.getLatitude();
//获取经度 //获取经度
@ -331,6 +345,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putString("key", value);
//在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态 //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态
mapView.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState);
} }
@ -391,7 +406,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
private void addSensorMarker(LatLng latLng) { private void addSensorMarker(LatLng latLng) {
// 显示浮动按钮 // 显示浮动按钮
// 添加传感器标点 // 添加传感器标点
MarkerOptions sensorMarkerOption = new MarkerOptions(); MarkerOptions sensorMarkerOption = new MarkerOptions();
sensorMarker = aMap.addMarker(sensorMarkerOption sensorMarker = aMap.addMarker(sensorMarkerOption
@ -402,7 +416,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.sensor))) fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.sensor)))
// 备注 // 备注
.title("传感器") .title("传感器")
.snippet("距离:")
); );
sensorMarker.showInfoWindow(); sensorMarker.showInfoWindow();
@ -524,16 +537,16 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList
moveUtil.moveDroneMarker(Monitorlatlng,time); moveUtil.moveDroneMarker(Monitorlatlng,time);
} }
public void changeAct(View view) { public void changeAct() {
udpReceiveThread.stopListening(); udpReceiveThread.stopListening();
Intent intent = new Intent(MainActivity.this, VideoActivity.class); Intent intent = new Intent(MainActivity.this, VideoActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("Angle", MonitorAngle); b.putString("Angle", MonitorAngle);
b.putFloat("Distance", MonitorDistance); b.putFloat("Distance", MonitorDistance);
intent.putExtras(b); intent.putExtras(b);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); int requestCode = 1; // 可以是任何非负整数
startActivity(intent); startActivity(intent);
} }
/** /**

@ -798,8 +798,8 @@ public class VideoActivity extends AppCompatActivity {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
// 返回到 MainActivity // 返回到 MainActivity
shutdown();
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent); startActivity(intent);
finish(); // 结束 VideoActivity finish(); // 结束 VideoActivity
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 26 KiB

@ -12,55 +12,41 @@
android:id="@+id/map_view" android:id="@+id/map_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<ImageButton
android:id="@+id/change_btn"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="50dp"
android:clickable="true"
android:scaleType="centerInside"
android:src="@drawable/wurenji"
app:backgroundTint="#FFF"
app:backgroundTintMode="screen"
app:fabSize="normal"
app:hoveredFocusedTranslationZ="18dp"
app:pressedTranslationZ="18dp" />
<!--浮动按钮--> <!--浮动按钮-->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_poi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="20dp"
android:clickable="true"
android:onClick="moveDrone"
android:src="@drawable/icon_favorite_red"
android:visibility="gone"
app:backgroundTint="#FFF"
app:backgroundTintMode="screen"
app:hoveredFocusedTranslationZ="18dp"
app:pressedTranslationZ="18dp" />
<!--浮动按钮 清空marker--> <!--浮动按钮 清空marker-->
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/clearMarker_btn" android:id="@+id/clearMarker_btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_above="@+id/fab_poi"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:clickable="true" android:clickable="true"
android:onClick="clearAllMarker" android:onClick="clearAllMarker"
app:fabSize="normal"
android:src="@drawable/icon_clear" android:src="@drawable/icon_clear"
app:backgroundTint="#FFF"
android:visibility="invisible" android:visibility="invisible"
app:backgroundTintMode="screen"
app:hoveredFocusedTranslationZ="18dp"
app:pressedTranslationZ="18dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/change_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginEnd="20dp"
android:clickable="true"
android:onClick="changeAct"
app:fabSize="normal"
android:src="@drawable/wurenji"
app:backgroundTint="#FFF" app:backgroundTint="#FFF"
android:visibility="invisible"
app:backgroundTintMode="screen" app:backgroundTintMode="screen"
app:fabSize="normal"
app:hoveredFocusedTranslationZ="18dp" app:hoveredFocusedTranslationZ="18dp"
app:pressedTranslationZ="18dp" /> app:pressedTranslationZ="18dp" />

Loading…
Cancel
Save