├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── deploymentTargetDropDown.xml ├── gradle.xml └── misc.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── AMap3DMap_8.1.0_AMapNavi_8.1.0_AMapSearch_8.1.0_AMapLocation_5.6.0_20211029.jar │ ├── arm64-v8a │ │ ├── libAMapSDK_NAVI_v8_1_0.so │ │ ├── libneonui_shared.so │ │ └── libneonuijni_public.so │ ├── armeabi-v7a │ │ ├── libAMapSDK_NAVI_v8_1_0.so │ │ ├── libneonui_shared.so │ │ └── libneonuijni_public.so │ ├── armeabi │ │ ├── libAMapSDK_NAVI_v8_1_0.so │ │ ├── libneonui_shared.so │ │ └── libneonuijni_public.so │ ├── mysql-connector-java-5.1.47.jar │ ├── x86 │ │ ├── libAMapSDK_NAVI_v8_1_0.so │ │ ├── libneonui_shared.so │ │ └── libneonuijni_public.so │ └── x86_64 │ │ ├── libAMapSDK_NAVI_v8_1_0.so │ │ ├── libneonui_shared.so │ │ └── libneonuijni_public.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── zzdayss │ │ └── yunyou │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── java │ │ └── com │ │ │ └── zzdayss │ │ │ └── yunyou │ │ │ ├── Code.java │ │ │ ├── InputTipsActivity.java │ │ │ ├── LoginActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MyActivity.java │ │ │ ├── PoiBean.java │ │ │ ├── RegisterActivity.java │ │ │ ├── TripActivity.java │ │ │ ├── TripaddActivity.java │ │ │ ├── ZhoubianActivity.java │ │ │ ├── adapter │ │ │ ├── InputTipsAdapter.java │ │ │ └── ZhoubianAdapter.java │ │ │ ├── dao │ │ │ └── UserDao.java │ │ │ ├── entity │ │ │ ├── Trip.java │ │ │ └── User.java │ │ │ ├── feedbackActivity.java │ │ │ ├── overlay │ │ │ └── PoiOverlay.java │ │ │ ├── util │ │ │ ├── Constants.java │ │ │ └── ToastUtil.java │ │ │ └── utils │ │ │ └── JDBCUtils.java │ └── res │ │ ├── color │ │ └── colortheme.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── back.xml │ │ ├── btn_bg_selector.xml │ │ ├── ic_arrow.xml │ │ ├── ic_back.xml │ │ ├── ic_cancel.xml │ │ ├── ic_face.xml │ │ ├── ic_feedback.xml │ │ ├── ic_food.xml │ │ ├── ic_hotel.xml │ │ ├── ic_local.xml │ │ ├── ic_logout.xml │ │ ├── ic_map.xml │ │ ├── ic_my.xml │ │ ├── ic_place.xml │ │ ├── ic_search.xml │ │ ├── ic_tour.xml │ │ ├── ic_travel.xml │ │ ├── icon_favorite_red.xml │ │ ├── my_location.xml │ │ ├── selector.xml │ │ ├── shape.xml │ │ ├── shapelogin.xml │ │ ├── shapemain.xml │ │ └── shapemsg.xml │ │ ├── layout │ │ ├── activity_feedback.xml │ │ ├── activity_input_tips.xml │ │ ├── activity_login.xml │ │ ├── activity_main.xml │ │ ├── activity_my.xml │ │ ├── activity_register.xml │ │ ├── activity_trip.xml │ │ ├── activity_tripadd.xml │ │ ├── activity_zhoubian.xml │ │ ├── adapter_inputtips.xml │ │ ├── adapter_trips.xml │ │ └── poikeywordsearch_uri.xml │ │ ├── menu │ │ └── menu_navigation.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── a002.png │ │ ├── account.png │ │ ├── code.png │ │ ├── gps.png │ │ ├── ic_arrow_back.png │ │ ├── ic_close.png │ │ ├── ic_launcher.webp │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.webp │ │ ├── ic_search.png │ │ ├── icon.png │ │ ├── jingweidu.png │ │ ├── logo.png │ │ ├── phone.png │ │ ├── pwd.png │ │ ├── renshu.png │ │ └── wenshidu.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ ├── styles.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── zzdayss │ └── yunyou │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── yunyou.sql /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 69 | 70 | 71 | 72 | 73 | 74 | 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # --云游APP-旅游类地图安卓应用-- 2 | 项目描述:用于旅游前的地图查询以及行程规划 3 | 采用技术:AndroidStudio、Java、MySQL、SQLite、XML 4 | 项目职责: 5 | 1.通过调用高德地图的SDK实现APP首页的地图浏览及定位功能。 6 | 2.通过获取高德的POI数据实现位置搜索、经纬度、天气以及周边美食住宿娱乐等功能。 7 | 3.使用Java、MySQL、SharedPreference等技术实现账户的注册登录、行程规划、用户反馈等功能。 8 | ![image](https://user-images.githubusercontent.com/47945908/228033746-e282b6e8-8810-472b-9d3b-9f8fb06713ca.png) 9 | ![image](https://user-images.githubusercontent.com/47945908/228033761-8c98168b-d66f-4821-85d7-f03381dbb718.png) 10 | ![image](https://user-images.githubusercontent.com/47945908/228035353-8f8d5197-f148-4628-9cdb-efd091eccb8b.png) 11 | ![image](https://user-images.githubusercontent.com/47945908/228033305-38089789-a4fe-4821-a6ca-3153146cd456.png) 12 | ![image](https://user-images.githubusercontent.com/47945908/228033324-0a6b9a86-c4dd-452d-9fed-a93e67e948e1.png) 13 | ![image](https://user-images.githubusercontent.com/47945908/228033358-641f11b2-b76e-4ec5-b4ab-1571cbee8908.png) 14 | ![image](https://user-images.githubusercontent.com/47945908/228033390-8460b3fb-9e7e-4228-a4f6-18d8cd36eb08.png) 15 | ![image](https://user-images.githubusercontent.com/47945908/228033422-402c4d7a-b6b5-4668-86e3-3bf30f61c2a0.png) 16 | ![image](https://user-images.githubusercontent.com/47945908/228033435-9e1666cc-1758-40c3-aacf-ecffd497b9bc.png) 17 | ![image](https://user-images.githubusercontent.com/47945908/228033522-947eb63d-173f-4058-8655-3b7c307a9b40.png) 18 | ![image](https://user-images.githubusercontent.com/47945908/228033595-d9443c28-9e75-421d-9d44-9a49b7f6f21a.png) 19 | ![image](https://user-images.githubusercontent.com/47945908/228033716-458c8a52-f9dd-4233-aade-a577134d4c92.png) 20 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 32 7 | sourceSets{ 8 | main{ 9 | jniLibs.srcDirs = ['libs'] 10 | } 11 | } 12 | defaultConfig { 13 | applicationId "com.zzdayss.yunyou" 14 | minSdk 27 15 | targetSdk 32 16 | versionCode 1 17 | versionName "1.0" 18 | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | } 21 | buildTypes { 22 | release { 23 | minifyEnabled false 24 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 | } 26 | } 27 | compileOptions { 28 | sourceCompatibility JavaVersion.VERSION_1_8 29 | targetCompatibility JavaVersion.VERSION_1_8 30 | } 31 | sourceSets{ 32 | main{ 33 | jniLibs.srcDirs = ['libs'] 34 | } 35 | } 36 | } 37 | 38 | dependencies { 39 | 40 | implementation 'androidx.appcompat:appcompat:1.4.1' 41 | implementation 'com.google.android.material:material:1.5.0' 42 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 43 | implementation files('libs\\AMap3DMap_8.1.0_AMapNavi_8.1.0_AMapSearch_8.1.0_AMapLocation_5.6.0_20211029.jar') 44 | implementation files('libs\\mysql-connector-java-5.1.47.jar') 45 | testImplementation 'junit:junit:4.13.2' 46 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 47 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 48 | implementation 'pub.devrel:easypermissions:3.0.0' 49 | implementation 'com.google.android.material:material:1.2.0' 50 | } -------------------------------------------------------------------------------- /app/libs/AMap3DMap_8.1.0_AMapNavi_8.1.0_AMapSearch_8.1.0_AMapLocation_5.6.0_20211029.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/AMap3DMap_8.1.0_AMapNavi_8.1.0_AMapSearch_8.1.0_AMapLocation_5.6.0_20211029.jar -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libAMapSDK_NAVI_v8_1_0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/arm64-v8a/libAMapSDK_NAVI_v8_1_0.so -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libneonui_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/arm64-v8a/libneonui_shared.so -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libneonuijni_public.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/arm64-v8a/libneonuijni_public.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libAMapSDK_NAVI_v8_1_0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi-v7a/libAMapSDK_NAVI_v8_1_0.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libneonui_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi-v7a/libneonui_shared.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libneonuijni_public.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi-v7a/libneonuijni_public.so -------------------------------------------------------------------------------- /app/libs/armeabi/libAMapSDK_NAVI_v8_1_0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi/libAMapSDK_NAVI_v8_1_0.so -------------------------------------------------------------------------------- /app/libs/armeabi/libneonui_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi/libneonui_shared.so -------------------------------------------------------------------------------- /app/libs/armeabi/libneonuijni_public.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/armeabi/libneonuijni_public.so -------------------------------------------------------------------------------- /app/libs/mysql-connector-java-5.1.47.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/mysql-connector-java-5.1.47.jar -------------------------------------------------------------------------------- /app/libs/x86/libAMapSDK_NAVI_v8_1_0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86/libAMapSDK_NAVI_v8_1_0.so -------------------------------------------------------------------------------- /app/libs/x86/libneonui_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86/libneonui_shared.so -------------------------------------------------------------------------------- /app/libs/x86/libneonuijni_public.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86/libneonuijni_public.so -------------------------------------------------------------------------------- /app/libs/x86_64/libAMapSDK_NAVI_v8_1_0.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86_64/libAMapSDK_NAVI_v8_1_0.so -------------------------------------------------------------------------------- /app/libs/x86_64/libneonui_shared.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86_64/libneonui_shared.so -------------------------------------------------------------------------------- /app/libs/x86_64/libneonuijni_public.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/libs/x86_64/libneonuijni_public.so -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zzdayss/yunyou/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.zzdayss.yunyou", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zzdayss/yunyou/3add4cca86e4b7ceb38648d3c7d839e5689b3a88/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/Code.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | 8 | import java.util.Random; 9 | 10 | public class Code { 11 | /** 12 | * 随机数数组 13 | * 去除了易混淆的 数字 0 和 字母 o O 14 | * 数字 1 和 字母 i I l L 15 | * 数字 6 和 字母 b 16 | * 数字 9 和 字母 q 17 | * 字母 c C 和 G 18 | * 字母 t (经常和随机线混在一起看不清) 19 | */ 20 | private static final char[] CHARS = { 21 | '2', '3', '4', '5', '7', '8', 22 | 'a', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 23 | 'n', 'p', 'r', 's', 'u', 'v', 'w', 'x', 'y', 'z', 24 | 'A', 'B', 'D', 'E', 'F', 'H', 'J', 'K', 'M', 25 | 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' 26 | }; 27 | 28 | private static Code bmpCode; 29 | 30 | public static Code getInstance() { 31 | if(bmpCode == null) 32 | bmpCode = new Code(); 33 | return bmpCode; 34 | } 35 | 36 | //default settings 37 | //验证码默认随机数的个数 38 | private static final int DEFAULT_CODE_LENGTH = 4; 39 | //默认字体大小 40 | private static final int DEFAULT_FONT_SIZE = 25; 41 | //默认线条的条数 42 | private static final int DEFAULT_LINE_NUMBER = 5; 43 | //padding值 44 | private static final int BASE_PADDING_LEFT = 10, RANGE_PADDING_LEFT = 15, BASE_PADDING_TOP = 15, RANGE_PADDING_TOP = 20; 45 | //验证码的默认宽高 46 | private static final int DEFAULT_WIDTH = 100, DEFAULT_HEIGHT = 40; 47 | 48 | //settings decided by the layout xml 49 | //canvas width and height 50 | private int width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT; 51 | 52 | //random word space and pading_top 53 | private int base_padding_left = BASE_PADDING_LEFT, range_padding_left = RANGE_PADDING_LEFT, 54 | base_padding_top = BASE_PADDING_TOP, range_padding_top = RANGE_PADDING_TOP; 55 | 56 | //number of chars, lines; font size 57 | private int codeLength = DEFAULT_CODE_LENGTH, line_number = DEFAULT_LINE_NUMBER, font_size = DEFAULT_FONT_SIZE; 58 | 59 | //variables 60 | private String code; 61 | private int padding_left, padding_top; 62 | private Random random = new Random(); 63 | //验证码图片 64 | public Bitmap createBitmap() { 65 | padding_left = 0; 66 | 67 | Bitmap bp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 68 | Canvas c = new Canvas(bp); 69 | 70 | code = createCode(); 71 | 72 | c.drawColor(Color.WHITE); 73 | Paint paint = new Paint(); 74 | paint.setAntiAlias(true); 75 | paint.setTextSize(font_size); 76 | //画验证码 77 | for (int i = 0; i < code.length(); i++) { 78 | randomTextStyle(paint); 79 | randomPadding(); 80 | c.drawText(code.charAt(i) + "", padding_left, padding_top, paint); 81 | } 82 | //画线条 83 | for (int i = 0; i < line_number; i++) { 84 | drawLine(c, paint); 85 | } 86 | 87 | // c.save( Canvas.ALL_SAVE_FLAG );//保存 88 | c.save();//保存 89 | c.restore();// 90 | return bp; 91 | } 92 | 93 | public String getCode() { 94 | return code; 95 | } 96 | 97 | //生成验证码 98 | private String createCode() { 99 | StringBuilder buffer = new StringBuilder(); 100 | for (int i = 0; i < codeLength; i++) { 101 | buffer.append(CHARS[random.nextInt(CHARS.length)]); 102 | } 103 | return buffer.toString(); 104 | } 105 | //画干扰线 106 | private void drawLine(Canvas canvas, Paint paint) { 107 | int color = randomColor(); 108 | int startX = random.nextInt(width); 109 | int startY = random.nextInt(height); 110 | int stopX = random.nextInt(width); 111 | int stopY = random.nextInt(height); 112 | paint.setStrokeWidth(1); 113 | paint.setColor(color); 114 | canvas.drawLine(startX, startY, stopX, stopY, paint); 115 | } 116 | //生成随机颜色 117 | private int randomColor() { 118 | return randomColor(1); 119 | } 120 | 121 | private int randomColor(int rate) { 122 | int red = random.nextInt(256) / rate; 123 | int green = random.nextInt(256) / rate; 124 | int blue = random.nextInt(256) / rate; 125 | return Color.rgb(red, green, blue); 126 | } 127 | //随机生成文字样式,颜色,粗细,倾斜度 128 | private void randomTextStyle(Paint paint) { 129 | int color = randomColor(); 130 | paint.setColor(color); 131 | paint.setFakeBoldText(random.nextBoolean()); //true为粗体,false为非粗体 132 | float skewX = random.nextInt(11) / 10; 133 | skewX = random.nextBoolean() ? skewX : -skewX; 134 | paint.setTextSkewX(skewX); //float类型参数,负数表示右斜,整数左斜 135 | //paint.setUnderlineText(true); //true为下划线,false为非下划线 136 | //paint.setStrikeThruText(true); //true为删除线,false为非删除线 137 | } 138 | //随机生成padding值 139 | private void randomPadding() { 140 | padding_left += base_padding_left + random.nextInt(range_padding_left); 141 | padding_top = base_padding_top + random.nextInt(range_padding_top); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/InputTipsActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.graphics.Color; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.AdapterView; 11 | import android.widget.ImageView; 12 | import android.widget.ListView; 13 | import android.widget.AdapterView.OnItemClickListener; 14 | import android.widget.Toast; 15 | import androidx.appcompat.widget.SearchView; 16 | import com.amap.api.services.help.Inputtips; 17 | import com.amap.api.services.help.InputtipsQuery; 18 | import com.amap.api.services.help.Tip; 19 | import com.zzdayss.yunyou.adapter.InputTipsAdapter; 20 | import com.zzdayss.yunyou.util.Constants; 21 | import com.zzdayss.yunyou.util.ToastUtil; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class InputTipsActivity extends Activity implements SearchView.OnQueryTextListener, Inputtips.InputtipsListener, OnItemClickListener, View.OnClickListener { 27 | private SearchView mSearchView;// 输入搜索关键字 28 | private ImageView mBack; 29 | private ListView mInputListView; 30 | private List mCurrentTipList; 31 | private InputTipsAdapter mIntipAdapter; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_input_tips); 37 | initSearchView(); 38 | setStatusBar(); 39 | mInputListView = (ListView) findViewById(R.id.inputtip_list); 40 | mInputListView.setOnItemClickListener(this); 41 | mBack = (ImageView) findViewById(R.id.back); 42 | mBack.setOnClickListener(this); 43 | } 44 | 45 | private void initSearchView() { 46 | mSearchView = findViewById(R.id.keyWord); 47 | mSearchView.findViewById(androidx.appcompat.R.id.search_plate).setBackground(null); 48 | mSearchView.findViewById(androidx.appcompat.R.id.submit_area).setBackground(null); 49 | mSearchView.setOnQueryTextListener(this); 50 | //设置SearchView默认为展开显示 51 | mSearchView.setIconified(false); 52 | mSearchView.onActionViewExpanded(); 53 | mSearchView.setIconifiedByDefault(false); 54 | mSearchView.setSubmitButtonEnabled(false); 55 | } 56 | 57 | /** 58 | * 输入提示回调 59 | * 60 | * @param tipList 61 | * @param rCode 62 | */ 63 | @Override 64 | public void onGetInputtips(List tipList, int rCode) { 65 | if (rCode == 1000) {// 正确返回 66 | mCurrentTipList = tipList; 67 | List listString = new ArrayList(); 68 | for (int i = 0; i < tipList.size(); i++) { 69 | listString.add(tipList.get(i).getName()); 70 | } 71 | mIntipAdapter = new InputTipsAdapter( 72 | getApplicationContext(), 73 | mCurrentTipList); 74 | mInputListView.setVisibility(View.VISIBLE); 75 | mInputListView.setAdapter(mIntipAdapter); 76 | mIntipAdapter.notifyDataSetChanged(); 77 | } else { 78 | ToastUtil.showerror(this, rCode); 79 | } 80 | 81 | } 82 | 83 | @Override 84 | public void onItemClick(AdapterView adapterView, View view, int i, long l) { 85 | if (mCurrentTipList != null) { 86 | Tip tip = (Tip) adapterView.getItemAtPosition(i); 87 | Intent intent = new Intent(); 88 | intent.putExtra(Constants.EXTRA_TIP, tip); 89 | setResult(MainActivity.RESULT_CODE_INPUTTIPS, intent); 90 | this.finish(); 91 | } 92 | } 93 | 94 | /** 95 | * 按下确认键触发,本例为键盘回车或搜索键 96 | * 97 | * @param query 98 | * @return 99 | */ 100 | @Override 101 | public boolean onQueryTextSubmit(String query) { 102 | Intent intent = new Intent(); 103 | intent.putExtra(Constants.KEY_WORDS_NAME, query); 104 | setResult(MainActivity.RESULT_CODE_KEYWORDS, intent); 105 | this.finish(); 106 | return false; 107 | } 108 | 109 | /** 110 | * 输入字符变化时触发 111 | * 112 | * @param newText 113 | * @return 114 | */ 115 | @Override 116 | public boolean onQueryTextChange(String newText) { 117 | if (!IsEmptyOrNullString(newText)) { 118 | Intent intent =getIntent(); 119 | String city=intent.getStringExtra("City"); 120 | InputtipsQuery inputquery = new InputtipsQuery(newText, city); 121 | Inputtips inputTips = new Inputtips(InputTipsActivity.this.getApplicationContext(), inputquery); 122 | inputTips.setInputtipsListener(this); 123 | inputTips.requestInputtipsAsyn(); 124 | } else { 125 | if (mIntipAdapter != null && mCurrentTipList != null) { 126 | mCurrentTipList.clear(); 127 | mInputListView.setVisibility(View.INVISIBLE); 128 | mIntipAdapter.notifyDataSetChanged(); 129 | } 130 | } 131 | return false; 132 | } 133 | 134 | @Override 135 | public void onClick(View view) { 136 | if (view.getId() == R.id.back) { 137 | this.finish(); 138 | } 139 | } 140 | 141 | public static boolean IsEmptyOrNullString(String s) { 142 | return (s == null) || (s.trim().length() == 0); 143 | } 144 | 145 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 146 | protected boolean useThemestatusBarColor = false; 147 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 148 | protected boolean useStatusBarColor = true; 149 | protected void setStatusBar() { 150 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 151 | View decorView = getWindow().getDecorView(); 152 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 153 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 154 | decorView.setSystemUiVisibility(option); 155 | //根据上面设置是否对状态栏单独设置颜色 156 | if (useThemestatusBarColor) { 157 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 158 | } else { 159 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 160 | } 161 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 162 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 163 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 164 | } else { 165 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 166 | } 167 | 168 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 169 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 170 | } 171 | } 172 | 173 | } 174 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.graphics.Color; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.view.View; 13 | import android.view.WindowManager; 14 | import android.widget.EditText; 15 | import android.widget.ImageView; 16 | import android.widget.Toast; 17 | 18 | import androidx.appcompat.app.AppCompatActivity; 19 | 20 | import com.zzdayss.yunyou.dao.UserDao; 21 | 22 | /** 23 | * function:连接页面加载首页 24 | */ 25 | public class LoginActivity extends Activity { 26 | private static final String TAG = "mysql-party-LoginActivity"; 27 | private String realCode; 28 | public String userName = null; 29 | private EditText EditTextAccount,EditTextPassword; 30 | private EditText mEtloginactivityPhonecodes; 31 | private ImageView mIvloginactivityShowcode; 32 | private SharedPreferences sp; 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_login); 37 | initView(); 38 | //将验证码用图片的形式显示出来 39 | mIvloginactivityShowcode.setImageBitmap(Code.getInstance().createBitmap()); 40 | realCode = Code.getInstance().getCode().toLowerCase(); 41 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 42 | setStatusBar(); 43 | } 44 | 45 | private void initView() { 46 | // 初始化控件 47 | mEtloginactivityPhonecodes = findViewById(R.id.et_loginactivity_phoneCodes); 48 | mIvloginactivityShowcode = findViewById(R.id.iv_loginactivity_showCode); 49 | 50 | } 51 | 52 | public void reg(View view){ 53 | startActivity(new Intent(getApplicationContext(),RegisterActivity.class)); 54 | } 55 | 56 | 57 | /** 58 | * function: 登录 59 | * */ 60 | public void login(View view){ 61 | 62 | EditTextAccount = findViewById(R.id.uesrAccount); 63 | EditTextPassword = findViewById(R.id.userPassword); 64 | 65 | new Thread(() -> { 66 | UserDao userDao = new UserDao(); 67 | int msg = userDao.login(EditTextAccount.getText().toString(),EditTextPassword.getText().toString()); 68 | userName = userDao.finduserName(EditTextAccount.getText().toString()); 69 | hand1.sendEmptyMessage(msg); 70 | }).start(); 71 | 72 | } 73 | 74 | public void ChangeCode(View view){ 75 | mIvloginactivityShowcode.setImageBitmap(Code.getInstance().createBitmap()); 76 | realCode = Code.getInstance().getCode().toLowerCase(); 77 | } 78 | @SuppressLint("HandlerLeak") 79 | final Handler hand1 = new Handler() { 80 | @Override 81 | public void handleMessage(Message msg) { 82 | if (msg.what == 0) { 83 | Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_LONG).show(); 84 | } else if (msg.what == 1) { 85 | String phoneCode = mEtloginactivityPhonecodes.getText().toString().toLowerCase(); 86 | if (phoneCode.equals(realCode)) { 87 | sp.edit().putString("userAccount",EditTextAccount.getText().toString()).apply(); 88 | sp.edit().putString("userPassword",EditTextPassword.getText().toString()).apply(); 89 | sp.edit().putString("getuserName",userName).apply(); 90 | 91 | Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_LONG).show(); 92 | Intent intent = new Intent(LoginActivity.this, MainActivity.class); 93 | startActivity(intent); 94 | LoginActivity.this.finish(); 95 | }else{ 96 | Toast.makeText(getApplicationContext(), "验证码错误!", Toast.LENGTH_LONG).show(); 97 | } 98 | } else if (msg.what == 2) { 99 | Toast.makeText(getApplicationContext(), "密码错误", Toast.LENGTH_LONG).show(); 100 | } else if (msg.what == 3) { 101 | Toast.makeText(getApplicationContext(), "账号不存在", Toast.LENGTH_LONG).show(); 102 | } 103 | } 104 | }; 105 | 106 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 107 | protected boolean useThemestatusBarColor = false; 108 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 109 | protected boolean useStatusBarColor = true; 110 | protected void setStatusBar() { 111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 112 | View decorView = getWindow().getDecorView(); 113 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 114 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 115 | decorView.setSystemUiVisibility(option); 116 | //根据上面设置是否对状态栏单独设置颜色 117 | if (useThemestatusBarColor) { 118 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 119 | } else { 120 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 121 | } 122 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 123 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 124 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 125 | } else { 126 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 127 | } 128 | 129 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 130 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/MyActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.graphics.Color; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.util.Log; 13 | import android.view.View; 14 | import android.view.WindowManager; 15 | import android.widget.EditText; 16 | import android.widget.ImageView; 17 | import android.widget.LinearLayout; 18 | import android.widget.RelativeLayout; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import androidx.appcompat.app.AppCompatActivity; 23 | 24 | import com.google.android.material.bottomnavigation.BottomNavigationView; 25 | import com.zzdayss.yunyou.dao.UserDao; 26 | 27 | /** 28 | * function:连接页面加载首页 29 | */ 30 | public class MyActivity extends Activity { 31 | private RelativeLayout logoutpanel; 32 | private LinearLayout line2; 33 | private TextView nickname,localcitytext,Temperaturetext,getHumiditytext; 34 | private SharedPreferences sp; 35 | private String userAccount,userPassword,getuserName,localcity,Temperature,getHumidity; 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_my); 40 | nickname = findViewById(R.id.nickname); 41 | localcitytext = findViewById(R.id.localcity); 42 | Temperaturetext = findViewById(R.id.Temperature); 43 | getHumiditytext = findViewById(R.id.getHumidity); 44 | 45 | logoutpanel = findViewById(R.id.logout_panel); 46 | line2 = findViewById(R.id.line2); 47 | 48 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 49 | localcity = sp.getString("city",""); 50 | Temperature = sp.getString("Temperature",""); 51 | getHumidity = sp.getString("getHumidity",""); 52 | 53 | userAccount = sp.getString("userAccount",""); 54 | userPassword = sp.getString("userPassword",""); 55 | getuserName = sp.getString("getuserName",""); 56 | Log.d("My",userAccount+"\t"+userPassword+"\t"+getuserName); 57 | if("".equals(userAccount)&&"".equals(userPassword)){ 58 | 59 | }else{ 60 | nickname.setText(getuserName); 61 | nickname.setClickable(false); 62 | nickname.setTextColor(this.getResources().getColor(R.color.black)); 63 | } 64 | 65 | localcitytext.setText(localcity); 66 | Temperaturetext.setText(Temperature+"℃"); 67 | getHumiditytext.setText(getHumidity+"%"); 68 | 69 | if("".equals(userAccount)||"".equals(userPassword)||"".equals(getuserName)) { 70 | logoutpanel.setVisibility(View.GONE); 71 | line2.setVisibility(View.GONE); 72 | } 73 | bottom(); 74 | setStatusBar(); 75 | } 76 | 77 | 78 | public void logout(View veiw){ 79 | showMsg("退出成功"); 80 | new Thread(() -> { 81 | UserDao userDao = new UserDao(); 82 | userDao.logout(userAccount); 83 | }).start(); 84 | sp.edit().remove("getuserName").apply(); 85 | sp.edit().remove("userAccount").apply(); 86 | sp.edit().remove("userPassword").apply(); 87 | onCreate(null); 88 | 89 | } 90 | 91 | public void trip(View view){ 92 | if("".equals(userAccount)&&"".equals(userPassword)&&"".equals(getuserName)){ 93 | showMsg("请先登录"); 94 | }else{ 95 | startActivity(new Intent(getApplicationContext(),TripActivity.class)); 96 | } 97 | } 98 | 99 | public void feedback(View view){ 100 | if("".equals(userAccount)&&"".equals(userPassword)&&"".equals(getuserName)){ 101 | showMsg("请先登录"); 102 | }else{ 103 | startActivity(new Intent(getApplicationContext(),feedbackActivity.class)); 104 | } 105 | } 106 | 107 | public void register(View view){ 108 | startActivity(new Intent(getApplicationContext(),RegisterActivity.class)); 109 | } 110 | 111 | 112 | /** 113 | * function: 登录 114 | * */ 115 | public void loginactivity(View view){ 116 | startActivity(new Intent(getApplicationContext(),LoginActivity.class)); 117 | } 118 | 119 | /** 120 | * Toast提示 121 | * @param msg 提示内容 122 | */ 123 | private void showMsg(String msg){ 124 | Toast.makeText(this,msg,Toast.LENGTH_SHORT).show(); 125 | } 126 | 127 | public void bottom(){ 128 | BottomNavigationView bottomNavigationView = findViewById(R.id.botton_navigation); 129 | bottomNavigationView.setSelectedItemId(R.id.my); 130 | bottomNavigationView.setOnNavigationItemSelectedListener(menuitem -> { 131 | switch (menuitem.getItemId()){ 132 | case R.id.my: 133 | return true; 134 | case R.id.zhoubian: 135 | startActivity(new Intent(getApplicationContext(), ZhoubianActivity.class)); 136 | overridePendingTransition(0,0); 137 | return true; 138 | case R.id.main: 139 | startActivity(new Intent(getApplicationContext(), MainActivity.class)); 140 | overridePendingTransition(0,0); 141 | return true; 142 | } 143 | return false; 144 | }); 145 | } 146 | 147 | 148 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 149 | protected boolean useThemestatusBarColor = false; 150 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 151 | protected boolean useStatusBarColor = true; 152 | protected void setStatusBar() { 153 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 154 | View decorView = getWindow().getDecorView(); 155 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 156 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 157 | decorView.setSystemUiVisibility(option); 158 | //根据上面设置是否对状态栏单独设置颜色 159 | if (useThemestatusBarColor) { 160 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 161 | } else { 162 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 163 | } 164 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 165 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 166 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 167 | } else { 168 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 169 | } 170 | 171 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 172 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 173 | } 174 | } 175 | 176 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/PoiBean.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.TextView; 9 | 10 | import com.amap.api.services.help.Tip; 11 | import com.zzdayss.yunyou.R; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 输入提示adapter,展示item名称和地址 17 | * Created by ligen on 16/11/25. 18 | */ 19 | public class PoiBean { 20 | private double longitude;//经度 21 | private double latitude;//纬度 22 | private String title;//信息标题 23 | private String snippet;//信息内容 24 | public PoiBean(double lon, double lat, String title, String snippet){ 25 | this.longitude = lon; 26 | this.latitude = lat; 27 | this.title = title; 28 | this.snippet = snippet; 29 | } 30 | 31 | public double getLongitude() { 32 | return longitude; 33 | } 34 | 35 | public void setLongitude(double longitude) { 36 | this.longitude = longitude; 37 | } 38 | 39 | public double getLatitude() { 40 | return latitude; 41 | } 42 | 43 | public void setLatitude(double latitude) { 44 | this.latitude = latitude; 45 | } 46 | 47 | public String getTitle() { 48 | return title; 49 | } 50 | 51 | public void setTitle(String title) { 52 | this.title = title; 53 | } 54 | 55 | public String getSnippet() { 56 | return snippet; 57 | } 58 | 59 | public void setSnippet(String snippet) { 60 | this.snippet = snippet; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/RegisterActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.graphics.Color; 7 | import android.os.Build; 8 | import android.os.Bundle; 9 | import android.os.Handler; 10 | import android.os.Message; 11 | import android.view.View; 12 | import android.view.WindowManager; 13 | import android.widget.EditText; 14 | import android.widget.ImageView; 15 | import android.widget.Toast; 16 | 17 | import androidx.appcompat.app.AppCompatActivity; 18 | 19 | import com.google.android.material.bottomnavigation.BottomNavigationView; 20 | import com.zzdayss.yunyou.dao.UserDao; 21 | import com.zzdayss.yunyou.entity.User; 22 | 23 | import java.util.Objects; 24 | 25 | /** 26 | * function:连接注册页面 27 | */ 28 | public class RegisterActivity extends Activity { 29 | EditText userAccount = null; 30 | EditText userPassword = null; 31 | EditText userName = null; 32 | private String realCode; 33 | private EditText mEtRegisteractivityPhonecodes; 34 | private ImageView mIvRegisteractivityShowcode; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_register); 40 | userAccount = findViewById(R.id.userAccount); 41 | userPassword = findViewById(R.id.userPassword); 42 | userName = findViewById(R.id.userName); 43 | initView(); 44 | setStatusBar(); 45 | //将验证码用图片的形式显示出来 46 | mIvRegisteractivityShowcode.setImageBitmap(Code.getInstance().createBitmap()); 47 | realCode = Code.getInstance().getCode().toLowerCase(); 48 | 49 | 50 | } 51 | private void initView() { 52 | // 初始化控件 53 | mEtRegisteractivityPhonecodes = findViewById(R.id.et_registeractivity_phoneCodes); 54 | mIvRegisteractivityShowcode = findViewById(R.id.iv_registeractivity_showCode); 55 | 56 | } 57 | public void ChangeCode(View view){ 58 | mIvRegisteractivityShowcode.setImageBitmap(Code.getInstance().createBitmap()); 59 | realCode = Code.getInstance().getCode().toLowerCase(); 60 | } 61 | public void register(View view){ 62 | 63 | String userAccount1 = userAccount.getText().toString(); 64 | String userPassword1 = userPassword.getText().toString(); 65 | String userName1 = userName.getText().toString(); 66 | 67 | 68 | User user = new User(); 69 | 70 | user.setUserAccount(userAccount1); 71 | user.setUserPassword(userPassword1); 72 | user.setUserName(userName1); 73 | 74 | new Thread(() -> { 75 | 76 | int msg = 0; 77 | 78 | UserDao userDao = new UserDao(); 79 | String phoneCode = mEtRegisteractivityPhonecodes.getText().toString().toLowerCase(); 80 | User uu = userDao.findUser(user.getUserAccount()); 81 | if(uu != null){ 82 | msg = 1; 83 | }else if("".equals(userAccount1)||"".equals(userPassword1)||"".equals(userName1)){ 84 | msg = 3; 85 | }else if(!phoneCode.equals(realCode)){ 86 | msg = 4; 87 | } 88 | else{ 89 | boolean flag = userDao.register(user); 90 | if(flag){ 91 | msg = 2; 92 | } 93 | } 94 | hand.sendEmptyMessage(msg); 95 | 96 | }).start(); 97 | 98 | 99 | } 100 | @SuppressLint("HandlerLeak") 101 | final Handler hand = new Handler() 102 | { 103 | public void handleMessage(Message msg) { 104 | if(msg.what == 0) { 105 | Toast.makeText(getApplicationContext(),"注册失败",Toast.LENGTH_LONG).show(); 106 | } else if(msg.what == 1) { 107 | Toast.makeText(getApplicationContext(),"该账号已经存在,请换一个账号",Toast.LENGTH_LONG).show(); 108 | } else if(msg.what == 3) { 109 | Toast.makeText(getApplicationContext(),"请将所有信息填写完整",Toast.LENGTH_LONG).show(); 110 | } else if(msg.what == 4) { 111 | Toast.makeText(getApplicationContext(), "验证码错误!", Toast.LENGTH_LONG).show(); 112 | } else if(msg.what == 2) { 113 | Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_LONG).show(); 114 | Intent intent = new Intent(); 115 | //将想要传递的数据用putExtra封装在intent中 116 | intent.putExtra("a", "注册"); 117 | setResult(RESULT_CANCELED, intent); 118 | finish(); 119 | } 120 | 121 | } 122 | }; 123 | public void login(View view){ 124 | Intent intent=new Intent(this,LoginActivity.class); 125 | startActivity(intent); 126 | this.finish(); 127 | } 128 | 129 | 130 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 131 | protected boolean useThemestatusBarColor = false; 132 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 133 | protected boolean useStatusBarColor = true; 134 | protected void setStatusBar() { 135 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 136 | View decorView = getWindow().getDecorView(); 137 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 138 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 139 | decorView.setSystemUiVisibility(option); 140 | //根据上面设置是否对状态栏单独设置颜色 141 | if (useThemestatusBarColor) { 142 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 143 | } else { 144 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 145 | } 146 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 147 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 148 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 149 | } else { 150 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 151 | } 152 | 153 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 154 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/TripActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.os.Bundle; 8 | import android.os.Handler; 9 | import android.os.Message; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.widget.ListView; 13 | import android.widget.SimpleAdapter; 14 | import androidx.annotation.NonNull; 15 | import androidx.annotation.Nullable; 16 | 17 | import com.zzdayss.yunyou.dao.UserDao; 18 | import com.zzdayss.yunyou.entity.Trip; 19 | import java.util.ArrayList; 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | public class TripActivity extends Activity { 25 | 26 | private SharedPreferences sp; 27 | private ListView triplist; 28 | private String userAccount; 29 | private List> lists; 30 | @Override 31 | protected void onCreate(@Nullable Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_trip); 34 | triplist = findViewById(R.id.trip_list); 35 | 36 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 37 | userAccount = sp.getString("userAccount",""); 38 | trip(); 39 | } 40 | 41 | 42 | public void trip(){ 43 | new Thread(() -> { 44 | UserDao userDao = new UserDao(); 45 | List trip = userDao.gettrip(userAccount); 46 | lists = new ArrayList<>(); 47 | for(int i= 0;i map =new HashMap<>(); 49 | map.put("getDeparture",trip.get(i).getDeparture()); 50 | map.put("getDestination",trip.get(i).getDestination()); 51 | map.put("getDate",trip.get(i).getDate()); 52 | lists.add(map); 53 | Log.d("Trip","gettrip: "+ trip.get(i).getDeparture()+trip.get(i).getDestination()+trip.get(i).getDate()); 54 | Log.d("Trip","tripAdapterTTTT: "+ lists); 55 | 56 | } 57 | // 将从数据库拿到的list1对象传给message再由handler传出,再在handler中处理,可进行更新UI 58 | // 新建一个message对象,尽量不要直接new,而是用这种方法,因为有内存的问题存在 59 | Message message=Message.obtain(); 60 | // 设置message的辨认码,这里设为1 61 | message.what=1; 62 | // 把刚才接收到的list1赋给message.obj对象 63 | message.obj=lists; 64 | // 通过handler将携带数据的message传出去,传到handler中 65 | handler.sendMessage(message); 66 | }).start(); 67 | } 68 | @SuppressLint("HandlerLeak") 69 | final Handler handler =new Handler(){ 70 | @Override 71 | public void handleMessage(@NonNull Message msg) { 72 | super.handleMessage(msg); 73 | final ListView triplist=findViewById(R.id.trip_list); 74 | if(msg.what==1){ 75 | SimpleAdapter simpleAdapter=new SimpleAdapter(TripActivity.this, lists,R.layout.adapter_trips,new String[]{"getDeparture","getDestination","getDate"},new int[]{R.id.name,R.id.address,R.id.date}); 76 | triplist.setAdapter(simpleAdapter); 77 | } 78 | } 79 | }; 80 | public void tripadd(View view){ 81 | startActivity(new Intent(getApplicationContext(), TripaddActivity.class)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/TripaddActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.app.DatePickerDialog; 6 | import android.app.TimePickerDialog; 7 | import android.content.Intent; 8 | import android.content.SharedPreferences; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.util.Log; 13 | import android.view.View; 14 | import android.widget.DatePicker; 15 | import android.widget.EditText; 16 | import android.widget.TextView; 17 | import android.widget.TimePicker; 18 | import android.widget.Toast; 19 | 20 | import androidx.annotation.Nullable; 21 | 22 | import com.zzdayss.yunyou.dao.UserDao; 23 | 24 | import java.util.Calendar; 25 | 26 | public class TripaddActivity extends Activity{ 27 | 28 | private TextView date,time; 29 | private EditText departure,destination; 30 | private SharedPreferences sp; 31 | 32 | @Override 33 | protected void onCreate(@Nullable Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_tripadd); 36 | departure = findViewById(R.id.departure); 37 | destination = findViewById(R.id.destination); 38 | date = findViewById(R.id.date); 39 | time = findViewById(R.id.time); 40 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 41 | Calendar cal=Calendar.getInstance(); 42 | int y=cal.get(Calendar.YEAR); 43 | int m=cal.get(Calendar.MONTH); 44 | int d=cal.get(Calendar.DATE); 45 | int h=cal.get(Calendar.HOUR_OF_DAY); 46 | int mi=cal.get(Calendar.MINUTE); 47 | int s=cal.get(Calendar.SECOND); 48 | date.setText(y+"年"+m+"月"+d+"日"); 49 | time.setText(h+"时"+mi+"分"+s+"秒"); 50 | } 51 | 52 | public void submit(View view){ 53 | String userAccount = sp.getString("userAccount",""); 54 | String departurecontext = (departure.getText().toString()); 55 | String destinationcontext = (destination.getText().toString()); 56 | String date1 = (date.getText().toString()+time.getText().toString()); 57 | new Thread(() -> { 58 | int msg = 0; 59 | UserDao userDao = new UserDao(); 60 | if("".equals(departurecontext)||"".equals(destinationcontext)){ 61 | msg = 0; 62 | } else{ 63 | boolean flag = userDao.tripadd(userAccount,departurecontext,destinationcontext,date1); 64 | Log.d("tripadd","departurecontext:::"+departurecontext); 65 | Log.d("tripadd","destinationcontext:::"+destinationcontext); 66 | if(flag){ 67 | msg = 1; 68 | }else { 69 | msg = 2; 70 | } 71 | } 72 | hand.sendEmptyMessage(msg); 73 | 74 | }).start(); 75 | 76 | } 77 | @SuppressLint("HandlerLeak") 78 | final Handler hand = new Handler() 79 | { 80 | public void handleMessage(Message msg) { 81 | if(msg.what == 0) { 82 | Toast.makeText(getApplicationContext(),"添加失败,请填写完整信息",Toast.LENGTH_LONG).show(); 83 | } else if(msg.what == 1) { 84 | Toast.makeText(getApplicationContext(),"添加成功",Toast.LENGTH_LONG).show(); 85 | startActivity(new Intent(getApplicationContext(),TripActivity.class)); 86 | }else if(msg.what == 2) { 87 | Toast.makeText(getApplicationContext(),"添加失败,连接数据库出错",Toast.LENGTH_LONG).show(); 88 | } 89 | } 90 | }; 91 | 92 | 93 | 94 | public void adddate(View view){ 95 | showdate(); 96 | } 97 | private void showdate() { 98 | Calendar calendar = Calendar.getInstance();//调用Calendar类获取年月日 99 | int mYear = calendar.get(Calendar.YEAR);//年 100 | int mMonth = calendar.get(Calendar.MONTH);//月份要加一个一,这个值的初始值是0。不加会日期会少一月。 101 | int mDay = calendar.get(Calendar.DAY_OF_MONTH);//日 102 | DatePickerDialog datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { 103 | @Override 104 | public void onDateSet(DatePicker datePicker, int i, int i1, int i2) { 105 | date.setText(i + "年" + (i1+1) + "月" + i2 + "日");//当选择完后将时间显示,记得月份i1加一 106 | } 107 | }, mYear,mMonth, mDay);//将年月日放入DatePickerDialog中,并将值传给参数 108 | datePickerDialog.show();//显示dialog 109 | } 110 | 111 | public void addtime(View view){ 112 | showtime(); 113 | } 114 | 115 | public void showtime(){ 116 | //获取日历的一个实例,里面包含了当前的时分秒 117 | Calendar calendar=Calendar.getInstance(); 118 | //构建一个时间对话框,该对话框已经集成了时间选择器 119 | //TimePickerDialog的第二个构造参数指定了事件监听器 120 | TimePickerDialog dialog=new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener(){ 121 | //一旦点击对话框上的确定按钮,触发该方法 122 | @Override 123 | public void onTimeSet(TimePicker timePicker, int i, int i1) { 124 | time.setText(i+"时"+i1+"分");//获取时间对话框设定的小时和分钟数 125 | } 126 | },calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true);//true表示使用二十四小时制 127 | //把时间对话框显示在界面上 128 | dialog.show(); 129 | } 130 | 131 | 132 | 133 | 134 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/ZhoubianActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.SharedPreferences; 8 | import android.graphics.Color; 9 | import android.os.Build; 10 | import android.os.Bundle; 11 | import android.os.Handler; 12 | import android.os.Message; 13 | import android.util.Log; 14 | import android.view.View; 15 | import android.view.WindowManager; 16 | import android.widget.AdapterView; 17 | import android.widget.LinearLayout; 18 | import android.widget.ListView; 19 | import android.widget.SimpleAdapter; 20 | import android.widget.TextView; 21 | import android.widget.Toast; 22 | 23 | import androidx.annotation.NonNull; 24 | 25 | import com.amap.api.maps.model.LatLng; 26 | import com.amap.api.services.core.AMapException; 27 | import com.amap.api.services.core.LatLonPoint; 28 | import com.amap.api.services.core.PoiItem; 29 | import com.amap.api.services.help.Tip; 30 | import com.amap.api.services.poisearch.PoiResult; 31 | import com.amap.api.services.poisearch.PoiSearch; 32 | import com.google.android.material.bottomnavigation.BottomNavigationView; 33 | import com.zzdayss.yunyou.adapter.InputTipsAdapter; 34 | import com.zzdayss.yunyou.adapter.ZhoubianAdapter; 35 | import com.zzdayss.yunyou.dao.UserDao; 36 | import com.zzdayss.yunyou.entity.Trip; 37 | import com.zzdayss.yunyou.util.Constants; 38 | import com.zzdayss.yunyou.util.ToastUtil; 39 | 40 | import java.util.ArrayList; 41 | import java.util.HashMap; 42 | import java.util.LinkedList; 43 | import java.util.List; 44 | import java.util.Map; 45 | 46 | public class ZhoubianActivity extends Activity implements PoiSearch.OnPoiSearchListener, AdapterView.OnItemClickListener { 47 | private List mData = null; 48 | private TextView Local; 49 | private ListView zhoubianlist; 50 | private PoiSearch.Query query; 51 | private ZhoubianAdapter poiAdapter; 52 | private String Localaddress,getuserName,userAccount; 53 | private Double Locallatitude; 54 | private Double Locallongitude; 55 | private Context mContext; 56 | //POI搜索对象 57 | private PoiSearch poiSearch; 58 | private SharedPreferences sp; 59 | private LinearLayout login; 60 | private List poiItems; 61 | private List> lists; 62 | protected void onCreate(Bundle savedInstanceState) { 63 | super.onCreate(savedInstanceState); 64 | setContentView(R.layout.activity_zhoubian); 65 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 66 | Local = findViewById(R.id.Local); 67 | mContext = this; 68 | zhoubianlist = (ListView) findViewById(R.id.zhoubian_list); 69 | zhoubianlist.setOnItemClickListener(this); 70 | login = findViewById(R.id.login); 71 | getuserName = sp.getString("getuserName",""); 72 | Localaddress = sp.getString("Localaddress",""); 73 | userAccount = sp.getString("userAccount",""); 74 | Locallatitude = Double.valueOf(sp.getString("latitude",""));; 75 | Locallongitude = Double.valueOf(sp.getString("longitude","")); 76 | Local.setText("当前地址:"+Localaddress); 77 | bottom(); 78 | setStatusBar(); 79 | zhoubianPOI("餐饮服务"); 80 | if("".equals(getuserName)){ 81 | zhoubianlist.setVisibility(View.INVISIBLE); 82 | login.setVisibility(View.VISIBLE); 83 | }else{ 84 | zhoubianlist.setVisibility(View.VISIBLE); 85 | login.setVisibility(View.INVISIBLE); 86 | } 87 | } 88 | 89 | public void foodPOI(View view){ 90 | zhoubianPOI("餐饮服务"); 91 | } 92 | public void hotelPOI(View view){ 93 | zhoubianPOI("住宿服务"); 94 | } 95 | public void tourPOI(View view){ 96 | zhoubianPOI("风景名胜"); 97 | } 98 | public void playPOI(View view){ 99 | zhoubianPOI("体育休闲服务"); 100 | } 101 | public void trip(View view){ 102 | trip(); 103 | } 104 | public void zhoubianPOI(String type) { 105 | //构造query对象 106 | query = new PoiSearch.Query(type, "", ""); 107 | // 设置每页最多返回多少条poiitem 108 | query.setPageSize(50); 109 | //设置查询页码 110 | query.setPageNum(1); 111 | //构造 PoiSearch 对象 112 | try { 113 | poiSearch = new PoiSearch(this, query); 114 | } catch (AMapException e) { 115 | e.printStackTrace(); 116 | } 117 | //设置搜索回调监听 118 | poiSearch.setOnPoiSearchListener(this); 119 | poiSearch.setBound(new PoiSearch.SearchBound(new LatLonPoint(Locallatitude, Locallongitude), 5000, true));// 120 | //发起搜索附近POI异步请求 121 | poiSearch.searchPOIAsyn(); 122 | } 123 | 124 | //回调的方法 125 | @Override 126 | public void onPoiItemSearched(PoiItem arg0, int arg1) { 127 | 128 | } 129 | 130 | @Override 131 | public void onPoiSearched(PoiResult result, int arg1) { 132 | if (arg1 == 1000) { 133 | if (result != null && result.getQuery() != null) {// 搜索poi的结果 134 | if (result.getQuery().equals(query)) {// 是否是同一条 135 | poiItems = result.getPois();// 取得第一页的poiitem数据,页数从数字0开始 136 | mData = new LinkedList(); 137 | if (poiItems != null && poiItems.size() > 0) { 138 | for (int i = 0; i < poiItems.size(); i++) { 139 | PoiItem poiItem = poiItems.get(i); //写一个bean,作为数据存储 140 | PoiBean bean = new PoiBean(Locallongitude,Locallatitude,poiItem.getTitle(),poiItem.getSnippet()); 141 | bean.setLatitude(Locallatitude); 142 | bean.setLongitude(Locallongitude); 143 | bean.setTitle(poiItem.getTitle()); 144 | bean.setSnippet(poiItem.getAdName()+poiItem.getSnippet()); 145 | Log.d("zhoubian","list:"+poiItem.getTitle()+","+poiItem.getProvinceName()+"," 146 | +poiItem.getCityName()+"," 147 | +poiItem.getAdName()+","//区 148 | +poiItem.getSnippet()+"\n"); 149 | mData.add(bean); 150 | } 151 | poiAdapter = new ZhoubianAdapter(mData, mContext); 152 | zhoubianlist.setAdapter(poiAdapter); 153 | poiAdapter.notifyDataSetChanged(); 154 | } else { 155 | ToastUtil.showerror(this, arg1); 156 | } 157 | 158 | // mAdapter.notifyDataSetChanged(); //解析成功更新list布局 159 | 160 | } 161 | } 162 | } 163 | } 164 | 165 | @Override 166 | public void onItemClick(AdapterView adapterView, View view, int i, long l) { 167 | if (poiAdapter != null) { 168 | 169 | Intent intent = new Intent(); 170 | Double mDatagetLatitude = poiItems.get(i).getLatLonPoint().getLatitude(); 171 | Double mDatagetLongitude = poiItems.get(i).getLatLonPoint().getLongitude(); 172 | String Titlezb = poiItems.get(i).getTitle(); 173 | String Snippetzb = poiItems.get(i).getSnippet(); 174 | sp.edit().putString("Titlezb", Titlezb).apply(); 175 | sp.edit().putString("Snippetzb", Snippetzb).apply(); 176 | sp.edit().putString("mDatagetLatitude", String.valueOf(mDatagetLatitude)).apply(); 177 | sp.edit().putString("mDatagetLongitude", String.valueOf(mDatagetLongitude)).apply(); 178 | sp.edit().putInt("zhoubian", 103).apply(); 179 | setResult(MainActivity.RESULT_CODE_ZHOUBIAN, intent); 180 | this.finish(); 181 | // startActivity(new Intent(getApplicationContext(),MainActivity.class)); 182 | } 183 | } 184 | /** 185 | * function: 登录 186 | * */ 187 | public void zhoubianlogin(View view){ 188 | startActivity(new Intent(getApplicationContext(),LoginActivity.class)); 189 | } 190 | 191 | public void bottom(){ 192 | BottomNavigationView bottomNavigationView = findViewById(R.id.botton_navigation); 193 | bottomNavigationView.setSelectedItemId(R.id.zhoubian); 194 | bottomNavigationView.setOnNavigationItemSelectedListener(menuitem -> { 195 | switch (menuitem.getItemId()) { 196 | case R.id.zhoubian: 197 | return true; 198 | case R.id.my: 199 | startActivity(new Intent(getApplicationContext(), MyActivity.class)); 200 | overridePendingTransition(0, 0); 201 | return true; 202 | case R.id.main: 203 | startActivity(new Intent(getApplicationContext(), MainActivity.class)); 204 | overridePendingTransition(0, 0); 205 | return true; 206 | } 207 | return false; 208 | }); 209 | } 210 | 211 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 212 | protected boolean useThemestatusBarColor = false; 213 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 214 | protected boolean useStatusBarColor = true; 215 | protected void setStatusBar() { 216 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 217 | View decorView = getWindow().getDecorView(); 218 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 219 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 220 | decorView.setSystemUiVisibility(option); 221 | //根据上面设置是否对状态栏单独设置颜色 222 | if (useThemestatusBarColor) { 223 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 224 | } else { 225 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 226 | } 227 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 228 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 229 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 230 | } else { 231 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 232 | } 233 | 234 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 235 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 236 | } 237 | } 238 | 239 | public void trip(){ 240 | new Thread(() -> { 241 | UserDao userDao = new UserDao(); 242 | List trip = userDao.gettrip(userAccount); 243 | lists = new ArrayList<>(); 244 | for(int i= 0;i map =new HashMap<>(); 246 | map.put("getDeparture",trip.get(i).getDeparture()); 247 | map.put("getDestination",trip.get(i).getDestination()); 248 | map.put("getDate",trip.get(i).getDate()); 249 | lists.add(map); 250 | Log.d("Trip","gettrip: "+ trip.get(i).getDeparture()+trip.get(i).getDestination()+trip.get(i).getDate()); 251 | Log.d("Trip","tripAdapterTTTT: "+ lists); 252 | 253 | } 254 | // 将从数据库拿到的list1对象传给message再由handler传出,再在handler中处理,可进行更新UI 255 | // 新建一个message对象,尽量不要直接new,而是用这种方法,因为有内存的问题存在 256 | Message message=Message.obtain(); 257 | // 设置message的辨认码,这里设为1 258 | message.what=1; 259 | // 把刚才接收到的list1赋给message.obj对象 260 | message.obj=lists; 261 | // 通过handler将携带数据的message传出去,传到handler中 262 | handler.sendMessage(message); 263 | }).start(); 264 | } 265 | @SuppressLint("HandlerLeak") 266 | final Handler handler =new Handler(){ 267 | @Override 268 | public void handleMessage(@NonNull Message msg) { 269 | super.handleMessage(msg); 270 | final ListView triplist=findViewById(R.id.zhoubian_list); 271 | if(msg.what==1){ 272 | SimpleAdapter simpleAdapter=new SimpleAdapter(ZhoubianActivity.this, lists,R.layout.adapter_trips,new String[]{"getDeparture","getDestination","getDate"},new int[]{R.id.name,R.id.address,R.id.date}); 273 | triplist.setAdapter(simpleAdapter); 274 | } 275 | } 276 | }; 277 | } 278 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/adapter/InputTipsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.amap.api.services.help.Tip; 12 | import com.zzdayss.yunyou.R; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * 输入提示adapter,展示item名称和地址 18 | * Created by ligen on 16/11/25. 19 | */ 20 | public class InputTipsAdapter extends BaseAdapter { 21 | private Context mContext; 22 | private List mListTips; 23 | 24 | public InputTipsAdapter(Context context, List tipList) { 25 | mContext = context; 26 | mListTips = tipList; 27 | } 28 | 29 | @Override 30 | public int getCount() { 31 | if (mListTips != null) { 32 | return mListTips.size(); 33 | } 34 | return 0; 35 | } 36 | 37 | 38 | @Override 39 | public Object getItem(int i) { 40 | if (mListTips != null) { 41 | return mListTips.get(i); 42 | } 43 | return null; 44 | } 45 | 46 | @Override 47 | public long getItemId(int i) { 48 | return i; 49 | } 50 | 51 | @Override 52 | public View getView(int i, View view, ViewGroup viewGroup) { 53 | Holder holder; 54 | if (view == null) { 55 | holder = new Holder(); 56 | view = LayoutInflater.from(mContext).inflate(R.layout.adapter_inputtips, null); 57 | holder.place = (ImageView) view.findViewById(R.id.place); 58 | holder.mName = (TextView) view.findViewById(R.id.name); 59 | holder.mAddress = (TextView) view.findViewById(R.id.adress); 60 | view.setTag(holder); 61 | } else{ 62 | holder = (Holder)view.getTag(); 63 | } 64 | if(mListTips == null){ 65 | return view; 66 | } 67 | 68 | holder.mName.setText(mListTips.get(i).getName()); 69 | String address = mListTips.get(i).getAddress(); 70 | if(address == null || address.equals("")){ 71 | holder.mAddress.setVisibility(View.GONE); 72 | }else{ 73 | holder.mAddress.setVisibility(View.VISIBLE); 74 | holder.mAddress.setText(address); 75 | } 76 | 77 | return view; 78 | } 79 | 80 | class Holder { 81 | ImageView place; 82 | TextView mName; 83 | TextView mAddress; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/adapter/ZhoubianAdapter.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.zzdayss.yunyou.PoiBean; 12 | import com.zzdayss.yunyou.R; 13 | 14 | import java.util.List; 15 | 16 | public class ZhoubianAdapter extends BaseAdapter { 17 | private List mData; 18 | private Context mContext; 19 | public ZhoubianAdapter(List mData, Context mContext) { 20 | this.mData = mData; 21 | this.mContext = mContext; 22 | } 23 | @Override 24 | public int getCount() { 25 | return mData.size(); 26 | } 27 | @Override 28 | public Object getItem(int position) { 29 | return mData.get(position); 30 | } 31 | @Override 32 | public long getItemId(int position) { 33 | return position; 34 | } 35 | @Override 36 | public View getView(int position, View convertView, ViewGroup parent) { 37 | convertView = 38 | LayoutInflater.from(mContext).inflate(R.layout.adapter_inputtips, 39 | parent, false); 40 | TextView title = (TextView) 41 | convertView.findViewById(R.id.name); 42 | TextView adress = (TextView) 43 | convertView.findViewById(R.id.adress); 44 | title.setText(mData.get(position).getTitle()); 45 | adress.setText(mData.get(position).getSnippet()); 46 | return convertView; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.dao; 2 | 3 | import android.util.Log; 4 | 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | import java.util.HashMap; 10 | import java.util.LinkedList; 11 | import java.util.List; 12 | 13 | import com.zzdayss.yunyou.entity.Trip; 14 | import com.zzdayss.yunyou.entity.User; 15 | import com.zzdayss.yunyou.utils.JDBCUtils; 16 | 17 | /** 18 | * author: yan 19 | * date: 2022.02.17 20 | * **/ 21 | public class UserDao { 22 | 23 | private static final String TAG = "mysql-party-UserDao"; 24 | 25 | /** 26 | * function: 登录 27 | * */ 28 | public int login(String userAccount, String userPassword){ 29 | 30 | HashMap map = new HashMap<>(); 31 | // 根据数据库名称,建立连接 32 | Connection connection = JDBCUtils.getConn(); 33 | Log.e(TAG,"connection1是:" + connection); 34 | int msg = 0; 35 | try { 36 | // mysql简单的查询语句。这里是根据user表的userAccount字段来查询某条记录 37 | String sql = "select * from user where userAccount = ?"; 38 | String loginsuccess = "update user set state = 1 where userAccount = ?"; 39 | if (connection != null){// connection不为null表示与数据库建立了连接 40 | PreparedStatement ps = connection.prepareStatement(sql); 41 | if (ps != null){ 42 | Log.e(TAG,"账号:" + userAccount); 43 | //根据账号进行查询 44 | ps.setString(1, userAccount); 45 | // 执行sql查询语句并返回结果集 46 | ResultSet rs = ps.executeQuery(); 47 | int count = rs.getMetaData().getColumnCount(); 48 | //将查到的内容储存在map里 49 | while (rs.next()){ 50 | // 注意:下标是从1开始的 51 | for (int i = 1;i <= count;i++){ 52 | String field = rs.getMetaData().getColumnName(i); 53 | map.put(field, rs.getString(field)); 54 | } 55 | } 56 | 57 | if (map.size()!=0){ 58 | StringBuilder s = new StringBuilder(); 59 | //寻找密码是否匹配 60 | for (String key : map.keySet()){ 61 | if(key.equals("userPassword")){ 62 | if(userPassword.equals(map.get(key))){ 63 | PreparedStatement ps1 = connection.prepareStatement(loginsuccess); 64 | ps1.setString(1, userAccount); 65 | int rs1 = ps1.executeUpdate(); 66 | if(rs1 == 1) { 67 | msg = 1; //密码正确 68 | }else{ 69 | msg = 4; 70 | } 71 | } 72 | else 73 | msg = 2; //密码错误 74 | break; 75 | } 76 | connection.close(); 77 | ps.close(); 78 | } 79 | }else { 80 | Log.e(TAG, "查询结果为空"); 81 | msg = 3; 82 | } 83 | }else { 84 | msg = 0; 85 | } 86 | }else { 87 | msg = 0; 88 | } 89 | }catch (Exception e){ 90 | e.printStackTrace(); 91 | Log.d(TAG, "异常login:" + e.getMessage()); 92 | msg = 0; 93 | } 94 | return msg; 95 | } 96 | 97 | public void logout(String userAccount) { 98 | Connection connection = JDBCUtils.getConn(); 99 | String logout = "update user set state = 0 where userAccount = ?"; 100 | try { 101 | if (connection != null) {// connection不为null表示与数据库建立了连接 102 | PreparedStatement ps = connection.prepareStatement(logout); 103 | if (ps != null) { 104 | Log.e(TAG, "账号:" + userAccount); 105 | //根据账号进行查询 106 | ps.setString(1, userAccount); 107 | // 执行sql查询语句并返回结果集 108 | ps.executeUpdate(); 109 | //将查到的内容储存在map里 110 | 111 | } 112 | } 113 | } catch (SQLException throwables) { 114 | throwables.printStackTrace(); 115 | } 116 | } 117 | 118 | public int getrenshu(){ 119 | Connection connection = JDBCUtils.getConn(); 120 | String logout = "select count(*) from user where state = 1"; 121 | int count = 0; 122 | try { 123 | if (connection != null) {// connection不为null表示与数据库建立了连接 124 | PreparedStatement ps = connection.prepareStatement(logout); 125 | if (ps != null) { 126 | // 执行sql查询语句并返回结果集 127 | ResultSet rs = ps.executeQuery(); 128 | while(rs.next()){ 129 | count = rs.getInt(1); 130 | } 131 | 132 | } 133 | } 134 | } catch (SQLException throwables) { 135 | throwables.printStackTrace(); 136 | } 137 | return count; 138 | } 139 | 140 | 141 | /** 142 | * function: 注册 143 | * */ 144 | public boolean register(User user){ 145 | HashMap map = new HashMap<>(); 146 | // 根据数据库名称,建立连接 147 | Connection connection = JDBCUtils.getConn(); 148 | Log.e(TAG,"connection2是:" + connection); 149 | 150 | try { 151 | String sql = "insert into user(userAccount,userPassword,userName) values (?,?,?)"; 152 | if (connection != null){// connection不为null表示与数据库建立了连接 153 | PreparedStatement ps = connection.prepareStatement(sql); 154 | if (ps != null){ 155 | 156 | //将数据插入数据库 157 | ps.setString(1,user.getUserAccount()); 158 | ps.setString(2,user.getUserPassword()); 159 | ps.setString(3,user.getUserName()); 160 | 161 | // 执行sql查询语句并返回结果集 162 | int rs = ps.executeUpdate(); 163 | if(rs>0) 164 | return true; 165 | else 166 | return false; 167 | }else { 168 | return false; 169 | } 170 | }else { 171 | return false; 172 | } 173 | }catch (Exception e){ 174 | e.printStackTrace(); 175 | Log.e(TAG, "异常register:" + e.getMessage()); 176 | return false; 177 | } 178 | 179 | } 180 | 181 | /** 182 | * function: 添加行程 183 | * */ 184 | public boolean tripadd(String userAccount, String departure, String destination, String date){ 185 | // 根据数据库名称,建立连接 186 | Connection connection = JDBCUtils.getConn(); 187 | try { 188 | String sql = "insert into trip(userAccount,departure,destination,date) values (?,?,?,?)"; 189 | if (connection != null){// connection不为null表示与数据库建立了连接 190 | PreparedStatement ps = connection.prepareStatement(sql); 191 | if (ps != null){ 192 | //将数据插入数据库 193 | ps.setString(1,userAccount); 194 | ps.setString(2,departure); 195 | ps.setString(3,destination); 196 | ps.setString(4,date); 197 | 198 | // 执行sql查询语句并返回结果集 199 | int rs = ps.executeUpdate(); 200 | if(rs>0) 201 | return true; 202 | else 203 | return false; 204 | }else { 205 | return false; 206 | } 207 | }else { 208 | return false; 209 | } 210 | }catch (Exception e){ 211 | e.printStackTrace(); 212 | Log.e(TAG, "异常register:" + e.getMessage()); 213 | return false; 214 | } 215 | 216 | } 217 | /** 218 | * function: 根据账号进行查询行程 219 | * 220 | * @return*/ 221 | public List gettrip(String userAccount) { 222 | 223 | // 根据数据库名称,建立连接 224 | Connection connection = JDBCUtils.getConn(); 225 | List tripdata = new LinkedList(); 226 | try { 227 | String sql = "select * from trip where userAccount = ?"; 228 | if (connection != null){// connection不为null表示与数据库建立了连接 229 | PreparedStatement ps = connection.prepareStatement(sql); 230 | if (ps != null) { 231 | ps.setString(1, userAccount); 232 | ResultSet rs = ps.executeQuery(); 233 | 234 | while (rs.next()) { 235 | //注意:下标是从1开始 236 | String departure = rs.getString(3); 237 | String destination = rs.getString(4); 238 | String date = rs.getString(5); 239 | Trip trip = new Trip(departure, destination, date); 240 | trip.setDeparture(departure); 241 | trip.setDestination(destination); 242 | trip.setDate(date); 243 | tripdata.add(trip); 244 | } 245 | } 246 | } 247 | }catch (Exception e){ 248 | e.printStackTrace(); 249 | Log.d(TAG, "异常findUser:" + e.getMessage()); 250 | return null; 251 | } 252 | return tripdata; 253 | } 254 | /** 255 | * function: 反馈 256 | * */ 257 | public boolean feedback(String userAccount,String content,String Stars){ 258 | // 根据数据库名称,建立连接 259 | Connection connection = JDBCUtils.getConn(); 260 | try { 261 | String sql = "insert into feedback(userAccount,content,Stars) values (?,?,?)"; 262 | if (connection != null){// connection不为null表示与数据库建立了连接 263 | PreparedStatement ps = connection.prepareStatement(sql); 264 | if (ps != null){ 265 | //将数据插入数据库 266 | ps.setString(1,userAccount); 267 | ps.setString(2,content); 268 | ps.setString(3,Stars); 269 | 270 | // 执行sql查询语句并返回结果集 271 | int rs = ps.executeUpdate(); 272 | if(rs>0) 273 | return true; 274 | else 275 | return false; 276 | }else { 277 | return false; 278 | } 279 | }else { 280 | return false; 281 | } 282 | }catch (Exception e){ 283 | e.printStackTrace(); 284 | Log.e(TAG, "异常register:" + e.getMessage()); 285 | return false; 286 | } 287 | 288 | } 289 | 290 | /** 291 | * function: 根据账号进行查找该用户是否存在 292 | * */ 293 | public User findUser(String userAccount) { 294 | 295 | // 根据数据库名称,建立连接 296 | Connection connection = JDBCUtils.getConn(); 297 | Log.e(TAG,"connection3是:" + connection); 298 | User user = null; 299 | try { 300 | String sql = "select * from user where userAccount = ?"; 301 | if (connection != null){// connection不为null表示与数据库建立了连接 302 | PreparedStatement ps = connection.prepareStatement(sql); 303 | if (ps != null) { 304 | ps.setString(1, userAccount); 305 | ResultSet rs = ps.executeQuery(); 306 | 307 | while (rs.next()) { 308 | //注意:下标是从1开始 309 | int id = rs.getInt(1); 310 | String userAccount1 = rs.getString(2); 311 | String userPassword = rs.getString(3); 312 | String userName = rs.getString(4); 313 | user = new User(id, userAccount1, userPassword, userName); 314 | } 315 | } 316 | } 317 | }catch (Exception e){ 318 | e.printStackTrace(); 319 | Log.d(TAG, "异常findUser:" + e.getMessage()); 320 | return null; 321 | } 322 | return user; 323 | } 324 | public String finduserName(String userAccount){ 325 | String userName = null; 326 | try{ 327 | String sql = "select * from user where userAccount ="+userAccount+""; 328 | Connection conn = new JDBCUtils().getConn(); 329 | Log.e(TAG,"connection2是:" + conn); 330 | PreparedStatement parstmt = conn.prepareStatement(sql); 331 | ResultSet rs = parstmt.executeQuery(); 332 | while(rs.next()) { 333 | userName = rs.getString("userName"); 334 | } 335 | conn.close(); 336 | parstmt.close(); 337 | rs.close(); 338 | }catch(SQLException e) { 339 | e.printStackTrace(); 340 | } 341 | return userName; 342 | } 343 | } 344 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/entity/Trip.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.entity; 2 | 3 | public class Trip { 4 | 5 | private String departure; 6 | private String destination; 7 | private String date; 8 | 9 | public Trip() { 10 | } 11 | 12 | public Trip(String departure, String destination, String date) { 13 | this.departure = departure; 14 | this.destination = destination; 15 | this.date = date; 16 | } 17 | 18 | public String getDeparture() { 19 | return departure; 20 | } 21 | 22 | public void setDeparture(String departure) { 23 | this.departure = departure; 24 | } 25 | 26 | public String getDestination() { 27 | return destination; 28 | } 29 | 30 | public void setDestination(String destination) { 31 | this.destination = destination; 32 | } 33 | 34 | public String getDate() { 35 | return date; 36 | } 37 | 38 | public void setDate(String date) { 39 | this.date = date; 40 | } 41 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.entity; 2 | 3 | public class User { 4 | 5 | private int id; 6 | private String userAccount; 7 | private String userPassword; 8 | private String userName; 9 | 10 | public User() { 11 | } 12 | 13 | public User(int id, String userAccount, String userPassword, String userName) { 14 | this.id = id; 15 | this.userAccount = userAccount; 16 | this.userPassword = userPassword; 17 | this.userName = userName; 18 | } 19 | 20 | public int getId() { 21 | return id; 22 | } 23 | 24 | public void setId(int id) { 25 | this.id = id; 26 | } 27 | 28 | public String getUserAccount() { 29 | return userAccount; 30 | } 31 | 32 | public void setUserAccount(String userAccount) { 33 | this.userAccount = userAccount; 34 | } 35 | 36 | public String getUserPassword() { 37 | return userPassword; 38 | } 39 | 40 | public void setUserPassword(String userPassword) { 41 | this.userPassword = userPassword; 42 | } 43 | 44 | public String getUserName() { 45 | return userName; 46 | } 47 | 48 | public void setUserName(String userName) { 49 | this.userName = userName; 50 | } 51 | } 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/feedbackActivity.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.graphics.Color; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.os.Handler; 11 | import android.os.Message; 12 | import android.util.Log; 13 | import android.view.View; 14 | import android.view.WindowManager; 15 | import android.widget.EditText; 16 | import android.widget.Toast; 17 | 18 | import com.zzdayss.yunyou.dao.UserDao; 19 | import com.zzdayss.yunyou.entity.User; 20 | 21 | public class feedbackActivity extends Activity { 22 | 23 | private EditText editText; 24 | private android.widget.RatingBar RatingBar; 25 | private SharedPreferences sp; 26 | private String userAccount,feedback,Stars; 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_feedback); 30 | 31 | editText = findViewById(R.id.feedback); 32 | RatingBar = findViewById(R.id.ratingBar); 33 | 34 | sp = getSharedPreferences("Personal", MODE_PRIVATE); 35 | 36 | setStatusBar(); 37 | 38 | } 39 | 40 | public void submit(View view){ 41 | userAccount = sp.getString("userAccount",""); 42 | 43 | feedback = (editText.getText().toString()); 44 | Stars = String.valueOf(RatingBar.getRating()); 45 | new Thread(() -> { 46 | int msg = 0; 47 | UserDao userDao = new UserDao(); 48 | if("".equals(feedback)||feedback==null){ 49 | msg = 0; 50 | } else{ 51 | boolean flag = userDao.feedback(userAccount,feedback,Stars); 52 | Log.d("feed","feedback:::"+feedback); 53 | Log.d("feed","Stars:::"+Stars); 54 | if(flag){ 55 | msg = 1; 56 | }else { 57 | msg = 2; 58 | } 59 | } 60 | hand.sendEmptyMessage(msg); 61 | 62 | }).start(); 63 | 64 | } 65 | @SuppressLint("HandlerLeak") 66 | final Handler hand = new Handler() 67 | { 68 | public void handleMessage(Message msg) { 69 | if(msg.what == 0) { 70 | Toast.makeText(getApplicationContext(),"提交失败,请填写完整信息",Toast.LENGTH_LONG).show(); 71 | } else if(msg.what == 1) { 72 | Toast.makeText(getApplicationContext(),"提交成功",Toast.LENGTH_LONG).show(); 73 | startActivity(new Intent(getApplicationContext(),MyActivity.class)); 74 | }else if(msg.what == 2) { 75 | Toast.makeText(getApplicationContext(),"提交失败,连接数据库出错",Toast.LENGTH_LONG).show(); 76 | } 77 | } 78 | }; 79 | 80 | //是否使用特殊的标题栏背景颜色,android5.0以上可以设置状态栏背景色,如果不使用则使用透明色值 81 | protected boolean useThemestatusBarColor = false; 82 | //是否使用状态栏文字和图标为暗色,如果状态栏采用了白色系,则需要使状态栏和图标为暗色,android6.0以上可以设置 83 | protected boolean useStatusBarColor = true; 84 | protected void setStatusBar() { 85 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上 86 | View decorView = getWindow().getDecorView(); 87 | int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 88 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 89 | decorView.setSystemUiVisibility(option); 90 | //根据上面设置是否对状态栏单独设置颜色 91 | if (useThemestatusBarColor) { 92 | getWindow().setStatusBarColor(getResources().getColor(R.color.colortheme));//设置状态栏背景色 93 | } else { 94 | getWindow().setStatusBarColor(Color.TRANSPARENT);//透明 95 | } 96 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0 97 | WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes(); 98 | localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags); 99 | } else { 100 | Toast.makeText(this, "低于4.4的android系统版本不存在沉浸式状态栏", Toast.LENGTH_SHORT).show(); 101 | } 102 | 103 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && useStatusBarColor) {//android6.0以后可以对状态栏文字颜色和图标进行修改 104 | getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/overlay/PoiOverlay.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.overlay; 2 | 3 | import com.amap.api.maps.AMap; 4 | import com.amap.api.maps.CameraUpdateFactory; 5 | import com.amap.api.maps.model.BitmapDescriptor; 6 | import com.amap.api.maps.model.LatLng; 7 | import com.amap.api.maps.model.LatLngBounds; 8 | import com.amap.api.maps.model.Marker; 9 | import com.amap.api.maps.model.MarkerOptions; 10 | import com.amap.api.services.core.PoiItem; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Poi图层类。在高德地图API里,如果要显示Poi,可以用此类来创建Poi图层。如不满足需求,也可以自己创建自定义的Poi图层。 17 | */ 18 | public class PoiOverlay { 19 | private List mPois; 20 | private AMap mAMap; 21 | private ArrayList mPoiMarks = new ArrayList(); 22 | /** 23 | * 通过此构造函数创建Poi图层。 24 | * @param amap 地图对象。 25 | * @param pois 要在地图上添加的poi。列表中的poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 PoiItem。 26 | * @since V2.1.0 27 | */ 28 | public PoiOverlay(AMap amap, List pois) { 29 | mAMap = amap; 30 | mPois = pois; 31 | } 32 | /** 33 | * 添加Marker到地图中。 34 | */ 35 | public void addToMap() { 36 | try{ 37 | for (int i = 0; i < mPois.size(); i++) { 38 | Marker marker = mAMap.addMarker(getMarkerOptions(i)); 39 | marker.setObject(i); 40 | mPoiMarks.add(marker); 41 | } 42 | }catch(Throwable e){ 43 | e.printStackTrace(); 44 | } 45 | } 46 | /** 47 | * 去掉PoiOverlay上所有的Marker。 48 | */ 49 | public void removeFromMap() { 50 | for (Marker mark : mPoiMarks) { 51 | mark.remove(); 52 | } 53 | } 54 | /** 55 | * 移动镜头到当前的视角。 56 | */ 57 | public void zoomToSpan() { 58 | try{ 59 | if (mPois != null && mPois.size() > 0) { 60 | if (mAMap == null) 61 | return; 62 | if(mPois.size()==1){ 63 | mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mPois.get(0).getLatLonPoint().getLatitude(), 64 | mPois.get(0).getLatLonPoint().getLongitude()), 18f)); 65 | }else{ 66 | LatLngBounds bounds = getLatLngBounds(); 67 | mAMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30)); 68 | } 69 | } 70 | }catch(Throwable e){ 71 | e.printStackTrace(); 72 | } 73 | } 74 | 75 | private LatLngBounds getLatLngBounds() { 76 | LatLngBounds.Builder b = LatLngBounds.builder(); 77 | for (int i = 0; i < mPois.size(); i++) { 78 | b.include(new LatLng(mPois.get(i).getLatLonPoint().getLatitude(), 79 | mPois.get(i).getLatLonPoint().getLongitude())); 80 | } 81 | return b.build(); 82 | } 83 | 84 | private MarkerOptions getMarkerOptions(int index) { 85 | return new MarkerOptions() 86 | .position( 87 | new LatLng(mPois.get(index).getLatLonPoint() 88 | .getLatitude(), mPois.get(index) 89 | .getLatLonPoint().getLongitude())) 90 | .title(getTitle(index)).snippet(getSnippet(index)) 91 | .icon(getBitmapDescriptor(index)); 92 | } 93 | /** 94 | * 给第几个Marker设置图标,并返回更换图标的图片。如不用默认图片,需要重写此方法。 95 | * @param index 第几个Marker。 96 | * @return 更换的Marker图片。 97 | */ 98 | protected BitmapDescriptor getBitmapDescriptor(int index) { 99 | return null; 100 | } 101 | /** 102 | * 返回第index的Marker的标题。 103 | * @param index 第几个Marker。 104 | * @return marker的标题。 105 | */ 106 | protected String getTitle(int index) { 107 | return mPois.get(index).getTitle(); 108 | } 109 | /** 110 | * 返回第index的Marker的详情。 111 | * @param index 第几个Marker。 112 | * @return marker的详情。 113 | */ 114 | protected String getSnippet(int index) { 115 | return mPois.get(index).getSnippet(); 116 | } 117 | /** 118 | * 从marker中得到poi在list的位置。 119 | * @param marker 一个标记的对象。 120 | * @return 返回该marker对应的poi在list的位置。 121 | * @since V2.1.0 122 | */ 123 | public int getPoiIndex(Marker marker) { 124 | for (int i = 0; i < mPoiMarks.size(); i++) { 125 | if (mPoiMarks.get(i).equals(marker)) { 126 | return i; 127 | } 128 | } 129 | return -1; 130 | } 131 | /** 132 | * 返回第index的poi的信息。 133 | * @param index 第几个poi。 134 | * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 PoiItem。 135 | */ 136 | public PoiItem getPoiItem(int index) { 137 | if (index < 0 || index >= mPois.size()) { 138 | return null; 139 | } 140 | return mPois.get(index); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/util/Constants.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.util; 2 | import com.amap.api.maps.model.LatLng; 3 | 4 | public class Constants { 5 | 6 | public static final String EXTRA_TIP = "ExtraTip"; 7 | public static final String KEY_WORDS_NAME = "KeyWord"; 8 | 9 | public static final LatLng BEIJING = new LatLng(39.90403, 116.407525);// 北京市经纬度 10 | public static final LatLng ZHONGGUANCUN = new LatLng(39.983456, 116.3154950);// 北京市中关村经纬度 11 | public static final LatLng SHANGHAI = new LatLng(31.238068, 121.501654);// 上海市经纬度 12 | public static final LatLng FANGHENG = new LatLng(39.989614, 116.481763);// 方恒国际中心经纬度 13 | public static final LatLng CHENGDU = new LatLng(30.679879, 104.064855);// 成都市经纬度 14 | public static final LatLng XIAN = new LatLng(34.341568, 108.940174);// 西安市经纬度 15 | public static final LatLng ZHENGZHOU = new LatLng(34.7466, 113.625367);// 郑州市经纬度 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/util/ToastUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.zzdayss.yunyou.util; 5 | 6 | import com.amap.api.services.core.AMapException; 7 | 8 | import android.content.Context; 9 | import android.widget.Toast; 10 | 11 | public class ToastUtil { 12 | 13 | public static void show(Context context, String info) { 14 | Toast.makeText(context, info, Toast.LENGTH_LONG).show(); 15 | } 16 | 17 | public static void show(Context context, int info) { 18 | Toast.makeText(context, info, Toast.LENGTH_LONG).show(); 19 | } 20 | 21 | public static void showerror(Context context, int rCode){ 22 | try { 23 | switch (rCode) { 24 | //服务错误码 25 | case 1001: 26 | throw new AMapException(AMapException.AMAP_SIGNATURE_ERROR); 27 | case 1002: 28 | throw new AMapException(AMapException.AMAP_INVALID_USER_KEY); 29 | case 1003: 30 | throw new AMapException(AMapException.AMAP_SERVICE_NOT_AVAILBALE); 31 | case 1004: 32 | throw new AMapException(AMapException.AMAP_DAILY_QUERY_OVER_LIMIT); 33 | case 1005: 34 | throw new AMapException(AMapException.AMAP_ACCESS_TOO_FREQUENT); 35 | case 1006: 36 | throw new AMapException(AMapException.AMAP_INVALID_USER_IP); 37 | case 1007: 38 | throw new AMapException(AMapException.AMAP_INVALID_USER_DOMAIN); 39 | case 1008: 40 | throw new AMapException(AMapException.AMAP_INVALID_USER_SCODE); 41 | case 1009: 42 | throw new AMapException(AMapException.AMAP_USERKEY_PLAT_NOMATCH); 43 | case 1010: 44 | throw new AMapException(AMapException.AMAP_IP_QUERY_OVER_LIMIT); 45 | case 1011: 46 | throw new AMapException(AMapException.AMAP_NOT_SUPPORT_HTTPS); 47 | case 1012: 48 | throw new AMapException(AMapException.AMAP_INSUFFICIENT_PRIVILEGES); 49 | case 1013: 50 | throw new AMapException(AMapException.AMAP_USER_KEY_RECYCLED); 51 | case 1100: 52 | throw new AMapException(AMapException.AMAP_ENGINE_RESPONSE_ERROR); 53 | case 1101: 54 | throw new AMapException(AMapException.AMAP_ENGINE_RESPONSE_DATA_ERROR); 55 | case 1102: 56 | throw new AMapException(AMapException.AMAP_ENGINE_CONNECT_TIMEOUT); 57 | case 1103: 58 | throw new AMapException(AMapException.AMAP_ENGINE_RETURN_TIMEOUT); 59 | case 1200: 60 | throw new AMapException(AMapException.AMAP_SERVICE_INVALID_PARAMS); 61 | case 1201: 62 | throw new AMapException(AMapException.AMAP_SERVICE_MISSING_REQUIRED_PARAMS); 63 | case 1202: 64 | throw new AMapException(AMapException.AMAP_SERVICE_ILLEGAL_REQUEST); 65 | case 1203: 66 | throw new AMapException(AMapException.AMAP_SERVICE_UNKNOWN_ERROR); 67 | //sdk返回错误 68 | case 1800: 69 | throw new AMapException(AMapException.AMAP_CLIENT_ERRORCODE_MISSSING); 70 | case 1801: 71 | throw new AMapException(AMapException.AMAP_CLIENT_ERROR_PROTOCOL); 72 | case 1802: 73 | throw new AMapException(AMapException.AMAP_CLIENT_SOCKET_TIMEOUT_EXCEPTION); 74 | case 1803: 75 | throw new AMapException(AMapException.AMAP_CLIENT_URL_EXCEPTION); 76 | case 1804: 77 | throw new AMapException(AMapException.AMAP_CLIENT_UNKNOWHOST_EXCEPTION); 78 | case 1806: 79 | throw new AMapException(AMapException.AMAP_CLIENT_NETWORK_EXCEPTION); 80 | case 1900: 81 | throw new AMapException(AMapException.AMAP_CLIENT_UNKNOWN_ERROR); 82 | case 1901: 83 | throw new AMapException(AMapException.AMAP_CLIENT_INVALID_PARAMETER); 84 | case 1902: 85 | throw new AMapException(AMapException.AMAP_CLIENT_IO_EXCEPTION); 86 | case 1903: 87 | throw new AMapException(AMapException.AMAP_CLIENT_NULLPOINT_EXCEPTION); 88 | //云图和附近错误码 89 | case 2000: 90 | throw new AMapException(AMapException.AMAP_SERVICE_TABLEID_NOT_EXIST); 91 | case 2001: 92 | throw new AMapException(AMapException.AMAP_ID_NOT_EXIST); 93 | case 2002: 94 | throw new AMapException(AMapException.AMAP_SERVICE_MAINTENANCE); 95 | case 2003: 96 | throw new AMapException(AMapException.AMAP_ENGINE_TABLEID_NOT_EXIST); 97 | case 2100: 98 | throw new AMapException(AMapException.AMAP_NEARBY_INVALID_USERID); 99 | case 2101: 100 | throw new AMapException(AMapException.AMAP_NEARBY_KEY_NOT_BIND); 101 | case 2200: 102 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOADAUTO_STARTED_ERROR); 103 | case 2201: 104 | throw new AMapException(AMapException.AMAP_CLIENT_USERID_ILLEGAL); 105 | case 2202: 106 | throw new AMapException(AMapException.AMAP_CLIENT_NEARBY_NULL_RESULT); 107 | case 2203: 108 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOAD_TOO_FREQUENT); 109 | case 2204: 110 | throw new AMapException(AMapException.AMAP_CLIENT_UPLOAD_LOCATION_ERROR); 111 | //路径规划 112 | case 3000: 113 | throw new AMapException(AMapException.AMAP_ROUTE_OUT_OF_SERVICE); 114 | case 3001: 115 | throw new AMapException(AMapException.AMAP_ROUTE_NO_ROADS_NEARBY); 116 | case 3002: 117 | throw new AMapException(AMapException.AMAP_ROUTE_FAIL); 118 | case 3003: 119 | throw new AMapException(AMapException.AMAP_OVER_DIRECTION_RANGE); 120 | //短传分享 121 | case 4000: 122 | throw new AMapException(AMapException.AMAP_SHARE_LICENSE_IS_EXPIRED); 123 | case 4001: 124 | throw new AMapException(AMapException.AMAP_SHARE_FAILURE); 125 | default: 126 | Toast.makeText(context,"查询失败:"+rCode , Toast.LENGTH_LONG).show(); 127 | break; 128 | } 129 | } catch (Exception e) { 130 | Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/zzdayss/yunyou/utils/JDBCUtils.java: -------------------------------------------------------------------------------- 1 | package com.zzdayss.yunyou.utils; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | 6 | /** 7 | * function: 数据库工具类,连接数据库用 8 | */ 9 | public class JDBCUtils { 10 | private static final String TAG = "mysql-party-JDBCUtils"; 11 | 12 | private static String driver = "com.mysql.jdbc.Driver";// MySql驱动 13 | 14 | private static String dbName = "yunyou";// 数据库名称 15 | 16 | private static String user = "yunyou";// 用户名 17 | 18 | private static String password = "123456";// 密码 19 | 20 | public static Connection getConn(){ 21 | 22 | 23 | Connection connection = null; 24 | try{ 25 | Class.forName(driver);// 动态加载类 26 | String ip = "192.168.1.10";// 写成本机地址,不能写成localhost,同时手机和电脑连接的网络必须是同一个 27 | 28 | // 尝试建立到给定数据库URL的连接 29 | connection = DriverManager.getConnection("jdbc:mysql://" + ip + ":3306/" + dbName, 30 | user, password); 31 | }catch (Exception e){ 32 | e.printStackTrace(); 33 | } 34 | return connection; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/res/color/colortheme.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/back.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_bg_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cancel.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_face.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_feedback.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_food.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_hotel.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_local.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logout.xml: -------------------------------------------------------------------------------- 1 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_map.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_my.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_place.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_tour.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_travel.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_favorite_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/my_location.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shapelogin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shapemain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shapemsg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_feedback.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 26 | 27 | 36 | 37 | 42 | 43 | 48 | 49 | 58 | 59 | 60 | 61 | 62 |