diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/2/a/2ab0711d9aa5839cecbb6cf0ed96f5a3f6470de5 b/src/sixaunyi/.idea/sonarlint/issuestore/2/a/2ab0711d9aa5839cecbb6cf0ed96f5a3f6470de5 deleted file mode 100644 index e69de29..0000000 diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/7/1/71fd1993763df2214bbdad8cfee650733993fe44 b/src/sixaunyi/.idea/sonarlint/issuestore/7/1/71fd1993763df2214bbdad8cfee650733993fe44 deleted file mode 100644 index cacece0..0000000 --- a/src/sixaunyi/.idea/sonarlint/issuestore/7/1/71fd1993763df2214bbdad8cfee650733993fe44 +++ /dev/null @@ -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".( -] -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]*$'.(Ο -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"Use isEmpty() to check whether the collection is empty or not.( -G -java:S1172"+Remove this unused method parameter "view".(ɑ -Q java:S125" -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.( -K -java:S1068f"0Remove this unused "listenStatus" private field.(㋸ -I -java:S1068g".Remove this unused "serverAddr" private field.( -E -java:S1068".Remove this unused "mReceiveIp" private field.( \ No newline at end of file diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/8/c/8c55c3ccc257e5907959013f99656e4c8ec3903e b/src/sixaunyi/.idea/sonarlint/issuestore/8/c/8c55c3ccc257e5907959013f99656e4c8ec3903e deleted file mode 100644 index e69de29..0000000 diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/9/6/9668392b13e33166876f2a7d3f10eb5405e757ad b/src/sixaunyi/.idea/sonarlint/issuestore/9/6/9668392b13e33166876f2a7d3f10eb5405e757ad deleted file mode 100644 index 1a7779d..0000000 --- a/src/sixaunyi/.idea/sonarlint/issuestore/9/6/9668392b13e33166876f2a7d3f10eb5405e757ad +++ /dev/null @@ -1,33 +0,0 @@ - -o -java:S2293Z"YReplace the type specification in this constructor call with the diamond operator ("<>").(ռ -K -java:S1066"/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"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.(81 -A -java:S1068$"+Remove this unused "button0" private field.( \ No newline at end of file diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/c/9/c99a584c2117ed2df42496451bb97ac1147f5ea0 b/src/sixaunyi/.idea/sonarlint/issuestore/c/9/c99a584c2117ed2df42496451bb97ac1147f5ea0 deleted file mode 100644 index e69de29..0000000 diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/f/4/f4a01d6a4fcb971362ec00a83903fd3902f52164 b/src/sixaunyi/.idea/sonarlint/issuestore/f/4/f4a01d6a4fcb971362ec00a83903fd3902f52164 deleted file mode 100644 index e69de29..0000000 diff --git a/src/sixaunyi/.idea/sonarlint/issuestore/index.pb b/src/sixaunyi/.idea/sonarlint/issuestore/index.pb index d34424b..bfc72ba 100644 --- a/src/sixaunyi/.idea/sonarlint/issuestore/index.pb +++ b/src/sixaunyi/.idea/sonarlint/issuestore/index.pb @@ -16,8 +16,4 @@ i j :app/src/main/java/com/example/sixaunyi/SecondFragment.java,1\2\12963d86ac5c2888cc2a9ae459de5665bc06b01f j -: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 \ No newline at end of file +:app/src/main/java/com/example/sixaunyi/MapApplication.java,7\7\776a4b5f215e52628a4164ac15ef90fa338360ce \ No newline at end of file diff --git a/src/sixaunyi/app/src/main/AndroidManifest.xml b/src/sixaunyi/app/src/main/AndroidManifest.xml index 844cd7a..fa4c93f 100644 --- a/src/sixaunyi/app/src/main/AndroidManifest.xml +++ b/src/sixaunyi/app/src/main/AndroidManifest.xml @@ -29,10 +29,7 @@ android:exported="false" android:screenOrientation="landscape" android:theme="@style/TransparentTheme"/> - + - + android:theme="@style/Theme.AppCompat.NoActionBar"> list = new ArrayList(); - - 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); - } - } - -} \ No newline at end of file diff --git a/src/sixaunyi/app/src/main/java/com/example/sixaunyi/MainActivity.java b/src/sixaunyi/app/src/main/java/com/example/sixaunyi/MainActivity.java index c2faa9b..87953a6 100644 --- a/src/sixaunyi/app/src/main/java/com/example/sixaunyi/MainActivity.java +++ b/src/sixaunyi/app/src/main/java/com/example/sixaunyi/MainActivity.java @@ -3,6 +3,9 @@ package com.example.sixaunyi; import static androidx.constraintlayout.motion.utils.Oscillator.TAG; import static java.lang.Math.PI; + +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.app.AlertDialog; @@ -19,6 +22,7 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; +import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; import android.animation.Animator; @@ -92,14 +96,17 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList //浮动按钮 清空地图标点 private FloatingActionButton ClearMarker_btn; //浮动按钮 更换活动 - private FloatingActionButton ChangeAct_btn; + private ImageButton ChangeAct_btn; //标点列表 private List markerList = new ArrayList<>(); //标识参数类 private MarkerOptions markerOption = new MarkerOptions(); // private DatagramSocket reveSocket; + private String value; private ExecutorService mThreadPool = Executors.newCachedThreadPool(); + //private ActivityResultLauncher launcher; + ////////////////////////////可修改部分///////////////////////////// private final LatLng Monitorlatlng = new LatLng(28.258348849051746,113.04552182879037); 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) { super.onCreate(savedInstanceState); 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); ChangeAct_btn = findViewById(R.id.change_btn); - ChangeAct_btn.show(); - //tvContent = findViewById(R.id.tv_content); - /*初始化定位,需要在检查版本之前 - *因为配置好之后才能启动定位,否则会报错 - */ + ChangeAct_btn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changeAct(); + } + }); initLocation(); //初始化地图 initMap(savedInstanceState); @@ -235,6 +247,8 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList aMap.setLocationSource(this); // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false aMap.setMyLocationEnabled(true); + //设置最小缩放等级为16 ,缩放级别范围为[3, 20] + aMap.setMinZoomLevel(18); //设置地图标志点击事件 aMap.setOnMarkerClickListener(this); //设置地图标志拖拽事件 @@ -288,7 +302,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList city = aMapLocation.getCity(); //当前位置经纬度坐标 Current_latlng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude()); - MonitorDistance = AMapUtils.calculateLineDistance(Current_latlng,Monitorlatlng); + //获取纬度 double latitude = aMapLocation.getLatitude(); //获取经度 @@ -331,6 +345,7 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); + outState.putString("key", value); //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState),保存地图当前的状态 mapView.onSaveInstanceState(outState); } @@ -391,7 +406,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList private void addSensorMarker(LatLng latLng) { // 显示浮动按钮 - // 添加传感器标点 MarkerOptions sensorMarkerOption = new MarkerOptions(); sensorMarker = aMap.addMarker(sensorMarkerOption @@ -402,7 +416,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.sensor))) // 备注 .title("传感器") - .snippet("距离:") ); sensorMarker.showInfoWindow(); @@ -524,16 +537,16 @@ public class MainActivity extends AppCompatActivity implements AMapLocationList moveUtil.moveDroneMarker(Monitorlatlng,time); } - public void changeAct(View view) { + public void changeAct() { udpReceiveThread.stopListening(); Intent intent = new Intent(MainActivity.this, VideoActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); Bundle b = new Bundle(); b.putString("Angle", MonitorAngle); b.putFloat("Distance", MonitorDistance); intent.putExtras(b); - intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + int requestCode = 1; // 可以是任何非负整数 startActivity(intent); + } /** diff --git a/src/sixaunyi/app/src/main/java/com/example/sixaunyi/VideoActivity.java b/src/sixaunyi/app/src/main/java/com/example/sixaunyi/VideoActivity.java index e640036..88c0ab5 100644 --- a/src/sixaunyi/app/src/main/java/com/example/sixaunyi/VideoActivity.java +++ b/src/sixaunyi/app/src/main/java/com/example/sixaunyi/VideoActivity.java @@ -798,8 +798,8 @@ public class VideoActivity extends AppCompatActivity { @Override public void onBackPressed() { // 返回到 MainActivity - shutdown(); Intent intent = new Intent(this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); finish(); // 结束 VideoActivity } diff --git a/src/sixaunyi/app/src/main/res/drawable-v24/wurenji.png b/src/sixaunyi/app/src/main/res/drawable-v24/wurenji.png index e8cc7e1..ad89365 100644 Binary files a/src/sixaunyi/app/src/main/res/drawable-v24/wurenji.png and b/src/sixaunyi/app/src/main/res/drawable-v24/wurenji.png differ diff --git a/src/sixaunyi/app/src/main/res/layout/activity_main.xml b/src/sixaunyi/app/src/main/res/layout/activity_main.xml index 0620642..762567a 100644 --- a/src/sixaunyi/app/src/main/res/layout/activity_main.xml +++ b/src/sixaunyi/app/src/main/res/layout/activity_main.xml @@ -12,55 +12,41 @@ android:id="@+id/map_view" android:layout_width="match_parent" android:layout_height="match_parent" /> + + - + - -