├── .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 |
5 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
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 | 
9 | 
10 | 
11 | 
12 | 
13 | 
14 | 
15 | 
16 | 
17 | 
18 | 
19 | 
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