Commit b9c422a7c5ae8c4fab482c7d76a492499d41e67a
0 parents
Exists in
master
提交
Showing
267 changed files
with
17026 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 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
File was created | 1 | # Default ignored files | |
2 | /shelf/ | ||
3 | /workspace.xml | ||
4 |
.idea/compiler.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <project version="4"> | ||
3 | <component name="CompilerConfiguration"> | ||
4 | <bytecodeTargetLevel target="11" /> | ||
5 | </component> | ||
6 | </project> |
.idea/gradle.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <project version="4"> | ||
3 | <component name="GradleMigrationSettings" migrationVersion="1" /> | ||
4 | <component name="GradleSettings"> | ||
5 | <option name="linkedExternalProjectsSettings"> | ||
6 | <GradleProjectSettings> | ||
7 | <option name="testRunner" value="GRADLE" /> | ||
8 | <option name="distributionType" value="DEFAULT_WRAPPED" /> | ||
9 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
10 | <option name="gradleHome" value="$USER_HOME$/.gradle/wrapper/dists/gradle-8.0-bin/ca5e32bp14vu59qr306oxotwh/gradle-8.0" /> | ||
11 | <option name="gradleJvm" value="1.8" /> | ||
12 | <option name="modules"> | ||
13 | <set> | ||
14 | <option value="$PROJECT_DIR$" /> | ||
15 | <option value="$PROJECT_DIR$/app" /> | ||
16 | <option value="$PROJECT_DIR$/libs" /> | ||
17 | <option value="$PROJECT_DIR$/libs/common" /> | ||
18 | </set> | ||
19 | </option> | ||
20 | </GradleProjectSettings> | ||
21 | </option> | ||
22 | </component> | ||
23 | </project> |
.idea/jarRepositories.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <project version="4"> | ||
3 | <component name="RemoteRepositoriesConfiguration"> | ||
4 | <remote-repository> | ||
5 | <option name="id" value="central" /> | ||
6 | <option name="name" value="Maven Central repository" /> | ||
7 | <option name="url" value="https://repo1.maven.org/maven2" /> | ||
8 | </remote-repository> | ||
9 | <remote-repository> | ||
10 | <option name="id" value="jboss.community" /> | ||
11 | <option name="name" value="JBoss Community repository" /> | ||
12 | <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> | ||
13 | </remote-repository> | ||
14 | <remote-repository> | ||
15 | <option name="id" value="maven" /> | ||
16 | <option name="name" value="maven" /> | ||
17 | <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/google" /> | ||
18 | </remote-repository> | ||
19 | <remote-repository> | ||
20 | <option name="id" value="BintrayJCenter" /> | ||
21 | <option name="name" value="BintrayJCenter" /> | ||
22 | <option name="url" value="https://jcenter.bintray.com/" /> | ||
23 | </remote-repository> | ||
24 | <remote-repository> | ||
25 | <option name="id" value="maven4" /> | ||
26 | <option name="name" value="maven4" /> | ||
27 | <option name="url" value="https://jitpack.io" /> | ||
28 | </remote-repository> | ||
29 | <remote-repository> | ||
30 | <option name="id" value="Google" /> | ||
31 | <option name="name" value="Google" /> | ||
32 | <option name="url" value="https://dl.google.com/dl/android/maven2/" /> | ||
33 | </remote-repository> | ||
34 | <remote-repository> | ||
35 | <option name="id" value="maven2" /> | ||
36 | <option name="name" value="maven2" /> | ||
37 | <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/jcenter" /> | ||
38 | </remote-repository> | ||
39 | <remote-repository> | ||
40 | <option name="id" value="maven3" /> | ||
41 | <option name="name" value="maven3" /> | ||
42 | <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" /> | ||
43 | </remote-repository> | ||
44 | </component> | ||
45 | </project> |
.idea/misc.xml
File was created | 1 | <project version="4"> | |
2 | <component name="DesignSurface"> | ||
3 | <option name="filePathToZoomLevelMap"> | ||
4 | <map> | ||
5 | <entry key="app/src/main/res/drawable/bg_solid_btn.xml" value="0.29907407407407405" /> | ||
6 | <entry key="app/src/main/res/drawable/bg_solid_btn_grad.xml" value="0.29907407407407405" /> | ||
7 | <entry key="app/src/main/res/drawable/bg_solid_white.xml" value="0.21851851851851853" /> | ||
8 | <entry key="app/src/main/res/drawable/bg_solid_white_10.xml" value="0.29907407407407405" /> | ||
9 | <entry key="app/src/main/res/drawable/bg_solid_white_10_bottom.xml" value="0.2388888888888889" /> | ||
10 | <entry key="app/src/main/res/drawable/bg_solid_white_10_or.xml" value="0.24814814814814815" /> | ||
11 | <entry key="app/src/main/res/drawable/bg_solid_white_10_top.xml" value="0.2388888888888889" /> | ||
12 | <entry key="app/src/main/res/drawable/bg_solid_white_20.xml" value="0.25555555555555554" /> | ||
13 | <entry key="app/src/main/res/drawable/checked_xc.xml" value="0.29907407407407405" /> | ||
14 | <entry key="app/src/main/res/drawable/select_b_1.xml" value="0.25555555555555554" /> | ||
15 | <entry key="app/src/main/res/drawable/select_b_2.xml" value="0.25555555555555554" /> | ||
16 | <entry key="app/src/main/res/drawable/select_t_1.xml" value="0.25555555555555554" /> | ||
17 | <entry key="app/src/main/res/drawable/welcome_bg.xml" value="0.38958333333333334" /> | ||
18 | <entry key="app/src/main/res/layout/activity_add_stu.xml" value="0.3734375" /> | ||
19 | <entry key="app/src/main/res/layout/activity_changem.xml" value="0.3734375" /> | ||
20 | <entry key="app/src/main/res/layout/activity_login.xml" value="0.20064724919093851" /> | ||
21 | <entry key="app/src/main/res/layout/activity_main.xml" value="0.359375" /> | ||
22 | <entry key="app/src/main/res/layout/activity_me.xml" value="0.3734375" /> | ||
23 | <entry key="app/src/main/res/layout/activity_qr.xml" value="0.1" /> | ||
24 | <entry key="app/src/main/res/layout/activity_register.xml" value="0.3734375" /> | ||
25 | <entry key="app/src/main/res/layout/activity_sao.xml" value="0.3734375" /> | ||
26 | <entry key="app/src/main/res/layout/activity_select_stu.xml" value="0.3734375" /> | ||
27 | <entry key="app/src/main/res/layout/activity_set_jia.xml" value="0.3734375" /> | ||
28 | <entry key="app/src/main/res/layout/activity_set_nian.xml" value="0.31952662721893493" /> | ||
29 | <entry key="app/src/main/res/layout/activity_set_nick.xml" value="0.3734375" /> | ||
30 | <entry key="app/src/main/res/layout/activity_set_sex.xml" value="0.2781065088757396" /> | ||
31 | <entry key="app/src/main/res/layout/activity_setac.xml" value="0.3734375" /> | ||
32 | <entry key="app/src/main/res/layout/activity_yin.xml" value="0.3734375" /> | ||
33 | <entry key="app/src/main/res/layout/fragment_home.xml" value="0.1" /> | ||
34 | <entry key="app/src/main/res/layout/fragment_me.xml" value="0.13197430135483507" /> | ||
35 | <entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.3814814814814815" /> | ||
36 | <entry key="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.3814814814814815" /> | ||
37 | <entry key="libs/common/src/main/res/drawable/bg_solid_white.xml" value="0.21851851851851853" /> | ||
38 | <entry key="libs/common/src/main/res/drawable/default_label_bg.xml" value="0.21851851851851853" /> | ||
39 | <entry key="libs/common/src/main/res/drawable/select_map_position_type.xml" value="0.21851851851851853" /> | ||
40 | <entry key="libs/common/src/main/res/drawable/shape_dialog_bg.xml" value="0.21851851851851853" /> | ||
41 | <entry key="libs/common/src/main/res/layout/dialog_auxiliary_point.xml" value="0.2791666666666667" /> | ||
42 | </map> | ||
43 | </option> | ||
44 | </component> | ||
45 | <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK"> | ||
46 | <output url="file://$PROJECT_DIR$/build/classes" /> | ||
47 | </component> | ||
48 | <component name="ProjectType"> | ||
49 | <option name="id" value="Android" /> | ||
50 | </component> | ||
51 | </project> |
.idea/vcs.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <project version="4"> | ||
3 | <component name="VcsDirectoryMappings"> | ||
4 | <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||
5 | </component> | ||
6 | </project> |
README
app/.gitignore
File was created | 1 | /build |
app/build.gradle
File was created | 1 | apply plugin: 'com.android.application' | |
2 | apply from: '../config.gradle' | ||
3 | |||
4 | |||
5 | def androidId = rootProject.ext.androidId | ||
6 | def support = rootProject.ext.dependencies | ||
7 | def url = rootProject.ext.url | ||
8 | |||
9 | |||
10 | android { | ||
11 | compileSdk 32 | ||
12 | |||
13 | defaultConfig { | ||
14 | applicationId "com.hjx.parent" | ||
15 | minSdk 24 | ||
16 | targetSdk 32 | ||
17 | versionCode 1 | ||
18 | versionName "1.0" | ||
19 | |||
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
21 | } | ||
22 | |||
23 | buildTypes { | ||
24 | release { | ||
25 | minifyEnabled false | ||
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
27 | } | ||
28 | } | ||
29 | compileOptions { | ||
30 | sourceCompatibility JavaVersion.VERSION_1_8 | ||
31 | targetCompatibility JavaVersion.VERSION_1_8 | ||
32 | } | ||
33 | } | ||
34 | |||
35 | dependencies { | ||
36 | support.each { k, v -> implementation v } | ||
37 | api project(path: ':libs:common') | ||
38 | implementation 'androidx.appcompat:appcompat:1.5.1' | ||
39 | implementation 'com.google.android.material:material:1.6.1' | ||
40 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
41 | |||
42 | } |
app/proguard-rules.pro
File was created | 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/main/AndroidManifest.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | package="com.hjx.parent"> | ||
4 | |||
5 | |||
6 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | ||
7 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> | ||
8 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> | ||
9 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> | ||
10 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | ||
11 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
12 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
13 | <uses-permission android:name="android.permission.INTERNET" /> | ||
14 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
15 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
16 | |||
17 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | ||
18 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
19 | <uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
20 | <uses-permission android:name="android.permission.CAMERA" /> | ||
21 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
22 | <uses-permission android:name="android.permission.VIBRATE" /> | ||
23 | |||
24 | <application | ||
25 | android:allowBackup="true" | ||
26 | android:icon="@mipmap/icon" | ||
27 | android:label="@string/app_name" | ||
28 | android:supportsRtl="true" | ||
29 | android:theme="@style/Theme.Parent" | ||
30 | android:name=".MyApplication" | ||
31 | > | ||
32 | <activity | ||
33 | android:name=".LoginActivity" | ||
34 | android:theme="@style/ThemeSplash" | ||
35 | android:exported="true"> | ||
36 | <intent-filter> | ||
37 | <action android:name="android.intent.action.MAIN" /> | ||
38 | <category android:name="android.intent.category.LAUNCHER" /> | ||
39 | </intent-filter> | ||
40 | </activity> | ||
41 | <activity android:name=".MainActivity" | ||
42 | android:theme="@style/Theme.AppCompat.NoActionBar" | ||
43 | /> | ||
44 | <activity android:name=".RegisterActivity" | ||
45 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
46 | <activity android:name=".UserActivity" | ||
47 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
48 | <activity android:name=".YinsiActivity" | ||
49 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
50 | <activity android:name=".QRActivity" | ||
51 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
52 | <activity android:name=".AddStudentActivity" | ||
53 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
54 | <activity android:name=".NickActivity" | ||
55 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
56 | <activity android:name=".SexActivity" | ||
57 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
58 | <activity android:name=".NianActivity" | ||
59 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
60 | <activity android:name=".ShenActivity" | ||
61 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
62 | <activity android:name=".AccountActivity" | ||
63 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
64 | |||
65 | <activity android:name=".ChangePwdActivity" | ||
66 | android:theme="@style/Theme.AppCompat.NoActionBar"/> | ||
67 | |||
68 | |||
69 | </application> | ||
70 | |||
71 | </manifest> |
app/src/main/java/com/hjx/parent/AccountActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.widget.TextView; | ||
4 | |||
5 | import com.prws.common.base.BaseActivity; | ||
6 | import com.prws.common.base.BasePresenter; | ||
7 | import com.prws.common.utils.SharedPreferencesUtil; | ||
8 | |||
9 | public class AccountActivity extends BaseActivity { | ||
10 | |||
11 | @Override | ||
12 | protected int layoutResId() { | ||
13 | return R.layout.activity_setac; | ||
14 | } | ||
15 | |||
16 | @Override | ||
17 | public Object getContract() { | ||
18 | return null; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public BasePresenter getPresenter() { | ||
23 | return null; | ||
24 | } | ||
25 | |||
26 | |||
27 | TextView tv_6; | ||
28 | @Override | ||
29 | protected void initView() { | ||
30 | tv_6 = findViewById(R.id.tv_6); | ||
31 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); | ||
32 | if (phone != null && phone.length() > 0) | ||
33 | tv_6.setText(phone); | ||
34 | } | ||
35 | |||
36 | @Override | ||
37 | protected void initListener() { | ||
38 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); | ||
39 | |||
40 | findViewById(R.id.tv_7).setOnClickListener(view -> startActivity(ChangePwdActivity.class)); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | protected void initData() { | ||
45 | |||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public void onNetChanged(int netWorkState) { | ||
50 | |||
51 | } | ||
52 | } |
app/src/main/java/com/hjx/parent/AddStudentActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.graphics.Color; | ||
4 | import android.view.View; | ||
5 | import android.widget.Button; | ||
6 | import android.widget.TextView; | ||
7 | import android.widget.Toast; | ||
8 | |||
9 | import com.prws.common.base.BaseActivity; | ||
10 | import com.prws.common.base.BasePresenter; | ||
11 | import com.prws.common.net.NetWorks; | ||
12 | import com.prws.common.utils.LogUtil; | ||
13 | import com.prws.common.utils.SharedPreferencesUtil; | ||
14 | |||
15 | import org.json.JSONObject; | ||
16 | |||
17 | import java.util.HashMap; | ||
18 | import java.util.Map; | ||
19 | |||
20 | import io.reactivex.Observer; | ||
21 | import io.reactivex.disposables.Disposable; | ||
22 | import okhttp3.ResponseBody; | ||
23 | |||
24 | public class AddStudentActivity extends BaseActivity { | ||
25 | @Override | ||
26 | protected int layoutResId() { | ||
27 | return R.layout.activity_add_stu; | ||
28 | } | ||
29 | |||
30 | @Override | ||
31 | public Object getContract() { | ||
32 | return null; | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public BasePresenter getPresenter() { | ||
37 | return null; | ||
38 | } | ||
39 | |||
40 | View view_2; | ||
41 | View view_3; | ||
42 | View view_4; | ||
43 | View view_5; | ||
44 | Button btn_next; | ||
45 | TextView tv_name, tv_sex, tv_nian, tv_shen; | ||
46 | |||
47 | @Override | ||
48 | protected void initView() { | ||
49 | view_2 = findViewById(R.id.view_2); | ||
50 | view_3 = findViewById(R.id.view_3); | ||
51 | view_4 = findViewById(R.id.view_4); | ||
52 | view_5 = findViewById(R.id.view_5); | ||
53 | tv_name = findViewById(R.id.tv_name); | ||
54 | tv_sex = findViewById(R.id.tv_sex); | ||
55 | tv_nian = findViewById(R.id.tv_nian); | ||
56 | tv_shen = findViewById(R.id.tv_shen); | ||
57 | |||
58 | |||
59 | btn_next = findViewById(R.id.btn_next); | ||
60 | } | ||
61 | |||
62 | boolean isName = false; | ||
63 | boolean isSex = false; | ||
64 | boolean isNian = false; | ||
65 | boolean isShen = false; | ||
66 | |||
67 | @Override | ||
68 | protected void onStart() { | ||
69 | super.onStart(); | ||
70 | String name = (String) SharedPreferencesUtil.getData("setName", ""); | ||
71 | String sex = (String) SharedPreferencesUtil.getData("setSex", ""); | ||
72 | String nian = (String) SharedPreferencesUtil.getData("setNian", ""); | ||
73 | String shen = (String) SharedPreferencesUtil.getData("setShen", ""); | ||
74 | |||
75 | if (name != null && name.length() > 0) { | ||
76 | tv_name.setText(name); | ||
77 | isName = true; | ||
78 | } else { | ||
79 | isName = false; | ||
80 | } | ||
81 | if (sex != null && sex.length() > 0) { | ||
82 | tv_sex.setText(sex); | ||
83 | isSex = true; | ||
84 | } else { | ||
85 | isSex = false; | ||
86 | } | ||
87 | if (nian != null && nian.length() > 0) { | ||
88 | tv_nian.setText(nian); | ||
89 | isNian = true; | ||
90 | } else { | ||
91 | isNian = false; | ||
92 | } | ||
93 | if (shen != null && shen.length() > 0) { | ||
94 | tv_shen.setText(shen); | ||
95 | isShen = true; | ||
96 | } else { | ||
97 | isShen = false; | ||
98 | } | ||
99 | |||
100 | if (isName && isSex && isNian && isShen) { | ||
101 | btn_next.setTextColor(Color.WHITE); | ||
102 | btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); | ||
103 | } | ||
104 | |||
105 | } | ||
106 | |||
107 | @Override | ||
108 | protected void initListener() { | ||
109 | view_2.setOnClickListener(view -> startActivity(NickActivity.class)); | ||
110 | view_3.setOnClickListener(view -> startActivity(SexActivity.class)); | ||
111 | view_4.setOnClickListener(view -> startActivity(NianActivity.class)); | ||
112 | view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); | ||
113 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | ||
114 | btn_next.setOnClickListener(view -> { | ||
115 | if (isName && isSex && isNian && isShen) { | ||
116 | addStudent(); | ||
117 | } else { | ||
118 | Toast.makeText(this, "请完成设置后点击", Toast.LENGTH_SHORT).show(); | ||
119 | } | ||
120 | }); | ||
121 | } | ||
122 | |||
123 | @Override | ||
124 | protected void onDestroy() { | ||
125 | super.onDestroy(); | ||
126 | SharedPreferencesUtil.putData("setName", ""); | ||
127 | SharedPreferencesUtil.putData("setSex", ""); | ||
128 | SharedPreferencesUtil.putData("setNian", ""); | ||
129 | SharedPreferencesUtil.putData("setShen", ""); | ||
130 | SharedPreferencesUtil.putData("setXueq", ""); | ||
131 | |||
132 | } | ||
133 | public void addStudent() { | ||
134 | String name = (String) SharedPreferencesUtil.getData("setName", ""); | ||
135 | String sex = (String) SharedPreferencesUtil.getData("setSex", ""); | ||
136 | String nian = (String) SharedPreferencesUtil.getData("setNian", ""); | ||
137 | String shen = (String) SharedPreferencesUtil.getData("setShen", ""); | ||
138 | String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); | ||
139 | |||
140 | |||
141 | Map map = new HashMap(); | ||
142 | map.put("nickName", name); | ||
143 | map.put("gender", "1"); | ||
144 | map.put("gradeId", 1); | ||
145 | map.put("parentIdentity", shen); | ||
146 | map.put("term", xueq); | ||
147 | |||
148 | |||
149 | NetWorks.registerStudent(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | ||
150 | @Override | ||
151 | public void onSubscribe(Disposable d) { | ||
152 | |||
153 | } | ||
154 | |||
155 | @Override | ||
156 | public void onNext(ResponseBody responseBody) { | ||
157 | try { | ||
158 | |||
159 | String str = responseBody.string().toString(); | ||
160 | LogUtil.e(TAG, "----" + str); | ||
161 | JSONObject jo = new JSONObject(str); | ||
162 | boolean isSucceed = jo.getBoolean("success"); | ||
163 | if (isSucceed) { | ||
164 | finish(); | ||
165 | } else { | ||
166 | Toast.makeText(AddStudentActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | ||
167 | } | ||
168 | } catch (Exception e) { | ||
169 | e.printStackTrace(); | ||
170 | Toast.makeText(AddStudentActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); | ||
171 | } | ||
172 | |||
173 | } | ||
174 | |||
175 | @Override | ||
176 | public void onError(Throwable e) { | ||
177 | |||
178 | } | ||
179 | |||
180 | @Override | ||
181 | public void onComplete() { | ||
182 | |||
183 | } | ||
184 | |||
185 | }); | ||
186 | } | ||
187 | |||
188 | @Override | ||
189 | protected void initData() { | ||
190 | |||
191 | } | ||
192 | |||
193 | @Override | ||
194 | public void onNetChanged(int netWorkState) { | ||
195 | |||
196 | } | ||
197 | } | ||
198 |
app/src/main/java/com/hjx/parent/ChangePwdActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.widget.EditText; | ||
4 | import android.widget.TextView; | ||
5 | import android.widget.Toast; | ||
6 | |||
7 | import com.prws.common.base.BaseActivity; | ||
8 | import com.prws.common.base.BasePresenter; | ||
9 | import com.prws.common.net.NetWorks; | ||
10 | import com.prws.common.utils.LogUtil; | ||
11 | import com.prws.common.utils.SharedPreferencesUtil; | ||
12 | |||
13 | import org.json.JSONObject; | ||
14 | |||
15 | import java.util.HashMap; | ||
16 | import java.util.Map; | ||
17 | |||
18 | import io.reactivex.Observer; | ||
19 | import io.reactivex.disposables.Disposable; | ||
20 | import okhttp3.ResponseBody; | ||
21 | |||
22 | public class ChangePwdActivity extends BaseActivity { | ||
23 | |||
24 | @Override | ||
25 | protected int layoutResId() { | ||
26 | return R.layout.activity_changem; | ||
27 | } | ||
28 | |||
29 | @Override | ||
30 | public Object getContract() { | ||
31 | return null; | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | public BasePresenter getPresenter() { | ||
36 | return null; | ||
37 | } | ||
38 | |||
39 | |||
40 | |||
41 | EditText et_pwd; | ||
42 | @Override | ||
43 | protected void initView() { | ||
44 | |||
45 | |||
46 | et_pwd = findViewById(R.id.et_pwd); | ||
47 | } | ||
48 | |||
49 | @Override | ||
50 | protected void initListener() { | ||
51 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); | ||
52 | |||
53 | findViewById(R.id.btn_next).setOnClickListener(view -> { | ||
54 | String pwd = et_pwd.getText().toString().trim(); | ||
55 | if (pwd == null || pwd.length() == 0){ | ||
56 | Toast.makeText(this,"密码不能为空",Toast.LENGTH_SHORT).show(); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | changePwd(pwd); | ||
61 | |||
62 | }); | ||
63 | |||
64 | } | ||
65 | |||
66 | public void changePwd(String pwd){ | ||
67 | String userId = (String) SharedPreferencesUtil.getData("userId", ""); | ||
68 | Map map = new HashMap(); | ||
69 | map.put("userId",userId); | ||
70 | map.put("password",pwd); | ||
71 | |||
72 | |||
73 | NetWorks.changePassword(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | ||
74 | @Override | ||
75 | public void onSubscribe(Disposable d) { | ||
76 | |||
77 | } | ||
78 | |||
79 | @Override | ||
80 | public void onNext(ResponseBody responseBody) { | ||
81 | try { | ||
82 | |||
83 | String str = responseBody.string().toString(); | ||
84 | |||
85 | |||
86 | LogUtil.e(TAG,"----"+str); | ||
87 | JSONObject jo = new JSONObject(str); | ||
88 | boolean isSucceed = jo.getBoolean("success"); | ||
89 | if (isSucceed){ | ||
90 | Toast.makeText(ChangePwdActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); | ||
91 | finish(); | ||
92 | |||
93 | }else { | ||
94 | Toast.makeText(ChangePwdActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | ||
95 | } | ||
96 | }catch (Exception e){ | ||
97 | e.printStackTrace(); | ||
98 | Toast.makeText(ChangePwdActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); | ||
99 | } | ||
100 | |||
101 | } | ||
102 | |||
103 | @Override | ||
104 | public void onError(Throwable e) { | ||
105 | |||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public void onComplete() { | ||
110 | |||
111 | } | ||
112 | }); | ||
113 | |||
114 | } | ||
115 | |||
116 | @Override | ||
117 | protected void initData() { | ||
118 | |||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public void onNetChanged(int netWorkState) { | ||
123 | |||
124 | } | ||
125 | } |
app/src/main/java/com/hjx/parent/LoginActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.os.Bundle; | ||
4 | import android.telephony.PhoneNumberUtils; | ||
5 | import android.text.InputType; | ||
6 | import android.widget.Button; | ||
7 | import android.widget.CheckBox; | ||
8 | import android.widget.EditText; | ||
9 | import android.widget.ImageView; | ||
10 | import android.widget.TextView; | ||
11 | import android.widget.Toast; | ||
12 | |||
13 | import androidx.appcompat.app.AppCompatActivity; | ||
14 | |||
15 | import com.prws.common.base.BaseActivity; | ||
16 | import com.prws.common.base.BasePresenter; | ||
17 | import com.prws.common.bean.BaseEntity; | ||
18 | import com.prws.common.net.NetWorks; | ||
19 | import com.prws.common.utils.LogUtil; | ||
20 | import com.prws.common.utils.SharedPreferencesUtil; | ||
21 | import com.prws.common.utils.acmanager.ActivityManager; | ||
22 | |||
23 | import org.json.JSONObject; | ||
24 | |||
25 | import java.io.IOException; | ||
26 | import java.util.HashMap; | ||
27 | import java.util.Map; | ||
28 | |||
29 | import io.reactivex.Observer; | ||
30 | import io.reactivex.disposables.Disposable; | ||
31 | import okhttp3.ResponseBody; | ||
32 | |||
33 | |||
34 | public class LoginActivity extends BaseActivity { | ||
35 | |||
36 | |||
37 | EditText et_phone; | ||
38 | EditText et_pwd; | ||
39 | ImageView iv_show; | ||
40 | ImageView iv_delete; | ||
41 | Button btn_login; | ||
42 | TextView tv_reg; | ||
43 | CheckBox cb_1; | ||
44 | TextView tv_user; | ||
45 | TextView tv_ys; | ||
46 | |||
47 | |||
48 | |||
49 | @Override | ||
50 | protected int layoutResId() { | ||
51 | return R.layout.activity_login; | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | public Object getContract() { | ||
56 | return null; | ||
57 | } | ||
58 | |||
59 | @Override | ||
60 | public BasePresenter getPresenter() { | ||
61 | return null; | ||
62 | } | ||
63 | |||
64 | |||
65 | @Override | ||
66 | protected void initView() { | ||
67 | et_phone = findViewById(R.id.et_phone); | ||
68 | et_pwd = findViewById(R.id.et_pwd); | ||
69 | iv_show = findViewById(R.id.iv_4); | ||
70 | iv_delete = findViewById(R.id.iv_2); | ||
71 | btn_login = findViewById(R.id.btn_1); | ||
72 | tv_reg = findViewById(R.id.tv_2); | ||
73 | cb_1 = findViewById(R.id.cb_1); | ||
74 | tv_user = findViewById(R.id.tv_4); | ||
75 | tv_ys = findViewById(R.id.tv_6); | ||
76 | |||
77 | |||
78 | String role = (String) SharedPreferencesUtil.getData("role",""); | ||
79 | |||
80 | if (role != null && role.length()> 0){ | ||
81 | LogUtil.e(TAG,"role 不是空----"); | ||
82 | startActivity(MainActivity.class); | ||
83 | finish(); | ||
84 | return; | ||
85 | }else { | ||
86 | LogUtil.e(TAG,"role 是空----"); | ||
87 | } | ||
88 | |||
89 | |||
90 | |||
91 | |||
92 | } | ||
93 | |||
94 | @Override | ||
95 | protected void initListener() { | ||
96 | iv_delete.setOnClickListener(view -> { | ||
97 | et_phone.setText(""); | ||
98 | }); | ||
99 | iv_show.setOnClickListener(view -> { | ||
100 | |||
101 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())){ | ||
102 | iv_show.setBackgroundResource(R.mipmap.yc); | ||
103 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | ||
104 | }else { | ||
105 | iv_show.setBackgroundResource(R.mipmap.xs); | ||
106 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | ||
107 | } | ||
108 | |||
109 | |||
110 | }); | ||
111 | |||
112 | |||
113 | btn_login.setOnClickListener(view -> { | ||
114 | |||
115 | String phone = et_phone.getText().toString().trim(); | ||
116 | String pwd = et_pwd.getText().toString().trim(); | ||
117 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0){ | ||
118 | Toast.makeText(this,"手机号以及密码不能为空",Toast.LENGTH_SHORT).show(); | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())){ | ||
123 | Toast.makeText(this,"请输入正确的手机号码",Toast.LENGTH_SHORT).show(); | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | if (!cb_1.isChecked()){ | ||
128 | Toast.makeText(this,"请勾选协议",Toast.LENGTH_SHORT).show(); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | login(phone,pwd); | ||
133 | |||
134 | }); | ||
135 | |||
136 | tv_reg.setOnClickListener(view -> { | ||
137 | startActivity(RegisterActivity.class); | ||
138 | finish(); | ||
139 | }); | ||
140 | |||
141 | tv_ys.setOnClickListener(view -> { | ||
142 | startActivity(YinsiActivity.class); | ||
143 | }); | ||
144 | tv_user.setOnClickListener(view -> { | ||
145 | startActivity(UserActivity.class); | ||
146 | }); | ||
147 | } | ||
148 | |||
149 | public void login(final String phone ,String pwd){ | ||
150 | |||
151 | Map map = new HashMap(); | ||
152 | map.put("username",phone); | ||
153 | map.put("password",pwd); | ||
154 | |||
155 | |||
156 | NetWorks.login(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | ||
157 | @Override | ||
158 | public void onSubscribe(Disposable d) { | ||
159 | |||
160 | } | ||
161 | |||
162 | @Override | ||
163 | public void onNext(ResponseBody responseBody) { | ||
164 | try { | ||
165 | |||
166 | String str = responseBody.string().toString(); | ||
167 | |||
168 | |||
169 | LogUtil.e(TAG,"----"+str); | ||
170 | JSONObject jo = new JSONObject(str); | ||
171 | boolean isSucceed = jo.getBoolean("success"); | ||
172 | if (isSucceed){ | ||
173 | JSONObject jo2 = jo.getJSONObject("data"); | ||
174 | SharedPreferencesUtil.putData("phone",phone); | ||
175 | SharedPreferencesUtil.putData("role",jo2.getString("role")); | ||
176 | SharedPreferencesUtil.putData("userId",jo2.getString("userId")); | ||
177 | SharedPreferencesUtil.putData("token",jo2.getString("token")); | ||
178 | |||
179 | startActivity(MainActivity.class); | ||
180 | |||
181 | }else { | ||
182 | Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | ||
183 | } | ||
184 | }catch (Exception e){ | ||
185 | e.printStackTrace(); | ||
186 | Toast.makeText(LoginActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); | ||
187 | } | ||
188 | |||
189 | } | ||
190 | |||
191 | @Override | ||
192 | public void onError(Throwable e) { | ||
193 | |||
194 | } | ||
195 | |||
196 | @Override | ||
197 | public void onComplete() { | ||
198 | |||
199 | } | ||
200 | }); | ||
201 | } | ||
202 | |||
203 | |||
204 | @Override | ||
205 | protected void initData() { | ||
206 | |||
207 | } | ||
208 | |||
209 | @Override | ||
210 | public void onNetChanged(int netWorkState) { | ||
211 | |||
212 | } | ||
213 | } |
app/src/main/java/com/hjx/parent/MainActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import androidx.appcompat.app.AppCompatActivity; | ||
4 | import androidx.constraintlayout.widget.ConstraintLayout; | ||
5 | |||
6 | import android.graphics.Color; | ||
7 | import android.os.Bundle; | ||
8 | import android.widget.ImageView; | ||
9 | import android.widget.TextView; | ||
10 | |||
11 | import com.hjx.parent.fragment.HomeFragment; | ||
12 | import com.hjx.parent.fragment.MeFragment; | ||
13 | import com.prws.common.base.BaseActivity; | ||
14 | import com.prws.common.base.BasePresenter; | ||
15 | |||
16 | public class MainActivity extends BaseActivity { | ||
17 | |||
18 | @Override | ||
19 | protected int layoutResId() { | ||
20 | return R.layout.activity_main; | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public Object getContract() { | ||
25 | return null; | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public BasePresenter getPresenter() { | ||
30 | return null; | ||
31 | } | ||
32 | |||
33 | |||
34 | |||
35 | |||
36 | HomeFragment homeFragment; | ||
37 | MeFragment meFragment; | ||
38 | ConstraintLayout cl_home; | ||
39 | ConstraintLayout cl_me; | ||
40 | ImageView iv_3,iv_4; | ||
41 | TextView tv_1,tv_4; | ||
42 | |||
43 | @Override | ||
44 | protected void initView() { | ||
45 | showFragment(getHomeFragment(),R.id.rl_content); | ||
46 | cl_home = findViewById(R.id.cl_home); | ||
47 | cl_me = findViewById(R.id.cl_me); | ||
48 | iv_3 = findViewById(R.id.iv_3); | ||
49 | iv_4 = findViewById(R.id.iv_4); | ||
50 | tv_1 = findViewById(R.id.tv_1); | ||
51 | tv_4 = findViewById(R.id.tv_4); | ||
52 | |||
53 | |||
54 | iv_3.setBackgroundResource(R.mipmap.hoss); | ||
55 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | ||
56 | |||
57 | |||
58 | |||
59 | } | ||
60 | |||
61 | public HomeFragment getHomeFragment(){ | ||
62 | if (homeFragment == null) | ||
63 | homeFragment = new HomeFragment(); | ||
64 | return homeFragment; | ||
65 | } | ||
66 | |||
67 | public MeFragment getMeFragment(){ | ||
68 | if (meFragment == null) | ||
69 | meFragment = new MeFragment(); | ||
70 | return meFragment; | ||
71 | } | ||
72 | |||
73 | |||
74 | |||
75 | @Override | ||
76 | protected void initListener() { | ||
77 | cl_home.setOnClickListener(view -> { | ||
78 | showFragment(getHomeFragment(),R.id.rl_content); | ||
79 | iv_3.setBackgroundResource(R.mipmap.hoss); | ||
80 | tv_1.setTextColor(Color.parseColor("#FE5E09")); | ||
81 | |||
82 | |||
83 | iv_4.setBackgroundResource(R.mipmap.wmus); | ||
84 | tv_4.setTextColor(Color.parseColor("#333333")); | ||
85 | |||
86 | |||
87 | }); | ||
88 | |||
89 | cl_me.setOnClickListener(view -> { | ||
90 | showFragment(getMeFragment(),R.id.rl_content); | ||
91 | |||
92 | iv_3.setBackgroundResource(R.mipmap.hous); | ||
93 | tv_1.setTextColor(Color.parseColor("#333333")); | ||
94 | |||
95 | |||
96 | iv_4.setBackgroundResource(R.mipmap.wmss); | ||
97 | tv_4.setTextColor(Color.parseColor("#FE5E09")); | ||
98 | |||
99 | |||
100 | }); | ||
101 | } | ||
102 | |||
103 | @Override | ||
104 | protected void initData() { | ||
105 | |||
106 | } | ||
107 | |||
108 | @Override | ||
109 | public void onNetChanged(int netWorkState) { | ||
110 | |||
111 | } | ||
112 | } |
app/src/main/java/com/hjx/parent/MyApplication.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import com.prws.common.CommonApplication; | ||
4 | import com.prws.common.utils.SharedPreferencesUtil; | ||
5 | import com.uuzuche.lib_zxing.activity.ZXingLibrary; | ||
6 | |||
7 | public class MyApplication extends CommonApplication { | ||
8 | |||
9 | @Override | ||
10 | public void onCreate() { | ||
11 | super.onCreate(); | ||
12 | |||
13 | SharedPreferencesUtil.getInstance(this,"config"); | ||
14 | |||
15 | ZXingLibrary.initDisplayOpinion(this); | ||
16 | |||
17 | } | ||
18 | } | ||
19 |
app/src/main/java/com/hjx/parent/NianActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.widget.TextView; | ||
4 | |||
5 | import com.prws.common.base.BaseActivity; | ||
6 | import com.prws.common.base.BasePresenter; | ||
7 | import com.prws.common.utils.SharedPreferencesUtil; | ||
8 | |||
9 | public class NianActivity extends BaseActivity { | ||
10 | @Override | ||
11 | protected int layoutResId() { | ||
12 | return R.layout.activity_set_nian; | ||
13 | } | ||
14 | |||
15 | @Override | ||
16 | public Object getContract() { | ||
17 | return null; | ||
18 | } | ||
19 | |||
20 | @Override | ||
21 | public BasePresenter getPresenter() { | ||
22 | return null; | ||
23 | } | ||
24 | |||
25 | TextView tv_nian; | ||
26 | TextView tv_xq; | ||
27 | |||
28 | @Override | ||
29 | protected void initView() { | ||
30 | tv_nian = findViewById(R.id.tv_nian); | ||
31 | tv_xq = findViewById(R.id.tv_xq); | ||
32 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | ||
33 | findViewById(R.id.tv_ok).setOnClickListener(view -> { | ||
34 | SharedPreferencesUtil.putData("setNian", tv_nian.getText()); | ||
35 | SharedPreferencesUtil.putData("setXueq", tv_xq.getText()); | ||
36 | finish(); | ||
37 | }); | ||
38 | |||
39 | |||
40 | } | ||
41 | |||
42 | @Override | ||
43 | protected void initListener() { | ||
44 | |||
45 | } | ||
46 | |||
47 | @Override | ||
48 | protected void initData() { | ||
49 | |||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public void onNetChanged(int netWorkState) { | ||
54 | |||
55 | } | ||
56 | } | ||
57 |
app/src/main/java/com/hjx/parent/NickActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.widget.EditText; | ||
4 | import android.widget.TextView; | ||
5 | import android.widget.Toast; | ||
6 | |||
7 | import com.prws.common.base.BaseActivity; | ||
8 | import com.prws.common.base.BasePresenter; | ||
9 | import com.prws.common.utils.SharedPreferencesUtil; | ||
10 | |||
11 | public class NickActivity extends BaseActivity { | ||
12 | @Override | ||
13 | protected int layoutResId() { | ||
14 | return R.layout.activity_set_nick; | ||
15 | } | ||
16 | |||
17 | @Override | ||
18 | public Object getContract() { | ||
19 | return null; | ||
20 | } | ||
21 | |||
22 | @Override | ||
23 | public BasePresenter getPresenter() { | ||
24 | return null; | ||
25 | } | ||
26 | |||
27 | EditText et_1; | ||
28 | |||
29 | @Override | ||
30 | protected void initView() { | ||
31 | et_1 = findViewById(R.id.et_1); | ||
32 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | ||
33 | findViewById(R.id.tv_ok).setOnClickListener(view -> { | ||
34 | String name = et_1.getText().toString().trim(); | ||
35 | if (name != null && name.length() > 0){ | ||
36 | SharedPreferencesUtil.putData("setName",name); | ||
37 | finish(); | ||
38 | }else { | ||
39 | Toast.makeText(this,"请设置昵称",Toast.LENGTH_SHORT).show(); | ||
40 | } | ||
41 | }); | ||
42 | } | ||
43 | |||
44 | @Override | ||
45 | protected void initListener() { | ||
46 | |||
47 | } | ||
48 | |||
49 | @Override | ||
50 | protected void initData() { | ||
51 | |||
52 | } | ||
53 | |||
54 | @Override | ||
55 | public void onNetChanged(int netWorkState) { | ||
56 | |||
57 | } | ||
58 | } | ||
59 |
app/src/main/java/com/hjx/parent/QRActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.graphics.Bitmap; | ||
4 | import android.widget.Toast; | ||
5 | |||
6 | import com.google.gson.Gson; | ||
7 | import com.hjx.parent.bean.RegisterBean; | ||
8 | import com.prws.common.base.BaseActivity; | ||
9 | import com.prws.common.base.BasePresenter; | ||
10 | import com.prws.common.net.NetWorks; | ||
11 | import com.prws.common.utils.LogUtil; | ||
12 | import com.prws.common.utils.SharedPreferencesUtil; | ||
13 | import com.uuzuche.lib_zxing.activity.CaptureFragment; | ||
14 | import com.uuzuche.lib_zxing.activity.CodeUtils; | ||
15 | |||
16 | import org.json.JSONObject; | ||
17 | |||
18 | import java.io.IOException; | ||
19 | |||
20 | import io.reactivex.Observer; | ||
21 | import io.reactivex.disposables.Disposable; | ||
22 | import okhttp3.ResponseBody; | ||
23 | |||
24 | public class QRActivity extends BaseActivity { | ||
25 | @Override | ||
26 | protected int layoutResId() { | ||
27 | return R.layout.activity_qr; | ||
28 | } | ||
29 | |||
30 | @Override | ||
31 | public Object getContract() { | ||
32 | return null; | ||
33 | } | ||
34 | |||
35 | @Override | ||
36 | public BasePresenter getPresenter() { | ||
37 | return null; | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | protected void initView() { | ||
42 | |||
43 | findViewById(R.id.iv_back).setOnClickListener(view -> startActivity(MainActivity.class)); | ||
44 | |||
45 | CaptureFragment captureFragment = new CaptureFragment(); | ||
46 | |||
47 | captureFragment.setAnalyzeCallback(new CodeUtils.AnalyzeCallback() { | ||
48 | @Override | ||
49 | public void onAnalyzeSuccess(Bitmap mBitmap, String result) { | ||
50 | LogUtil.e(TAG,"result----:"+result); | ||
51 | |||
52 | loginAnd(result); | ||
53 | |||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public void onAnalyzeFailed() { | ||
58 | |||
59 | } | ||
60 | }); | ||
61 | |||
62 | |||
63 | getSupportFragmentManager().beginTransaction().replace(R.id.rl_content, captureFragment).commit(); | ||
64 | |||
65 | |||
66 | } | ||
67 | |||
68 | public void loginAnd(String str){ | ||
69 | NetWorks.scanAndLogin(str, new Observer<ResponseBody>() { | ||
70 | @Override | ||
71 | public void onSubscribe(Disposable d) { | ||
72 | |||
73 | } | ||
74 | |||
75 | @Override | ||
76 | public void onNext(ResponseBody responseBody) { | ||
77 | try { | ||
78 | |||
79 | String str = responseBody.string().toString(); | ||
80 | LogUtil.e(TAG,"----"+str); | ||
81 | JSONObject jo = new JSONObject(str); | ||
82 | boolean isSucceed = jo.getBoolean("success"); | ||
83 | if (isSucceed){ | ||
84 | startActivity(MainActivity.class); | ||
85 | finish(); | ||
86 | }else { | ||
87 | Toast.makeText(QRActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); | ||
88 | } | ||
89 | }catch (Exception e){ | ||
90 | e.printStackTrace(); | ||
91 | Toast.makeText(QRActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); | ||
92 | startActivity(MainActivity.class); | ||
93 | } | ||
94 | |||
95 | |||
96 | |||
97 | |||
98 | |||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public void onError(Throwable e) { | ||
103 | |||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public void onComplete() { | ||
108 | |||
109 | } | ||
110 | }); | ||
111 | } | ||
112 | |||
113 | @Override | ||
114 | protected void initListener() { | ||
115 | |||
116 | } | ||
117 | |||
118 | @Override | ||
119 | protected void initData() { | ||
120 | |||
121 | } | ||
122 | |||
123 | @Override | ||
124 | public void onNetChanged(int netWorkState) { | ||
125 | |||
126 | } | ||
127 | } | ||
128 |
app/src/main/java/com/hjx/parent/RegisterActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.content.Intent; | ||
4 | import android.os.Bundle; | ||
5 | import android.telephony.PhoneNumberUtils; | ||
6 | import android.text.InputType; | ||
7 | import android.widget.Button; | ||
8 | import android.widget.CheckBox; | ||
9 | import android.widget.EditText; | ||
10 | import android.widget.ImageView; | ||
11 | import android.widget.TextView; | ||
12 | import android.widget.Toast; | ||
13 | |||
14 | import androidx.annotation.Nullable; | ||
15 | |||
16 | import com.google.gson.Gson; | ||
17 | import com.hjq.permissions.OnPermissionCallback; | ||
18 | import com.hjq.permissions.Permission; | ||
19 | import com.hjq.permissions.XXPermissions; | ||
20 | import com.hjx.parent.bean.RegisterBean; | ||
21 | import com.prws.common.base.BaseActivity; | ||
22 | import com.prws.common.base.BasePresenter; | ||
23 | import com.prws.common.bean.BaseEntity; | ||
24 | import com.prws.common.net.NetWorks; | ||
25 | import com.prws.common.utils.GsonUtil; | ||
26 | import com.prws.common.utils.LogUtil; | ||
27 | import com.prws.common.utils.SharedPreferencesUtil; | ||
28 | import com.uuzuche.lib_zxing.activity.CaptureActivity; | ||
29 | import com.uuzuche.lib_zxing.activity.CodeUtils; | ||
30 | |||
31 | import java.io.IOException; | ||
32 | import java.util.HashMap; | ||
33 | import java.util.List; | ||
34 | import java.util.Map; | ||
35 | |||
36 | import io.reactivex.Observer; | ||
37 | import io.reactivex.disposables.Disposable; | ||
38 | import okhttp3.ResponseBody; | ||
39 | |||
40 | public class RegisterActivity extends BaseActivity { | ||
41 | |||
42 | EditText et_phone; | ||
43 | EditText et_pwd; | ||
44 | EditText et_pwd_2; | ||
45 | ImageView iv_show; | ||
46 | ImageView iv_show_2; | ||
47 | ImageView iv_delete; | ||
48 | Button btn_reg; | ||
49 | TextView tv_log; | ||
50 | CheckBox cb_1; | ||
51 | TextView tv_user; | ||
52 | TextView tv_ys; | ||
53 | |||
54 | |||
55 | @Override | ||
56 | protected int layoutResId() { | ||
57 | return R.layout.activity_register; | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public Object getContract() { | ||
62 | return null; | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public BasePresenter getPresenter() { | ||
67 | return null; | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | protected void initView() { | ||
72 | et_phone = findViewById(R.id.et_phone); | ||
73 | et_pwd = findViewById(R.id.et_pwd); | ||
74 | iv_show = findViewById(R.id.iv_4); | ||
75 | iv_show_2 = findViewById(R.id.iv_6); | ||
76 | et_pwd_2 = findViewById(R.id.et_pwd_2); | ||
77 | iv_delete = findViewById(R.id.iv_2); | ||
78 | btn_reg = findViewById(R.id.btn_1); | ||
79 | tv_log = findViewById(R.id.tv_2); | ||
80 | cb_1 = findViewById(R.id.cb_1); | ||
81 | tv_user = findViewById(R.id.tv_4); | ||
82 | tv_ys = findViewById(R.id.tv_6); | ||
83 | |||
84 | |||
85 | } | ||
86 | |||
87 | @Override | ||
88 | protected void initListener() { | ||
89 | iv_delete.setOnClickListener(view -> { | ||
90 | et_phone.setText(""); | ||
91 | }); | ||
92 | iv_show.setOnClickListener(view -> { | ||
93 | |||
94 | if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { | ||
95 | iv_show.setBackgroundResource(R.mipmap.yc); | ||
96 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | ||
97 | } else { | ||
98 | iv_show.setBackgroundResource(R.mipmap.xs); | ||
99 | et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | ||
100 | } | ||
101 | |||
102 | |||
103 | }); | ||
104 | |||
105 | iv_show_2.setOnClickListener(view -> { | ||
106 | |||
107 | if (iv_show_2.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { | ||
108 | iv_show_2.setBackgroundResource(R.mipmap.yc); | ||
109 | et_pwd_2.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); | ||
110 | } else { | ||
111 | iv_show_2.setBackgroundResource(R.mipmap.xs); | ||
112 | et_pwd_2.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); | ||
113 | } | ||
114 | |||
115 | |||
116 | }); | ||
117 | |||
118 | |||
119 | btn_reg.setOnClickListener(view -> { | ||
120 | |||
121 | String phone = et_phone.getText().toString().trim(); | ||
122 | String pwd = et_pwd.getText().toString().trim(); | ||
123 | String pwd2 = et_pwd_2.getText().toString().trim(); | ||
124 | if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { | ||
125 | Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { | ||
130 | Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | if (!cb_1.isChecked()) { | ||
135 | Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); | ||
136 | return; | ||
137 | } | ||
138 | if (!pwd.equals(pwd2)) { | ||
139 | Toast.makeText(this, "两次密码需要一致", Toast.LENGTH_SHORT).show(); | ||
140 | return; | ||
141 | } | ||
142 | |||
143 | reg(phone, pwd); | ||
144 | |||
145 | }); | ||
146 | |||
147 | tv_log.setOnClickListener(view -> { | ||
148 | startActivity(LoginActivity.class); | ||
149 | finish(); | ||
150 | }); | ||
151 | |||
152 | tv_ys.setOnClickListener(view -> { | ||
153 | startActivity(YinsiActivity.class); | ||
154 | }); | ||
155 | tv_user.setOnClickListener(view -> { | ||
156 | startActivity(UserActivity.class); | ||
157 | }); | ||
158 | } | ||
159 | |||
160 | public void reg(final String phone, String pwd) { | ||
161 | |||
162 | Map map = new HashMap(); | ||
163 | map.put("username", phone); | ||
164 | map.put("password", pwd); | ||
165 | |||
166 | |||
167 | NetWorks.registerParent(NetWorks.getMapRequestBody(map), new Observer<ResponseBody>() { | ||
168 | @Override | ||
169 | public void onSubscribe(Disposable d) { | ||
170 | |||
171 | } | ||
172 | |||
173 | @Override | ||
174 | public void onNext(ResponseBody responseBody) { | ||
175 | String str = null; | ||
176 | try { | ||
177 | str = responseBody.string(); | ||
178 | } catch (IOException e) { | ||
179 | e.printStackTrace(); | ||
180 | } | ||
181 | |||
182 | if (str == null || str.length() == 0) { | ||
183 | Toast.makeText(RegisterActivity.this, "服务器繁忙", Toast.LENGTH_SHORT).show(); | ||
184 | return; | ||
185 | } | ||
186 | |||
187 | RegisterBean registerBean = new Gson().fromJson(str, RegisterBean.class); | ||
188 | |||
189 | if (!registerBean.isSuccess()) { | ||
190 | Toast.makeText(RegisterActivity.this, registerBean.getMsg(), Toast.LENGTH_SHORT).show(); | ||
191 | return; | ||
192 | } | ||
193 | |||
194 | if (registerBean.getData().getUserName() != null && registerBean.getData().getUserName().length() > 0) { | ||
195 | SharedPreferencesUtil.putData("phone",phone); | ||
196 | SharedPreferencesUtil.putData("role",registerBean.getData().getUserName()); | ||
197 | SharedPreferencesUtil.putData("userId",registerBean.getData().getUserName()); | ||
198 | |||
199 | //进入扫码界面 | ||
200 | goQRView(); | ||
201 | |||
202 | } | ||
203 | |||
204 | |||
205 | } | ||
206 | |||
207 | @Override | ||
208 | public void onError(Throwable e) { | ||
209 | |||
210 | } | ||
211 | |||
212 | @Override | ||
213 | public void onComplete() { | ||
214 | |||
215 | } | ||
216 | }); | ||
217 | } | ||
218 | |||
219 | public void goQRView() { | ||
220 | |||
221 | if (!XXPermissions.isGranted(this, Permission.CAMERA)) { | ||
222 | XXPermissions.with(this) | ||
223 | // 申请多个权限 | ||
224 | .permission(Permission.CAMERA) | ||
225 | .request(new OnPermissionCallback() { | ||
226 | @Override | ||
227 | public void onGranted(List<String> permissions, boolean all) { | ||
228 | if (all) { | ||
229 | //开启扫码界面 | ||
230 | startQRView(); | ||
231 | |||
232 | } else { | ||
233 | Toast.makeText(RegisterActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); | ||
234 | } | ||
235 | } | ||
236 | |||
237 | @Override | ||
238 | public void onDenied(List<String> permissions, boolean never) { | ||
239 | XXPermissions.startPermissionActivity(RegisterActivity.this, permissions); | ||
240 | } | ||
241 | }); | ||
242 | |||
243 | |||
244 | } else { | ||
245 | startQRView(); | ||
246 | } | ||
247 | |||
248 | |||
249 | } | ||
250 | |||
251 | public void startQRView() { | ||
252 | |||
253 | startActivity(QRActivity.class); | ||
254 | finish(); | ||
255 | |||
256 | } | ||
257 | |||
258 | |||
259 | |||
260 | @Override | ||
261 | protected void initData() { | ||
262 | |||
263 | } | ||
264 | |||
265 | @Override | ||
266 | public void onNetChanged(int netWorkState) { | ||
267 | |||
268 | } | ||
269 | } |
app/src/main/java/com/hjx/parent/SexActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.view.View; | ||
4 | import android.widget.ImageView; | ||
5 | |||
6 | import com.prws.common.base.BaseActivity; | ||
7 | import com.prws.common.base.BasePresenter; | ||
8 | import com.prws.common.utils.SharedPreferencesUtil; | ||
9 | |||
10 | public class SexActivity extends BaseActivity { | ||
11 | @Override | ||
12 | protected int layoutResId() { | ||
13 | return R.layout.activity_set_sex; | ||
14 | } | ||
15 | |||
16 | @Override | ||
17 | public Object getContract() { | ||
18 | return null; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public BasePresenter getPresenter() { | ||
23 | return null; | ||
24 | } | ||
25 | |||
26 | View view_nv; | ||
27 | View view_nan; | ||
28 | boolean isNv = true; | ||
29 | ImageView cb_1,cb_2; | ||
30 | @Override | ||
31 | protected void initView() { | ||
32 | view_nv = findViewById(R.id.view_2); | ||
33 | view_nan = findViewById(R.id.view_3); | ||
34 | cb_1 = findViewById(R.id.cb_1); | ||
35 | cb_2 = findViewById(R.id.cb_2); | ||
36 | |||
37 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | ||
38 | findViewById(R.id.tv_ok).setOnClickListener(view -> { | ||
39 | SharedPreferencesUtil.putData("setSex", isNv?"女":"男"); | ||
40 | finish(); | ||
41 | }); | ||
42 | view_nv.setOnClickListener(view -> { | ||
43 | view_nv.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
44 | view_nan.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
45 | cb_1.setBackgroundResource(R.mipmap.gx); | ||
46 | cb_2.setBackgroundResource(R.mipmap.wsyq); | ||
47 | isNv = true; | ||
48 | }); | ||
49 | view_nan.setOnClickListener(view -> { | ||
50 | view_nv.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
51 | view_nan.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
52 | cb_1.setBackgroundResource(R.mipmap.wsyq); | ||
53 | cb_2.setBackgroundResource(R.mipmap.gx); | ||
54 | isNv = false; | ||
55 | }); | ||
56 | } | ||
57 | |||
58 | @Override | ||
59 | protected void initListener() { | ||
60 | |||
61 | } | ||
62 | |||
63 | @Override | ||
64 | protected void initData() { | ||
65 | |||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public void onNetChanged(int netWorkState) { | ||
70 | |||
71 | } | ||
72 | } | ||
73 |
app/src/main/java/com/hjx/parent/ShenActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import android.view.View; | ||
4 | import android.widget.ImageView; | ||
5 | |||
6 | import com.prws.common.base.BaseActivity; | ||
7 | import com.prws.common.base.BasePresenter; | ||
8 | import com.prws.common.utils.SharedPreferencesUtil; | ||
9 | |||
10 | public class ShenActivity extends BaseActivity { | ||
11 | @Override | ||
12 | protected int layoutResId() { | ||
13 | return R.layout.activity_set_jia; | ||
14 | } | ||
15 | |||
16 | @Override | ||
17 | public Object getContract() { | ||
18 | return null; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | public BasePresenter getPresenter() { | ||
23 | return null; | ||
24 | } | ||
25 | View view_1; | ||
26 | View view_2,view_3,view_4,view_5,view_6; | ||
27 | ImageView iv_1,iv_2,iv_3,iv_4,iv_5,iv_6; | ||
28 | |||
29 | String shen = "爸爸"; | ||
30 | @Override | ||
31 | protected void initView() { | ||
32 | findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); | ||
33 | findViewById(R.id.tv_ok).setOnClickListener(view -> { | ||
34 | SharedPreferencesUtil.putData("setShen", shen); | ||
35 | finish(); | ||
36 | }); | ||
37 | view_1 = findViewById(R.id.view_2); | ||
38 | view_2 = findViewById(R.id.view_3); | ||
39 | view_3 = findViewById(R.id.view_4); | ||
40 | view_4 = findViewById(R.id.view_5); | ||
41 | view_5 = findViewById(R.id.view_6); | ||
42 | view_6 = findViewById(R.id.view_7); | ||
43 | iv_1 = findViewById(R.id.iv_1); | ||
44 | iv_2 = findViewById(R.id.iv_2); | ||
45 | iv_3 = findViewById(R.id.iv_3); | ||
46 | iv_4 = findViewById(R.id.iv_4); | ||
47 | iv_5 = findViewById(R.id.iv_5); | ||
48 | iv_6 = findViewById(R.id.iv_6); | ||
49 | |||
50 | view_1.setOnClickListener(view -> { | ||
51 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
52 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
53 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
54 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
55 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
56 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
57 | iv_1.setBackgroundResource(R.mipmap.gx); | ||
58 | iv_2.setBackgroundResource(R.mipmap.wsyq); | ||
59 | iv_3.setBackgroundResource(R.mipmap.wsyq); | ||
60 | iv_4.setBackgroundResource(R.mipmap.wsyq); | ||
61 | iv_5.setBackgroundResource(R.mipmap.wsyq); | ||
62 | iv_6.setBackgroundResource(R.mipmap.wsyq); | ||
63 | shen = "爸爸"; | ||
64 | }); | ||
65 | view_2.setOnClickListener(view -> { | ||
66 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
67 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
68 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
69 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
70 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
71 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
72 | shen = "妈妈"; | ||
73 | iv_1.setBackgroundResource(R.mipmap.wsyq); | ||
74 | iv_2.setBackgroundResource(R.mipmap.gx); | ||
75 | iv_3.setBackgroundResource(R.mipmap.wsyq); | ||
76 | iv_4.setBackgroundResource(R.mipmap.wsyq); | ||
77 | iv_5.setBackgroundResource(R.mipmap.wsyq); | ||
78 | iv_6.setBackgroundResource(R.mipmap.wsyq); | ||
79 | }); | ||
80 | view_3.setOnClickListener(view -> { | ||
81 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
82 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
83 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
84 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
85 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
86 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
87 | shen = "爷爷"; | ||
88 | iv_1.setBackgroundResource(R.mipmap.wsyq); | ||
89 | iv_2.setBackgroundResource(R.mipmap.wsyq); | ||
90 | iv_3.setBackgroundResource(R.mipmap.gx); | ||
91 | iv_4.setBackgroundResource(R.mipmap.wsyq); | ||
92 | iv_5.setBackgroundResource(R.mipmap.wsyq); | ||
93 | iv_6.setBackgroundResource(R.mipmap.wsyq); | ||
94 | }); | ||
95 | view_4.setOnClickListener(view -> { | ||
96 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
97 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
98 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
99 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
100 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
101 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
102 | shen = "奶奶"; | ||
103 | iv_1.setBackgroundResource(R.mipmap.wsyq); | ||
104 | iv_2.setBackgroundResource(R.mipmap.wsyq); | ||
105 | iv_3.setBackgroundResource(R.mipmap.wsyq); | ||
106 | iv_4.setBackgroundResource(R.mipmap.gx); | ||
107 | iv_5.setBackgroundResource(R.mipmap.wsyq); | ||
108 | iv_6.setBackgroundResource(R.mipmap.wsyq); | ||
109 | }); | ||
110 | view_5.setOnClickListener(view -> { | ||
111 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
112 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
113 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
114 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
115 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
116 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
117 | shen = "外公"; | ||
118 | iv_1.setBackgroundResource(R.mipmap.wsyq); | ||
119 | iv_2.setBackgroundResource(R.mipmap.wsyq); | ||
120 | iv_3.setBackgroundResource(R.mipmap.wsyq); | ||
121 | iv_4.setBackgroundResource(R.mipmap.wsyq); | ||
122 | iv_5.setBackgroundResource(R.mipmap.gx); | ||
123 | iv_6.setBackgroundResource(R.mipmap.wsyq); | ||
124 | }); | ||
125 | view_6.setOnClickListener(view -> { | ||
126 | view_1.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
127 | view_2.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
128 | view_3.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
129 | view_4.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
130 | view_5.setBackgroundResource(R.drawable.bg_solid_white_10); | ||
131 | view_6.setBackgroundResource(R.drawable.bg_solid_white_10_or); | ||
132 | shen = "外婆"; | ||
133 | iv_1.setBackgroundResource(R.mipmap.wsyq); | ||
134 | iv_2.setBackgroundResource(R.mipmap.wsyq); | ||
135 | iv_3.setBackgroundResource(R.mipmap.wsyq); | ||
136 | iv_4.setBackgroundResource(R.mipmap.wsyq); | ||
137 | iv_5.setBackgroundResource(R.mipmap.wsyq); | ||
138 | iv_6.setBackgroundResource(R.mipmap.gx); | ||
139 | }); | ||
140 | |||
141 | } | ||
142 | |||
143 | @Override | ||
144 | protected void initListener() { | ||
145 | |||
146 | } | ||
147 | |||
148 | @Override | ||
149 | protected void initData() { | ||
150 | |||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public void onNetChanged(int netWorkState) { | ||
155 | |||
156 | } | ||
157 | } | ||
158 |
app/src/main/java/com/hjx/parent/UserActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import com.prws.common.base.BaseActivity; | ||
4 | import com.prws.common.base.BasePresenter; | ||
5 | |||
6 | public class UserActivity extends BaseActivity { | ||
7 | |||
8 | @Override | ||
9 | protected int layoutResId() { | ||
10 | return R.layout.activity_me; | ||
11 | } | ||
12 | |||
13 | @Override | ||
14 | public Object getContract() { | ||
15 | return null; | ||
16 | } | ||
17 | |||
18 | @Override | ||
19 | public BasePresenter getPresenter() { | ||
20 | return null; | ||
21 | } | ||
22 | |||
23 | |||
24 | @Override | ||
25 | protected void initView() { | ||
26 | |||
27 | } | ||
28 | |||
29 | @Override | ||
30 | protected void initListener() { | ||
31 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | protected void initData() { | ||
36 | |||
37 | } | ||
38 | |||
39 | @Override | ||
40 | public void onNetChanged(int netWorkState) { | ||
41 | |||
42 | } | ||
43 | } |
app/src/main/java/com/hjx/parent/YinsiActivity.java
File was created | 1 | package com.hjx.parent; | |
2 | |||
3 | import com.prws.common.base.BaseActivity; | ||
4 | import com.prws.common.base.BasePresenter; | ||
5 | |||
6 | public class YinsiActivity extends BaseActivity { | ||
7 | |||
8 | @Override | ||
9 | protected int layoutResId() { | ||
10 | return R.layout.activity_yin; | ||
11 | } | ||
12 | |||
13 | @Override | ||
14 | public Object getContract() { | ||
15 | return null; | ||
16 | } | ||
17 | |||
18 | @Override | ||
19 | public BasePresenter getPresenter() { | ||
20 | return null; | ||
21 | } | ||
22 | |||
23 | |||
24 | @Override | ||
25 | protected void initView() { | ||
26 | |||
27 | } | ||
28 | |||
29 | @Override | ||
30 | protected void initListener() { | ||
31 | findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); | ||
32 | } | ||
33 | |||
34 | @Override | ||
35 | protected void initData() { | ||
36 | |||
37 | } | ||
38 | |||
39 | @Override | ||
40 | public void onNetChanged(int netWorkState) { | ||
41 | |||
42 | } | ||
43 | } |
app/src/main/java/com/hjx/parent/bean/RegisterBean.java
File was created | 1 | package com.hjx.parent.bean; | |
2 | |||
3 | import java.io.Serializable; | ||
4 | |||
5 | public class RegisterBean implements Serializable { | ||
6 | |||
7 | Integer code; | ||
8 | String msg; | ||
9 | RegisterDataBean data; | ||
10 | boolean success; | ||
11 | |||
12 | public Integer getCode() { | ||
13 | return code; | ||
14 | } | ||
15 | |||
16 | public void setCode(Integer code) { | ||
17 | this.code = code; | ||
18 | } | ||
19 | |||
20 | public String getMsg() { | ||
21 | return msg; | ||
22 | } | ||
23 | |||
24 | public void setMsg(String msg) { | ||
25 | this.msg = msg; | ||
26 | } | ||
27 | |||
28 | public RegisterDataBean getData() { | ||
29 | return data; | ||
30 | } | ||
31 | |||
32 | public void setData(RegisterDataBean data) { | ||
33 | this.data = data; | ||
34 | } | ||
35 | |||
36 | public boolean isSuccess() { | ||
37 | return success; | ||
38 | } | ||
39 | |||
40 | public void setSuccess(boolean success) { | ||
41 | this.success = success; | ||
42 | } | ||
43 | } | ||
44 |
app/src/main/java/com/hjx/parent/bean/RegisterDataBean.java
File was created | 1 | package com.hjx.parent.bean; | |
2 | |||
3 | public class RegisterDataBean { | ||
4 | Integer id; | ||
5 | String userName; | ||
6 | String account; | ||
7 | String password; | ||
8 | String nickName; | ||
9 | String phone; | ||
10 | String mail; | ||
11 | String identity; | ||
12 | String photo; | ||
13 | String qrCode; | ||
14 | Integer sex; | ||
15 | Integer createBy; | ||
16 | String createTime; | ||
17 | Integer updateBy; | ||
18 | String updateTime; | ||
19 | Integer delFlag; | ||
20 | |||
21 | |||
22 | public Integer getId() { | ||
23 | return id; | ||
24 | } | ||
25 | |||
26 | public void setId(Integer id) { | ||
27 | this.id = id; | ||
28 | } | ||
29 | |||
30 | public String getUserName() { | ||
31 | return userName; | ||
32 | } | ||
33 | |||
34 | public void setUserName(String userName) { | ||
35 | this.userName = userName; | ||
36 | } | ||
37 | |||
38 | public String getAccount() { | ||
39 | return account; | ||
40 | } | ||
41 | |||
42 | public void setAccount(String account) { | ||
43 | this.account = account; | ||
44 | } | ||
45 | |||
46 | public String getPassword() { | ||
47 | return password; | ||
48 | } | ||
49 | |||
50 | public void setPassword(String password) { | ||
51 | this.password = password; | ||
52 | } | ||
53 | |||
54 | public String getNickName() { | ||
55 | return nickName; | ||
56 | } | ||
57 | |||
58 | public void setNickName(String nickName) { | ||
59 | this.nickName = nickName; | ||
60 | } | ||
61 | |||
62 | public String getPhone() { | ||
63 | return phone; | ||
64 | } | ||
65 | |||
66 | public void setPhone(String phone) { | ||
67 | this.phone = phone; | ||
68 | } | ||
69 | |||
70 | public String getMail() { | ||
71 | return mail; | ||
72 | } | ||
73 | |||
74 | public void setMail(String mail) { | ||
75 | this.mail = mail; | ||
76 | } | ||
77 | |||
78 | public String getIdentity() { | ||
79 | return identity; | ||
80 | } | ||
81 | |||
82 | public void setIdentity(String identity) { | ||
83 | this.identity = identity; | ||
84 | } | ||
85 | |||
86 | public String getPhoto() { | ||
87 | return photo; | ||
88 | } | ||
89 | |||
90 | public void setPhoto(String photo) { | ||
91 | this.photo = photo; | ||
92 | } | ||
93 | |||
94 | public String getQrCode() { | ||
95 | return qrCode; | ||
96 | } | ||
97 | |||
98 | public void setQrCode(String qrCode) { | ||
99 | this.qrCode = qrCode; | ||
100 | } | ||
101 | |||
102 | public Integer getSex() { | ||
103 | return sex; | ||
104 | } | ||
105 | |||
106 | public void setSex(Integer sex) { | ||
107 | this.sex = sex; | ||
108 | } | ||
109 | |||
110 | public Integer getCreateBy() { | ||
111 | return createBy; | ||
112 | } | ||
113 | |||
114 | public void setCreateBy(Integer createBy) { | ||
115 | this.createBy = createBy; | ||
116 | } | ||
117 | |||
118 | public String getCreateTime() { | ||
119 | return createTime; | ||
120 | } | ||
121 | |||
122 | public void setCreateTime(String createTime) { | ||
123 | this.createTime = createTime; | ||
124 | } | ||
125 | |||
126 | public Integer getUpdateBy() { | ||
127 | return updateBy; | ||
128 | } | ||
129 | |||
130 | public void setUpdateBy(Integer updateBy) { | ||
131 | this.updateBy = updateBy; | ||
132 | } | ||
133 | |||
134 | public String getUpdateTime() { | ||
135 | return updateTime; | ||
136 | } | ||
137 | |||
138 | public void setUpdateTime(String updateTime) { | ||
139 | this.updateTime = updateTime; | ||
140 | } | ||
141 | |||
142 | public Integer getDelFlag() { | ||
143 | return delFlag; | ||
144 | } | ||
145 | |||
146 | public void setDelFlag(Integer delFlag) { | ||
147 | this.delFlag = delFlag; | ||
148 | } | ||
149 | } | ||
150 |
app/src/main/java/com/hjx/parent/bean/StudentBean.java
File was created | 1 | package com.hjx.parent.bean; | |
2 | |||
3 | public class StudentBean { | ||
4 | |||
5 | String stuId; | ||
6 | String stuName; | ||
7 | int gender; | ||
8 | String term; | ||
9 | String account; | ||
10 | String nickName; | ||
11 | String address; | ||
12 | String phone; | ||
13 | String photo; | ||
14 | int fromType; | ||
15 | int gradeId; | ||
16 | String oriSchool; | ||
17 | String parentPhone; | ||
18 | String parentIdentity; | ||
19 | String teacherName; | ||
20 | int teacherId; | ||
21 | |||
22 | @Override | ||
23 | public String toString() { | ||
24 | return "StudentBean{" + | ||
25 | "stuId='" + stuId + '\'' + | ||
26 | ", stuName='" + stuName + '\'' + | ||
27 | ", gender=" + gender + | ||
28 | ", term='" + term + '\'' + | ||
29 | ", account='" + account + '\'' + | ||
30 | ", nickName='" + nickName + '\'' + | ||
31 | ", address='" + address + '\'' + | ||
32 | ", phone='" + phone + '\'' + | ||
33 | ", photo='" + photo + '\'' + | ||
34 | ", fromType=" + fromType + | ||
35 | ", gradeId=" + gradeId + | ||
36 | ", oriSchool='" + oriSchool + '\'' + | ||
37 | ", parentPhone='" + parentPhone + '\'' + | ||
38 | ", parentIdentity='" + parentIdentity + '\'' + | ||
39 | ", teacherName='" + teacherName + '\'' + | ||
40 | ", teacherId=" + teacherId + | ||
41 | '}'; | ||
42 | } | ||
43 | |||
44 | public String getStuId() { | ||
45 | return stuId; | ||
46 | } | ||
47 | |||
48 | public void setStuId(String stuId) { | ||
49 | this.stuId = stuId; | ||
50 | } | ||
51 | |||
52 | public String getStuName() { | ||
53 | return stuName; | ||
54 | } | ||
55 | |||
56 | public void setStuName(String stuName) { | ||
57 | this.stuName = stuName; | ||
58 | } | ||
59 | |||
60 | public int getGender() { | ||
61 | return gender; | ||
62 | } | ||
63 | |||
64 | public void setGender(int gender) { | ||
65 | this.gender = gender; | ||
66 | } | ||
67 | |||
68 | public String getTerm() { | ||
69 | return term; | ||
70 | } | ||
71 | |||
72 | public void setTerm(String term) { | ||
73 | this.term = term; | ||
74 | } | ||
75 | |||
76 | public String getAccount() { | ||
77 | return account; | ||
78 | } | ||
79 | |||
80 | public void setAccount(String account) { | ||
81 | this.account = account; | ||
82 | } | ||
83 | |||
84 | public String getNickName() { | ||
85 | return nickName; | ||
86 | } | ||
87 | |||
88 | public void setNickName(String nickName) { | ||
89 | this.nickName = nickName; | ||
90 | } | ||
91 | |||
92 | public String getAddress() { | ||
93 | return address; | ||
94 | } | ||
95 | |||
96 | public void setAddress(String address) { | ||
97 | this.address = address; | ||
98 | } | ||
99 | |||
100 | public String getPhone() { | ||
101 | return phone; | ||
102 | } | ||
103 | |||
104 | public void setPhone(String phone) { | ||
105 | this.phone = phone; | ||
106 | } | ||
107 | |||
108 | public String getPhoto() { | ||
109 | return photo; | ||
110 | } | ||
111 | |||
112 | public void setPhoto(String photo) { | ||
113 | this.photo = photo; | ||
114 | } | ||
115 | |||
116 | public int getFromType() { | ||
117 | return fromType; | ||
118 | } | ||
119 | |||
120 | public void setFromType(int fromType) { | ||
121 | this.fromType = fromType; | ||
122 | } | ||
123 | |||
124 | public int getGradeId() { | ||
125 | return gradeId; | ||
126 | } | ||
127 | |||
128 | public void setGradeId(int gradeId) { | ||
129 | this.gradeId = gradeId; | ||
130 | } | ||
131 | |||
132 | public String getOriSchool() { | ||
133 | return oriSchool; | ||
134 | } | ||
135 | |||
136 | public void setOriSchool(String oriSchool) { | ||
137 | this.oriSchool = oriSchool; | ||
138 | } | ||
139 | |||
140 | public String getParentPhone() { | ||
141 | return parentPhone; | ||
142 | } | ||
143 | |||
144 | public void setParentPhone(String parentPhone) { | ||
145 | this.parentPhone = parentPhone; | ||
146 | } | ||
147 | |||
148 | public String getParentIdentity() { | ||
149 | return parentIdentity; | ||
150 | } | ||
151 | |||
152 | public void setParentIdentity(String parentIdentity) { | ||
153 | this.parentIdentity = parentIdentity; | ||
154 | } | ||
155 | |||
156 | public String getTeacherName() { | ||
157 | return teacherName; | ||
158 | } | ||
159 | |||
160 | public void setTeacherName(String teacherName) { | ||
161 | this.teacherName = teacherName; | ||
162 | } | ||
163 | |||
164 | public int getTeacherId() { | ||
165 | return teacherId; | ||
166 | } | ||
167 | |||
168 | public void setTeacherId(int teacherId) { | ||
169 | this.teacherId = teacherId; | ||
170 | } | ||
171 | } | ||
172 |
app/src/main/java/com/hjx/parent/fragment/HomeFragment.java
File was created | 1 | package com.hjx.parent.fragment; | |
2 | |||
3 | import android.content.Intent; | ||
4 | import android.os.Bundle; | ||
5 | import android.widget.ImageView; | ||
6 | import android.widget.TextView; | ||
7 | import android.widget.Toast; | ||
8 | |||
9 | import androidx.annotation.Nullable; | ||
10 | |||
11 | import com.hjq.permissions.OnPermissionCallback; | ||
12 | import com.hjq.permissions.Permission; | ||
13 | import com.hjq.permissions.XXPermissions; | ||
14 | import com.hjx.parent.R; | ||
15 | import com.prws.common.base.BaseFragment; | ||
16 | import com.prws.common.utils.SharedPreferencesUtil; | ||
17 | import com.uuzuche.lib_zxing.activity.CaptureActivity; | ||
18 | import com.uuzuche.lib_zxing.activity.CodeUtils; | ||
19 | |||
20 | import java.util.List; | ||
21 | |||
22 | public class HomeFragment extends BaseFragment { | ||
23 | @Override | ||
24 | protected int getLayoutRes() { | ||
25 | return R.layout.fragment_home; | ||
26 | } | ||
27 | |||
28 | ImageView iv_sapmiao; | ||
29 | TextView tv_name; | ||
30 | @Override | ||
31 | protected void initDatas() { | ||
32 | super.initDatas(); | ||
33 | iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); | ||
34 | tv_name = mRootView.findViewById(R.id.tv_name); | ||
35 | iv_sapmiao.setOnClickListener(view -> { | ||
36 | |||
37 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)){ | ||
38 | XXPermissions.with(getActivity()) | ||
39 | // 申请多个权限 | ||
40 | .permission(Permission.CAMERA) | ||
41 | .request(new OnPermissionCallback() { | ||
42 | @Override | ||
43 | public void onGranted(List<String> permissions, boolean all) { | ||
44 | if (all){ | ||
45 | //开启扫码界面 | ||
46 | startQRView(); | ||
47 | |||
48 | |||
49 | }else { | ||
50 | Toast.makeText(getActivity(),"需要相机权限",Toast.LENGTH_SHORT).show(); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | public void onDenied(List<String> permissions, boolean never) { | ||
56 | XXPermissions.startPermissionActivity(getActivity(), permissions); | ||
57 | } | ||
58 | }); | ||
59 | |||
60 | |||
61 | |||
62 | |||
63 | }else { | ||
64 | startQRView(); | ||
65 | } | ||
66 | |||
67 | |||
68 | }); | ||
69 | |||
70 | String role = (String) SharedPreferencesUtil.getData("role",""); | ||
71 | String userId = (String) SharedPreferencesUtil.getData("userId",""); | ||
72 | String token = (String) SharedPreferencesUtil.getData("token",""); | ||
73 | String phone = (String) SharedPreferencesUtil.getData("phone",""); | ||
74 | if (role != null && role.length() > 0) | ||
75 | tv_name.setText(role); | ||
76 | |||
77 | } | ||
78 | |||
79 | public void startQRView(){ | ||
80 | |||
81 | |||
82 | startActivityForResult(new Intent(getActivity(), CaptureActivity.class),101); | ||
83 | |||
84 | |||
85 | } | ||
86 | |||
87 | @Override | ||
88 | public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | ||
89 | super.onActivityResult(requestCode, resultCode, data); | ||
90 | if (requestCode == 101){ | ||
91 | if (null != data) { | ||
92 | Bundle bundle = data.getExtras(); | ||
93 | if (bundle == null) { | ||
94 | return; | ||
95 | } | ||
96 | if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { | ||
97 | String result = bundle.getString(CodeUtils.RESULT_STRING); | ||
98 | Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); | ||
99 | } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { | ||
100 | Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | |||
106 | } | ||
107 | } | ||
108 |
app/src/main/java/com/hjx/parent/fragment/MeFragment.java
File was created | 1 | package com.hjx.parent.fragment; | |
2 | |||
3 | import android.content.Intent; | ||
4 | import android.view.View; | ||
5 | import android.widget.ImageView; | ||
6 | import android.widget.TextView; | ||
7 | import android.widget.Toast; | ||
8 | |||
9 | import androidx.constraintlayout.widget.Group; | ||
10 | |||
11 | import com.bumptech.glide.Glide; | ||
12 | import com.developer.wang.utils.PermissionUtils; | ||
13 | import com.google.gson.Gson; | ||
14 | import com.google.gson.JsonArray; | ||
15 | import com.hjq.permissions.OnPermissionCallback; | ||
16 | import com.hjq.permissions.Permission; | ||
17 | import com.hjq.permissions.XXPermissions; | ||
18 | import com.hjx.parent.AccountActivity; | ||
19 | import com.hjx.parent.AddStudentActivity; | ||
20 | import com.hjx.parent.LoginActivity; | ||
21 | import com.hjx.parent.MainActivity; | ||
22 | import com.hjx.parent.QRActivity; | ||
23 | import com.hjx.parent.R; | ||
24 | import com.hjx.parent.UserActivity; | ||
25 | import com.hjx.parent.YinsiActivity; | ||
26 | import com.hjx.parent.bean.StudentBean; | ||
27 | import com.prws.common.base.BaseFragment; | ||
28 | import com.prws.common.net.NetWorks; | ||
29 | import com.prws.common.utils.LogUtil; | ||
30 | import com.prws.common.utils.SharedPreferencesUtil; | ||
31 | |||
32 | import org.json.JSONArray; | ||
33 | import org.json.JSONObject; | ||
34 | |||
35 | import java.util.ArrayList; | ||
36 | import java.util.HashMap; | ||
37 | import java.util.List; | ||
38 | import java.util.Map; | ||
39 | |||
40 | import io.reactivex.Observer; | ||
41 | import io.reactivex.disposables.Disposable; | ||
42 | import okhttp3.ResponseBody; | ||
43 | |||
44 | public class MeFragment extends BaseFragment { | ||
45 | @Override | ||
46 | protected int getLayoutRes() { | ||
47 | return R.layout.fragment_me; | ||
48 | } | ||
49 | |||
50 | ImageView iv_bann; | ||
51 | Group group_1; | ||
52 | TextView tv_name; | ||
53 | TextView tv_phone; | ||
54 | ImageView iv_21, iv_22, iv_23; | ||
55 | TextView tv_21, tv_22, tv_23; | ||
56 | |||
57 | |||
58 | @Override | ||
59 | protected void initDatas() { | ||
60 | super.initDatas(); | ||
61 | |||
62 | |||
63 | iv_bann = mRootView.findViewById(R.id.iv_bann); | ||
64 | group_1 = mRootView.findViewById(R.id.group_1); | ||
65 | |||
66 | String role = (String) SharedPreferencesUtil.getData("role", ""); | ||
67 | String userId = (String) SharedPreferencesUtil.getData("userId", ""); | ||
68 | String token = (String) SharedPreferencesUtil.getData("token", ""); | ||
69 | String phone = (String) SharedPreferencesUtil.getData("phone", ""); | ||
70 | if (role == null || role.length() == 0) { | ||
71 | iv_bann.setVisibility(View.VISIBLE); | ||
72 | group_1.setVisibility(View.GONE); | ||
73 | |||
74 | iv_bann.setOnClickListener(view -> { | ||
75 | |||
76 | if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { | ||
77 | XXPermissions.with(getActivity()) | ||
78 | // 申请多个权限 | ||
79 | .permission(Permission.CAMERA) | ||
80 | .request(new OnPermissionCallback() { | ||
81 | @Override | ||
82 | public void onGranted(List<String> permissions, boolean all) { | ||
83 | if (all) { | ||
84 | //开启扫码界面 | ||
85 | startActivity(new Intent(getActivity(), QRActivity.class)); | ||
86 | getActivity().finish(); | ||
87 | } else { | ||
88 | Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | @Override | ||
93 | public void onDenied(List<String> permissions, boolean never) { | ||
94 | XXPermissions.startPermissionActivity(getActivity(), permissions); | ||
95 | } | ||
96 | }); | ||
97 | |||
98 | |||
99 | } | ||
100 | |||
101 | |||
102 | }); | ||
103 | return; | ||
104 | } else { | ||
105 | iv_bann.setVisibility(View.GONE); | ||
106 | group_1.setVisibility(View.VISIBLE); | ||
107 | } | ||
108 | tv_name = mRootView.findViewById(R.id.tv_name); | ||
109 | tv_phone = mRootView.findViewById(R.id.tv_phone); | ||
110 | iv_21 = mRootView.findViewById(R.id.iv_21); | ||
111 | iv_22 = mRootView.findViewById(R.id.iv_22); | ||
112 | iv_23 = mRootView.findViewById(R.id.iv_23); | ||
113 | tv_21 = mRootView.findViewById(R.id.tv_21); | ||
114 | tv_22 = mRootView.findViewById(R.id.tv_22); | ||
115 | tv_23 = mRootView.findViewById(R.id.tv_23); | ||
116 | |||
117 | tv_phone.setText(phone); | ||
118 | tv_name.setText(role); | ||
119 | |||
120 | iv_21.setOnClickListener(view -> { | ||
121 | if (iv_21.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { | ||
122 | startActivity(new Intent(getActivity(), AddStudentActivity.class)); | ||
123 | } | ||
124 | |||
125 | }); | ||
126 | |||
127 | iv_22.setOnClickListener(view -> { | ||
128 | if (iv_22.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { | ||
129 | startActivity(new Intent(getActivity(), AddStudentActivity.class)); | ||
130 | |||
131 | } | ||
132 | }); | ||
133 | iv_23.setOnClickListener(view -> { | ||
134 | if (iv_23.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { | ||
135 | startActivity(new Intent(getActivity(), AddStudentActivity.class)); | ||
136 | } | ||
137 | }); | ||
138 | |||
139 | |||
140 | } | ||
141 | |||
142 | @Override | ||
143 | public void onResume() { | ||
144 | super.onResume(); | ||
145 | loadChildList(); | ||
146 | } | ||
147 | |||
148 | ArrayList<StudentBean> alist = new ArrayList<>(); | ||
149 | |||
150 | public void loadChildList() { | ||
151 | |||
152 | |||
153 | NetWorks.listChildren(new Observer<ResponseBody>() { | ||
154 | @Override | ||
155 | public void onSubscribe(Disposable d) { | ||
156 | |||
157 | } | ||
158 | |||
159 | @Override | ||
160 | public void onNext(ResponseBody responseBody) { | ||
161 | try { | ||
162 | |||
163 | String str = responseBody.string().toString(); | ||
164 | |||
165 | |||
166 | LogUtil.e("TAG", "----" + str); | ||
167 | JSONObject jo = new JSONObject(str); | ||
168 | boolean isSucceed = jo.getBoolean("success"); | ||
169 | if (isSucceed) { | ||
170 | JSONArray jarr = jo.getJSONArray("data"); | ||
171 | alist.clear(); | ||
172 | for (int i = 0; i < jarr.length(); i++) { | ||
173 | JSONObject jo2 = jarr.getJSONObject(i); | ||
174 | StudentBean sb = new StudentBean(); | ||
175 | try { | ||
176 | sb.setStuId(jo2.getString("stuId")); | ||
177 | } catch (Exception e) { | ||
178 | } | ||
179 | try { | ||
180 | sb.setStuName(jo2.getString("stuName")); | ||
181 | } catch (Exception e) { | ||
182 | } | ||
183 | try { | ||
184 | sb.setGender(jo2.getInt("gender")); | ||
185 | } catch (Exception e) { | ||
186 | } | ||
187 | try { | ||
188 | sb.setTerm(jo2.getString("term")); | ||
189 | } catch (Exception e) { | ||
190 | } | ||
191 | try { | ||
192 | sb.setAccount(jo2.getString("account")); | ||
193 | } catch (Exception e) { | ||
194 | } | ||
195 | try { | ||
196 | sb.setNickName(jo2.getString("nickName")); | ||
197 | } catch (Exception e) { | ||
198 | } | ||
199 | try { | ||
200 | sb.setAddress(jo2.getString("address")); | ||
201 | } catch (Exception e) { | ||
202 | } | ||
203 | try { | ||
204 | sb.setPhone(jo2.getString("phone")); | ||
205 | } catch (Exception e) { | ||
206 | } | ||
207 | try { | ||
208 | sb.setPhoto(jo2.getString("photo")); | ||
209 | } catch (Exception e) { | ||
210 | } | ||
211 | try { | ||
212 | sb.setFromType(jo2.getInt("fromType")); | ||
213 | } catch (Exception e) { | ||
214 | } | ||
215 | try { | ||
216 | sb.setGradeId(jo2.getInt("gradeId")); | ||
217 | } catch (Exception e) { | ||
218 | } | ||
219 | try { | ||
220 | sb.setTeacherId(jo2.getInt("teacherId")); | ||
221 | } catch (Exception e) { | ||
222 | } | ||
223 | try { | ||
224 | sb.setOriSchool(jo2.getString("oriSchool")); | ||
225 | } catch (Exception e) { | ||
226 | } | ||
227 | try { | ||
228 | sb.setParentPhone(jo2.getString("parentPhone")); | ||
229 | } catch (Exception e) { | ||
230 | } | ||
231 | try { | ||
232 | sb.setParentIdentity(jo2.getString("parentIdentity")); | ||
233 | } catch (Exception e) { | ||
234 | } | ||
235 | try { | ||
236 | sb.setTeacherName(jo2.getString("teacherName")); | ||
237 | } catch (Exception e) { | ||
238 | } | ||
239 | alist.add(sb); | ||
240 | } | ||
241 | |||
242 | if (alist.size() > 0) | ||
243 | loadList(); | ||
244 | |||
245 | } else { | ||
246 | |||
247 | } | ||
248 | } catch (Exception e) { | ||
249 | e.printStackTrace(); | ||
250 | |||
251 | } | ||
252 | |||
253 | } | ||
254 | |||
255 | @Override | ||
256 | public void onError(Throwable e) { | ||
257 | |||
258 | } | ||
259 | |||
260 | @Override | ||
261 | public void onComplete() { | ||
262 | |||
263 | } | ||
264 | }); | ||
265 | |||
266 | |||
267 | mRootView.findViewById(R.id.view_4).setOnClickListener(view -> startActivity(new Intent(getActivity(), YinsiActivity.class))); | ||
268 | mRootView.findViewById(R.id.view_5).setOnClickListener(view -> startActivity(new Intent(getActivity(), UserActivity.class))); | ||
269 | mRootView.findViewById(R.id.view_3).setOnClickListener(view -> startActivity(new Intent(getActivity(), AccountActivity.class))); | ||
270 | |||
271 | } | ||
272 | |||
273 | public void loadList() { | ||
274 | iv_21.setBackgroundResource(R.mipmap.tjxss); | ||
275 | tv_21.setText("添加学生"); | ||
276 | |||
277 | |||
278 | iv_22.setBackgroundResource(R.mipmap.tjxss); | ||
279 | tv_22.setText("添加学生"); | ||
280 | |||
281 | iv_23.setBackgroundResource(R.mipmap.tjxss); | ||
282 | tv_23.setText("添加学生"); | ||
283 | |||
284 | if (alist.size() >= 1) { | ||
285 | // if (alist.get(0).getPhoto() != null && alist.get(0).getPhoto().length() > 0) | ||
286 | // Glide.with(getActivity()).load(alist.get(0).getPhoto()).into(iv_21); | ||
287 | // else | ||
288 | iv_21.setBackgroundResource(R.mipmap.txz); | ||
289 | tv_21.setText(alist.get(0).getStuName()); | ||
290 | } | ||
291 | if (alist.size() >= 2) { | ||
292 | // if (alist.get(1).getPhoto() != null && alist.get(1).getPhoto().length() > 0) | ||
293 | // Glide.with(getActivity()).load(alist.get(1).getPhoto()).into(iv_22); | ||
294 | // else | ||
295 | iv_22.setBackgroundResource(R.mipmap.txz); | ||
296 | tv_22.setText(alist.get(1).getStuName()); | ||
297 | } | ||
298 | if (alist.size() >= 3) { | ||
299 | // if (alist.get(2).getPhoto() != null && alist.get(2).getPhoto().length() > 0) | ||
300 | // Glide.with(getActivity()).load(alist.get(2).getPhoto()).into(iv_23); | ||
301 | // else | ||
302 | iv_23.setBackgroundResource(R.mipmap.txz); | ||
303 | tv_23.setText(alist.get(2).getStuName()); | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 |
app/src/main/res/drawable/bg_solid_btn.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FE5E09" /> | ||
6 | |||
7 | <corners | ||
8 | android:radius="25dp" | ||
9 | /> | ||
10 | |||
11 | </shape> |
app/src/main/res/drawable/bg_solid_btn_grad.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#E5E5E5" /> | ||
6 | |||
7 | <corners | ||
8 | android:radius="20dp" | ||
9 | /> | ||
10 | |||
11 | </shape> |
app/src/main/res/drawable/bg_solid_white.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#F7F8FA" /> | ||
6 | |||
7 | <corners | ||
8 | android:radius="25dp" | ||
9 | /> | ||
10 | |||
11 | </shape> |
app/src/main/res/drawable/bg_solid_white_10.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" /> | ||
6 | |||
7 | <corners | ||
8 | android:radius="10dp" | ||
9 | /> | ||
10 | |||
11 | </shape> |
app/src/main/res/drawable/bg_solid_white_10_bottom.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" /> | ||
6 | |||
7 | <corners | ||
8 | android:bottomLeftRadius="10dp" | ||
9 | android:bottomRightRadius="10dp" | ||
10 | /> | ||
11 | |||
12 | </shape> |
app/src/main/res/drawable/bg_solid_white_10_or.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" | ||
6 | /> | ||
7 | <stroke android:width="2dp" | ||
8 | android:color="#FE5E09" | ||
9 | /> | ||
10 | |||
11 | <corners | ||
12 | android:radius="10dp" | ||
13 | /> | ||
14 | |||
15 | </shape> |
app/src/main/res/drawable/bg_solid_white_10_top.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" /> | ||
6 | |||
7 | <corners | ||
8 | android:topRightRadius="10dp" | ||
9 | android:topLeftRadius="10dp" | ||
10 | /> | ||
11 | |||
12 | </shape> |
app/src/main/res/drawable/bg_solid_white_20.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <solid android:color="#FFFFFF" /> | ||
6 | |||
7 | <corners | ||
8 | android:topLeftRadius="20dp" | ||
9 | android:topRightRadius="20dp" | ||
10 | /> | ||
11 | |||
12 | </shape> |
app/src/main/res/drawable/checked_xc.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | |||
4 | <item android:state_checked="true" | ||
5 | android:drawable="@mipmap/gx" | ||
6 | /> | ||
7 | <item android:state_checked="false" | ||
8 | android:drawable="@mipmap/wsyq" | ||
9 | /> | ||
10 | |||
11 | </selector> |
app/src/main/res/drawable/ic_launcher_background.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:width="108dp" | ||
4 | android:height="108dp" | ||
5 | android:viewportWidth="108" | ||
6 | android:viewportHeight="108"> | ||
7 | <path | ||
8 | android:fillColor="#3DDC84" | ||
9 | android:pathData="M0,0h108v108h-108z" /> | ||
10 | <path | ||
11 | android:fillColor="#00000000" | ||
12 | android:pathData="M9,0L9,108" | ||
13 | android:strokeWidth="0.8" | ||
14 | android:strokeColor="#33FFFFFF" /> | ||
15 | <path | ||
16 | android:fillColor="#00000000" | ||
17 | android:pathData="M19,0L19,108" | ||
18 | android:strokeWidth="0.8" | ||
19 | android:strokeColor="#33FFFFFF" /> | ||
20 | <path | ||
21 | android:fillColor="#00000000" | ||
22 | android:pathData="M29,0L29,108" | ||
23 | android:strokeWidth="0.8" | ||
24 | android:strokeColor="#33FFFFFF" /> | ||
25 | <path | ||
26 | android:fillColor="#00000000" | ||
27 | android:pathData="M39,0L39,108" | ||
28 | android:strokeWidth="0.8" | ||
29 | android:strokeColor="#33FFFFFF" /> | ||
30 | <path | ||
31 | android:fillColor="#00000000" | ||
32 | android:pathData="M49,0L49,108" | ||
33 | android:strokeWidth="0.8" | ||
34 | android:strokeColor="#33FFFFFF" /> | ||
35 | <path | ||
36 | android:fillColor="#00000000" | ||
37 | android:pathData="M59,0L59,108" | ||
38 | android:strokeWidth="0.8" | ||
39 | android:strokeColor="#33FFFFFF" /> | ||
40 | <path | ||
41 | android:fillColor="#00000000" | ||
42 | android:pathData="M69,0L69,108" | ||
43 | android:strokeWidth="0.8" | ||
44 | android:strokeColor="#33FFFFFF" /> | ||
45 | <path | ||
46 | android:fillColor="#00000000" | ||
47 | android:pathData="M79,0L79,108" | ||
48 | android:strokeWidth="0.8" | ||
49 | android:strokeColor="#33FFFFFF" /> | ||
50 | <path | ||
51 | android:fillColor="#00000000" | ||
52 | android:pathData="M89,0L89,108" | ||
53 | android:strokeWidth="0.8" | ||
54 | android:strokeColor="#33FFFFFF" /> | ||
55 | <path | ||
56 | android:fillColor="#00000000" | ||
57 | android:pathData="M99,0L99,108" | ||
58 | android:strokeWidth="0.8" | ||
59 | android:strokeColor="#33FFFFFF" /> | ||
60 | <path | ||
61 | android:fillColor="#00000000" | ||
62 | android:pathData="M0,9L108,9" | ||
63 | android:strokeWidth="0.8" | ||
64 | android:strokeColor="#33FFFFFF" /> | ||
65 | <path | ||
66 | android:fillColor="#00000000" | ||
67 | android:pathData="M0,19L108,19" | ||
68 | android:strokeWidth="0.8" | ||
69 | android:strokeColor="#33FFFFFF" /> | ||
70 | <path | ||
71 | android:fillColor="#00000000" | ||
72 | android:pathData="M0,29L108,29" | ||
73 | android:strokeWidth="0.8" | ||
74 | android:strokeColor="#33FFFFFF" /> | ||
75 | <path | ||
76 | android:fillColor="#00000000" | ||
77 | android:pathData="M0,39L108,39" | ||
78 | android:strokeWidth="0.8" | ||
79 | android:strokeColor="#33FFFFFF" /> | ||
80 | <path | ||
81 | android:fillColor="#00000000" | ||
82 | android:pathData="M0,49L108,49" | ||
83 | android:strokeWidth="0.8" | ||
84 | android:strokeColor="#33FFFFFF" /> | ||
85 | <path | ||
86 | android:fillColor="#00000000" | ||
87 | android:pathData="M0,59L108,59" | ||
88 | android:strokeWidth="0.8" | ||
89 | android:strokeColor="#33FFFFFF" /> | ||
90 | <path | ||
91 | android:fillColor="#00000000" | ||
92 | android:pathData="M0,69L108,69" | ||
93 | android:strokeWidth="0.8" | ||
94 | android:strokeColor="#33FFFFFF" /> | ||
95 | <path | ||
96 | android:fillColor="#00000000" | ||
97 | android:pathData="M0,79L108,79" | ||
98 | android:strokeWidth="0.8" | ||
99 | android:strokeColor="#33FFFFFF" /> | ||
100 | <path | ||
101 | android:fillColor="#00000000" | ||
102 | android:pathData="M0,89L108,89" | ||
103 | android:strokeWidth="0.8" | ||
104 | android:strokeColor="#33FFFFFF" /> | ||
105 | <path | ||
106 | android:fillColor="#00000000" | ||
107 | android:pathData="M0,99L108,99" | ||
108 | android:strokeWidth="0.8" | ||
109 | android:strokeColor="#33FFFFFF" /> | ||
110 | <path | ||
111 | android:fillColor="#00000000" | ||
112 | android:pathData="M19,29L89,29" | ||
113 | android:strokeWidth="0.8" | ||
114 | android:strokeColor="#33FFFFFF" /> | ||
115 | <path | ||
116 | android:fillColor="#00000000" | ||
117 | android:pathData="M19,39L89,39" | ||
118 | android:strokeWidth="0.8" | ||
119 | android:strokeColor="#33FFFFFF" /> | ||
120 | <path | ||
121 | android:fillColor="#00000000" | ||
122 | android:pathData="M19,49L89,49" | ||
123 | android:strokeWidth="0.8" | ||
124 | android:strokeColor="#33FFFFFF" /> | ||
125 | <path | ||
126 | android:fillColor="#00000000" | ||
127 | android:pathData="M19,59L89,59" | ||
128 | android:strokeWidth="0.8" | ||
129 | android:strokeColor="#33FFFFFF" /> | ||
130 | <path | ||
131 | android:fillColor="#00000000" | ||
132 | android:pathData="M19,69L89,69" | ||
133 | android:strokeWidth="0.8" | ||
134 | android:strokeColor="#33FFFFFF" /> | ||
135 | <path | ||
136 | android:fillColor="#00000000" | ||
137 | android:pathData="M19,79L89,79" | ||
138 | android:strokeWidth="0.8" | ||
139 | android:strokeColor="#33FFFFFF" /> | ||
140 | <path | ||
141 | android:fillColor="#00000000" | ||
142 | android:pathData="M29,19L29,89" | ||
143 | android:strokeWidth="0.8" | ||
144 | android:strokeColor="#33FFFFFF" /> | ||
145 | <path | ||
146 | android:fillColor="#00000000" | ||
147 | android:pathData="M39,19L39,89" | ||
148 | android:strokeWidth="0.8" | ||
149 | android:strokeColor="#33FFFFFF" /> | ||
150 | <path | ||
151 | android:fillColor="#00000000" | ||
152 | android:pathData="M49,19L49,89" | ||
153 | android:strokeWidth="0.8" | ||
154 | android:strokeColor="#33FFFFFF" /> | ||
155 | <path | ||
156 | android:fillColor="#00000000" | ||
157 | android:pathData="M59,19L59,89" | ||
158 | android:strokeWidth="0.8" | ||
159 | android:strokeColor="#33FFFFFF" /> | ||
160 | <path | ||
161 | android:fillColor="#00000000" | ||
162 | android:pathData="M69,19L69,89" | ||
163 | android:strokeWidth="0.8" | ||
164 | android:strokeColor="#33FFFFFF" /> | ||
165 | <path | ||
166 | android:fillColor="#00000000" | ||
167 | android:pathData="M79,19L79,89" | ||
168 | android:strokeWidth="0.8" | ||
169 | android:strokeColor="#33FFFFFF" /> | ||
170 | </vector> | ||
171 |
app/src/main/res/drawable/select_b_1.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:drawable="@mipmap/hoss" android:state_checked="true" /> | ||
4 | <item android:drawable="@mipmap/hous" /> | ||
5 | |||
6 | </selector> |
app/src/main/res/drawable/select_b_2.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:drawable="@mipmap/wmss" android:state_checked="true" /> | ||
4 | <item android:drawable="@mipmap/wmus" /> | ||
5 | |||
6 | </selector> |
app/src/main/res/drawable/select_t_1.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <item android:drawable="@color/c_1" android:state_checked="true" /> | ||
4 | <item android:drawable="@color/c_2" /> | ||
5 | |||
6 | </selector> |
app/src/main/res/drawable/welcome_bg.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <!-- 设置整个屏幕背景为白色 --> | ||
4 | <item> | ||
5 | <color android:color="@android:color/white" /> | ||
6 | </item> | ||
7 | |||
8 | <!-- 中间logo --> | ||
9 | <item android:top="120dp"> | ||
10 | <bitmap | ||
11 | android:gravity="top|center_horizontal" | ||
12 | android:src="@mipmap/icon_qd" /> | ||
13 | </item> | ||
14 | |||
15 | |||
16 | <item android:top="470dp"> | ||
17 | <bitmap | ||
18 | android:gravity="top|center_horizontal" | ||
19 | android:src="@mipmap/abcdss" /> | ||
20 | </item> | ||
21 | |||
22 | </layer-list> |
app/src/main/res/layout/activity_add_stu.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="添加学生" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <TextView | ||
28 | android:id="@+id/tv_cancel" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:layout_height="wrap_content" | ||
31 | android:text="取消" | ||
32 | android:textColor="#666666" | ||
33 | android:textSize="16dp" | ||
34 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
35 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
36 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
37 | android:layout_marginLeft="15dp" | ||
38 | /> | ||
39 | <ImageView | ||
40 | android:layout_width="75dp" | ||
41 | android:layout_height="75dp" | ||
42 | android:background="@mipmap/txz" | ||
43 | app:layout_constraintLeft_toLeftOf="parent" | ||
44 | app:layout_constraintRight_toRightOf="parent" | ||
45 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
46 | android:layout_marginTop="32dp" | ||
47 | /> | ||
48 | |||
49 | <View | ||
50 | android:id="@+id/view_2" | ||
51 | android:layout_width="345dp" | ||
52 | android:layout_height="50dp" | ||
53 | android:background="@drawable/bg_solid_white_10" | ||
54 | app:layout_constraintLeft_toLeftOf="parent" | ||
55 | app:layout_constraintRight_toRightOf="parent" | ||
56 | app:layout_constraintTop_toTopOf="parent" | ||
57 | android:layout_marginTop="195dp" | ||
58 | /> | ||
59 | |||
60 | <TextView | ||
61 | android:layout_width="wrap_content" | ||
62 | android:layout_height="wrap_content" | ||
63 | android:textColor="#666666" | ||
64 | android:textSize="16dp" | ||
65 | android:text="昵称" | ||
66 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
67 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
68 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
69 | android:layout_marginLeft="15dp" | ||
70 | /> | ||
71 | <ImageView | ||
72 | android:layout_width="5.5dp" | ||
73 | android:layout_height="9.5dp" | ||
74 | android:background="@mipmap/ycaj" | ||
75 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
76 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
77 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
78 | android:layout_marginRight="15dp" | ||
79 | /> | ||
80 | |||
81 | <TextView | ||
82 | android:id="@+id/tv_name" | ||
83 | android:layout_width="wrap_content" | ||
84 | android:layout_height="wrap_content" | ||
85 | android:textColor="#999999" | ||
86 | android:textSize="16dp" | ||
87 | android:text="请输入" | ||
88 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
89 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
90 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
91 | android:layout_marginRight="26dp" | ||
92 | /> | ||
93 | |||
94 | <View | ||
95 | android:id="@+id/view_3" | ||
96 | android:layout_width="345dp" | ||
97 | android:layout_height="50dp" | ||
98 | android:background="@drawable/bg_solid_white_10" | ||
99 | app:layout_constraintLeft_toLeftOf="parent" | ||
100 | app:layout_constraintRight_toRightOf="parent" | ||
101 | app:layout_constraintTop_toTopOf="parent" | ||
102 | android:layout_marginTop="260dp" | ||
103 | /> | ||
104 | |||
105 | <TextView | ||
106 | android:layout_width="wrap_content" | ||
107 | android:layout_height="wrap_content" | ||
108 | android:textColor="#666666" | ||
109 | android:textSize="16dp" | ||
110 | android:text="性别" | ||
111 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
112 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
113 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
114 | android:layout_marginLeft="15dp" | ||
115 | /> | ||
116 | <ImageView | ||
117 | android:layout_width="5.5dp" | ||
118 | android:layout_height="9.5dp" | ||
119 | android:background="@mipmap/ycaj" | ||
120 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
121 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
122 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
123 | android:layout_marginRight="15dp" | ||
124 | /> | ||
125 | <TextView | ||
126 | android:id="@+id/tv_sex" | ||
127 | android:layout_width="wrap_content" | ||
128 | android:layout_height="wrap_content" | ||
129 | android:textColor="#999999" | ||
130 | android:textSize="16dp" | ||
131 | android:text="请选择" | ||
132 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
133 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
134 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
135 | android:layout_marginRight="26dp" | ||
136 | /> | ||
137 | |||
138 | <View | ||
139 | android:id="@+id/view_4" | ||
140 | android:layout_width="345dp" | ||
141 | android:layout_height="50dp" | ||
142 | android:background="@drawable/bg_solid_white_10" | ||
143 | app:layout_constraintLeft_toLeftOf="parent" | ||
144 | app:layout_constraintRight_toRightOf="parent" | ||
145 | app:layout_constraintTop_toTopOf="parent" | ||
146 | android:layout_marginTop="325dp" | ||
147 | |||
148 | /> | ||
149 | |||
150 | <TextView | ||
151 | android:layout_width="wrap_content" | ||
152 | android:layout_height="wrap_content" | ||
153 | android:textColor="#666666" | ||
154 | android:textSize="16dp" | ||
155 | android:text="年级" | ||
156 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
157 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
158 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
159 | android:layout_marginLeft="15dp" | ||
160 | /> | ||
161 | <ImageView | ||
162 | android:layout_width="5.5dp" | ||
163 | android:layout_height="9.5dp" | ||
164 | android:background="@mipmap/ycaj" | ||
165 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
166 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
167 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
168 | android:layout_marginRight="15dp" | ||
169 | /> | ||
170 | <TextView | ||
171 | android:id="@+id/tv_nian" | ||
172 | android:layout_width="wrap_content" | ||
173 | android:layout_height="wrap_content" | ||
174 | android:textColor="#999999" | ||
175 | android:textSize="16dp" | ||
176 | android:text="请选择" | ||
177 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
178 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
179 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
180 | android:layout_marginRight="26dp" | ||
181 | /> | ||
182 | <View | ||
183 | android:id="@+id/view_5" | ||
184 | android:layout_width="345dp" | ||
185 | android:layout_height="50dp" | ||
186 | android:background="@drawable/bg_solid_white_10" | ||
187 | app:layout_constraintLeft_toLeftOf="parent" | ||
188 | app:layout_constraintRight_toRightOf="parent" | ||
189 | app:layout_constraintTop_toTopOf="parent" | ||
190 | android:layout_marginTop="390dp" | ||
191 | |||
192 | /> | ||
193 | |||
194 | <TextView | ||
195 | |||
196 | android:layout_width="wrap_content" | ||
197 | android:layout_height="wrap_content" | ||
198 | android:textColor="#666666" | ||
199 | android:textSize="16dp" | ||
200 | android:text="家长身份" | ||
201 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
202 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
203 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
204 | android:layout_marginLeft="15dp" | ||
205 | /> | ||
206 | <TextView | ||
207 | android:id="@+id/tv_shen" | ||
208 | android:layout_width="wrap_content" | ||
209 | android:layout_height="wrap_content" | ||
210 | android:textColor="#999999" | ||
211 | android:textSize="16dp" | ||
212 | android:text="请选择" | ||
213 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
214 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
215 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
216 | android:layout_marginRight="26dp" | ||
217 | /> | ||
218 | <ImageView | ||
219 | android:layout_width="5.5dp" | ||
220 | android:layout_height="9.5dp" | ||
221 | android:background="@mipmap/ycaj" | ||
222 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
223 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
224 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
225 | android:layout_marginRight="15dp" | ||
226 | /> | ||
227 | |||
228 | |||
229 | |||
230 | <Button | ||
231 | android:id="@+id/btn_next" | ||
232 | android:layout_width="180dp" | ||
233 | android:layout_height="40dp" | ||
234 | app:layout_constraintLeft_toLeftOf="parent" | ||
235 | app:layout_constraintRight_toRightOf="parent" | ||
236 | app:layout_constraintTop_toTopOf="parent" | ||
237 | android:layout_marginTop="500dp" | ||
238 | android:background="@drawable/bg_solid_btn_grad" | ||
239 | android:text="确认" | ||
240 | android:textColor="#999999" | ||
241 | android:textSize="16dp" | ||
242 | /> | ||
243 | |||
244 | |||
245 | |||
246 | |||
247 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_changem.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="修改密码" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:id="@+id/iv_back" | ||
29 | android:layout_width="10dp" | ||
30 | android:layout_height="16dp" | ||
31 | app:layout_constraintLeft_toLeftOf="parent" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | android:layout_marginLeft="15dp" | ||
35 | android:background="@mipmap/icon_back" | ||
36 | /> | ||
37 | <View | ||
38 | android:layout_width="match_parent" | ||
39 | android:layout_height="1dp" | ||
40 | android:background="#EEEEEE" | ||
41 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
42 | /> | ||
43 | |||
44 | <View | ||
45 | android:id="@+id/view_3" | ||
46 | android:layout_width="match_parent" | ||
47 | android:layout_height="45dp" | ||
48 | android:background="@android:color/white" | ||
49 | app:layout_constraintLeft_toLeftOf="parent" | ||
50 | app:layout_constraintRight_toRightOf="parent" | ||
51 | app:layout_constraintTop_toTopOf="parent" | ||
52 | android:layout_marginTop="80dp" | ||
53 | /> | ||
54 | <ImageView | ||
55 | android:id="@+id/iv_3" | ||
56 | android:layout_width="20dp" | ||
57 | android:layout_height="16dp" | ||
58 | android:background="@mipmap/xs" | ||
59 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
60 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
61 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
62 | android:layout_marginRight="20dp" | ||
63 | /> | ||
64 | <TextView | ||
65 | android:id="@+id/tv_3" | ||
66 | android:layout_width="wrap_content" | ||
67 | android:layout_height="wrap_content" | ||
68 | android:text="请输入原密码" | ||
69 | android:textColor="#333333" | ||
70 | android:textSize="15dp" | ||
71 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
72 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
73 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
74 | android:layout_marginLeft="15dp" | ||
75 | /> | ||
76 | |||
77 | |||
78 | <EditText | ||
79 | android:layout_width="0dp" | ||
80 | android:layout_height="45dp" | ||
81 | android:background="@android:color/transparent" | ||
82 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
83 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
84 | app:layout_constraintLeft_toRightOf="@id/tv_3" | ||
85 | app:layout_constraintRight_toRightOf="parent" | ||
86 | android:layout_marginLeft="30dp" | ||
87 | android:layout_marginRight="50dp" | ||
88 | android:textSize="15dp" | ||
89 | android:gravity="left|center_vertical" | ||
90 | android:inputType="textPassword" | ||
91 | android:hint="请输入密码" | ||
92 | android:textColor="#333333" | ||
93 | android:textColorHint="#666666" | ||
94 | |||
95 | /> | ||
96 | |||
97 | <View | ||
98 | android:id="@+id/view_4" | ||
99 | android:layout_width="match_parent" | ||
100 | android:layout_height="45dp" | ||
101 | android:background="@android:color/white" | ||
102 | app:layout_constraintLeft_toLeftOf="parent" | ||
103 | app:layout_constraintRight_toRightOf="parent" | ||
104 | app:layout_constraintTop_toTopOf="parent" | ||
105 | android:layout_marginTop="125dp" | ||
106 | /> | ||
107 | <ImageView | ||
108 | android:id="@+id/iv_4" | ||
109 | android:layout_width="20dp" | ||
110 | android:layout_height="16dp" | ||
111 | android:background="@mipmap/xs" | ||
112 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
113 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
114 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
115 | android:layout_marginRight="20dp" | ||
116 | /> | ||
117 | <TextView | ||
118 | android:id="@+id/tv_4" | ||
119 | android:layout_width="wrap_content" | ||
120 | android:layout_height="wrap_content" | ||
121 | android:text="请输入新密码" | ||
122 | android:textColor="#333333" | ||
123 | android:textSize="15dp" | ||
124 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
125 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
126 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
127 | android:layout_marginLeft="15dp" | ||
128 | /> | ||
129 | |||
130 | |||
131 | <EditText | ||
132 | android:id="@+id/et_pwd" | ||
133 | android:layout_width="0dp" | ||
134 | android:layout_height="45dp" | ||
135 | android:background="@android:color/transparent" | ||
136 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
137 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
138 | app:layout_constraintLeft_toRightOf="@id/tv_4" | ||
139 | app:layout_constraintRight_toRightOf="parent" | ||
140 | android:layout_marginLeft="30dp" | ||
141 | android:layout_marginRight="50dp" | ||
142 | android:textSize="15dp" | ||
143 | android:gravity="left|center_vertical" | ||
144 | android:inputType="textPassword" | ||
145 | android:hint="请输入密码" | ||
146 | android:textColor="#333333" | ||
147 | android:textColorHint="#666666" | ||
148 | /> | ||
149 | |||
150 | |||
151 | <View | ||
152 | android:id="@+id/view_5" | ||
153 | android:layout_width="match_parent" | ||
154 | android:layout_height="45dp" | ||
155 | android:background="@android:color/white" | ||
156 | app:layout_constraintLeft_toLeftOf="parent" | ||
157 | app:layout_constraintRight_toRightOf="parent" | ||
158 | app:layout_constraintTop_toTopOf="parent" | ||
159 | android:layout_marginTop="171dp" | ||
160 | /> | ||
161 | <ImageView | ||
162 | android:id="@+id/iv_5" | ||
163 | android:layout_width="20dp" | ||
164 | android:layout_height="16dp" | ||
165 | android:background="@mipmap/xs" | ||
166 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
167 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
168 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
169 | android:layout_marginRight="20dp" | ||
170 | /> | ||
171 | <TextView | ||
172 | android:id="@+id/tv_5" | ||
173 | android:layout_width="wrap_content" | ||
174 | android:layout_height="wrap_content" | ||
175 | android:text="再次输入新密码" | ||
176 | android:textColor="#333333" | ||
177 | android:textSize="15dp" | ||
178 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
179 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
180 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
181 | android:layout_marginLeft="15dp" | ||
182 | /> | ||
183 | |||
184 | |||
185 | <EditText | ||
186 | android:layout_width="0dp" | ||
187 | android:layout_height="45dp" | ||
188 | android:background="@android:color/transparent" | ||
189 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
190 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
191 | app:layout_constraintLeft_toRightOf="@id/tv_5" | ||
192 | app:layout_constraintRight_toRightOf="parent" | ||
193 | android:layout_marginLeft="15dp" | ||
194 | android:layout_marginRight="50dp" | ||
195 | android:textSize="15dp" | ||
196 | android:gravity="left|center_vertical" | ||
197 | android:inputType="textPassword" | ||
198 | android:hint="请再次输入密码" | ||
199 | android:textColor="#333333" | ||
200 | android:textColorHint="#666666" | ||
201 | /> | ||
202 | <TextView | ||
203 | android:layout_width="wrap_content" | ||
204 | android:layout_height="wrap_content" | ||
205 | android:text="6-16位密码,数字或字母" | ||
206 | android:textColor="#999999" | ||
207 | android:textSize="15dp" | ||
208 | app:layout_constraintLeft_toLeftOf="parent" | ||
209 | app:layout_constraintTop_toTopOf="parent" | ||
210 | android:layout_marginTop="230dp" | ||
211 | android:layout_marginLeft="15dp" | ||
212 | /> | ||
213 | |||
214 | <Button | ||
215 | android:id="@+id/btn_next" | ||
216 | android:layout_width="180dp" | ||
217 | android:layout_height="40dp" | ||
218 | android:text="确认" | ||
219 | android:textColor="@color/white" | ||
220 | android:textSize="16dp" | ||
221 | android:background="@drawable/bg_solid_btn" | ||
222 | app:layout_constraintLeft_toLeftOf="parent" | ||
223 | app:layout_constraintRight_toRightOf="parent" | ||
224 | app:layout_constraintTop_toTopOf="parent" | ||
225 | android:layout_marginTop="310dp" | ||
226 | /> | ||
227 | |||
228 | |||
229 | |||
230 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_login.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="@mipmap/bg" | ||
7 | > | ||
8 | |||
9 | |||
10 | |||
11 | <TextView | ||
12 | android:layout_width="wrap_content" | ||
13 | android:layout_height="wrap_content" | ||
14 | android:text="登陆" | ||
15 | android:textColor="#333333" | ||
16 | android:textStyle="bold" | ||
17 | android:textSize="25dp" | ||
18 | android:layout_marginLeft="30dp" | ||
19 | android:layout_marginTop="64dp" | ||
20 | app:layout_constraintLeft_toLeftOf="parent" | ||
21 | app:layout_constraintTop_toTopOf="parent" | ||
22 | /> | ||
23 | |||
24 | <View | ||
25 | android:id="@+id/view_1" | ||
26 | android:layout_width="315dp" | ||
27 | android:layout_height="50dp" | ||
28 | app:layout_constraintLeft_toLeftOf="parent" | ||
29 | app:layout_constraintRight_toRightOf="parent" | ||
30 | app:layout_constraintTop_toTopOf="parent" | ||
31 | android:layout_marginTop="166dp" | ||
32 | android:background="@drawable/bg_solid_white" | ||
33 | /> | ||
34 | |||
35 | <ImageView | ||
36 | android:id="@+id/iv_1" | ||
37 | android:layout_width="16dp" | ||
38 | android:layout_height="18dp" | ||
39 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
40 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
41 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
42 | android:background="@mipmap/sjh" | ||
43 | android:layout_marginLeft="20dp" | ||
44 | /> | ||
45 | |||
46 | <ImageView | ||
47 | android:id="@+id/iv_2" | ||
48 | android:layout_width="13dp" | ||
49 | android:layout_height="13dp" | ||
50 | android:background="@mipmap/sc" | ||
51 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
52 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
53 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
54 | android:layout_marginRight="20dp" | ||
55 | /> | ||
56 | |||
57 | <EditText | ||
58 | android:id="@+id/et_phone" | ||
59 | android:layout_width="0dp" | ||
60 | android:layout_height="0dp" | ||
61 | android:background="@android:color/transparent" | ||
62 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
63 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
64 | app:layout_constraintRight_toLeftOf="@id/iv_2" | ||
65 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
66 | android:textColorHint="#999999" | ||
67 | android:hint="请输入手机号" | ||
68 | android:textSize="16dp" | ||
69 | android:gravity="left|center_vertical" | ||
70 | android:inputType="number" | ||
71 | android:layout_marginLeft="46dp" | ||
72 | android:maxLength="11" | ||
73 | /> | ||
74 | |||
75 | |||
76 | <View | ||
77 | android:id="@+id/view_2" | ||
78 | android:layout_width="315dp" | ||
79 | android:layout_height="50dp" | ||
80 | app:layout_constraintLeft_toLeftOf="parent" | ||
81 | app:layout_constraintRight_toRightOf="parent" | ||
82 | app:layout_constraintTop_toTopOf="parent" | ||
83 | android:layout_marginTop="241dp" | ||
84 | android:background="@drawable/bg_solid_white" | ||
85 | /> | ||
86 | |||
87 | <ImageView | ||
88 | android:id="@+id/iv_3" | ||
89 | android:layout_width="16dp" | ||
90 | android:layout_height="18dp" | ||
91 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
92 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
93 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
94 | android:background="@mipmap/mm" | ||
95 | android:layout_marginLeft="20dp" | ||
96 | /> | ||
97 | |||
98 | <ImageView | ||
99 | android:id="@+id/iv_4" | ||
100 | android:layout_width="20dp" | ||
101 | android:layout_height="16dp" | ||
102 | android:background="@mipmap/xs" | ||
103 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
104 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
105 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
106 | android:layout_marginRight="20dp" | ||
107 | /> | ||
108 | |||
109 | <EditText | ||
110 | android:id="@+id/et_pwd" | ||
111 | android:layout_width="0dp" | ||
112 | android:layout_height="0dp" | ||
113 | android:background="@android:color/transparent" | ||
114 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
115 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
116 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
117 | app:layout_constraintRight_toLeftOf="@id/iv_4" | ||
118 | android:layout_marginLeft="46dp" | ||
119 | android:textColorHint="#999999" | ||
120 | android:hint="请输入密码" | ||
121 | android:textSize="16dp" | ||
122 | android:gravity="left|center_vertical" | ||
123 | android:inputType="textPassword" | ||
124 | android:layout_marginRight="20dp" | ||
125 | /> | ||
126 | |||
127 | |||
128 | <Button | ||
129 | android:id="@+id/btn_1" | ||
130 | android:layout_width="315dp" | ||
131 | android:layout_height="50dp" | ||
132 | app:layout_constraintLeft_toLeftOf="parent" | ||
133 | app:layout_constraintRight_toRightOf="parent" | ||
134 | app:layout_constraintTop_toTopOf="parent" | ||
135 | android:layout_marginTop="331dp" | ||
136 | android:background="@drawable/bg_solid_btn" | ||
137 | android:textColor="@color/white" | ||
138 | android:textSize="18dp" | ||
139 | android:text="登陆" | ||
140 | /> | ||
141 | <TextView | ||
142 | android:id="@+id/tv_1" | ||
143 | android:layout_width="wrap_content" | ||
144 | android:layout_height="wrap_content" | ||
145 | android:text="没有账号,立即" | ||
146 | android:textColor="#666666" | ||
147 | android:textSize="17dp" | ||
148 | app:layout_constraintLeft_toLeftOf="@id/btn_1" | ||
149 | app:layout_constraintTop_toBottomOf="@id/btn_1" | ||
150 | android:layout_marginLeft="85dp" | ||
151 | android:layout_marginTop="15dp" | ||
152 | /> | ||
153 | <TextView | ||
154 | android:id="@+id/tv_2" | ||
155 | android:layout_width="wrap_content" | ||
156 | android:layout_height="wrap_content" | ||
157 | android:text="注册" | ||
158 | android:textColor="#FE5E09" | ||
159 | android:textSize="17dp" | ||
160 | app:layout_constraintLeft_toRightOf="@id/tv_1" | ||
161 | app:layout_constraintTop_toBottomOf="@id/btn_1" | ||
162 | android:layout_marginTop="15dp" | ||
163 | /> | ||
164 | |||
165 | |||
166 | <CheckBox | ||
167 | android:id="@+id/cb_1" | ||
168 | android:layout_width="13dp" | ||
169 | android:layout_height="13dp" | ||
170 | app:layout_constraintBottom_toBottomOf="parent" | ||
171 | app:layout_constraintLeft_toLeftOf="parent" | ||
172 | android:layout_marginLeft="67dp" | ||
173 | android:layout_marginBottom="50dp" | ||
174 | android:background="@android:color/transparent" | ||
175 | android:button="@drawable/checked_xc" | ||
176 | /> | ||
177 | <TextView | ||
178 | android:id="@+id/tv_3" | ||
179 | android:layout_width="wrap_content" | ||
180 | android:layout_height="wrap_content" | ||
181 | android:text="已阅读并同意《" | ||
182 | android:textColor="#999999" | ||
183 | android:textSize="12dp" | ||
184 | app:layout_constraintLeft_toRightOf="@id/cb_1" | ||
185 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
186 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
187 | android:layout_marginLeft="5dp" | ||
188 | /> | ||
189 | <TextView | ||
190 | android:id="@+id/tv_4" | ||
191 | android:layout_width="wrap_content" | ||
192 | android:layout_height="wrap_content" | ||
193 | android:text="用户协议" | ||
194 | android:textColor="#FE5E09" | ||
195 | android:textSize="12dp" | ||
196 | app:layout_constraintLeft_toRightOf="@id/tv_3" | ||
197 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
198 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
199 | /> | ||
200 | <TextView | ||
201 | android:id="@+id/tv_5" | ||
202 | android:layout_width="wrap_content" | ||
203 | android:layout_height="wrap_content" | ||
204 | android:text="》和《" | ||
205 | android:textColor="#999999" | ||
206 | android:textSize="12dp" | ||
207 | app:layout_constraintLeft_toRightOf="@id/tv_4" | ||
208 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
209 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
210 | /> | ||
211 | <TextView | ||
212 | android:id="@+id/tv_6" | ||
213 | android:layout_width="wrap_content" | ||
214 | android:layout_height="wrap_content" | ||
215 | android:text="隐私政策" | ||
216 | android:textColor="#FE5E09" | ||
217 | android:textSize="12dp" | ||
218 | app:layout_constraintLeft_toRightOf="@id/tv_5" | ||
219 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
220 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
221 | /> | ||
222 | <TextView | ||
223 | android:id="@+id/tv_7" | ||
224 | android:layout_width="wrap_content" | ||
225 | android:layout_height="wrap_content" | ||
226 | android:text="》" | ||
227 | android:textColor="#999999" | ||
228 | android:textSize="12dp" | ||
229 | app:layout_constraintLeft_toRightOf="@id/tv_6" | ||
230 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
231 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
232 | /> | ||
233 | |||
234 | |||
235 | |||
236 | |||
237 | |||
238 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_main.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | xmlns:tools="http://schemas.android.com/tools" | ||
5 | android:layout_width="match_parent" | ||
6 | android:layout_height="match_parent" | ||
7 | android:background="#F4F6F8" | ||
8 | tools:context=".MainActivity"> | ||
9 | |||
10 | <FrameLayout | ||
11 | android:id="@+id/rl_content" | ||
12 | android:layout_width="match_parent" | ||
13 | android:layout_height="0dp" | ||
14 | app:layout_constraintLeft_toLeftOf="parent" | ||
15 | app:layout_constraintTop_toTopOf="parent" | ||
16 | app:layout_constraintBottom_toTopOf="@id/cl_1" | ||
17 | /> | ||
18 | |||
19 | |||
20 | <androidx.constraintlayout.widget.ConstraintLayout | ||
21 | android:id="@+id/cl_1" | ||
22 | android:layout_width="match_parent" | ||
23 | android:layout_height="50dp" | ||
24 | app:layout_constraintBottom_toBottomOf="parent" | ||
25 | android:background="@drawable/bg_solid_white_20" | ||
26 | > | ||
27 | |||
28 | <View | ||
29 | android:id="@+id/view_5" | ||
30 | android:layout_width="1dp" | ||
31 | android:layout_height="1dp" | ||
32 | app:layout_constraintLeft_toLeftOf="parent" | ||
33 | app:layout_constraintRight_toRightOf="parent" | ||
34 | app:layout_constraintBottom_toBottomOf="parent" | ||
35 | /> | ||
36 | |||
37 | <androidx.constraintlayout.widget.ConstraintLayout | ||
38 | android:id="@+id/cl_home" | ||
39 | android:layout_width="0dp" | ||
40 | android:layout_height="0dp" | ||
41 | app:layout_constraintLeft_toLeftOf="parent" | ||
42 | app:layout_constraintBottom_toBottomOf="parent" | ||
43 | app:layout_constraintTop_toTopOf="@id/cl_1" | ||
44 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
45 | > | ||
46 | <ImageView | ||
47 | android:id="@+id/iv_3" | ||
48 | android:layout_width="27dp" | ||
49 | android:layout_height="24dp" | ||
50 | app:layout_constraintLeft_toLeftOf="parent" | ||
51 | app:layout_constraintRight_toRightOf="parent" | ||
52 | app:layout_constraintTop_toTopOf="parent" | ||
53 | android:layout_marginTop="5dp" | ||
54 | android:background="@mipmap/hous" | ||
55 | /> | ||
56 | |||
57 | <TextView | ||
58 | android:id="@+id/tv_1" | ||
59 | android:layout_width="wrap_content" | ||
60 | android:layout_height="wrap_content" | ||
61 | app:layout_constraintLeft_toLeftOf="parent" | ||
62 | app:layout_constraintRight_toRightOf="parent" | ||
63 | app:layout_constraintTop_toBottomOf="@id/iv_3" | ||
64 | android:layout_marginTop="5dp" | ||
65 | android:textSize="11dp" | ||
66 | android:textColor="@drawable/select_t_1" | ||
67 | android:text="首页" | ||
68 | /> | ||
69 | |||
70 | |||
71 | </androidx.constraintlayout.widget.ConstraintLayout> | ||
72 | <androidx.constraintlayout.widget.ConstraintLayout | ||
73 | android:id="@+id/cl_me" | ||
74 | android:layout_width="0dp" | ||
75 | android:layout_height="0dp" | ||
76 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
77 | app:layout_constraintBottom_toBottomOf="parent" | ||
78 | app:layout_constraintTop_toTopOf="@id/cl_1" | ||
79 | app:layout_constraintRight_toRightOf="parent" | ||
80 | > | ||
81 | <ImageView | ||
82 | android:id="@+id/iv_4" | ||
83 | android:layout_width="22dp" | ||
84 | android:layout_height="25dp" | ||
85 | app:layout_constraintLeft_toLeftOf="parent" | ||
86 | app:layout_constraintRight_toRightOf="parent" | ||
87 | app:layout_constraintTop_toTopOf="parent" | ||
88 | android:layout_marginTop="5dp" | ||
89 | android:background="@mipmap/wmus" | ||
90 | /> | ||
91 | |||
92 | <TextView | ||
93 | android:id="@+id/tv_4" | ||
94 | android:layout_width="wrap_content" | ||
95 | android:layout_height="wrap_content" | ||
96 | app:layout_constraintLeft_toLeftOf="parent" | ||
97 | app:layout_constraintRight_toRightOf="parent" | ||
98 | app:layout_constraintTop_toBottomOf="@id/iv_4" | ||
99 | android:layout_marginTop="5dp" | ||
100 | android:textSize="11dp" | ||
101 | android:textColor="@drawable/select_t_1" | ||
102 | android:text="我的" | ||
103 | /> | ||
104 | |||
105 | </androidx.constraintlayout.widget.ConstraintLayout> | ||
106 | |||
107 | |||
108 | |||
109 | </androidx.constraintlayout.widget.ConstraintLayout> | ||
110 | |||
111 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_me.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="关于我们" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:id="@+id/iv_back" | ||
29 | android:layout_width="10dp" | ||
30 | android:layout_height="16dp" | ||
31 | app:layout_constraintLeft_toLeftOf="parent" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | android:layout_marginLeft="15dp" | ||
35 | android:background="@mipmap/icon_back" | ||
36 | /> | ||
37 | <View | ||
38 | android:layout_width="match_parent" | ||
39 | android:layout_height="1dp" | ||
40 | android:background="#EEEEEE" | ||
41 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
42 | /> | ||
43 | |||
44 | <View | ||
45 | android:id="@+id/view_3" | ||
46 | android:layout_width="345dp" | ||
47 | android:layout_height="68dp" | ||
48 | android:background="@drawable/bg_solid_white_10" | ||
49 | app:layout_constraintLeft_toLeftOf="parent" | ||
50 | app:layout_constraintRight_toRightOf="parent" | ||
51 | app:layout_constraintTop_toTopOf="parent" | ||
52 | android:layout_marginTop="90dp" | ||
53 | /> | ||
54 | <TextView | ||
55 | android:layout_width="wrap_content" | ||
56 | android:layout_height="wrap_content" | ||
57 | android:text="我们的官网" | ||
58 | android:textColor="#333333" | ||
59 | android:textSize="15dp" | ||
60 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
61 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
62 | android:layout_marginLeft="15dp" | ||
63 | android:layout_marginTop="15dp" | ||
64 | /> | ||
65 | <TextView | ||
66 | android:layout_width="wrap_content" | ||
67 | android:layout_height="wrap_content" | ||
68 | android:text="www.hjx.com" | ||
69 | android:textColor="#666666" | ||
70 | android:textSize="13dp" | ||
71 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
72 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
73 | android:layout_marginLeft="15dp" | ||
74 | android:layout_marginBottom="15dp" | ||
75 | /> | ||
76 | |||
77 | <View | ||
78 | android:id="@+id/view_4" | ||
79 | android:layout_width="345dp" | ||
80 | android:layout_height="111dp" | ||
81 | android:background="@drawable/bg_solid_white_10" | ||
82 | app:layout_constraintLeft_toLeftOf="parent" | ||
83 | app:layout_constraintRight_toRightOf="parent" | ||
84 | app:layout_constraintTop_toTopOf="parent" | ||
85 | android:layout_marginTop="173dp" | ||
86 | /> | ||
87 | <TextView | ||
88 | android:layout_width="wrap_content" | ||
89 | android:layout_height="wrap_content" | ||
90 | android:text="联系我们" | ||
91 | android:textColor="#333333" | ||
92 | android:textSize="15dp" | ||
93 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
94 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
95 | android:layout_marginLeft="15dp" | ||
96 | android:layout_marginTop="15dp" | ||
97 | /> | ||
98 | <TextView | ||
99 | android:id="@+id/tv_3" | ||
100 | android:layout_width="wrap_content" | ||
101 | android:layout_height="wrap_content" | ||
102 | android:text="邮箱: www.info@hjx.com" | ||
103 | android:textColor="#666666" | ||
104 | android:textSize="15dp" | ||
105 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
106 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
107 | android:layout_marginLeft="15dp" | ||
108 | android:layout_marginTop="44dp" | ||
109 | /> | ||
110 | <TextView | ||
111 | android:id="@+id/tv_4" | ||
112 | android:layout_width="wrap_content" | ||
113 | android:layout_height="wrap_content" | ||
114 | android:text="客服电话: 400-800-3813" | ||
115 | android:textColor="#666666" | ||
116 | android:textSize="15dp" | ||
117 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
118 | app:layout_constraintTop_toBottomOf="@id/tv_3" | ||
119 | android:layout_marginLeft="15dp" | ||
120 | /> | ||
121 | <TextView | ||
122 | android:layout_width="wrap_content" | ||
123 | android:layout_height="wrap_content" | ||
124 | android:text="地址: 上海市徐汇区桂箐路65号新研大厦B座701室" | ||
125 | android:textColor="#666666" | ||
126 | android:textSize="15dp" | ||
127 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
128 | app:layout_constraintTop_toBottomOf="@id/tv_4" | ||
129 | android:layout_marginLeft="15dp" | ||
130 | /> | ||
131 | |||
132 | <View | ||
133 | android:id="@+id/view_5" | ||
134 | android:layout_width="345dp" | ||
135 | android:layout_height="132dp" | ||
136 | android:background="@drawable/bg_solid_white_10" | ||
137 | app:layout_constraintLeft_toLeftOf="parent" | ||
138 | app:layout_constraintRight_toRightOf="parent" | ||
139 | app:layout_constraintTop_toTopOf="parent" | ||
140 | android:layout_marginTop="299dp" | ||
141 | /> | ||
142 | <TextView | ||
143 | android:layout_width="wrap_content" | ||
144 | android:layout_height="wrap_content" | ||
145 | android:text="官方微信公众号" | ||
146 | android:textColor="#333333" | ||
147 | android:textSize="15dp" | ||
148 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
149 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
150 | android:layout_marginLeft="15dp" | ||
151 | android:layout_marginTop="15dp" | ||
152 | /> | ||
153 | |||
154 | <ImageView | ||
155 | android:layout_width="73dp" | ||
156 | android:layout_height="73dp" | ||
157 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
158 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
159 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
160 | android:layout_marginBottom="15dp" | ||
161 | android:background="@mipmap/eco" | ||
162 | /> | ||
163 | |||
164 | |||
165 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_qr.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="扫码登陆" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:id="@+id/iv_back" | ||
29 | android:layout_width="10dp" | ||
30 | android:layout_height="16dp" | ||
31 | app:layout_constraintLeft_toLeftOf="parent" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | android:layout_marginLeft="15dp" | ||
35 | android:background="@mipmap/icon_back" | ||
36 | /> | ||
37 | <View | ||
38 | android:layout_width="match_parent" | ||
39 | android:layout_height="1dp" | ||
40 | android:background="#EEEEEE" | ||
41 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
42 | /> | ||
43 | <FrameLayout | ||
44 | android:id="@+id/rl_content" | ||
45 | android:layout_width="match_parent" | ||
46 | android:layout_height="0dp" | ||
47 | app:layout_constraintBottom_toBottomOf="parent" | ||
48 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
49 | |||
50 | /> | ||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_register.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="@mipmap/bg" | ||
7 | > | ||
8 | |||
9 | |||
10 | |||
11 | <TextView | ||
12 | android:layout_width="wrap_content" | ||
13 | android:layout_height="wrap_content" | ||
14 | android:text="注册" | ||
15 | android:textColor="#333333" | ||
16 | android:textStyle="bold" | ||
17 | android:textSize="25dp" | ||
18 | android:layout_marginLeft="30dp" | ||
19 | android:layout_marginTop="64dp" | ||
20 | app:layout_constraintLeft_toLeftOf="parent" | ||
21 | app:layout_constraintTop_toTopOf="parent" | ||
22 | /> | ||
23 | |||
24 | <View | ||
25 | android:id="@+id/view_1" | ||
26 | android:layout_width="315dp" | ||
27 | android:layout_height="50dp" | ||
28 | app:layout_constraintLeft_toLeftOf="parent" | ||
29 | app:layout_constraintRight_toRightOf="parent" | ||
30 | app:layout_constraintTop_toTopOf="parent" | ||
31 | android:layout_marginTop="166dp" | ||
32 | android:background="@drawable/bg_solid_white" | ||
33 | /> | ||
34 | |||
35 | <ImageView | ||
36 | android:id="@+id/iv_1" | ||
37 | android:layout_width="16dp" | ||
38 | android:layout_height="18dp" | ||
39 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
40 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
41 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
42 | android:background="@mipmap/sjh" | ||
43 | android:layout_marginLeft="20dp" | ||
44 | /> | ||
45 | |||
46 | <ImageView | ||
47 | android:id="@+id/iv_2" | ||
48 | android:layout_width="13dp" | ||
49 | android:layout_height="13dp" | ||
50 | android:background="@mipmap/sc" | ||
51 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
52 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
53 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
54 | android:layout_marginRight="20dp" | ||
55 | /> | ||
56 | |||
57 | <EditText | ||
58 | android:id="@+id/et_phone" | ||
59 | android:layout_width="0dp" | ||
60 | android:layout_height="0dp" | ||
61 | android:background="@android:color/transparent" | ||
62 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
63 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
64 | app:layout_constraintRight_toLeftOf="@id/iv_2" | ||
65 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
66 | android:textColorHint="#999999" | ||
67 | android:hint="请输入手机号" | ||
68 | android:textSize="16dp" | ||
69 | android:gravity="left|center_vertical" | ||
70 | android:inputType="number" | ||
71 | android:layout_marginLeft="46dp" | ||
72 | android:maxLength="11" | ||
73 | android:textColor="#333333" | ||
74 | /> | ||
75 | |||
76 | |||
77 | <View | ||
78 | android:id="@+id/view_2" | ||
79 | android:layout_width="315dp" | ||
80 | android:layout_height="50dp" | ||
81 | app:layout_constraintLeft_toLeftOf="parent" | ||
82 | app:layout_constraintRight_toRightOf="parent" | ||
83 | app:layout_constraintTop_toTopOf="parent" | ||
84 | android:layout_marginTop="241dp" | ||
85 | android:background="@drawable/bg_solid_white" | ||
86 | /> | ||
87 | |||
88 | <ImageView | ||
89 | android:id="@+id/iv_3" | ||
90 | android:layout_width="16dp" | ||
91 | android:layout_height="18dp" | ||
92 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
93 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
94 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
95 | android:background="@mipmap/mm" | ||
96 | android:layout_marginLeft="20dp" | ||
97 | /> | ||
98 | |||
99 | <ImageView | ||
100 | android:id="@+id/iv_4" | ||
101 | android:layout_width="20dp" | ||
102 | android:layout_height="16dp" | ||
103 | android:background="@mipmap/xs" | ||
104 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
105 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
106 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
107 | android:layout_marginRight="20dp" | ||
108 | /> | ||
109 | |||
110 | <EditText | ||
111 | android:id="@+id/et_pwd" | ||
112 | android:layout_width="0dp" | ||
113 | android:layout_height="0dp" | ||
114 | android:background="@android:color/transparent" | ||
115 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
116 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
117 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
118 | app:layout_constraintRight_toLeftOf="@id/iv_4" | ||
119 | android:layout_marginLeft="46dp" | ||
120 | android:textColorHint="#999999" | ||
121 | android:hint="请输入密码" | ||
122 | android:textSize="16dp" | ||
123 | android:gravity="left|center_vertical" | ||
124 | android:inputType="textPassword" | ||
125 | android:layout_marginRight="20dp" | ||
126 | android:textColor="#333333" | ||
127 | /> | ||
128 | |||
129 | |||
130 | <View | ||
131 | android:id="@+id/view_3" | ||
132 | android:layout_width="315dp" | ||
133 | android:layout_height="50dp" | ||
134 | app:layout_constraintLeft_toLeftOf="parent" | ||
135 | app:layout_constraintRight_toRightOf="parent" | ||
136 | app:layout_constraintTop_toTopOf="parent" | ||
137 | android:layout_marginTop="316dp" | ||
138 | android:background="@drawable/bg_solid_white" | ||
139 | /> | ||
140 | |||
141 | <ImageView | ||
142 | android:id="@+id/iv_5" | ||
143 | android:layout_width="16dp" | ||
144 | android:layout_height="18dp" | ||
145 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
146 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
147 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
148 | android:background="@mipmap/mm" | ||
149 | android:layout_marginLeft="20dp" | ||
150 | /> | ||
151 | |||
152 | <ImageView | ||
153 | android:id="@+id/iv_6" | ||
154 | android:layout_width="20dp" | ||
155 | android:layout_height="16dp" | ||
156 | android:background="@mipmap/xs" | ||
157 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
158 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
159 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
160 | android:layout_marginRight="20dp" | ||
161 | /> | ||
162 | |||
163 | <EditText | ||
164 | android:id="@+id/et_pwd_2" | ||
165 | android:layout_width="0dp" | ||
166 | android:layout_height="0dp" | ||
167 | android:background="@android:color/transparent" | ||
168 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
169 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
170 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
171 | app:layout_constraintRight_toLeftOf="@id/iv_6" | ||
172 | android:layout_marginLeft="46dp" | ||
173 | android:textColorHint="#999999" | ||
174 | android:hint="再次输入密码" | ||
175 | android:textSize="16dp" | ||
176 | android:gravity="left|center_vertical" | ||
177 | android:inputType="textPassword" | ||
178 | android:layout_marginRight="20dp" | ||
179 | android:textColor="#333333" | ||
180 | /> | ||
181 | <TextView | ||
182 | android:layout_width="wrap_content" | ||
183 | android:layout_height="wrap_content" | ||
184 | app:layout_constraintTop_toBottomOf="@id/view_3" | ||
185 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
186 | android:layout_marginLeft="45dp" | ||
187 | android:layout_marginTop="10dp" | ||
188 | android:textSize="13dp" | ||
189 | android:text="6-16位密码,数字或字母" | ||
190 | android:textColor="#999999" | ||
191 | /> | ||
192 | |||
193 | <Button | ||
194 | android:id="@+id/btn_1" | ||
195 | android:layout_width="315dp" | ||
196 | android:layout_height="50dp" | ||
197 | app:layout_constraintLeft_toLeftOf="parent" | ||
198 | app:layout_constraintRight_toRightOf="parent" | ||
199 | app:layout_constraintTop_toTopOf="parent" | ||
200 | android:layout_marginTop="428dp" | ||
201 | android:background="@drawable/bg_solid_btn" | ||
202 | android:textColor="@color/white" | ||
203 | android:textSize="18dp" | ||
204 | android:text="注册" | ||
205 | /> | ||
206 | <TextView | ||
207 | android:id="@+id/tv_1" | ||
208 | android:layout_width="wrap_content" | ||
209 | android:layout_height="wrap_content" | ||
210 | android:text="已有账号,立即" | ||
211 | android:textColor="#666666" | ||
212 | android:textSize="17dp" | ||
213 | app:layout_constraintLeft_toLeftOf="@id/btn_1" | ||
214 | app:layout_constraintTop_toBottomOf="@id/btn_1" | ||
215 | android:layout_marginLeft="85dp" | ||
216 | android:layout_marginTop="15dp" | ||
217 | /> | ||
218 | <TextView | ||
219 | android:id="@+id/tv_2" | ||
220 | android:layout_width="wrap_content" | ||
221 | android:layout_height="wrap_content" | ||
222 | android:text="登陆" | ||
223 | android:textColor="#FE5E09" | ||
224 | android:textSize="17dp" | ||
225 | app:layout_constraintLeft_toRightOf="@id/tv_1" | ||
226 | app:layout_constraintTop_toBottomOf="@id/btn_1" | ||
227 | android:layout_marginTop="15dp" | ||
228 | /> | ||
229 | |||
230 | |||
231 | <CheckBox | ||
232 | android:id="@+id/cb_1" | ||
233 | android:layout_width="13dp" | ||
234 | android:layout_height="13dp" | ||
235 | app:layout_constraintBottom_toBottomOf="parent" | ||
236 | app:layout_constraintLeft_toLeftOf="parent" | ||
237 | android:layout_marginLeft="67dp" | ||
238 | android:layout_marginBottom="50dp" | ||
239 | android:background="@android:color/transparent" | ||
240 | android:button="@drawable/checked_xc" | ||
241 | /> | ||
242 | <TextView | ||
243 | android:id="@+id/tv_3" | ||
244 | android:layout_width="wrap_content" | ||
245 | android:layout_height="wrap_content" | ||
246 | android:text="已阅读并同意《" | ||
247 | android:textColor="#999999" | ||
248 | android:textSize="12dp" | ||
249 | app:layout_constraintLeft_toRightOf="@id/cb_1" | ||
250 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
251 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
252 | android:layout_marginLeft="5dp" | ||
253 | /> | ||
254 | <TextView | ||
255 | android:id="@+id/tv_4" | ||
256 | android:layout_width="wrap_content" | ||
257 | android:layout_height="wrap_content" | ||
258 | android:text="用户协议" | ||
259 | android:textColor="#FE5E09" | ||
260 | android:textSize="12dp" | ||
261 | app:layout_constraintLeft_toRightOf="@id/tv_3" | ||
262 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
263 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
264 | /> | ||
265 | <TextView | ||
266 | android:id="@+id/tv_5" | ||
267 | android:layout_width="wrap_content" | ||
268 | android:layout_height="wrap_content" | ||
269 | android:text="》和《" | ||
270 | android:textColor="#999999" | ||
271 | android:textSize="12dp" | ||
272 | app:layout_constraintLeft_toRightOf="@id/tv_4" | ||
273 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
274 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
275 | /> | ||
276 | <TextView | ||
277 | android:id="@+id/tv_6" | ||
278 | android:layout_width="wrap_content" | ||
279 | android:layout_height="wrap_content" | ||
280 | android:text="隐私政策" | ||
281 | android:textColor="#FE5E09" | ||
282 | android:textSize="12dp" | ||
283 | app:layout_constraintLeft_toRightOf="@id/tv_5" | ||
284 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
285 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
286 | /> | ||
287 | <TextView | ||
288 | android:id="@+id/tv_7" | ||
289 | android:layout_width="wrap_content" | ||
290 | android:layout_height="wrap_content" | ||
291 | android:text="》" | ||
292 | android:textColor="#999999" | ||
293 | android:textSize="12dp" | ||
294 | app:layout_constraintLeft_toRightOf="@id/tv_6" | ||
295 | app:layout_constraintTop_toTopOf="@id/cb_1" | ||
296 | app:layout_constraintBottom_toBottomOf="@id/cb_1" | ||
297 | /> | ||
298 | |||
299 | |||
300 | |||
301 | |||
302 | |||
303 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_sao.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="扫码登陆" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:layout_width="10dp" | ||
29 | android:layout_height="16dp" | ||
30 | app:layout_constraintLeft_toLeftOf="parent" | ||
31 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
32 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
33 | android:layout_marginLeft="15dp" | ||
34 | android:background="@mipmap/icon_back" | ||
35 | /> | ||
36 | |||
37 | |||
38 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_select_stu.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="选择学生" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | |||
28 | |||
29 | <Button | ||
30 | android:layout_width="180dp" | ||
31 | android:layout_height="40dp" | ||
32 | app:layout_constraintLeft_toLeftOf="parent" | ||
33 | app:layout_constraintRight_toRightOf="parent" | ||
34 | app:layout_constraintTop_toTopOf="parent" | ||
35 | android:layout_marginTop="500dp" | ||
36 | android:background="@drawable/bg_solid_btn" | ||
37 | android:text="确认" | ||
38 | android:textColor="#FFFFFF" | ||
39 | android:textSize="16dp" | ||
40 | /> | ||
41 | |||
42 | |||
43 | |||
44 | |||
45 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_set_jia.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="家长身份" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <TextView | ||
28 | android:id="@+id/tv_cancel" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:layout_height="wrap_content" | ||
31 | android:text="取消" | ||
32 | android:textColor="#666666" | ||
33 | android:textSize="16dp" | ||
34 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
35 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
36 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
37 | android:layout_marginLeft="15dp" | ||
38 | /> | ||
39 | <TextView | ||
40 | android:id="@+id/tv_ok" | ||
41 | android:layout_width="wrap_content" | ||
42 | android:layout_height="wrap_content" | ||
43 | android:text="确认" | ||
44 | android:textColor="#FE5E09" | ||
45 | android:textSize="16dp" | ||
46 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
47 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
48 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
49 | android:layout_marginRight="15dp" | ||
50 | /> | ||
51 | <TextView | ||
52 | android:layout_width="wrap_content" | ||
53 | android:layout_height="wrap_content" | ||
54 | android:text="请选择身份" | ||
55 | app:layout_constraintBottom_toTopOf="@id/view_2" | ||
56 | android:layout_marginBottom="15dp" | ||
57 | app:layout_constraintLeft_toLeftOf="parent" | ||
58 | android:layout_marginLeft="15dp" | ||
59 | android:textColor="#666666" | ||
60 | android:textSize="16dp" | ||
61 | /> | ||
62 | |||
63 | <View | ||
64 | android:id="@+id/view_2" | ||
65 | android:layout_width="345dp" | ||
66 | android:layout_height="50dp" | ||
67 | android:background="@drawable/bg_solid_white_10" | ||
68 | app:layout_constraintLeft_toLeftOf="parent" | ||
69 | app:layout_constraintRight_toRightOf="parent" | ||
70 | app:layout_constraintTop_toTopOf="parent" | ||
71 | android:layout_marginTop="109dp" | ||
72 | /> | ||
73 | |||
74 | |||
75 | <TextView | ||
76 | android:layout_width="wrap_content" | ||
77 | android:layout_height="wrap_content" | ||
78 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
79 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
80 | app:layout_constraintTop_toTopOf="@+id/view_2" | ||
81 | app:layout_constraintBottom_toBottomOf="@+id/view_2" | ||
82 | android:textColor="#333333" | ||
83 | android:textSize="16dp" | ||
84 | android:text="爸爸" | ||
85 | /> | ||
86 | |||
87 | <ImageView | ||
88 | android:id="@+id/iv_1" | ||
89 | android:layout_width="13dp" | ||
90 | android:layout_height="13dp" | ||
91 | android:background="@mipmap/wsyq" | ||
92 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
93 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
94 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
95 | android:layout_marginRight="20dp" | ||
96 | /> | ||
97 | |||
98 | <View | ||
99 | android:id="@+id/view_3" | ||
100 | android:layout_width="345dp" | ||
101 | android:layout_height="50dp" | ||
102 | android:background="@drawable/bg_solid_white_10" | ||
103 | app:layout_constraintLeft_toLeftOf="parent" | ||
104 | app:layout_constraintRight_toRightOf="parent" | ||
105 | app:layout_constraintTop_toTopOf="parent" | ||
106 | android:layout_marginTop="175dp" | ||
107 | /> | ||
108 | |||
109 | |||
110 | <TextView | ||
111 | android:layout_width="wrap_content" | ||
112 | android:layout_height="wrap_content" | ||
113 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
114 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
115 | app:layout_constraintTop_toTopOf="@+id/view_3" | ||
116 | app:layout_constraintBottom_toBottomOf="@+id/view_3" | ||
117 | android:textColor="#333333" | ||
118 | android:textSize="16dp" | ||
119 | android:text="妈妈" | ||
120 | /> | ||
121 | |||
122 | <ImageView | ||
123 | android:id="@+id/iv_2" | ||
124 | android:layout_width="13dp" | ||
125 | android:layout_height="13dp" | ||
126 | android:background="@mipmap/wsyq" | ||
127 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
128 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
129 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
130 | android:layout_marginRight="20dp" | ||
131 | /> | ||
132 | <View | ||
133 | android:id="@+id/view_4" | ||
134 | android:layout_width="345dp" | ||
135 | android:layout_height="50dp" | ||
136 | android:background="@drawable/bg_solid_white_10" | ||
137 | app:layout_constraintLeft_toLeftOf="parent" | ||
138 | app:layout_constraintRight_toRightOf="parent" | ||
139 | app:layout_constraintTop_toTopOf="parent" | ||
140 | android:layout_marginTop="240dp" | ||
141 | /> | ||
142 | |||
143 | |||
144 | <TextView | ||
145 | android:layout_width="wrap_content" | ||
146 | android:layout_height="wrap_content" | ||
147 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
148 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
149 | app:layout_constraintTop_toTopOf="@+id/view_4" | ||
150 | app:layout_constraintBottom_toBottomOf="@+id/view_4" | ||
151 | android:textColor="#333333" | ||
152 | android:textSize="16dp" | ||
153 | android:text="爷爷" | ||
154 | /> | ||
155 | |||
156 | <ImageView | ||
157 | android:id="@+id/iv_3" | ||
158 | android:layout_width="13dp" | ||
159 | android:layout_height="13dp" | ||
160 | android:background="@mipmap/wsyq" | ||
161 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
162 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
163 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
164 | android:layout_marginRight="20dp" | ||
165 | /> | ||
166 | <View | ||
167 | android:id="@+id/view_5" | ||
168 | android:layout_width="345dp" | ||
169 | android:layout_height="50dp" | ||
170 | android:background="@drawable/bg_solid_white_10" | ||
171 | app:layout_constraintLeft_toLeftOf="parent" | ||
172 | app:layout_constraintRight_toRightOf="parent" | ||
173 | app:layout_constraintTop_toTopOf="parent" | ||
174 | android:layout_marginTop="304dp" | ||
175 | /> | ||
176 | |||
177 | |||
178 | <TextView | ||
179 | android:layout_width="wrap_content" | ||
180 | android:layout_height="wrap_content" | ||
181 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
182 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
183 | app:layout_constraintTop_toTopOf="@+id/view_5" | ||
184 | app:layout_constraintBottom_toBottomOf="@+id/view_5" | ||
185 | android:textColor="#333333" | ||
186 | android:textSize="16dp" | ||
187 | android:text="奶奶" | ||
188 | /> | ||
189 | |||
190 | <ImageView | ||
191 | android:id="@+id/iv_4" | ||
192 | android:layout_width="13dp" | ||
193 | android:layout_height="13dp" | ||
194 | android:background="@mipmap/wsyq" | ||
195 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
196 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
197 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
198 | android:layout_marginRight="20dp" | ||
199 | /> | ||
200 | <View | ||
201 | android:id="@+id/view_6" | ||
202 | android:layout_width="345dp" | ||
203 | android:layout_height="50dp" | ||
204 | android:background="@drawable/bg_solid_white_10" | ||
205 | app:layout_constraintLeft_toLeftOf="parent" | ||
206 | app:layout_constraintRight_toRightOf="parent" | ||
207 | app:layout_constraintTop_toTopOf="parent" | ||
208 | android:layout_marginTop="370dp" | ||
209 | /> | ||
210 | |||
211 | |||
212 | <TextView | ||
213 | android:layout_width="wrap_content" | ||
214 | android:layout_height="wrap_content" | ||
215 | app:layout_constraintLeft_toLeftOf="@id/view_6" | ||
216 | app:layout_constraintRight_toRightOf="@id/view_6" | ||
217 | app:layout_constraintTop_toTopOf="@+id/view_6" | ||
218 | app:layout_constraintBottom_toBottomOf="@+id/view_6" | ||
219 | android:textColor="#333333" | ||
220 | android:textSize="16dp" | ||
221 | android:text="外公" | ||
222 | /> | ||
223 | |||
224 | <ImageView | ||
225 | android:id="@+id/iv_5" | ||
226 | android:layout_width="13dp" | ||
227 | android:layout_height="13dp" | ||
228 | android:background="@mipmap/wsyq" | ||
229 | app:layout_constraintTop_toTopOf="@id/view_6" | ||
230 | app:layout_constraintBottom_toBottomOf="@id/view_6" | ||
231 | app:layout_constraintRight_toRightOf="@id/view_6" | ||
232 | android:layout_marginRight="20dp" | ||
233 | /> | ||
234 | <View | ||
235 | android:id="@+id/view_7" | ||
236 | android:layout_width="345dp" | ||
237 | android:layout_height="50dp" | ||
238 | android:background="@drawable/bg_solid_white_10" | ||
239 | app:layout_constraintLeft_toLeftOf="parent" | ||
240 | app:layout_constraintRight_toRightOf="parent" | ||
241 | app:layout_constraintTop_toTopOf="parent" | ||
242 | android:layout_marginTop="434dp" | ||
243 | /> | ||
244 | |||
245 | |||
246 | <TextView | ||
247 | android:layout_width="wrap_content" | ||
248 | android:layout_height="wrap_content" | ||
249 | app:layout_constraintLeft_toLeftOf="@id/view_7" | ||
250 | app:layout_constraintRight_toRightOf="@id/view_7" | ||
251 | app:layout_constraintTop_toTopOf="@+id/view_7" | ||
252 | app:layout_constraintBottom_toBottomOf="@+id/view_7" | ||
253 | android:textColor="#333333" | ||
254 | android:textSize="16dp" | ||
255 | android:text="外婆" | ||
256 | /> | ||
257 | |||
258 | <ImageView | ||
259 | android:id="@+id/iv_6" | ||
260 | android:layout_width="13dp" | ||
261 | android:layout_height="13dp" | ||
262 | android:background="@mipmap/wsyq" | ||
263 | app:layout_constraintTop_toTopOf="@id/view_7" | ||
264 | app:layout_constraintBottom_toBottomOf="@id/view_7" | ||
265 | app:layout_constraintRight_toRightOf="@id/view_7" | ||
266 | android:layout_marginRight="20dp" | ||
267 | /> | ||
268 | |||
269 | |||
270 | |||
271 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_set_nian.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="年级" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <TextView | ||
28 | android:id="@+id/tv_cancel" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:layout_height="wrap_content" | ||
31 | android:text="取消" | ||
32 | android:textColor="#666666" | ||
33 | android:textSize="16dp" | ||
34 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
35 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
36 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
37 | android:layout_marginLeft="15dp" | ||
38 | /> | ||
39 | <TextView | ||
40 | android:id="@+id/tv_ok" | ||
41 | android:layout_width="wrap_content" | ||
42 | android:layout_height="wrap_content" | ||
43 | android:text="确认" | ||
44 | android:textColor="#FE5E09" | ||
45 | android:textSize="16dp" | ||
46 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
47 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
48 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
49 | android:layout_marginRight="15dp" | ||
50 | /> | ||
51 | <TextView | ||
52 | android:layout_width="wrap_content" | ||
53 | android:layout_height="wrap_content" | ||
54 | android:text="请选择年级" | ||
55 | app:layout_constraintBottom_toTopOf="@id/view_2" | ||
56 | android:layout_marginBottom="15dp" | ||
57 | app:layout_constraintLeft_toLeftOf="parent" | ||
58 | android:layout_marginLeft="15dp" | ||
59 | android:textColor="#666666" | ||
60 | android:textSize="16dp" | ||
61 | /> | ||
62 | |||
63 | <View | ||
64 | android:id="@+id/view_2" | ||
65 | android:layout_width="345dp" | ||
66 | android:layout_height="50dp" | ||
67 | android:background="@drawable/bg_solid_white_10" | ||
68 | app:layout_constraintLeft_toLeftOf="parent" | ||
69 | app:layout_constraintRight_toRightOf="parent" | ||
70 | app:layout_constraintTop_toTopOf="parent" | ||
71 | android:layout_marginTop="109dp" | ||
72 | /> | ||
73 | |||
74 | |||
75 | <TextView | ||
76 | android:id="@+id/tv_nian" | ||
77 | android:layout_width="wrap_content" | ||
78 | android:layout_height="wrap_content" | ||
79 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
80 | app:layout_constraintTop_toTopOf="@+id/view_2" | ||
81 | app:layout_constraintBottom_toBottomOf="@+id/view_2" | ||
82 | android:textColor="#333333" | ||
83 | android:textSize="16dp" | ||
84 | android:text="一年纪" | ||
85 | android:layout_marginLeft="15dp" | ||
86 | /> | ||
87 | |||
88 | <ImageView | ||
89 | android:layout_width="5.5dp" | ||
90 | android:layout_height="9.5dp" | ||
91 | android:background="@mipmap/ycaj" | ||
92 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
93 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
94 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
95 | android:layout_marginRight="15dp" | ||
96 | /> | ||
97 | |||
98 | <TextView | ||
99 | android:layout_width="wrap_content" | ||
100 | android:layout_height="wrap_content" | ||
101 | android:text="请选择学期" | ||
102 | app:layout_constraintBottom_toTopOf="@id/view_3" | ||
103 | android:layout_marginBottom="15dp" | ||
104 | app:layout_constraintLeft_toLeftOf="parent" | ||
105 | android:layout_marginLeft="15dp" | ||
106 | android:textColor="#666666" | ||
107 | android:textSize="16dp" | ||
108 | /> | ||
109 | |||
110 | <View | ||
111 | android:id="@+id/view_3" | ||
112 | android:layout_width="345dp" | ||
113 | android:layout_height="50dp" | ||
114 | android:background="@drawable/bg_solid_white_10" | ||
115 | app:layout_constraintLeft_toLeftOf="parent" | ||
116 | app:layout_constraintRight_toRightOf="parent" | ||
117 | app:layout_constraintTop_toTopOf="parent" | ||
118 | android:layout_marginTop="209dp" | ||
119 | /> | ||
120 | |||
121 | <ImageView | ||
122 | android:layout_width="5.5dp" | ||
123 | android:layout_height="9.5dp" | ||
124 | android:background="@mipmap/ycaj" | ||
125 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
126 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
127 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
128 | android:layout_marginRight="15dp" | ||
129 | /> | ||
130 | |||
131 | <TextView | ||
132 | android:id="@+id/tv_xq" | ||
133 | android:layout_width="wrap_content" | ||
134 | android:layout_height="wrap_content" | ||
135 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
136 | app:layout_constraintTop_toTopOf="@+id/view_3" | ||
137 | app:layout_constraintBottom_toBottomOf="@+id/view_3" | ||
138 | android:textColor="#333333" | ||
139 | android:textSize="16dp" | ||
140 | android:text="上学期" | ||
141 | android:layout_marginLeft="15dp" | ||
142 | /> | ||
143 | |||
144 | |||
145 | |||
146 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_set_nick.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="昵称" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <TextView | ||
28 | android:id="@+id/tv_cancel" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:layout_height="wrap_content" | ||
31 | android:text="取消" | ||
32 | android:textColor="#666666" | ||
33 | android:textSize="16dp" | ||
34 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
35 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
36 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
37 | android:layout_marginLeft="15dp" | ||
38 | /> | ||
39 | <TextView | ||
40 | android:id="@+id/tv_ok" | ||
41 | android:layout_width="wrap_content" | ||
42 | android:layout_height="wrap_content" | ||
43 | android:text="确认" | ||
44 | android:textColor="#FE5E09" | ||
45 | android:textSize="16dp" | ||
46 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
47 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
48 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
49 | android:layout_marginRight="15dp" | ||
50 | /> | ||
51 | |||
52 | |||
53 | <View | ||
54 | android:id="@+id/view_3" | ||
55 | android:layout_width="345dp" | ||
56 | android:layout_height="50dp" | ||
57 | android:background="@drawable/bg_solid_white_10" | ||
58 | app:layout_constraintLeft_toLeftOf="parent" | ||
59 | app:layout_constraintRight_toRightOf="parent" | ||
60 | app:layout_constraintTop_toTopOf="parent" | ||
61 | android:layout_marginTop="109dp" | ||
62 | /> | ||
63 | <EditText | ||
64 | android:id="@+id/et_1" | ||
65 | android:layout_width="0dp" | ||
66 | android:layout_height="0dp" | ||
67 | app:layout_constraintLeft_toLeftOf="@+id/view_3" | ||
68 | app:layout_constraintRight_toRightOf="@+id/view_3" | ||
69 | app:layout_constraintTop_toTopOf="@+id/view_3" | ||
70 | app:layout_constraintBottom_toBottomOf="@+id/view_3" | ||
71 | android:layout_marginLeft="5dp" | ||
72 | android:layout_marginRight="5dp" | ||
73 | android:textSize="16dp" | ||
74 | android:textColorHint="#999999" | ||
75 | android:hint="请设置2-10个字符,不包括无效字符" | ||
76 | android:textColor="#333333" | ||
77 | /> | ||
78 | |||
79 | <TextView | ||
80 | android:layout_width="wrap_content" | ||
81 | android:layout_height="wrap_content" | ||
82 | android:text="请输入昵称" | ||
83 | app:layout_constraintBottom_toTopOf="@id/et_1" | ||
84 | android:layout_marginBottom="15dp" | ||
85 | app:layout_constraintLeft_toLeftOf="parent" | ||
86 | android:layout_marginLeft="15dp" | ||
87 | /> | ||
88 | |||
89 | |||
90 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_set_sex.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="性别" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <TextView | ||
28 | android:id="@+id/tv_cancel" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:layout_height="wrap_content" | ||
31 | android:text="取消" | ||
32 | android:textColor="#666666" | ||
33 | android:textSize="16dp" | ||
34 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
35 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
36 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
37 | android:layout_marginLeft="15dp" | ||
38 | /> | ||
39 | <TextView | ||
40 | android:id="@+id/tv_ok" | ||
41 | android:layout_width="wrap_content" | ||
42 | android:layout_height="wrap_content" | ||
43 | android:text="确认" | ||
44 | android:textColor="#FE5E09" | ||
45 | android:textSize="16dp" | ||
46 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
47 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
48 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
49 | android:layout_marginRight="15dp" | ||
50 | /> | ||
51 | |||
52 | |||
53 | <View | ||
54 | android:id="@+id/view_2" | ||
55 | android:layout_width="345dp" | ||
56 | android:layout_height="50dp" | ||
57 | android:background="@drawable/bg_solid_white_10" | ||
58 | app:layout_constraintLeft_toLeftOf="parent" | ||
59 | app:layout_constraintRight_toRightOf="parent" | ||
60 | app:layout_constraintTop_toTopOf="parent" | ||
61 | android:layout_marginTop="109dp" | ||
62 | /> | ||
63 | |||
64 | <ImageView | ||
65 | android:id="@+id/cb_1" | ||
66 | android:layout_width="13dp" | ||
67 | android:layout_height="13dp" | ||
68 | android:background="@mipmap/wsyq" | ||
69 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
70 | app:layout_constraintBottom_toBottomOf="@id/view_2" | ||
71 | app:layout_constraintRight_toRightOf="@id/view_2" | ||
72 | android:layout_marginRight="20dp" | ||
73 | /> | ||
74 | |||
75 | <ImageView | ||
76 | android:id="@+id/iv_1" | ||
77 | android:layout_width="10dp" | ||
78 | android:layout_height="14dp" | ||
79 | android:background="@mipmap/xb_nv" | ||
80 | app:layout_constraintTop_toTopOf="@+id/view_2" | ||
81 | app:layout_constraintBottom_toBottomOf="@+id/view_2" | ||
82 | app:layout_constraintLeft_toLeftOf="@+id/view_2" | ||
83 | android:layout_marginLeft="161dp" | ||
84 | /> | ||
85 | <TextView | ||
86 | android:layout_width="wrap_content" | ||
87 | android:layout_height="wrap_content" | ||
88 | app:layout_constraintLeft_toRightOf="@id/iv_1" | ||
89 | app:layout_constraintTop_toTopOf="@+id/iv_1" | ||
90 | app:layout_constraintBottom_toBottomOf="@+id/iv_1" | ||
91 | android:textColor="#333333" | ||
92 | android:textSize="16dp" | ||
93 | android:text="女" | ||
94 | android:layout_marginLeft="5dp" | ||
95 | /> | ||
96 | |||
97 | <TextView | ||
98 | android:layout_width="wrap_content" | ||
99 | android:layout_height="wrap_content" | ||
100 | android:text="请选择性别" | ||
101 | app:layout_constraintBottom_toTopOf="@id/view_2" | ||
102 | android:layout_marginBottom="15dp" | ||
103 | app:layout_constraintLeft_toLeftOf="parent" | ||
104 | android:layout_marginLeft="15dp" | ||
105 | android:textColor="#666666" | ||
106 | android:textSize="16dp" | ||
107 | /> | ||
108 | |||
109 | <View | ||
110 | android:id="@+id/view_3" | ||
111 | android:layout_width="345dp" | ||
112 | android:layout_height="50dp" | ||
113 | android:background="@drawable/bg_solid_white_10" | ||
114 | app:layout_constraintLeft_toLeftOf="parent" | ||
115 | app:layout_constraintRight_toRightOf="parent" | ||
116 | app:layout_constraintTop_toTopOf="parent" | ||
117 | android:layout_marginTop="174dp" | ||
118 | /> | ||
119 | |||
120 | <ImageView | ||
121 | android:id="@+id/cb_2" | ||
122 | android:layout_width="13dp" | ||
123 | android:layout_height="13dp" | ||
124 | android:background="@mipmap/wsyq" | ||
125 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
126 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
127 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
128 | android:layout_marginRight="20dp" | ||
129 | /> | ||
130 | <ImageView | ||
131 | android:id="@+id/iv_2" | ||
132 | android:layout_width="10dp" | ||
133 | android:layout_height="14dp" | ||
134 | android:background="@mipmap/xb_n" | ||
135 | app:layout_constraintTop_toTopOf="@+id/view_3" | ||
136 | app:layout_constraintBottom_toBottomOf="@+id/view_3" | ||
137 | app:layout_constraintLeft_toLeftOf="@+id/view_3" | ||
138 | android:layout_marginLeft="161dp" | ||
139 | /> | ||
140 | <TextView | ||
141 | android:layout_width="wrap_content" | ||
142 | android:layout_height="wrap_content" | ||
143 | app:layout_constraintLeft_toRightOf="@id/iv_2" | ||
144 | app:layout_constraintTop_toTopOf="@+id/iv_2" | ||
145 | app:layout_constraintBottom_toBottomOf="@+id/iv_2" | ||
146 | android:textColor="#333333" | ||
147 | android:textSize="16dp" | ||
148 | android:text="男" | ||
149 | android:layout_marginLeft="5dp" | ||
150 | /> | ||
151 | |||
152 | |||
153 | |||
154 | |||
155 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_setac.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="账号设置" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:id="@+id/iv_back" | ||
29 | android:layout_width="10dp" | ||
30 | android:layout_height="16dp" | ||
31 | app:layout_constraintLeft_toLeftOf="parent" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | android:layout_marginLeft="15dp" | ||
35 | android:background="@mipmap/icon_back" | ||
36 | /> | ||
37 | <View | ||
38 | android:layout_width="match_parent" | ||
39 | android:layout_height="1dp" | ||
40 | android:background="#EEEEEE" | ||
41 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
42 | /> | ||
43 | |||
44 | <View | ||
45 | android:id="@+id/view_3" | ||
46 | android:layout_width="345dp" | ||
47 | android:layout_height="80dp" | ||
48 | android:background="@drawable/bg_solid_white_10" | ||
49 | app:layout_constraintLeft_toLeftOf="parent" | ||
50 | app:layout_constraintRight_toRightOf="parent" | ||
51 | app:layout_constraintTop_toTopOf="parent" | ||
52 | android:layout_marginTop="90dp" | ||
53 | /> | ||
54 | <ImageView | ||
55 | android:id="@+id/iv_3" | ||
56 | android:layout_width="57dp" | ||
57 | android:layout_height="57dp" | ||
58 | android:background="@mipmap/txz" | ||
59 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
60 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
61 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
62 | android:layout_marginRight="31dp" | ||
63 | /> | ||
64 | <TextView | ||
65 | android:id="@+id/tv_3" | ||
66 | android:layout_width="wrap_content" | ||
67 | android:layout_height="wrap_content" | ||
68 | android:text="头像" | ||
69 | android:textColor="#333333" | ||
70 | android:textSize="15dp" | ||
71 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
72 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
73 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
74 | android:layout_marginLeft="15dp" | ||
75 | /> | ||
76 | <ImageView | ||
77 | android:layout_width="5.5dp" | ||
78 | android:layout_height="9.5dp" | ||
79 | android:background="@mipmap/ycaj" | ||
80 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
81 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
82 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
83 | android:layout_marginRight="15dp" | ||
84 | /> | ||
85 | |||
86 | <View | ||
87 | android:id="@+id/view_4" | ||
88 | android:layout_width="345dp" | ||
89 | android:layout_height="90dp" | ||
90 | android:background="@drawable/bg_solid_white_10" | ||
91 | app:layout_constraintLeft_toLeftOf="parent" | ||
92 | app:layout_constraintRight_toRightOf="parent" | ||
93 | app:layout_constraintTop_toTopOf="parent" | ||
94 | android:layout_marginTop="185dp" | ||
95 | /> | ||
96 | |||
97 | <TextView | ||
98 | android:id="@+id/tv_4" | ||
99 | android:layout_width="wrap_content" | ||
100 | android:layout_height="wrap_content" | ||
101 | android:text="账户" | ||
102 | android:textColor="#333333" | ||
103 | android:textSize="15dp" | ||
104 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
105 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
106 | android:layout_marginLeft="15dp" | ||
107 | android:layout_marginTop="15dp" | ||
108 | /> | ||
109 | <TextView | ||
110 | android:id="@+id/tv_5" | ||
111 | android:layout_width="wrap_content" | ||
112 | android:layout_height="wrap_content" | ||
113 | android:text="密码" | ||
114 | android:textColor="#333333" | ||
115 | android:textSize="15dp" | ||
116 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
117 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
118 | android:layout_marginLeft="15dp" | ||
119 | android:layout_marginTop="60dp" | ||
120 | /> | ||
121 | <TextView | ||
122 | android:id="@+id/tv_6" | ||
123 | android:layout_width="wrap_content" | ||
124 | android:layout_height="wrap_content" | ||
125 | android:text="123" | ||
126 | android:textColor="#666666" | ||
127 | android:textSize="15dp" | ||
128 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
129 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
130 | android:layout_marginRight="15dp" | ||
131 | android:layout_marginTop="15dp" | ||
132 | /> | ||
133 | <ImageView | ||
134 | android:layout_width="5.5dp" | ||
135 | android:layout_height="9.5dp" | ||
136 | android:background="@mipmap/ycaj" | ||
137 | app:layout_constraintTop_toTopOf="@id/tv_7" | ||
138 | app:layout_constraintBottom_toBottomOf="@id/tv_7" | ||
139 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
140 | android:layout_marginRight="15dp" | ||
141 | /> | ||
142 | <TextView | ||
143 | android:id="@+id/tv_7" | ||
144 | android:layout_width="wrap_content" | ||
145 | android:layout_height="wrap_content" | ||
146 | android:text="已设置" | ||
147 | android:textColor="#666666" | ||
148 | android:textSize="15dp" | ||
149 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
150 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
151 | android:layout_marginRight="31dp" | ||
152 | android:layout_marginTop="60dp" | ||
153 | /> | ||
154 | |||
155 | |||
156 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/activity_yin.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <TextView | ||
17 | android:layout_width="wrap_content" | ||
18 | android:layout_height="wrap_content" | ||
19 | android:text="隐私政策" | ||
20 | android:textColor="#333333" | ||
21 | android:textSize="18dp" | ||
22 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
23 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
24 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
25 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
26 | /> | ||
27 | <ImageView | ||
28 | android:id="@+id/iv_back" | ||
29 | android:layout_width="10dp" | ||
30 | android:layout_height="16dp" | ||
31 | app:layout_constraintLeft_toLeftOf="parent" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | android:layout_marginLeft="15dp" | ||
35 | android:background="@mipmap/icon_back" | ||
36 | /> | ||
37 | <View | ||
38 | android:layout_width="match_parent" | ||
39 | android:layout_height="1dp" | ||
40 | android:background="#EEEEEE" | ||
41 | app:layout_constraintTop_toBottomOf="@id/view_1" | ||
42 | /> | ||
43 | |||
44 | |||
45 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/fragment_home.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <View | ||
10 | android:id="@+id/view_1" | ||
11 | android:layout_width="match_parent" | ||
12 | android:layout_height="44dp" | ||
13 | app:layout_constraintTop_toTopOf="parent" | ||
14 | android:background="@android:color/white" | ||
15 | /> | ||
16 | <ImageView | ||
17 | android:id="@+id/iv_1" | ||
18 | android:layout_width="10dp" | ||
19 | android:layout_height="16dp" | ||
20 | app:layout_constraintLeft_toLeftOf="parent" | ||
21 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
22 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
23 | android:layout_marginLeft="15dp" | ||
24 | android:background="@mipmap/icon_back" | ||
25 | /> | ||
26 | |||
27 | <ImageView | ||
28 | android:id="@+id/iv_2" | ||
29 | android:layout_width="31dp" | ||
30 | android:layout_height="31dp" | ||
31 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
32 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
33 | app:layout_constraintLeft_toLeftOf="parent" | ||
34 | android:layout_marginLeft="35dp" | ||
35 | android:background="@mipmap/txz" | ||
36 | /> | ||
37 | <TextView | ||
38 | android:id="@+id/tv_name" | ||
39 | android:layout_width="wrap_content" | ||
40 | android:layout_height="wrap_content" | ||
41 | android:textColor="#333333" | ||
42 | android:textSize="15dp" | ||
43 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
44 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
45 | app:layout_constraintLeft_toRightOf="@id/iv_2" | ||
46 | android:layout_marginLeft="6.5dp" | ||
47 | /> | ||
48 | <ImageView | ||
49 | android:id="@+id/iv_3" | ||
50 | android:layout_width="8dp" | ||
51 | android:layout_height="5dp" | ||
52 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
53 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
54 | app:layout_constraintLeft_toRightOf="@id/tv_name" | ||
55 | android:layout_marginLeft="5dp" | ||
56 | android:background="@mipmap/xxan" | ||
57 | /> | ||
58 | |||
59 | <ImageView | ||
60 | android:id="@+id/iv_sapmiao" | ||
61 | android:layout_width="345dp" | ||
62 | android:layout_height="167dp" | ||
63 | app:layout_constraintLeft_toLeftOf="parent" | ||
64 | app:layout_constraintRight_toRightOf="parent" | ||
65 | app:layout_constraintTop_toTopOf="parent" | ||
66 | android:layout_marginTop="60dp" | ||
67 | android:background="@mipmap/ssss" | ||
68 | /> | ||
69 | |||
70 | |||
71 | <View | ||
72 | android:id="@+id/view_2" | ||
73 | android:layout_width="345dp" | ||
74 | android:layout_height="100dp" | ||
75 | app:layout_constraintLeft_toLeftOf="parent" | ||
76 | app:layout_constraintRight_toRightOf="parent" | ||
77 | app:layout_constraintTop_toTopOf="parent" | ||
78 | android:background="@drawable/bg_solid_white_10" | ||
79 | android:layout_marginTop="240dp" | ||
80 | /> | ||
81 | |||
82 | <ImageView | ||
83 | android:id="@+id/iv_21" | ||
84 | android:layout_width="50dp" | ||
85 | android:layout_height="50dp" | ||
86 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
87 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
88 | android:layout_marginLeft="10dp" | ||
89 | android:layout_marginTop="15dp" | ||
90 | android:background="@mipmap/yyxz" | ||
91 | /> | ||
92 | <TextView | ||
93 | android:layout_width="wrap_content" | ||
94 | android:layout_height="wrap_content" | ||
95 | android:textColor="#333333" | ||
96 | android:textSize="13dp" | ||
97 | android:text="应用管理" | ||
98 | android:layout_marginTop="8dp" | ||
99 | app:layout_constraintLeft_toLeftOf="@id/iv_21" | ||
100 | app:layout_constraintRight_toRightOf="@id/iv_21" | ||
101 | app:layout_constraintTop_toBottomOf="@id/iv_21" | ||
102 | /> | ||
103 | <ImageView | ||
104 | android:id="@+id/iv_22" | ||
105 | android:layout_width="50dp" | ||
106 | android:layout_height="50dp" | ||
107 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
108 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
109 | android:layout_marginLeft="101dp" | ||
110 | android:layout_marginTop="15dp" | ||
111 | android:background="@mipmap/xxxt" | ||
112 | /> | ||
113 | <TextView | ||
114 | android:layout_width="wrap_content" | ||
115 | android:layout_height="wrap_content" | ||
116 | android:textColor="#333333" | ||
117 | android:textSize="13dp" | ||
118 | android:text="小星错题" | ||
119 | android:layout_marginTop="8dp" | ||
120 | app:layout_constraintLeft_toLeftOf="@id/iv_22" | ||
121 | app:layout_constraintRight_toRightOf="@id/iv_22" | ||
122 | app:layout_constraintTop_toBottomOf="@id/iv_22" | ||
123 | /> | ||
124 | <ImageView | ||
125 | android:id="@+id/iv_23" | ||
126 | android:layout_width="50dp" | ||
127 | android:layout_height="50dp" | ||
128 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
129 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
130 | android:layout_marginLeft="194dp" | ||
131 | android:layout_marginTop="15dp" | ||
132 | android:background="@mipmap/ffsj" | ||
133 | /> | ||
134 | <TextView | ||
135 | android:layout_width="wrap_content" | ||
136 | android:layout_height="wrap_content" | ||
137 | android:textColor="#333333" | ||
138 | android:textSize="13dp" | ||
139 | android:text="分发试卷" | ||
140 | android:layout_marginTop="8dp" | ||
141 | app:layout_constraintLeft_toLeftOf="@id/iv_23" | ||
142 | app:layout_constraintRight_toRightOf="@id/iv_23" | ||
143 | app:layout_constraintTop_toBottomOf="@id/iv_23" | ||
144 | /> | ||
145 | <ImageView | ||
146 | android:id="@+id/iv_24" | ||
147 | android:layout_width="50dp" | ||
148 | android:layout_height="50dp" | ||
149 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
150 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
151 | android:layout_marginLeft="285dp" | ||
152 | android:layout_marginTop="15dp" | ||
153 | android:background="@mipmap/sbgl" | ||
154 | /> | ||
155 | <TextView | ||
156 | android:layout_width="wrap_content" | ||
157 | android:layout_height="wrap_content" | ||
158 | android:textColor="#333333" | ||
159 | android:textSize="13dp" | ||
160 | android:text="设备管理" | ||
161 | android:layout_marginTop="8dp" | ||
162 | app:layout_constraintLeft_toLeftOf="@id/iv_24" | ||
163 | app:layout_constraintRight_toRightOf="@id/iv_24" | ||
164 | app:layout_constraintTop_toBottomOf="@id/iv_24" | ||
165 | /> | ||
166 | |||
167 | <View | ||
168 | android:id="@+id/view_3" | ||
169 | android:layout_width="345dp" | ||
170 | android:layout_height="225dp" | ||
171 | app:layout_constraintLeft_toLeftOf="parent" | ||
172 | app:layout_constraintRight_toRightOf="parent" | ||
173 | app:layout_constraintTop_toTopOf="parent" | ||
174 | android:background="@drawable/bg_solid_white_10" | ||
175 | android:layout_marginTop="357dp" | ||
176 | /> | ||
177 | <TextView | ||
178 | android:id="@+id/tv_31" | ||
179 | android:layout_width="wrap_content" | ||
180 | android:layout_height="wrap_content" | ||
181 | android:textColor="#333333" | ||
182 | android:textSize="15dp" | ||
183 | android:text="本周学习计划" | ||
184 | android:layout_marginTop="15dp" | ||
185 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
186 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
187 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
188 | /> | ||
189 | <View | ||
190 | android:layout_width="25dp" | ||
191 | android:layout_height="1dp" | ||
192 | android:background="#EEEEEE" | ||
193 | app:layout_constraintRight_toLeftOf="@+id/tv_31" | ||
194 | app:layout_constraintTop_toTopOf="@id/tv_31" | ||
195 | app:layout_constraintBottom_toBottomOf="@id/tv_31" | ||
196 | android:layout_marginRight="10dp" | ||
197 | /> | ||
198 | <View | ||
199 | android:layout_width="25dp" | ||
200 | android:layout_height="1dp" | ||
201 | android:background="#EEEEEE" | ||
202 | app:layout_constraintLeft_toRightOf="@+id/tv_31" | ||
203 | app:layout_constraintTop_toTopOf="@id/tv_31" | ||
204 | app:layout_constraintBottom_toBottomOf="@id/tv_31" | ||
205 | android:layout_marginLeft="10dp" | ||
206 | /> | ||
207 | <ImageView | ||
208 | android:layout_width="103dp" | ||
209 | android:layout_height="66dp" | ||
210 | android:background="@mipmap/zwjh" | ||
211 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
212 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
213 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
214 | android:layout_marginTop="77dp" | ||
215 | /> | ||
216 | <TextView | ||
217 | android:layout_width="wrap_content" | ||
218 | android:layout_height="wrap_content" | ||
219 | android:textColor="#666666" | ||
220 | android:textSize="12dp" | ||
221 | android:text="本周学习计划" | ||
222 | android:layout_marginTop="161dp" | ||
223 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
224 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
225 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
226 | /> | ||
227 | |||
228 | |||
229 | |||
230 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/layout/fragment_me.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:layout_width="match_parent" | ||
4 | android:layout_height="match_parent" | ||
5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
6 | android:background="#F4F6F8" | ||
7 | > | ||
8 | |||
9 | <androidx.constraintlayout.widget.Group | ||
10 | android:id="@+id/group_1" | ||
11 | android:layout_width="wrap_content" | ||
12 | android:layout_height="wrap_content" | ||
13 | app:constraint_referenced_ids="iv_toux,tv_name,tv_phone,view_2,tv_title,iv_21,iv_22,iv_23,tv_21,tv_22,tv_23" | ||
14 | android:visibility="gone" | ||
15 | /> | ||
16 | |||
17 | <View | ||
18 | android:id="@+id/view_1" | ||
19 | android:layout_width="match_parent" | ||
20 | android:layout_height="44dp" | ||
21 | app:layout_constraintTop_toTopOf="parent" | ||
22 | android:background="@android:color/white" | ||
23 | /> | ||
24 | <TextView | ||
25 | android:layout_width="wrap_content" | ||
26 | android:layout_height="wrap_content" | ||
27 | android:text="个人中心" | ||
28 | android:textColor="#333333" | ||
29 | android:textSize="18dp" | ||
30 | app:layout_constraintLeft_toLeftOf="@id/view_1" | ||
31 | app:layout_constraintRight_toRightOf="@id/view_1" | ||
32 | app:layout_constraintTop_toTopOf="@id/view_1" | ||
33 | app:layout_constraintBottom_toBottomOf="@id/view_1" | ||
34 | /> | ||
35 | |||
36 | <ImageView | ||
37 | android:id="@+id/iv_bann" | ||
38 | android:layout_width="345dp" | ||
39 | android:layout_height="167dp" | ||
40 | android:background="@mipmap/smdlaa" | ||
41 | app:layout_constraintLeft_toLeftOf="parent" | ||
42 | app:layout_constraintRight_toRightOf="parent" | ||
43 | app:layout_constraintTop_toTopOf="parent" | ||
44 | android:layout_marginTop="63dp" | ||
45 | android:visibility="visible" | ||
46 | /> | ||
47 | |||
48 | <ImageView | ||
49 | android:id="@+id/iv_toux" | ||
50 | android:layout_width="57dp" | ||
51 | android:layout_height="57dp" | ||
52 | app:layout_constraintLeft_toLeftOf="parent" | ||
53 | app:layout_constraintTop_toTopOf="parent" | ||
54 | android:layout_marginLeft="15dp" | ||
55 | android:layout_marginTop="63dp" | ||
56 | android:background="@mipmap/txz" | ||
57 | /> | ||
58 | |||
59 | <TextView | ||
60 | android:id="@+id/tv_name" | ||
61 | android:layout_width="wrap_content" | ||
62 | android:layout_height="wrap_content" | ||
63 | app:layout_constraintLeft_toLeftOf="parent" | ||
64 | app:layout_constraintTop_toTopOf="parent" | ||
65 | android:layout_marginLeft="88dp" | ||
66 | android:layout_marginTop="72dp" | ||
67 | android:textSize="20dp" | ||
68 | android:textColor="#333333" | ||
69 | android:text="名字" | ||
70 | /> | ||
71 | <TextView | ||
72 | android:id="@+id/tv_phone" | ||
73 | android:layout_width="wrap_content" | ||
74 | android:layout_height="wrap_content" | ||
75 | app:layout_constraintLeft_toLeftOf="parent" | ||
76 | app:layout_constraintTop_toTopOf="parent" | ||
77 | android:layout_marginLeft="88dp" | ||
78 | android:layout_marginTop="98dp" | ||
79 | android:textColor="#999999" | ||
80 | android:textSize="17dp" | ||
81 | android:text="1231223123" | ||
82 | /> | ||
83 | |||
84 | |||
85 | |||
86 | <View | ||
87 | android:id="@+id/view_2" | ||
88 | android:layout_width="345dp" | ||
89 | android:layout_height="140dp" | ||
90 | app:layout_constraintLeft_toLeftOf="parent" | ||
91 | app:layout_constraintRight_toRightOf="parent" | ||
92 | app:layout_constraintTop_toTopOf="parent" | ||
93 | android:layout_marginTop="140dp" | ||
94 | android:background="@drawable/bg_solid_white_10" | ||
95 | /> | ||
96 | |||
97 | <TextView | ||
98 | android:id="@+id/tv_title" | ||
99 | android:layout_width="wrap_content" | ||
100 | android:layout_height="wrap_content" | ||
101 | android:text="学生" | ||
102 | android:textColor="#333333" | ||
103 | android:textSize="16dp" | ||
104 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
105 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
106 | android:layout_marginLeft="15dp" | ||
107 | android:layout_marginTop="15dp" | ||
108 | /> | ||
109 | |||
110 | <ImageView | ||
111 | android:id="@+id/iv_21" | ||
112 | android:layout_width="56dp" | ||
113 | android:layout_height="56dp" | ||
114 | android:background="@mipmap/tjxss" | ||
115 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
116 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
117 | android:layout_marginLeft="15dp" | ||
118 | android:layout_marginTop="44dp" | ||
119 | /> | ||
120 | <TextView | ||
121 | android:id="@+id/tv_21" | ||
122 | android:layout_width="wrap_content" | ||
123 | android:layout_height="wrap_content" | ||
124 | app:layout_constraintLeft_toLeftOf="@id/iv_21" | ||
125 | app:layout_constraintRight_toRightOf="@id/iv_21" | ||
126 | app:layout_constraintTop_toBottomOf="@id/iv_21" | ||
127 | android:layout_marginTop="10dp" | ||
128 | android:textColor="#000000" | ||
129 | android:textSize="13dp" | ||
130 | android:text="添加学生" | ||
131 | /> | ||
132 | <ImageView | ||
133 | android:id="@+id/iv_22" | ||
134 | android:layout_width="56dp" | ||
135 | android:layout_height="56dp" | ||
136 | android:background="@mipmap/tjxss" | ||
137 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
138 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
139 | android:layout_marginLeft="144dp" | ||
140 | android:layout_marginTop="44dp" | ||
141 | /> | ||
142 | <TextView | ||
143 | android:id="@+id/tv_22" | ||
144 | android:layout_width="wrap_content" | ||
145 | android:layout_height="wrap_content" | ||
146 | app:layout_constraintLeft_toLeftOf="@id/iv_22" | ||
147 | app:layout_constraintRight_toRightOf="@id/iv_22" | ||
148 | app:layout_constraintTop_toBottomOf="@id/iv_22" | ||
149 | android:layout_marginTop="10dp" | ||
150 | android:textColor="#000000" | ||
151 | android:textSize="13dp" | ||
152 | android:text="添加学生" | ||
153 | /> | ||
154 | <ImageView | ||
155 | android:id="@+id/iv_23" | ||
156 | android:layout_width="56dp" | ||
157 | android:layout_height="56dp" | ||
158 | android:background="@mipmap/tjxss" | ||
159 | app:layout_constraintLeft_toLeftOf="@id/view_2" | ||
160 | app:layout_constraintTop_toTopOf="@id/view_2" | ||
161 | android:layout_marginLeft="274dp" | ||
162 | android:layout_marginTop="44dp" | ||
163 | /> | ||
164 | <TextView | ||
165 | android:id="@+id/tv_23" | ||
166 | android:layout_width="wrap_content" | ||
167 | android:layout_height="wrap_content" | ||
168 | app:layout_constraintLeft_toLeftOf="@id/iv_23" | ||
169 | app:layout_constraintRight_toRightOf="@id/iv_23" | ||
170 | app:layout_constraintTop_toBottomOf="@id/iv_23" | ||
171 | android:layout_marginTop="10dp" | ||
172 | android:textColor="#000000" | ||
173 | android:textSize="13dp" | ||
174 | android:text="添加学生" | ||
175 | /> | ||
176 | |||
177 | |||
178 | |||
179 | |||
180 | |||
181 | |||
182 | |||
183 | |||
184 | |||
185 | <View | ||
186 | android:id="@+id/view_3" | ||
187 | android:layout_width="345dp" | ||
188 | android:layout_height="45dp" | ||
189 | app:layout_constraintLeft_toLeftOf="parent" | ||
190 | app:layout_constraintRight_toRightOf="parent" | ||
191 | app:layout_goneMarginTop="241dp" | ||
192 | app:layout_constraintTop_toBottomOf="@id/view_2" | ||
193 | android:layout_marginTop="15dp" | ||
194 | android:background="@drawable/bg_solid_white_10_top" | ||
195 | /> | ||
196 | <ImageView | ||
197 | android:layout_width="6.8dp" | ||
198 | android:layout_height="12dp" | ||
199 | android:background="@mipmap/ycaj" | ||
200 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
201 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
202 | app:layout_constraintRight_toRightOf="@id/view_3" | ||
203 | android:layout_marginRight="15dp" | ||
204 | /> | ||
205 | <ImageView | ||
206 | android:layout_width="14dp" | ||
207 | android:layout_height="14dp" | ||
208 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
209 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
210 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
211 | android:layout_marginLeft="15dp" | ||
212 | android:background="@mipmap/szz" | ||
213 | /> | ||
214 | |||
215 | <TextView | ||
216 | android:layout_width="wrap_content" | ||
217 | android:layout_height="wrap_content" | ||
218 | android:textColor="#333333" | ||
219 | android:textSize="15dp" | ||
220 | android:text="账户设置" | ||
221 | app:layout_constraintTop_toTopOf="@id/view_3" | ||
222 | app:layout_constraintBottom_toBottomOf="@id/view_3" | ||
223 | app:layout_constraintLeft_toLeftOf="@id/view_3" | ||
224 | android:layout_marginLeft="40dp" | ||
225 | /> | ||
226 | <View | ||
227 | android:id="@+id/view_4" | ||
228 | android:layout_width="345dp" | ||
229 | android:layout_height="45dp" | ||
230 | app:layout_constraintLeft_toLeftOf="parent" | ||
231 | app:layout_constraintRight_toRightOf="parent" | ||
232 | app:layout_constraintTop_toBottomOf="@id/view_3" | ||
233 | android:background="@android:color/white" | ||
234 | /> | ||
235 | <ImageView | ||
236 | android:layout_width="6.8dp" | ||
237 | android:layout_height="12dp" | ||
238 | android:background="@mipmap/ycaj" | ||
239 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
240 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
241 | app:layout_constraintRight_toRightOf="@id/view_4" | ||
242 | android:layout_marginRight="15dp" | ||
243 | /> | ||
244 | <ImageView | ||
245 | android:layout_width="14dp" | ||
246 | android:layout_height="14dp" | ||
247 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
248 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
249 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
250 | android:layout_marginLeft="15dp" | ||
251 | android:background="@mipmap/yincs" | ||
252 | /> | ||
253 | |||
254 | <TextView | ||
255 | android:layout_width="wrap_content" | ||
256 | android:layout_height="wrap_content" | ||
257 | android:textColor="#333333" | ||
258 | android:textSize="15dp" | ||
259 | android:text="隐私设置" | ||
260 | app:layout_constraintTop_toTopOf="@id/view_4" | ||
261 | app:layout_constraintBottom_toBottomOf="@id/view_4" | ||
262 | app:layout_constraintLeft_toLeftOf="@id/view_4" | ||
263 | android:layout_marginLeft="40dp" | ||
264 | /> | ||
265 | |||
266 | <View | ||
267 | android:id="@+id/view_5" | ||
268 | android:layout_width="345dp" | ||
269 | android:layout_height="45dp" | ||
270 | app:layout_constraintLeft_toLeftOf="parent" | ||
271 | app:layout_constraintRight_toRightOf="parent" | ||
272 | app:layout_constraintTop_toBottomOf="@id/view_4" | ||
273 | android:background="@android:color/white" | ||
274 | /> | ||
275 | <ImageView | ||
276 | android:layout_width="6.8dp" | ||
277 | android:layout_height="12dp" | ||
278 | android:background="@mipmap/ycaj" | ||
279 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
280 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
281 | app:layout_constraintRight_toRightOf="@id/view_5" | ||
282 | android:layout_marginRight="15dp" | ||
283 | /> | ||
284 | <ImageView | ||
285 | android:layout_width="14dp" | ||
286 | android:layout_height="14dp" | ||
287 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
288 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
289 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
290 | android:layout_marginLeft="15dp" | ||
291 | android:background="@mipmap/gywmm" | ||
292 | /> | ||
293 | |||
294 | <TextView | ||
295 | android:layout_width="wrap_content" | ||
296 | android:layout_height="wrap_content" | ||
297 | android:textColor="#333333" | ||
298 | android:textSize="15dp" | ||
299 | android:text="关于我们" | ||
300 | app:layout_constraintTop_toTopOf="@id/view_5" | ||
301 | app:layout_constraintBottom_toBottomOf="@id/view_5" | ||
302 | app:layout_constraintLeft_toLeftOf="@id/view_5" | ||
303 | android:layout_marginLeft="40dp" | ||
304 | /> | ||
305 | <View | ||
306 | android:id="@+id/view_6" | ||
307 | android:layout_width="345dp" | ||
308 | android:layout_height="45dp" | ||
309 | app:layout_constraintLeft_toLeftOf="parent" | ||
310 | app:layout_constraintRight_toRightOf="parent" | ||
311 | app:layout_constraintTop_toBottomOf="@id/view_5" | ||
312 | android:background="@drawable/bg_solid_white_10_bottom" | ||
313 | /> | ||
314 | |||
315 | <ImageView | ||
316 | android:layout_width="14dp" | ||
317 | android:layout_height="14dp" | ||
318 | app:layout_constraintTop_toTopOf="@id/view_6" | ||
319 | app:layout_constraintBottom_toBottomOf="@id/view_6" | ||
320 | app:layout_constraintLeft_toLeftOf="@id/view_6" | ||
321 | android:layout_marginLeft="15dp" | ||
322 | android:background="@mipmap/banb" | ||
323 | /> | ||
324 | |||
325 | <TextView | ||
326 | android:layout_width="wrap_content" | ||
327 | android:layout_height="wrap_content" | ||
328 | android:textColor="#333333" | ||
329 | android:textSize="15dp" | ||
330 | android:text="当前版本" | ||
331 | app:layout_constraintTop_toTopOf="@id/view_6" | ||
332 | app:layout_constraintBottom_toBottomOf="@id/view_6" | ||
333 | app:layout_constraintLeft_toLeftOf="@id/view_6" | ||
334 | android:layout_marginLeft="40dp" | ||
335 | /> | ||
336 | <TextView | ||
337 | android:layout_width="wrap_content" | ||
338 | android:layout_height="wrap_content" | ||
339 | android:textColor="#333333" | ||
340 | android:textSize="15dp" | ||
341 | android:text="V1.0" | ||
342 | app:layout_constraintTop_toTopOf="@id/view_6" | ||
343 | app:layout_constraintBottom_toBottomOf="@id/view_6" | ||
344 | app:layout_constraintRight_toRightOf="@id/view_6" | ||
345 | android:layout_marginRight="15dp" | ||
346 | /> | ||
347 | |||
348 | |||
349 | </androidx.constraintlayout.widget.ConstraintLayout> |
app/src/main/res/mipmap-hdpi/abcdss.jpg
20.6 KB
app/src/main/res/mipmap-hdpi/banb.png
573 Bytes
app/src/main/res/mipmap-hdpi/bg.png
45.2 KB
app/src/main/res/mipmap-hdpi/eco.png
15.1 KB
app/src/main/res/mipmap-hdpi/ffsj.png
4.54 KB
app/src/main/res/mipmap-hdpi/gx.png
847 Bytes
app/src/main/res/mipmap-hdpi/gywmm.png
492 Bytes
app/src/main/res/mipmap-hdpi/hoss.png
847 Bytes
app/src/main/res/mipmap-hdpi/hous.png
832 Bytes
app/src/main/res/mipmap-hdpi/icon.png
82.3 KB
app/src/main/res/mipmap-hdpi/icon_back.png
694 Bytes
app/src/main/res/mipmap-hdpi/icon_qd.png
105 KB
app/src/main/res/mipmap-hdpi/mm.png
959 Bytes
app/src/main/res/mipmap-hdpi/mrtx.png
3.72 KB
app/src/main/res/mipmap-hdpi/sbgl.png
5.19 KB
app/src/main/res/mipmap-hdpi/sc.png
732 Bytes
app/src/main/res/mipmap-hdpi/sjh.png
767 Bytes
app/src/main/res/mipmap-hdpi/smdlaa.png
145 KB
app/src/main/res/mipmap-hdpi/ssss.png
139 KB
app/src/main/res/mipmap-hdpi/szz.png
775 Bytes
app/src/main/res/mipmap-hdpi/tjxss.png
3.37 KB
app/src/main/res/mipmap-hdpi/txz.png
13.3 KB
app/src/main/res/mipmap-hdpi/wmss.png
1.2 KB
app/src/main/res/mipmap-hdpi/wmus.png
1.25 KB
app/src/main/res/mipmap-hdpi/wsyq.png
563 Bytes
app/src/main/res/mipmap-hdpi/xb_n.png
796 Bytes
app/src/main/res/mipmap-hdpi/xb_nv.png
799 Bytes
app/src/main/res/mipmap-hdpi/xs.png
1.5 KB
app/src/main/res/mipmap-hdpi/xxan.png
348 Bytes
app/src/main/res/mipmap-hdpi/xxxt.png
5.01 KB
app/src/main/res/mipmap-hdpi/yc.png
1.53 KB
app/src/main/res/mipmap-hdpi/ycaj.png
362 Bytes
app/src/main/res/mipmap-hdpi/yincs.png
700 Bytes
app/src/main/res/mipmap-hdpi/yyxz.png
4.26 KB
app/src/main/res/mipmap-hdpi/zwjh.png
10.9 KB
app/src/main/res/mipmap-mdpi/icon.png
34.9 KB
app/src/main/res/mipmap-xhdpi/icon.png
136 KB
app/src/main/res/mipmap-xxhdpi/icon.png
354 KB
app/src/main/res/mipmap-xxxhdpi/icon.png
632 KB
app/src/main/res/values-night/themes.xml
File was created | 1 | <resources xmlns:tools="http://schemas.android.com/tools"> | |
2 | <!-- Base application theme. --> | ||
3 | <style name="Theme.Parent" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
4 | <!-- Primary brand color. --> | ||
5 | <item name="colorPrimary">@color/purple_200</item> | ||
6 | <item name="colorPrimaryVariant">@color/purple_700</item> | ||
7 | <item name="colorOnPrimary">@color/black</item> | ||
8 | <!-- Secondary brand color. --> | ||
9 | <item name="colorSecondary">@color/teal_200</item> | ||
10 | <item name="colorSecondaryVariant">@color/teal_200</item> | ||
11 | <item name="colorOnSecondary">@color/black</item> | ||
12 | <!-- Status bar color. --> | ||
13 | <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> | ||
14 | <!-- Customize your theme here. --> | ||
15 | </style> | ||
16 | </resources> |
app/src/main/res/values/colors.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <resources> | ||
3 | <color name="purple_200">#FFBB86FC</color> | ||
4 | <color name="purple_500">#FF6200EE</color> | ||
5 | <color name="purple_700">#FF3700B3</color> | ||
6 | <color name="teal_200">#FF03DAC5</color> | ||
7 | <color name="teal_700">#FF018786</color> | ||
8 | <color name="black">#FF000000</color> | ||
9 | <color name="white">#FFFFFFFF</color> | ||
10 | <color name="c_1">#FE5E09</color> | ||
11 | <color name="c_2">#333333</color> | ||
12 | </resources> |
app/src/main/res/values/strings.xml
File was created | 1 | <resources> | |
2 | <string name="app_name">家长管控</string> | ||
3 | </resources> |
app/src/main/res/values/styles.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <resources> | ||
3 | |||
4 | |||
5 | <style name="ThemeSplash" parent="Theme.AppCompat.Light.NoActionBar"> | ||
6 | <item name="android:windowBackground">@drawable/welcome_bg</item> | ||
7 | <item name="colorPrimaryDark">@android:color/transparent</item> | ||
8 | <item name="windowActionBar">false</item> | ||
9 | <item name="windowNoTitle">true</item> | ||
10 | <item name="android:windowFullscreen">true</item> | ||
11 | </style> | ||
12 | |||
13 | <style name="main_bottom_navigaton_menu_item"> | ||
14 | <item name="android:layout_width">0dp</item> | ||
15 | <item name="android:layout_weight">1</item> | ||
16 | <item name="android:layout_height">match_parent</item> | ||
17 | <item name="android:background">@android:color/transparent</item> | ||
18 | <item name="android:button">@null</item> | ||
19 | <item name="android:gravity">center</item> | ||
20 | <item name="android:textSize">11dp</item> | ||
21 | <item name="android:drawablePadding">2dp</item> | ||
22 | </style> | ||
23 | |||
24 | |||
25 | </resources> |
app/src/main/res/values/themes.xml
File was created | 1 | <resources xmlns:tools="http://schemas.android.com/tools"> | |
2 | <!-- Base application theme. --> | ||
3 | <style name="Theme.Parent" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> | ||
4 | <!-- Primary brand color. --> | ||
5 | <item name="colorPrimary">@color/purple_500</item> | ||
6 | <item name="colorPrimaryVariant">@color/purple_700</item> | ||
7 | <item name="colorOnPrimary">@color/white</item> | ||
8 | <!-- Secondary brand color. --> | ||
9 | <item name="colorSecondary">@color/teal_200</item> | ||
10 | <item name="colorSecondaryVariant">@color/teal_700</item> | ||
11 | <item name="colorOnSecondary">@color/black</item> | ||
12 | <!-- Status bar color. --> | ||
13 | <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> | ||
14 | <!-- Customize your theme here. --> | ||
15 | </style> | ||
16 | </resources> |
build.gradle
File was created | 1 | buildscript { | |
2 | |||
3 | |||
4 | ext { | ||
5 | |||
6 | |||
7 | androidId = [ | ||
8 | compileSdkVersion: 32, | ||
9 | minSdkVersion : 24, | ||
10 | targetSdkVersion : 32, | ||
11 | versionCode : 1, | ||
12 | versionName : "0.0.1" | ||
13 | |||
14 | |||
15 | ] | ||
16 | |||
17 | |||
18 | url = [ | ||
19 | server_url: "https://mgr.hjx.com", //http 请求指令 | ||
20 | |||
21 | ] | ||
22 | |||
23 | |||
24 | dependencies = [ | ||
25 | appcompat : 'androidx.appcompat:appcompat:1.0.0', | ||
26 | constraint : 'androidx.constraintlayout:constraintlayout:1.1.3', | ||
27 | cardview : 'androidx.cardview:cardview:1.0.0', | ||
28 | recyclerview : 'androidx.recyclerview:recyclerview:1.0.0', | ||
29 | material : 'com.google.android.material:material:1.0.0', | ||
30 | // 依赖RxAndroid 2X 的依赖库 | ||
31 | // 增加RxJava 2X 的依赖库 | ||
32 | rxandroid : 'io.reactivex.rxjava2:rxandroid:2.0.1', | ||
33 | rxjava : 'io.reactivex.rxjava2:rxjava:2.0.7', | ||
34 | |||
35 | // 以下需要使用Retrofit | ||
36 | //retrofit | ||
37 | retrofit : 'com.squareup.retrofit2:retrofit:2.1.0', | ||
38 | //Gson converter | ||
39 | converter : 'com.squareup.retrofit2:converter-gson:2.1.0', | ||
40 | //RxJava2 Adapter | ||
41 | retrofit2 : 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0', | ||
42 | //okhttp | ||
43 | okhttp : 'com.squareup.okhttp3:okhttp:3.8.1', | ||
44 | logging : 'com.squareup.okhttp3:logging-interceptor:3.4.1', | ||
45 | utils : 'com.github.wang-developer:AndroidUtilsDemo:1.0.6', | ||
46 | commons_lang : 'org.apache.commons:commons-lang3:3.7', | ||
47 | commons_compress: 'org.apache.commons:commons-compress:1.19', | ||
48 | commons_c_lang : 'commons-lang:commons-lang:2.3', | ||
49 | commons_codec : 'commons-codec:commons-codec:1.7', | ||
50 | eventbus : 'org.greenrobot:eventbus:3.2.0', | ||
51 | eventbus2 : 'org.simple:androideventbus:1.0.5.1', | ||
52 | glide : 'com.github.bumptech.glide:glide:3.7.0', | ||
53 | permissions : 'com.github.getActivity:XXPermissions:11.6', | ||
54 | orcode : 'cn.yipianfengye.android:zxing-library:2.2' | ||
55 | // push : 'com.umeng.sdk:push:4.1.0', | ||
56 | // litepal : 'org.litepal.android:java:3.0.0', | ||
57 | |||
58 | |||
59 | // AlivcFFmpeg : 'com.aliyun.video.android:AlivcFFmpeg:2.0.0', | ||
60 | |||
61 | // | ||
62 | // basequickadapter : 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34', | ||
63 | // SwipeDelMenuLayout: 'com.github.mcxtzhang:SwipeDelMenuLayout:V1.3.0', | ||
64 | // flycoTabLayout : 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' | ||
65 | |||
66 | |||
67 | ] | ||
68 | } | ||
69 | |||
70 | |||
71 | repositories { | ||
72 | google() | ||
73 | jcenter() | ||
74 | maven { url 'https://maven.aliyun.com/repository/jcenter' } | ||
75 | maven { url 'https://maven.aliyun.com/repository/google' } | ||
76 | maven { url 'https://maven.aliyun.com/repository/central' } | ||
77 | maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } | ||
78 | } | ||
79 | dependencies { | ||
80 | classpath 'com.android.tools.build:gradle:4.2.2' | ||
81 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' | ||
82 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' | ||
83 | classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3' | ||
84 | classpath "com.alibaba:arouter-register:1.0.2" | ||
85 | // NOTE: Do not place your application dependencies here; they belong | ||
86 | // in the individual module build.gradle files | ||
87 | } | ||
88 | |||
89 | |||
90 | } | ||
91 | |||
92 | |||
93 | allprojects { | ||
94 | repositories { | ||
95 | google() | ||
96 | jcenter() | ||
97 | maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' } | ||
98 | maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } | ||
99 | maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } | ||
100 | maven { url 'https://jitpack.io' } | ||
101 | } | ||
102 | } | ||
103 | task clean(type: Delete) { | ||
104 | delete rootProject.buildDir | ||
105 | } | ||
106 |
config.gradle
File was created | 1 | ||
2 | |||
3 | |||
4 | android { | ||
5 | |||
6 | defaultConfig { | ||
7 | javaCompileOptions { | ||
8 | annotationProcessorOptions { | ||
9 | arguments = [AROUTER_MODULE_NAME: project.getName()] | ||
10 | } | ||
11 | } | ||
12 | } | ||
13 | |||
14 | |||
15 | |||
16 | |||
17 | } | ||
18 | dependencies { | ||
19 | implementation 'com.alibaba:arouter-api:1.5.2' | ||
20 | annotationProcessor 'com.alibaba:arouter-compiler:1.5.2' | ||
21 | |||
22 | implementation 'com.jakewharton:butterknife:10.2.3' | ||
23 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' | ||
24 | } |
gradle.properties
File was created | 1 | # Project-wide Gradle settings. | |
2 | # IDE (e.g. Android Studio) users: | ||
3 | # Gradle settings configured through the IDE *will override* | ||
4 | # any settings specified in this file. | ||
5 | # For more details on how to configure your build environment visit | ||
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html | ||
7 | # Specifies the JVM arguments used for the daemon process. | ||
8 | # The setting is particularly useful for tweaking memory settings. | ||
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
10 | # When configured, Gradle will run in incubating parallel mode. | ||
11 | # This option should only be used with decoupled projects. More details, visit | ||
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
13 | # org.gradle.parallel=true | ||
14 | # AndroidX package structure to make it clearer which packages are bundled with the | ||
15 | # Android operating system, and which are packaged with your app"s APK | ||
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
17 | android.useAndroidX=true | ||
18 | # Automatically convert third-party libraries to use AndroidX | ||
19 | android.enableJetifier=true |
gradle/wrapper/gradle-wrapper.jar
No preview for this file type
gradle/wrapper/gradle-wrapper.properties
File was created | 1 | #Fri Jan 26 04:09:01 CST 2024 | |
2 | distributionBase=GRADLE_USER_HOME | ||
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip | ||
4 | distributionPath=wrapper/dists | ||
5 | zipStorePath=wrapper/dists | ||
6 | zipStoreBase=GRADLE_USER_HOME | ||
7 |
gradlew
File was created | 1 | #!/usr/bin/env sh | |
2 | |||
3 | # | ||
4 | # Copyright 2015 the original author or authors. | ||
5 | # | ||
6 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | # you may not use this file except in compliance with the License. | ||
8 | # You may obtain a copy of the License at | ||
9 | # | ||
10 | # https://www.apache.org/licenses/LICENSE-2.0 | ||
11 | # | ||
12 | # Unless required by applicable law or agreed to in writing, software | ||
13 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | # See the License for the specific language governing permissions and | ||
16 | # limitations under the License. | ||
17 | # | ||
18 | |||
19 | ############################################################################## | ||
20 | ## | ||
21 | ## Gradle start up script for UN*X | ||
22 | ## | ||
23 | ############################################################################## | ||
24 | |||
25 | # Attempt to set APP_HOME | ||
26 | # Resolve links: $0 may be a link | ||
27 | PRG="$0" | ||
28 | # Need this for relative symlinks. | ||
29 | while [ -h "$PRG" ] ; do | ||
30 | ls=`ls -ld "$PRG"` | ||
31 | link=`expr "$ls" : '.*-> \(.*\)$'` | ||
32 | if expr "$link" : '/.*' > /dev/null; then | ||
33 | PRG="$link" | ||
34 | else | ||
35 | PRG=`dirname "$PRG"`"/$link" | ||
36 | fi | ||
37 | done | ||
38 | SAVED="`pwd`" | ||
39 | cd "`dirname \"$PRG\"`/" >/dev/null | ||
40 | APP_HOME="`pwd -P`" | ||
41 | cd "$SAVED" >/dev/null | ||
42 | |||
43 | APP_NAME="Gradle" | ||
44 | APP_BASE_NAME=`basename "$0"` | ||
45 | |||
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | ||
48 | |||
49 | # Use the maximum available, or set MAX_FD != -1 to use that value. | ||
50 | MAX_FD="maximum" | ||
51 | |||
52 | warn () { | ||
53 | echo "$*" | ||
54 | } | ||
55 | |||
56 | die () { | ||
57 | echo | ||
58 | echo "$*" | ||
59 | echo | ||
60 | exit 1 | ||
61 | } | ||
62 | |||
63 | # OS specific support (must be 'true' or 'false'). | ||
64 | cygwin=false | ||
65 | msys=false | ||
66 | darwin=false | ||
67 | nonstop=false | ||
68 | case "`uname`" in | ||
69 | CYGWIN* ) | ||
70 | cygwin=true | ||
71 | ;; | ||
72 | Darwin* ) | ||
73 | darwin=true | ||
74 | ;; | ||
75 | MINGW* ) | ||
76 | msys=true | ||
77 | ;; | ||
78 | NONSTOP* ) | ||
79 | nonstop=true | ||
80 | ;; | ||
81 | esac | ||
82 | |||
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
84 | |||
85 | |||
86 | # Determine the Java command to use to start the JVM. | ||
87 | if [ -n "$JAVA_HOME" ] ; then | ||
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
89 | # IBM's JDK on AIX uses strange locations for the executables | ||
90 | JAVACMD="$JAVA_HOME/jre/sh/java" | ||
91 | else | ||
92 | JAVACMD="$JAVA_HOME/bin/java" | ||
93 | fi | ||
94 | if [ ! -x "$JAVACMD" ] ; then | ||
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
96 | |||
97 | Please set the JAVA_HOME variable in your environment to match the | ||
98 | location of your Java installation." | ||
99 | fi | ||
100 | else | ||
101 | JAVACMD="java" | ||
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
103 | |||
104 | Please set the JAVA_HOME variable in your environment to match the | ||
105 | location of your Java installation." | ||
106 | fi | ||
107 | |||
108 | # Increase the maximum file descriptors if we can. | ||
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | ||
110 | MAX_FD_LIMIT=`ulimit -H -n` | ||
111 | if [ $? -eq 0 ] ; then | ||
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
113 | MAX_FD="$MAX_FD_LIMIT" | ||
114 | fi | ||
115 | ulimit -n $MAX_FD | ||
116 | if [ $? -ne 0 ] ; then | ||
117 | warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
118 | fi | ||
119 | else | ||
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
121 | fi | ||
122 | fi | ||
123 | |||
124 | # For Darwin, add options to specify how the application appears in the dock | ||
125 | if $darwin; then | ||
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
127 | fi | ||
128 | |||
129 | # For Cygwin or MSYS, switch paths to Windows format before running java | ||
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then | ||
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
133 | |||
134 | JAVACMD=`cygpath --unix "$JAVACMD"` | ||
135 | |||
136 | # We build the pattern for arguments to be converted via cygpath | ||
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
138 | SEP="" | ||
139 | for dir in $ROOTDIRSRAW ; do | ||
140 | ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
141 | SEP="|" | ||
142 | done | ||
143 | OURCYGPATTERN="(^($ROOTDIRS))" | ||
144 | # Add a user-defined pattern to the cygpath arguments | ||
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
147 | fi | ||
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
149 | i=0 | ||
150 | for arg in "$@" ; do | ||
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
153 | |||
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
156 | else | ||
157 | eval `echo args$i`="\"$arg\"" | ||
158 | fi | ||
159 | i=`expr $i + 1` | ||
160 | done | ||
161 | case $i in | ||
162 | 0) set -- ;; | ||
163 | 1) set -- "$args0" ;; | ||
164 | 2) set -- "$args0" "$args1" ;; | ||
165 | 3) set -- "$args0" "$args1" "$args2" ;; | ||
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
172 | esac | ||
173 | fi | ||
174 | |||
175 | # Escape application args | ||
176 | save () { | ||
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
178 | echo " " | ||
179 | } | ||
180 | APP_ARGS=`save "$@"` | ||
181 | |||
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules | ||
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
184 | |||
185 | exec "$JAVACMD" "$@" | ||
186 |
gradlew.bat
File was created | 1 | @rem | |
2 | @rem Copyright 2015 the original author or authors. | ||
3 | @rem | ||
4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | @rem you may not use this file except in compliance with the License. | ||
6 | @rem You may obtain a copy of the License at | ||
7 | @rem | ||
8 | @rem https://www.apache.org/licenses/LICENSE-2.0 | ||
9 | @rem | ||
10 | @rem Unless required by applicable law or agreed to in writing, software | ||
11 | @rem distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | @rem See the License for the specific language governing permissions and | ||
14 | @rem limitations under the License. | ||
15 | @rem | ||
16 | |||
17 | @if "%DEBUG%" == "" @echo off | ||
18 | @rem ########################################################################## | ||
19 | @rem | ||
20 | @rem Gradle startup script for Windows | ||
21 | @rem | ||
22 | @rem ########################################################################## | ||
23 | |||
24 | @rem Set local scope for the variables with windows NT shell | ||
25 | if "%OS%"=="Windows_NT" setlocal | ||
26 | |||
27 | set DIRNAME=%~dp0 | ||
28 | if "%DIRNAME%" == "" set DIRNAME=. | ||
29 | set APP_BASE_NAME=%~n0 | ||
30 | set APP_HOME=%DIRNAME% | ||
31 | |||
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
34 | |||
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
37 | |||
38 | @rem Find java.exe | ||
39 | if defined JAVA_HOME goto findJavaFromJavaHome | ||
40 | |||
41 | set JAVA_EXE=java.exe | ||
42 | %JAVA_EXE% -version >NUL 2>&1 | ||
43 | if "%ERRORLEVEL%" == "0" goto execute | ||
44 | |||
45 | echo. | ||
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
47 | echo. | ||
48 | echo Please set the JAVA_HOME variable in your environment to match the | ||
49 | echo location of your Java installation. | ||
50 | |||
51 | goto fail | ||
52 | |||
53 | :findJavaFromJavaHome | ||
54 | set JAVA_HOME=%JAVA_HOME:"=% | ||
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
56 | |||
57 | if exist "%JAVA_EXE%" goto execute | ||
58 | |||
59 | echo. | ||
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
61 | echo. | ||
62 | echo Please set the JAVA_HOME variable in your environment to match the | ||
63 | echo location of your Java installation. | ||
64 | |||
65 | goto fail | ||
66 | |||
67 | :execute | ||
68 | @rem Setup the command line | ||
69 | |||
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
71 | |||
72 | |||
73 | @rem Execute Gradle | ||
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
75 | |||
76 | :end | ||
77 | @rem End local scope for the variables with windows NT shell | ||
78 | if "%ERRORLEVEL%"=="0" goto mainEnd | ||
79 | |||
80 | :fail | ||
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
82 | rem the _cmd.exe /c_ return code! | ||
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
84 | exit /b 1 | ||
85 | |||
86 | :mainEnd | ||
87 | if "%OS%"=="Windows_NT" endlocal | ||
88 | |||
89 | :omega | ||
90 |
libs/common/.gitignore
File was created | 1 | /build |
libs/common/build.gradle
File was created | 1 | apply plugin: 'com.android.library' | |
2 | apply from: '../../config.gradle' | ||
3 | |||
4 | |||
5 | |||
6 | def androidId = rootProject.ext.androidId | ||
7 | def support = rootProject.ext.dependencies | ||
8 | def url = rootProject.ext.url | ||
9 | |||
10 | |||
11 | android { | ||
12 | compileSdkVersion androidId.compileSdkVersion | ||
13 | |||
14 | |||
15 | defaultConfig { | ||
16 | minSdkVersion androidId.minSdkVersion | ||
17 | targetSdkVersion androidId.targetSdkVersion | ||
18 | versionCode androidId.versionCode | ||
19 | versionName androidId.versionName | ||
20 | |||
21 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
22 | |||
23 | } | ||
24 | |||
25 | buildTypes { | ||
26 | debug { | ||
27 | minifyEnabled false | ||
28 | buildConfigField("String", "SERVER_URL", "\"${url.server_url}\"") | ||
29 | |||
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
31 | } | ||
32 | release { | ||
33 | minifyEnabled false | ||
34 | buildConfigField("String", "SERVER_URL", "\"${url.server_url}\"") | ||
35 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
36 | } | ||
37 | } | ||
38 | |||
39 | compileOptions { | ||
40 | sourceCompatibility JavaVersion.VERSION_1_8 | ||
41 | targetCompatibility JavaVersion.VERSION_1_8 | ||
42 | } | ||
43 | } | ||
44 | |||
45 | dependencies { | ||
46 | implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
47 | |||
48 | |||
49 | support.each { k, v -> implementation v } | ||
50 | |||
51 | |||
52 | } |
libs/common/consumer-rules.pro
libs/common/libs/bdasr_V3_20191210_81acdf5.jar
No preview for this file type
libs/common/proguard-rules.pro
File was created | 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 |
libs/common/src/main/AndroidManifest.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | package="com.prws.common"> | ||
4 | |||
5 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
6 | </manifest> |
libs/common/src/main/assets/app-config-area-type.json
File was created | 1 | [ | |
2 | { | ||
3 | "typeName": "导航点", | ||
4 | "typeIndex": 2 | ||
5 | }, | ||
6 | { | ||
7 | "typeName": "工作区域", | ||
8 | "typeIndex": 6 | ||
9 | }, | ||
10 | { | ||
11 | "typeName": "边推工作区", | ||
12 | "typeIndex": 14 | ||
13 | }, | ||
14 | { | ||
15 | "typeName": "清洁点", | ||
16 | "typeIndex": 7 | ||
17 | }, | ||
18 | { | ||
19 | "typeName": "地毯区", | ||
20 | "typeIndex": 8 | ||
21 | }, | ||
22 | { | ||
23 | "typeName": "减速带区", | ||
24 | "typeIndex": 9 | ||
25 | }, | ||
26 | { | ||
27 | "typeName": "斜坡区", | ||
28 | "typeIndex": 10 | ||
29 | }, | ||
30 | { | ||
31 | "typeName": "长走廊区", | ||
32 | "typeIndex": 11 | ||
33 | }, | ||
34 | { | ||
35 | "typeName": "盲道区", | ||
36 | "typeIndex": 12 | ||
37 | }, | ||
38 | { | ||
39 | "typeName": "初始点", | ||
40 | "typeIndex": 0 | ||
41 | }, | ||
42 | { | ||
43 | "typeName": "充电点", | ||
44 | "typeIndex": 1 | ||
45 | }, | ||
46 | { | ||
47 | "typeName": "避障区", | ||
48 | "typeIndex": 13 | ||
49 | }, | ||
50 | { | ||
51 | "typeName": "定位辅助点", | ||
52 | "typeIndex": 17 | ||
53 | }, | ||
54 | { | ||
55 | "typeName": "手绘区域路径", | ||
56 | "typeIndex": 18 | ||
57 | }, | ||
58 | { | ||
59 | "typeName": "机器定位区域路径", | ||
60 | "typeIndex": 19 | ||
61 | } | ||
62 | ] | ||
63 | |||
64 |
libs/common/src/main/assets/app-config-default.json
File was created | 1 | { | |
2 | "splash": "prws", | ||
3 | "batteryThreshold": 20, | ||
4 | "defaultAdvancedPassword": "sh", | ||
5 | "defaultLockScreenPassword": "sh", | ||
6 | "chargeSpotsMacAddress": "88:4A:18:82:E7:82", | ||
7 | "cloudConfig": { | ||
8 | "tenant": "prws", | ||
9 | "domain": "172.168.28.13", | ||
10 | "loginInfo": { | ||
11 | "username": "user001@pairs.prws.com.cn", | ||
12 | "password": "user001" | ||
13 | } | ||
14 | }, | ||
15 | "cleanConfig": { | ||
16 | "cleanLineSpacing": 0.3 | ||
17 | }, | ||
18 | "advertDisplayInterval": 60000, | ||
19 | "lockScreenInterval": 600000 | ||
20 | } |
libs/common/src/main/assets/app-config-dev.json
File was created | 1 | { | |
2 | "cloudConfig": { | ||
3 | "domain": "172.168.28.13" | ||
4 | } | ||
5 | } |
libs/common/src/main/java/com/prws/common/CommonApplication.java
File was created | 1 | package com.prws.common; | |
2 | |||
3 | import android.app.Application; | ||
4 | import android.content.Context; | ||
5 | |||
6 | import com.prws.common.utils.acmanager.ActivityManager; | ||
7 | |||
8 | public class CommonApplication extends Application { | ||
9 | /** | ||
10 | * 系统上下文 | ||
11 | */ | ||
12 | private static Context mAppContext; | ||
13 | |||
14 | @Override | ||
15 | public void onCreate() { | ||
16 | super.onCreate(); | ||
17 | mAppContext = getApplicationContext(); | ||
18 | //初始化activity管理器 | ||
19 | initActivityManager(); | ||
20 | |||
21 | |||
22 | } | ||
23 | |||
24 | |||
25 | /** | ||
26 | * 获取系统上下文:用于ToastUtil类 | ||
27 | */ | ||
28 | public static Context getAppContext() { | ||
29 | return mAppContext; | ||
30 | } | ||
31 | |||
32 | |||
33 | public void initActivityManager(){ | ||
34 | ActivityManager.getInstance().register(this); | ||
35 | } | ||
36 | |||
37 | |||
38 | } | ||
39 |
libs/common/src/main/java/com/prws/common/adapter/CommonAdapter.java
File was created | 1 | package com.prws.common.adapter; | |
2 | |||
3 | import android.view.ViewGroup; | ||
4 | |||
5 | import androidx.recyclerview.widget.RecyclerView; | ||
6 | |||
7 | import java.util.ArrayList; | ||
8 | import java.util.List; | ||
9 | |||
10 | /** | ||
11 | * @author zhiqun.tang | ||
12 | * @Description: | ||
13 | * @date 2022/8/10 | ||
14 | */ | ||
15 | public class CommonAdapter<T> extends RecyclerView.Adapter<CommonViewHolder> { | ||
16 | private List<T> mList; | ||
17 | |||
18 | private OnBindDataListener<T> onBindDataListener; | ||
19 | private OnMoreBindDataListener<T> onMoreBindDataListener; | ||
20 | |||
21 | public CommonAdapter(List<T> mList, OnBindDataListener<T> onBindDataListener) { | ||
22 | this.mList = mList; | ||
23 | this.onBindDataListener = onBindDataListener; | ||
24 | } | ||
25 | |||
26 | public CommonAdapter(List<T> mList, OnMoreBindDataListener<T> onMoreBindDataListener) { | ||
27 | this.mList = mList; | ||
28 | // this.mList.addAll(mList); | ||
29 | this.onBindDataListener = onMoreBindDataListener; | ||
30 | this.onMoreBindDataListener = onMoreBindDataListener; | ||
31 | } | ||
32 | |||
33 | //绑定数据 | ||
34 | public interface OnBindDataListener<T> { | ||
35 | void onBindViewHolder(T model, CommonViewHolder viewHolder, int type, int position); | ||
36 | |||
37 | int getLayoutId(int type); | ||
38 | } | ||
39 | |||
40 | //绑定多类型的数据 | ||
41 | public interface OnMoreBindDataListener<T> extends OnBindDataListener<T> { | ||
42 | int getItemType(int position); | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public int getItemViewType(int position) { | ||
47 | if (onMoreBindDataListener != null) { | ||
48 | return onMoreBindDataListener.getItemType(position); | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | @Override | ||
54 | public CommonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
55 | int layoutId = onBindDataListener.getLayoutId(viewType); | ||
56 | CommonViewHolder viewHolder = CommonViewHolder.getViewHolder(parent, layoutId); | ||
57 | return viewHolder; | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public void onBindViewHolder(CommonViewHolder holder, int position) { | ||
62 | onBindDataListener.onBindViewHolder( | ||
63 | mList.get(position), holder, getItemViewType(position), position); | ||
64 | } | ||
65 | |||
66 | @Override | ||
67 | public int getItemCount() { | ||
68 | return mList == null ? 0 : mList.size(); | ||
69 | } | ||
70 | } | ||
71 |
libs/common/src/main/java/com/prws/common/adapter/CommonViewHolder.java
File was created | 1 | package com.prws.common.adapter; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.util.SparseArray; | ||
5 | import android.view.LayoutInflater; | ||
6 | import android.view.View; | ||
7 | import android.view.ViewGroup; | ||
8 | import android.widget.ImageView; | ||
9 | import android.widget.TextView; | ||
10 | |||
11 | import androidx.recyclerview.widget.RecyclerView; | ||
12 | |||
13 | import com.prws.common.utils.GlideHelper; | ||
14 | |||
15 | import java.io.File; | ||
16 | |||
17 | /** | ||
18 | * @author zhiqun.tang | ||
19 | * @Description: CommonViewHolder | ||
20 | * @date 2022/8/10 | ||
21 | */ | ||
22 | public class CommonViewHolder extends RecyclerView.ViewHolder { | ||
23 | //子View的集合 | ||
24 | private SparseArray<View> mViews; | ||
25 | private View mContentView; | ||
26 | |||
27 | public CommonViewHolder(View itemView) { | ||
28 | super(itemView); | ||
29 | mViews = new SparseArray<>(); | ||
30 | mContentView = itemView; | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * 获取CommonViewHolder实体 | ||
35 | * | ||
36 | * @param parent | ||
37 | * @param layoutId | ||
38 | * @return | ||
39 | */ | ||
40 | public static CommonViewHolder getViewHolder(ViewGroup parent, int layoutId) { | ||
41 | return new CommonViewHolder(LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false)); | ||
42 | |||
43 | } | ||
44 | |||
45 | /** | ||
46 | * 提供给外部访问View的方法 | ||
47 | * | ||
48 | * @param viewId | ||
49 | * @param <T> | ||
50 | * @return | ||
51 | */ | ||
52 | public <T extends View> T getView(int viewId) { | ||
53 | View view = mViews.get(viewId); | ||
54 | if (view == null) { | ||
55 | view = mContentView.findViewById(viewId); | ||
56 | mViews.put(viewId, view); | ||
57 | } | ||
58 | return (T) view; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * @Author Zhiqun | ||
63 | * @Time 2022/3/28 | ||
64 | * @Description | ||
65 | **/ | ||
66 | public CommonViewHolder setText(int viewId, String text) { | ||
67 | TextView tv = getView(viewId); | ||
68 | tv.setText(text); | ||
69 | return this; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * 设置图片链接 | ||
74 | * | ||
75 | * @param mContext | ||
76 | * @param viewId | ||
77 | * @param url | ||
78 | * @return | ||
79 | */ | ||
80 | public CommonViewHolder setImageUrl(Context mContext, int viewId, String url) { | ||
81 | ImageView iv = getView(viewId); | ||
82 | GlideHelper.loadUrl(mContext, url, iv); | ||
83 | return this; | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * 压缩 | ||
88 | * | ||
89 | * @param mContext | ||
90 | * @param viewId | ||
91 | * @param url | ||
92 | * @param w | ||
93 | * @param h | ||
94 | * @return | ||
95 | */ | ||
96 | public CommonViewHolder setImageUrl(Context mContext, int viewId, String url, int w, int h) { | ||
97 | ImageView iv = getView(viewId); | ||
98 | GlideHelper.loadSmollUrl(mContext, url, w, h, iv); | ||
99 | return this; | ||
100 | } | ||
101 | |||
102 | |||
103 | /** | ||
104 | * 设置图片文件 | ||
105 | * | ||
106 | * @param mContext | ||
107 | * @param viewId | ||
108 | * @param file | ||
109 | * @return | ||
110 | */ | ||
111 | public CommonViewHolder setImageFile(Context mContext, int viewId, File file) { | ||
112 | ImageView iv = getView(viewId); | ||
113 | GlideHelper.loadFile(mContext, file, iv); | ||
114 | return this; | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * 设置图片 | ||
119 | * | ||
120 | * @param viewId | ||
121 | * @param resId | ||
122 | * @return | ||
123 | */ | ||
124 | public CommonViewHolder setImageResource(int viewId, int resId) { | ||
125 | ImageView iv = getView(viewId); | ||
126 | iv.setImageResource(resId); | ||
127 | return this; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * 设置背景颜色 | ||
132 | * | ||
133 | * @param viewId | ||
134 | * @param color | ||
135 | * @return | ||
136 | */ | ||
137 | public CommonViewHolder setBackgroundColor(int viewId, int color) { | ||
138 | ImageView iv = getView(viewId); | ||
139 | iv.setBackgroundColor(color); | ||
140 | return this; | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * 设置文本颜色 | ||
145 | * | ||
146 | * @param viewId | ||
147 | * @param color | ||
148 | * @return | ||
149 | */ | ||
150 | public CommonViewHolder setTextColor(int viewId, int color) { | ||
151 | TextView tv = getView(viewId); | ||
152 | tv.setTextColor(color); | ||
153 | return this; | ||
154 | } | ||
155 | |||
156 | |||
157 | /** | ||
158 | * 设置控件的显示隐藏 | ||
159 | * | ||
160 | * @param viewId | ||
161 | * @param visibility | ||
162 | * @return | ||
163 | */ | ||
164 | public CommonViewHolder setVisibility(int viewId, int visibility) { | ||
165 | TextView tv = getView(viewId); | ||
166 | tv.setVisibility(visibility); | ||
167 | return this; | ||
168 | } | ||
169 | } | ||
170 |
libs/common/src/main/java/com/prws/common/base/BaseActivity.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | |||
4 | import android.app.Activity; | ||
5 | import android.content.Context; | ||
6 | import android.content.Intent; | ||
7 | import android.os.Bundle; | ||
8 | import android.os.IBinder; | ||
9 | import android.util.Log; | ||
10 | import android.view.MotionEvent; | ||
11 | import android.view.View; | ||
12 | import android.view.Window; | ||
13 | import android.view.WindowManager; | ||
14 | import android.view.inputmethod.InputMethodManager; | ||
15 | import android.widget.EditText; | ||
16 | |||
17 | import androidx.annotation.IdRes; | ||
18 | import androidx.annotation.Nullable; | ||
19 | import androidx.appcompat.app.AppCompatActivity; | ||
20 | import androidx.fragment.app.Fragment; | ||
21 | import androidx.fragment.app.FragmentTransaction; | ||
22 | import androidx.lifecycle.Lifecycle; | ||
23 | |||
24 | import com.developer.wang.utils.PermissionUtils; | ||
25 | import com.prws.common.R; | ||
26 | import com.prws.common.net.INetEvent; | ||
27 | import com.prws.common.utils.LogUtil; | ||
28 | import com.prws.common.utils.ScreenUtils; | ||
29 | import com.prws.common.view.LoadingView; | ||
30 | |||
31 | import org.simple.eventbus.EventBus; | ||
32 | |||
33 | import java.util.ArrayList; | ||
34 | import java.util.List; | ||
35 | |||
36 | import butterknife.ButterKnife; | ||
37 | import io.reactivex.disposables.CompositeDisposable; | ||
38 | import io.reactivex.disposables.Disposable; | ||
39 | |||
40 | |||
41 | /** | ||
42 | * @author 描述:BaseActivity | ||
43 | */ | ||
44 | public abstract class BaseActivity<P extends BasePresenter, CONTRACT> extends AppCompatActivity implements INetEvent, BaseView { | ||
45 | |||
46 | |||
47 | private LoadingView loading; | ||
48 | |||
49 | public static INetEvent mINetEvent; | ||
50 | protected final String TAG = getClass().getSimpleName(); | ||
51 | private CompositeDisposable mCompositeDisposable; | ||
52 | protected P p; | ||
53 | |||
54 | /** | ||
55 | * 获取布局文件 | ||
56 | * | ||
57 | * @return | ||
58 | */ | ||
59 | protected abstract int layoutResId(); | ||
60 | |||
61 | /** | ||
62 | * 让P层做相应需求 | ||
63 | */ | ||
64 | public abstract CONTRACT getContract(); | ||
65 | |||
66 | /** | ||
67 | * 子类获取具体契约 | ||
68 | */ | ||
69 | public abstract P getPresenter(); | ||
70 | |||
71 | @Override | ||
72 | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
73 | super.onCreate(savedInstanceState); | ||
74 | setNetEvent(); | ||
75 | initPresenter(); | ||
76 | // setWindow(); | ||
77 | setContentView(layoutResId()); | ||
78 | ButterKnife.bind(this); | ||
79 | registerEventBus(); | ||
80 | initView(); | ||
81 | initListener(); | ||
82 | initData(); | ||
83 | |||
84 | } | ||
85 | |||
86 | |||
87 | @Override | ||
88 | protected void onResume() { | ||
89 | super.onResume(); | ||
90 | } | ||
91 | |||
92 | protected abstract void initView(); | ||
93 | |||
94 | protected abstract void initListener(); | ||
95 | |||
96 | protected abstract void initData(); | ||
97 | |||
98 | |||
99 | private void setNetEvent() { | ||
100 | mINetEvent = this; | ||
101 | } | ||
102 | |||
103 | private void initPresenter() { | ||
104 | p = getPresenter(); | ||
105 | if (p != null) | ||
106 | p.bindView(this); | ||
107 | } | ||
108 | |||
109 | private void setWindow() { | ||
110 | Window window = getWindow(); | ||
111 | WindowManager.LayoutParams params = window.getAttributes(); | ||
112 | params.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN | ||
113 | ; | ||
114 | window.setAttributes(params); | ||
115 | } | ||
116 | |||
117 | |||
118 | |||
119 | |||
120 | private void addNavigationBar() { | ||
121 | //判断是否有浮窗权限 | ||
122 | if (PermissionUtils.requestWindowManager(this)) { | ||
123 | //开启浮窗 | ||
124 | // openFloatWindow(); | ||
125 | } else { | ||
126 | showAlertDialogOfFloatWindow(); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | // public void openFloatWindow() { | ||
131 | // if (FloatWindow.get("navigation") == null) { | ||
132 | // NavigationBarView navigationBarView = new NavigationBarView(this); | ||
133 | // FloatWindow.with(CommonApplication.getAppContext()) | ||
134 | // .setView(navigationBarView) | ||
135 | // .setWidth(Screen.width, 1) | ||
136 | // .setHeight(WindowManager.LayoutParams.WRAP_CONTENT) | ||
137 | // .setX(0) | ||
138 | // .setY(0) | ||
139 | // .setMoveType(MoveType.inactive) | ||
140 | // .setDesktopShow(false) | ||
141 | // .setTag("navigation") | ||
142 | // .build(); | ||
143 | // } | ||
144 | // if (!FloatWindow.get("navigation").isShowing()) | ||
145 | // FloatWindow.get("navigation").show(); | ||
146 | // | ||
147 | // } | ||
148 | |||
149 | |||
150 | |||
151 | public void showAlertDialogOfFloatWindow() { | ||
152 | //弹窗提示用户开启权限 | ||
153 | // new AlertDialog(this).builder().setTitle(getString(R.string.need_permission)) | ||
154 | // .setMsg(getString(R.string.need_permission_window)) | ||
155 | // .setPositiveButton(getString(R.string.open), new View.OnClickListener() { | ||
156 | // @Override | ||
157 | // public void onClick(View v) { | ||
158 | // Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); | ||
159 | // intent.setData(Uri.parse("package:" + getPackageName())); | ||
160 | // startActivity(intent); | ||
161 | // } | ||
162 | // }).setNegativeButton(getString(R.string.cancel), new View.OnClickListener() { | ||
163 | // @Override | ||
164 | // public void onClick(View v) { | ||
165 | // } | ||
166 | // }).show(); | ||
167 | LogUtil.toast("请开启浮窗权限"); | ||
168 | } | ||
169 | |||
170 | |||
171 | public void showLoading(String title) { | ||
172 | synchronized (this) { | ||
173 | if (loading != null || !isLiving(this)) return; | ||
174 | runOnUiThread(() -> { | ||
175 | loading = new LoadingView(this, R.style.CustomDialog, title); | ||
176 | loading.show(); | ||
177 | ScreenUtils.hideBottomUIMenu(this); | ||
178 | ScreenUtils.hideDialogBottomUIMenu(loading); | ||
179 | }); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | |||
184 | public void setCanAble(boolean canAble) { | ||
185 | if (loading != null) | ||
186 | loading.setCancelable(canAble); | ||
187 | |||
188 | } | ||
189 | |||
190 | public boolean isShowLoading() { | ||
191 | if (loading == null) return false; | ||
192 | return loading.isShowing(); | ||
193 | } | ||
194 | |||
195 | public void dismissLoading() { | ||
196 | runOnUiThread(() -> { | ||
197 | if (loading == null || loading.isShowing() == false || !isLiving(this)) { | ||
198 | Log.w(TAG, "loading == null" + | ||
199 | " || loading.isShowing() == false >> return;"); | ||
200 | return; | ||
201 | } | ||
202 | loading.dismiss(); | ||
203 | loading = null; | ||
204 | |||
205 | }); | ||
206 | } | ||
207 | |||
208 | |||
209 | private static boolean isLiving(Activity activity) { | ||
210 | |||
211 | if (activity == null) { | ||
212 | Log.d("wisely", "activity == null"); | ||
213 | return false; | ||
214 | } | ||
215 | |||
216 | if (activity.isFinishing()) { | ||
217 | Log.d("wisely", "activity is finishing"); | ||
218 | return false; | ||
219 | } | ||
220 | |||
221 | return true; | ||
222 | } | ||
223 | |||
224 | |||
225 | /** | ||
226 | * 是否需要弹窗提示更新 | ||
227 | */ | ||
228 | protected void isNeedGetVersionUpdate() { | ||
229 | // View view = findViewById(R.id.view_loading); | ||
230 | //如果显示正在下载的页面,则不弹出更新弹窗 | ||
231 | // if (null == view || view.getVisibility() == View.VISIBLE) return; | ||
232 | // UpdateUtils.getVersion(this); | ||
233 | } | ||
234 | |||
235 | |||
236 | /** | ||
237 | * 全局检测网络广播的回调 处理网络变化 | ||
238 | * 注:在程序第一次启动的时候,没网并不会回调,需要自己在启动页面,或者主页自己再判断一次 | ||
239 | * | ||
240 | * @param netWorkState 网络状态 -1:没网络 0:移动网络 1:WiFi网络 | ||
241 | */ | ||
242 | public abstract void onNetChanged(int netWorkState); | ||
243 | |||
244 | @Override | ||
245 | public void onNetChange(int netWorkState) { | ||
246 | onNetChanged(netWorkState); | ||
247 | } | ||
248 | |||
249 | @Override | ||
250 | protected void onDestroy() { | ||
251 | super.onDestroy(); | ||
252 | unSubscribe(); | ||
253 | cleanFragment(); | ||
254 | unregisterEventBus(); | ||
255 | if (p != null) { | ||
256 | p.onBindView(); | ||
257 | p.cancelAllRequest(); | ||
258 | } | ||
259 | } | ||
260 | |||
261 | @Override | ||
262 | protected void onPause() { | ||
263 | super.onPause(); | ||
264 | |||
265 | } | ||
266 | |||
267 | private void registerEventBus(){ | ||
268 | EventBus.getDefault().register(this); | ||
269 | } | ||
270 | |||
271 | private void unregisterEventBus(){ | ||
272 | EventBus.getDefault().unregister(this); | ||
273 | } | ||
274 | |||
275 | public void showErrorToast() { | ||
276 | // LogUtil.toast(MainApplication.getAppContext(), getString(R.string.service_error)); | ||
277 | } | ||
278 | |||
279 | private void unSubscribe() { | ||
280 | if (mCompositeDisposable != null) { | ||
281 | mCompositeDisposable.clear(); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | protected void addSubscribe(Disposable disposable) { | ||
286 | if (mCompositeDisposable == null) { | ||
287 | mCompositeDisposable = new CompositeDisposable(); | ||
288 | } | ||
289 | mCompositeDisposable.add(disposable); | ||
290 | } | ||
291 | |||
292 | protected void startActivity(Class clazz) { | ||
293 | startActivity(new Intent(this, clazz)); | ||
294 | } | ||
295 | |||
296 | /******************** 处理fragment *******************************/ | ||
297 | List<Fragment> fragmentList = new ArrayList<>(); | ||
298 | |||
299 | protected void showFragment(Fragment fragment, @IdRes int id) { | ||
300 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | ||
301 | |||
302 | if (!fragmentList.contains(fragment)) { | ||
303 | fragmentList.add(fragment); | ||
304 | fragmentTransaction.add(id, fragment, fragment.getClass().getSimpleName()).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); | ||
305 | } | ||
306 | |||
307 | fragmentTransaction.show(fragment).setMaxLifecycle(fragment, Lifecycle.State.RESUMED); | ||
308 | |||
309 | for (Fragment fragment1 : fragmentList) { | ||
310 | if (fragment1 != fragment) { | ||
311 | fragmentTransaction.hide(fragment1).setMaxLifecycle(fragment1, Lifecycle.State.STARTED); | ||
312 | } | ||
313 | } | ||
314 | |||
315 | fragmentTransaction.commitAllowingStateLoss(); | ||
316 | |||
317 | } | ||
318 | |||
319 | protected void cleanFragment() { | ||
320 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); | ||
321 | if (fragmentList.size() > 0) { | ||
322 | for (Fragment fragment : fragmentList) { | ||
323 | fragmentTransaction.remove(fragment); | ||
324 | } | ||
325 | try { | ||
326 | fragmentTransaction.commitNowAllowingStateLoss(); | ||
327 | }catch (Exception e){e.printStackTrace();} | ||
328 | } | ||
329 | fragmentList.clear(); | ||
330 | } | ||
331 | |||
332 | //************************* 用于隐藏键盘 ***************************************// | ||
333 | @Override | ||
334 | public boolean dispatchTouchEvent(MotionEvent ev) { | ||
335 | if (ev.getAction() == MotionEvent.ACTION_DOWN){ | ||
336 | |||
337 | View v = getCurrentFocus(); | ||
338 | if (isShouldHideInput(v,ev)){ | ||
339 | hideSoftInput(v.getWindowToken()); | ||
340 | } | ||
341 | } | ||
342 | return super.dispatchTouchEvent(ev); | ||
343 | } | ||
344 | private boolean isShouldHideInput(View v,MotionEvent event){ | ||
345 | if(v !=null&&(v instanceof EditText)){ | ||
346 | int[] l ={0,0}; | ||
347 | v.getLocationInWindow(l); | ||
348 | int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left | ||
349 | + v.getWidth(); | ||
350 | if(event.getX()> left &&event.getX()< right | ||
351 | &&event.getY()> top &&event.getY()< bottom){ | ||
352 | // 点击EditText的事件,忽略它。 | ||
353 | return false; | ||
354 | }else{ | ||
355 | return true; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | return false; | ||
360 | } | ||
361 | |||
362 | /** | ||
363 | * 多种隐藏软件盘方法的其中一种 | ||
364 | * | ||
365 | * @param token | ||
366 | */ | ||
367 | private void hideSoftInput(IBinder token){ | ||
368 | LogUtil.i(TAG,"隐藏键盘"); | ||
369 | if(token !=null){ | ||
370 | InputMethodManager im =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | ||
371 | im.hideSoftInputFromWindow(token, | ||
372 | InputMethodManager.HIDE_NOT_ALWAYS); | ||
373 | } | ||
374 | } | ||
375 | |||
376 | //************************* 用于隐藏键盘 end***************************************// | ||
377 | |||
378 | |||
379 | } | ||
380 |
libs/common/src/main/java/com/prws/common/base/BaseContract.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | import io.reactivex.disposables.Disposable; | ||
4 | |||
5 | /** | ||
6 | * 基础契约类,用于管理presenter和view | ||
7 | */ | ||
8 | public interface BaseContract { | ||
9 | interface BaseView { | ||
10 | /** | ||
11 | * 显示进度框 | ||
12 | */ | ||
13 | void showProgress(); | ||
14 | |||
15 | /** | ||
16 | * 隐藏loading框 | ||
17 | */ | ||
18 | void dismissProgress(); | ||
19 | /** | ||
20 | * 添加disposable,用于在合适的时机释放 | ||
21 | * | ||
22 | * @param disposable | ||
23 | */ | ||
24 | void addDisposable(Disposable disposable); | ||
25 | |||
26 | /** | ||
27 | * 请求失败情况下,某些接口需要特殊处理 | ||
28 | * 可以再这里处理,默认空实现 | ||
29 | * | ||
30 | * @param code 失败code | ||
31 | */ | ||
32 | default void loadDataError(int code, String message) { | ||
33 | |||
34 | } | ||
35 | } | ||
36 | |||
37 | interface BasePresenter<T> { | ||
38 | |||
39 | /** | ||
40 | * 绑定 | ||
41 | * | ||
42 | * @param view view | ||
43 | */ | ||
44 | void attachView(T view); | ||
45 | |||
46 | /** | ||
47 | * 解绑 | ||
48 | */ | ||
49 | void detachView(); | ||
50 | } | ||
51 | |||
52 | } | ||
53 |
libs/common/src/main/java/com/prws/common/base/BaseFragment.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.os.Bundle; | ||
5 | import android.view.LayoutInflater; | ||
6 | import android.view.View; | ||
7 | import android.view.ViewGroup; | ||
8 | |||
9 | import androidx.annotation.LayoutRes; | ||
10 | import androidx.annotation.NonNull; | ||
11 | import androidx.annotation.Nullable; | ||
12 | import androidx.fragment.app.Fragment; | ||
13 | |||
14 | |||
15 | import org.simple.eventbus.EventBus; | ||
16 | |||
17 | import io.reactivex.disposables.CompositeDisposable; | ||
18 | import io.reactivex.disposables.Disposable; | ||
19 | |||
20 | public abstract class BaseFragment extends Fragment { | ||
21 | |||
22 | protected View mRootView; | ||
23 | |||
24 | |||
25 | @Override | ||
26 | public void onCreate(@Nullable Bundle savedInstanceState) { | ||
27 | super.onCreate(savedInstanceState); | ||
28 | EventBus.getDefault().register(this); | ||
29 | } | ||
30 | |||
31 | |||
32 | @Nullable | ||
33 | @Override | ||
34 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
35 | if (mRootView != null) { | ||
36 | ViewGroup parent = (ViewGroup) mRootView.getParent(); | ||
37 | if (parent != null) | ||
38 | parent.removeView(mRootView); | ||
39 | } else { | ||
40 | mRootView = inflater.inflate(getLayoutRes(), container, false); | ||
41 | } | ||
42 | return mRootView; | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
47 | super.onViewCreated(view, savedInstanceState); | ||
48 | |||
49 | initDatas(); | ||
50 | } | ||
51 | |||
52 | protected abstract @LayoutRes | ||
53 | int getLayoutRes(); | ||
54 | |||
55 | |||
56 | protected void initDatas() { | ||
57 | } | ||
58 | |||
59 | @Override | ||
60 | public void onAttach(Context context) { | ||
61 | super.onAttach(context); | ||
62 | } | ||
63 | |||
64 | @Override | ||
65 | public void onDetach() { | ||
66 | super.onDetach(); | ||
67 | } | ||
68 | |||
69 | @Override | ||
70 | public void onPause() { | ||
71 | super.onPause(); | ||
72 | |||
73 | } | ||
74 | |||
75 | @Override | ||
76 | public void onResume() { | ||
77 | super.onResume(); | ||
78 | |||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public void onDestroy() { | ||
83 | super.onDestroy(); | ||
84 | EventBus.getDefault().unregister(this); | ||
85 | |||
86 | } | ||
87 | |||
88 | |||
89 | protected void showErrorToast() { | ||
90 | // LogUtil.toast(MainApplication.getAppContext(),getString(R.string.service_error)); | ||
91 | } | ||
92 | |||
93 | } | ||
94 |
libs/common/src/main/java/com/prws/common/base/BaseModel.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | import io.reactivex.disposables.CompositeDisposable; | ||
4 | |||
5 | /** | ||
6 | * @author | ||
7 | * | ||
8 | * 描述:BaseModel | ||
9 | */ | ||
10 | public abstract class BaseModel<P extends BasePresenter, CONTRACT> { | ||
11 | public P p; | ||
12 | //销毁Tag集合 | ||
13 | protected CompositeDisposable disposables = new CompositeDisposable(); | ||
14 | |||
15 | public BaseModel(P p) { | ||
16 | this.p = p; | ||
17 | } | ||
18 | |||
19 | public abstract CONTRACT getContract(); | ||
20 | |||
21 | /** | ||
22 | * 页面销毁时取消所有网络请求 | ||
23 | */ | ||
24 | void cancelAllRequest() { | ||
25 | disposables.clear(); | ||
26 | } | ||
27 | } | ||
28 |
libs/common/src/main/java/com/prws/common/base/BasePresenter.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | import java.lang.ref.WeakReference; | ||
4 | |||
5 | /** | ||
6 | * @author | ||
7 | * | ||
8 | * 描述:BasePresenter | ||
9 | */ | ||
10 | public abstract class BasePresenter<V extends BaseView,M extends BaseModel,CONTRACT> { | ||
11 | |||
12 | protected final String TAG = getClass().getSimpleName(); | ||
13 | |||
14 | protected M m; | ||
15 | |||
16 | private WeakReference<V> vWeakReference; | ||
17 | |||
18 | public BasePresenter() { | ||
19 | m=getModel(); | ||
20 | } | ||
21 | |||
22 | public void bindView(V v) { | ||
23 | vWeakReference =new WeakReference<>(v); | ||
24 | } | ||
25 | |||
26 | public void onBindView() { | ||
27 | if(vWeakReference!=null){ | ||
28 | vWeakReference.clear(); | ||
29 | vWeakReference=null; | ||
30 | System.gc(); | ||
31 | } | ||
32 | |||
33 | } | ||
34 | |||
35 | |||
36 | public V getView() { | ||
37 | if(vWeakReference!=null){ | ||
38 | return vWeakReference.get(); | ||
39 | } | ||
40 | return null; | ||
41 | } | ||
42 | |||
43 | public abstract CONTRACT getContract(); | ||
44 | |||
45 | /** | ||
46 | * 获取子类MODE层具体业务 | ||
47 | * @return | ||
48 | */ | ||
49 | public abstract M getModel(); | ||
50 | |||
51 | /** | ||
52 | * 页面销毁时取消所有网络请求 | ||
53 | */ | ||
54 | public void cancelAllRequest() { | ||
55 | m.cancelAllRequest(); | ||
56 | } | ||
57 | } | ||
58 |
libs/common/src/main/java/com/prws/common/base/BaseView.java
File was created | 1 | package com.prws.common.base; | |
2 | |||
3 | import android.os.Bundle; | ||
4 | |||
5 | /** | ||
6 | * @author | ||
7 | * | ||
8 | * 描述:BaseView | ||
9 | */ | ||
10 | public interface BaseView { | ||
11 | |||
12 | } | ||
13 |
libs/common/src/main/java/com/prws/common/bean/BaseEntity.java
File was created | 1 | package com.prws.common.bean; | |
2 | |||
3 | import com.google.gson.annotations.SerializedName; | ||
4 | |||
5 | /** | ||
6 | * | ||
7 | * | ||
8 | * 描述:BaseEntity | ||
9 | */ | ||
10 | public class BaseEntity { | ||
11 | protected int code; | ||
12 | |||
13 | @SerializedName(value = "message",alternate = "msg") | ||
14 | protected Object message; | ||
15 | |||
16 | protected boolean success; | ||
17 | |||
18 | |||
19 | public boolean isSucceed() { | ||
20 | return success; | ||
21 | } | ||
22 | |||
23 | public void setSucceed(boolean succeed) { | ||
24 | this.success = succeed; | ||
25 | } | ||
26 | |||
27 | public int getCode() { | ||
28 | return code; | ||
29 | } | ||
30 | |||
31 | public void setCode(int code) { | ||
32 | this.code = code; | ||
33 | } | ||
34 | |||
35 | public String getMessage() { | ||
36 | if (message == null) | ||
37 | return ""; | ||
38 | return message.toString(); | ||
39 | } | ||
40 | |||
41 | public void setMessage(Object message) { | ||
42 | this.message = message; | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public String toString() { | ||
47 | return "BaseEntity{" + | ||
48 | "code=" + code + | ||
49 | ", message=" + message + | ||
50 | ", success=" + success + | ||
51 | '}'; | ||
52 | } | ||
53 | } | ||
54 |
libs/common/src/main/java/com/prws/common/bean/NavigationBarStatusBean.java
File was created | 1 | package com.prws.common.bean; | |
2 | |||
3 | public class NavigationBarStatusBean { | ||
4 | boolean isStop; | ||
5 | boolean isCharging; | ||
6 | int battery; | ||
7 | int mode; | ||
8 | |||
9 | public int getMode() { | ||
10 | return mode; | ||
11 | } | ||
12 | |||
13 | public NavigationBarStatusBean setMode(int mode) { | ||
14 | this.mode = mode; | ||
15 | return this; | ||
16 | } | ||
17 | |||
18 | public boolean isStop() { | ||
19 | return isStop; | ||
20 | } | ||
21 | |||
22 | public NavigationBarStatusBean setStop(boolean stop) { | ||
23 | isStop = stop; | ||
24 | return this; | ||
25 | } | ||
26 | |||
27 | public boolean isCharging() { | ||
28 | return isCharging; | ||
29 | } | ||
30 | |||
31 | public NavigationBarStatusBean setCharging(boolean charging) { | ||
32 | isCharging = charging; | ||
33 | return this; | ||
34 | } | ||
35 | |||
36 | public int getBattery() { | ||
37 | return battery; | ||
38 | } | ||
39 | |||
40 | public NavigationBarStatusBean setBattery(int battery) { | ||
41 | this.battery = battery; | ||
42 | return this; | ||
43 | } | ||
44 | } | ||
45 |
libs/common/src/main/java/com/prws/common/config/AppConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | public interface AppConfig { | ||
4 | |||
5 | //上传CCU 分段文件的大小 | ||
6 | int uploadFileCuttingSize = 10 * 1024 * 1024; | ||
7 | |||
8 | |||
9 | /********************************************* 用于请求接口使用的接口后缀 start************************************/ | ||
10 | //机器人指令 派特纳公司 尘推 | ||
11 | String MACHINE_INSTRUCTION_PRW_TYPE_CLEANER = "/device/cleaner"; | ||
12 | |||
13 | //机器人指令 派特纳公司 消杀 | ||
14 | String MACHINE_INSTRUCTION_PRW_TYPE_DISINFECTION = "/device/disinfection"; | ||
15 | |||
16 | String MACHINE_INSTRUCTION_PRW_TYPE_SETTING = "/ccu_server/set_param"; | ||
17 | |||
18 | String MACHINE_INSTRUCTION_PRW_TYPE_TTS = "/prw_speaker/tts"; | ||
19 | |||
20 | String MACHINE_INSTRUCTION_PRW_TYPE_TASK_LIST = "/ccu_server/exec_task_list"; | ||
21 | |||
22 | String MACHINE_INSTRUCTION_PRW_TYPE_AUDIO_SET = "/ccu_server/set_audio_info"; | ||
23 | |||
24 | String MACHINE_INSTRUCTION_PRW_TYPE_SET_VOLUME = "/ccu_server/set_system_volume"; | ||
25 | |||
26 | String MACHINE_INSTRUCTION_PRW_TYPE_SET_MAX_SPEED = "/ccu_server/set_max_speed"; | ||
27 | |||
28 | String MACHINE_INSTRUCTION_PRW_TYPE_INITIAL_POSE = "/ccu_server/initial_pose"; | ||
29 | |||
30 | //导航路径 | ||
31 | String MACHINE_INSTRUCTION_PRW_TYPE_COVERAGE_PATH = "/ccu_server/coverage_path"; | ||
32 | |||
33 | //切换地图 | ||
34 | String MACHINE_INSTRUCTION_PRW_TYPE_SWITCH_NAV_MAP = "/ccu_server/switch_nav_map"; | ||
35 | |||
36 | //加载地图element | ||
37 | String MACHINE_INSTRUCTION_PRW_TYPE_RELOAD_MAP_ELEMENT = "/ccu_server/reload_map_element"; | ||
38 | |||
39 | String MACHINE_INSTRUCTION_PRW_TYPE_MONITOR_FAILURE = "/monitor_failure/control"; | ||
40 | |||
41 | String MACHINE_INSTRUCTION_PRW_TYPE_SIDE_PUSH = "/paimo_sidebrush"; | ||
42 | |||
43 | String MACHINE_INSTRUCTION_PRW_TYPE_MONITOR_QUERY = "/monitor_failure/query"; | ||
44 | |||
45 | String MACHINE_INSTRUCTION_PRW_TYPE_MONITOR_DEVICE_STATE = "/monitor_failure/device_state"; | ||
46 | |||
47 | String MACHINE_INSTRUCTION_PRW_TYPE_MONITOR_PURGE_POLICY = "/monitor_failure/purge_policy"; | ||
48 | |||
49 | String MACHINE_INSTRUCTION_PRW_TYPE_PACK_MAP = "/pack_map"; | ||
50 | |||
51 | String MACHINE_INSTRUCTION_PRW_TYPE_SCORE = "/loca_eva/score_srv"; | ||
52 | |||
53 | String MACHINE_INSTRUCTION_PRW_TYPE_CUSTOM_TASK = "/custom_task"; | ||
54 | |||
55 | String MACHINE_INSTRUCTION_PRW_TYPE_CURRENT_NAV_MAP = "/ccu_server/get_cur_nav_map"; | ||
56 | |||
57 | String MACHINE_INSTRUCTION_PRW_TYPE_DELETE_NAV_MAP = "/ccu_server/del_nav_map"; | ||
58 | |||
59 | String MACHINE_INSTRUCTION_PRW_TYPE_CREATE_MAP = "/ccu_server/create_nav_map"; | ||
60 | |||
61 | String MACHINE_INSTRUCTION_PRW_TYPE_SAVE_NAV_MAP = "/ccu_server/save_nav_map"; | ||
62 | |||
63 | String MACHINE_INSTRUCTION_PRW_TYPE_CANCEL_MAPPING = "/ccu_server/cancel_mapping"; | ||
64 | |||
65 | String MACHINE_INSTRUCTION_PRW_TYPE_WASH = "/paiwe_cleaner"; | ||
66 | |||
67 | String MACHINE_INSTRUCTION_PRW_TYPE_DEPRECATED = "/ccu_server/edge_task"; | ||
68 | |||
69 | |||
70 | /********************************************* 用于请求接口使用的接口后缀 end ************************************/ | ||
71 | |||
72 | |||
73 | /****************************** 一些app的初始化配置项 start *******************************/ | ||
74 | |||
75 | |||
76 | } | ||
77 |
libs/common/src/main/java/com/prws/common/config/AppConstant.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | import com.prws.common.utils.LogUtil; | ||
4 | |||
5 | import java.util.Map; | ||
6 | |||
7 | final public class AppConstant { | ||
8 | public static String splash; | ||
9 | public static final String cacheKey = "AppConfigCacheKey"; | ||
10 | public static Boolean pendingSync = false; | ||
11 | |||
12 | public static Integer batteryThreshold = 20; | ||
13 | public static Integer advertDisplayInterval = 60000; | ||
14 | public static Integer lockScreenInterval = 60 * 1000; | ||
15 | |||
16 | public static String rdkVersion = "bozhon"; | ||
17 | |||
18 | |||
19 | public static String defaultAdvancedPassword; | ||
20 | public static String defaultLockScreenPassword; | ||
21 | |||
22 | public static String chargeSpotsMacAddress; | ||
23 | |||
24 | public static Map<String, Object> defaultMedia; | ||
25 | |||
26 | public static WorkConfig workConfig = new WorkConfig(); | ||
27 | |||
28 | public static CloudConfig cloudConfig = new CloudConfig(); | ||
29 | public static String deviceId = null; | ||
30 | public static void setDeviceId(String id){ | ||
31 | if (id!=null) | ||
32 | LogUtil.e("AppConstant","setDeviceId : "+id); | ||
33 | else | ||
34 | LogUtil.e("AppConstant","setDeviceId : is null "); | ||
35 | deviceId = id; | ||
36 | } | ||
37 | } | ||
38 |
libs/common/src/main/java/com/prws/common/config/CleanConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | import java.util.Map; | ||
4 | |||
5 | public class CleanConfig { | ||
6 | private Double cleanLineSpacing = 0.4D; // 弓字清扫的行间距 | ||
7 | |||
8 | public CleanConfig setMap(Map<String, Object> cloudMap) { | ||
9 | if (cloudMap.get("cleanLineSpacing") != null) { | ||
10 | cleanLineSpacing = (Double) cloudMap.get("cleanLineSpacing"); | ||
11 | } | ||
12 | return this; | ||
13 | } | ||
14 | |||
15 | public Double getCleanLineSpacing() { | ||
16 | return cleanLineSpacing; | ||
17 | } | ||
18 | |||
19 | public void setCleanLineSpacing(Double cleanLineSpacing) { | ||
20 | this.cleanLineSpacing = cleanLineSpacing; | ||
21 | } | ||
22 | } | ||
23 |
libs/common/src/main/java/com/prws/common/config/CloudConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | import android.util.Log; | ||
4 | |||
5 | import com.prws.common.net.NetWorks; | ||
6 | |||
7 | import java.util.Map; | ||
8 | import java.util.Timer; | ||
9 | import java.util.TimerTask; | ||
10 | |||
11 | public class CloudConfig { | ||
12 | private String tenant; | ||
13 | private String domain; | ||
14 | private String apiBase; | ||
15 | private String mqttBaseUrl; | ||
16 | private String loginUsername; | ||
17 | private String loginPassword; | ||
18 | |||
19 | public void setCloudMap(Map<String, Object> cloudMap) { | ||
20 | // if (cloudMap.get("apiBase") != null) | ||
21 | // this.setApiBase((String) cloudMap.get("apiBase")); | ||
22 | // if (cloudMap.get("mqttBaseUrl") != null) | ||
23 | // this.setMqttBaseUrl((String) cloudMap.get("mqttBaseUrl")); | ||
24 | |||
25 | if (cloudMap.get("domain") != null) { | ||
26 | this.setDomain((String) cloudMap.get("domain")); | ||
27 | } | ||
28 | |||
29 | if (cloudMap.get("tenant") != null) | ||
30 | this.setTenant((String) cloudMap.get("tenant")); | ||
31 | if (cloudMap.get("loginInfo") != null) { | ||
32 | Map<String, Object> loginInfoMap = (Map) cloudMap.get("loginInfo"); | ||
33 | this.setLoginUsername((String) loginInfoMap.get("username")); | ||
34 | this.setLoginPassword((String) loginInfoMap.get("password")); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | public String getTenant() { | ||
39 | return tenant; | ||
40 | } | ||
41 | |||
42 | public void setTenant(String tenant) { | ||
43 | this.tenant = tenant; | ||
44 | } | ||
45 | |||
46 | public String getDomain() { | ||
47 | return domain; | ||
48 | } | ||
49 | |||
50 | public void setDomain(String domain) { | ||
51 | this.domain = domain; | ||
52 | apiBase = "http://" + domain + ":88"; | ||
53 | mqttBaseUrl = "tcp://" + domain + ":1883"; | ||
54 | Log.e("TAG","domain:"+domain); | ||
55 | //这里由于加载文件的逻辑,会导致其运行多次,而Retrofit的url为final所以做个延迟处理 | ||
56 | |||
57 | } | ||
58 | |||
59 | |||
60 | public String getApiBase() { | ||
61 | return apiBase; | ||
62 | } | ||
63 | |||
64 | public void setApiBase(String apiBase) { | ||
65 | this.apiBase = apiBase; | ||
66 | } | ||
67 | |||
68 | public String getMqttBaseUrl() { | ||
69 | return mqttBaseUrl; | ||
70 | } | ||
71 | |||
72 | public void setMqttBaseUrl(String mqttBaseUrl) { | ||
73 | this.mqttBaseUrl = mqttBaseUrl; | ||
74 | } | ||
75 | |||
76 | public String getLoginUsername() { | ||
77 | return loginUsername; | ||
78 | } | ||
79 | |||
80 | public void setLoginUsername(String loginUsername) { | ||
81 | this.loginUsername = loginUsername; | ||
82 | } | ||
83 | |||
84 | public String getLoginPassword() { | ||
85 | return loginPassword; | ||
86 | } | ||
87 | |||
88 | public void setLoginPassword(String loginPassword) { | ||
89 | this.loginPassword = loginPassword; | ||
90 | } | ||
91 | } | ||
92 |
libs/common/src/main/java/com/prws/common/config/DevicesConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | public class DevicesConfig { | ||
4 | /****************************** 一些设备的初始化配置项 end *******************************/ | ||
5 | //清洁的配置项 | ||
6 | public static CleanConfig cleanConfig = null; | ||
7 | } | ||
8 |
libs/common/src/main/java/com/prws/common/config/SettingConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.SharedPreferences; | ||
5 | |||
6 | import com.developer.wang.utils.SharedPreferencesUtils; | ||
7 | import com.developer.wang.utils.gson.MyGson; | ||
8 | import com.prws.common.CommonApplication; | ||
9 | |||
10 | |||
11 | public class SettingConfig { | ||
12 | private Boolean showDefaultImage = false; | ||
13 | private Boolean showLogo = false; | ||
14 | |||
15 | private Boolean loadDisinfectModel = false; // 是否启用消杀 | ||
16 | private Boolean loadCleanModel = true; // 是否启用 | ||
17 | private Boolean loadSidePushModel = false;//是否启用边推 | ||
18 | |||
19 | private Integer cleanModelPressureLevel = 2; // 清洁模块的压力等级 | ||
20 | |||
21 | private static volatile SettingConfig mInstance; | ||
22 | |||
23 | public static SettingConfig getInstance() { | ||
24 | if (mInstance == null) { | ||
25 | synchronized (SettingConfig.class) { | ||
26 | if (mInstance == null) { | ||
27 | String json = getSharedPreferences().getString("SettingConfig",""); | ||
28 | if (json == null || json.length() == 0) { | ||
29 | mInstance = new SettingConfig(); | ||
30 | } else { | ||
31 | mInstance = MyGson.buildGson().fromJson(json, SettingConfig.class); | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | return mInstance; | ||
37 | } | ||
38 | |||
39 | |||
40 | public static void cacheToDisk() { | ||
41 | SharedPreferences sp = getSharedPreferences(); | ||
42 | SharedPreferences.Editor editor = sp.edit(); | ||
43 | editor.putString("SettingConfig", MyGson.buildGson().toJson(getInstance())); | ||
44 | editor.commit(); | ||
45 | } | ||
46 | public static SharedPreferences getSharedPreferences(){ | ||
47 | return CommonApplication.getAppContext().getSharedPreferences("Delivery", Context.MODE_PRIVATE); | ||
48 | } | ||
49 | |||
50 | public Boolean getShowDefaultImage() { | ||
51 | return showDefaultImage; | ||
52 | } | ||
53 | |||
54 | public void setShowDefaultImage(Boolean showDefaultImage) { | ||
55 | this.showDefaultImage = showDefaultImage; | ||
56 | } | ||
57 | |||
58 | public Boolean getShowLogo() { | ||
59 | return showLogo; | ||
60 | } | ||
61 | |||
62 | public void setShowLogo(Boolean showLogo) { | ||
63 | this.showLogo = showLogo; | ||
64 | } | ||
65 | |||
66 | public Boolean getLoadDisinfectModel() { | ||
67 | return loadDisinfectModel; | ||
68 | } | ||
69 | |||
70 | public void setLoadDisinfectModel(Boolean loadDisinfectModel) { | ||
71 | this.loadDisinfectModel = loadDisinfectModel; | ||
72 | } | ||
73 | |||
74 | public Boolean getLoadSidePushModel() { | ||
75 | return loadSidePushModel; | ||
76 | } | ||
77 | |||
78 | public void setLoadSidePushModel(Boolean loadSidePushModel) { | ||
79 | this.loadSidePushModel = loadSidePushModel; | ||
80 | } | ||
81 | |||
82 | public Boolean getLoadCleanModel() { | ||
83 | return loadCleanModel; | ||
84 | } | ||
85 | |||
86 | public void setLoadCleanModel(Boolean loadCleanModel) { | ||
87 | this.loadCleanModel = loadCleanModel; | ||
88 | } | ||
89 | |||
90 | public Integer getCleanModelPressureLevel() { | ||
91 | return cleanModelPressureLevel; | ||
92 | } | ||
93 | |||
94 | public void setCleanModelPressureLevel(Integer cleanModelPressureLevel) { | ||
95 | this.cleanModelPressureLevel = cleanModelPressureLevel; | ||
96 | } | ||
97 | } | ||
98 |
libs/common/src/main/java/com/prws/common/config/WorkConfig.java
File was created | 1 | package com.prws.common.config; | |
2 | |||
3 | public class WorkConfig { | ||
4 | private String voiceBroadcastText; | ||
5 | private Long voiceBroadcastInterval; | ||
6 | |||
7 | public String getVoiceBroadcastText() { | ||
8 | return voiceBroadcastText; | ||
9 | } | ||
10 | |||
11 | public void setVoiceBroadcastText(String voiceBroadcastText) { | ||
12 | this.voiceBroadcastText = voiceBroadcastText; | ||
13 | } | ||
14 | |||
15 | public Long getVoiceBroadcastInterval() { | ||
16 | return voiceBroadcastInterval; | ||
17 | } | ||
18 | |||
19 | public void setVoiceBroadcastInterval(Long voiceBroadcastInterval) { | ||
20 | this.voiceBroadcastInterval = voiceBroadcastInterval; | ||
21 | } | ||
22 | } | ||
23 |
libs/common/src/main/java/com/prws/common/interfaces/DownTimerInterface.java
File was created | 1 | package com.prws.common.interfaces; | |
2 | |||
3 | /** | ||
4 | * @author zhiqun.tang | ||
5 | * @Description: | ||
6 | * @date 2022/8/17 | ||
7 | */ | ||
8 | public interface DownTimerInterface { | ||
9 | void confirm(Object... object); | ||
10 | |||
11 | } | ||
12 |
libs/common/src/main/java/com/prws/common/manager/DialogManager.java
File was created | 1 | package com.prws.common.manager; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.view.Gravity; | ||
5 | |||
6 | import com.prws.common.R; | ||
7 | import com.prws.common.view.DialogView; | ||
8 | |||
9 | /** | ||
10 | * @author zhiqun.tang | ||
11 | * @Description: | ||
12 | * @date 2022/9/26 | ||
13 | */ | ||
14 | public class DialogManager { | ||
15 | private static volatile DialogManager mInstance = null; | ||
16 | |||
17 | private DialogManager() { | ||
18 | |||
19 | } | ||
20 | |||
21 | public static DialogManager getInstance() { | ||
22 | if (mInstance == null) { | ||
23 | synchronized (DialogManager.class) { | ||
24 | if (mInstance == null) { | ||
25 | mInstance = new DialogManager(); | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | return mInstance; | ||
30 | } | ||
31 | |||
32 | public DialogView initView(Context mContext, int layout) { | ||
33 | return new DialogView(mContext, layout, R.style.Theme_Dialog, Gravity.CENTER); | ||
34 | } | ||
35 | |||
36 | public DialogView initView(Context mContext, int layout, int gravity) { | ||
37 | return new DialogView(mContext, layout, R.style.Theme_Dialog, gravity); | ||
38 | } | ||
39 | |||
40 | public void show(DialogView view) { | ||
41 | if (view != null) { | ||
42 | if (!view.isShowing()) { | ||
43 | view.show(); | ||
44 | } | ||
45 | } | ||
46 | } | ||
47 | |||
48 | public void hide(DialogView view) { | ||
49 | if (view != null) { | ||
50 | if (view.isShowing()) { | ||
51 | view.dismiss(); | ||
52 | } | ||
53 | |||
54 | } | ||
55 | } | ||
56 | } | ||
57 |
libs/common/src/main/java/com/prws/common/net/ByteProgressRequestBody.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import java.io.IOException; | ||
4 | |||
5 | import okio.BufferedSink; | ||
6 | |||
7 | public class ByteProgressRequestBody extends FileProgressRequestBody { | ||
8 | |||
9 | protected final byte[] content; | ||
10 | |||
11 | public ByteProgressRequestBody(byte[] content, String contentType, ProgressListener listener) { | ||
12 | super(null,contentType,listener); | ||
13 | this.content = content; | ||
14 | |||
15 | } | ||
16 | |||
17 | @Override | ||
18 | |||
19 | public long contentLength() { | ||
20 | |||
21 | return content.length; | ||
22 | |||
23 | } | ||
24 | |||
25 | @Override | ||
26 | |||
27 | public void writeTo(BufferedSink sink) throws IOException { | ||
28 | |||
29 | int offset = 0; | ||
30 | //每一块,分多次输出文件上传流 | ||
31 | int count = (int) (content.length / SEGMENT_SIZE + (content.length % SEGMENT_SIZE != 0 ? 1 : 0)); | ||
32 | for (int i = 0; i < count; i++) { | ||
33 | |||
34 | int chunk = i != count - 1 ? SEGMENT_SIZE : content.length - offset; | ||
35 | |||
36 | sink.buffer().write(content, offset, chunk);//每次写入SEGMENT_SIZE 字节 | ||
37 | |||
38 | sink.buffer().flush(); | ||
39 | |||
40 | offset += chunk; | ||
41 | |||
42 | listener.progress(chunk,offset); | ||
43 | |||
44 | } | ||
45 | |||
46 | } | ||
47 | |||
48 | |||
49 | } |
libs/common/src/main/java/com/prws/common/net/DownloadInterceptor.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import java.io.IOException; | ||
4 | |||
5 | import okhttp3.Interceptor; | ||
6 | import okhttp3.Response; | ||
7 | |||
8 | /** | ||
9 | * @author | ||
10 | * | ||
11 | * 描述:DownloadInterceptor | ||
12 | */ | ||
13 | public class DownloadInterceptor implements Interceptor { | ||
14 | private DownloadResponseBody.DownloadListener downloadListener; | ||
15 | public DownloadInterceptor(DownloadResponseBody.DownloadListener downloadListener) { | ||
16 | this.downloadListener = downloadListener; | ||
17 | } | ||
18 | @Override | ||
19 | public Response intercept(Chain chain) throws IOException { | ||
20 | Response response = chain.proceed(chain.request()); | ||
21 | return response.newBuilder().body( | ||
22 | new DownloadResponseBody(response.body(), downloadListener)).build(); | ||
23 | } | ||
24 | } | ||
25 |
libs/common/src/main/java/com/prws/common/net/DownloadResponseBody.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | |||
4 | |||
5 | import com.developer.wang.utils.MainHandler; | ||
6 | |||
7 | import okhttp3.MediaType; | ||
8 | import okhttp3.ResponseBody; | ||
9 | import okio.Buffer; | ||
10 | import okio.BufferedSource; | ||
11 | import okio.ForwardingSource; | ||
12 | import okio.Okio; | ||
13 | import okio.Source; | ||
14 | |||
15 | /** | ||
16 | * @author | ||
17 | * | ||
18 | * 描述:DownloadResponseBody | ||
19 | */ | ||
20 | public class DownloadResponseBody extends ResponseBody { | ||
21 | private ResponseBody responseBody; | ||
22 | // BufferedSource 是okio库中的输入流,这里就当作inputStream来使用。 | ||
23 | private BufferedSource bufferedSource; | ||
24 | private DownloadListener mDownloadListener; | ||
25 | public DownloadResponseBody(ResponseBody responseBody, DownloadListener downloadListener) { | ||
26 | this.responseBody = responseBody; | ||
27 | this.mDownloadListener = downloadListener; | ||
28 | downloadListener.onStartDownload(responseBody.contentLength()); | ||
29 | } | ||
30 | @Override | ||
31 | public MediaType contentType() { | ||
32 | return responseBody.contentType(); | ||
33 | } | ||
34 | @Override | ||
35 | public long contentLength() { | ||
36 | return responseBody.contentLength(); | ||
37 | } | ||
38 | @Override | ||
39 | public BufferedSource source() { | ||
40 | if (bufferedSource == null) { | ||
41 | bufferedSource = Okio.buffer(source(responseBody.source())); | ||
42 | } | ||
43 | return bufferedSource; | ||
44 | } | ||
45 | private Source source(Source source) { | ||
46 | return new ForwardingSource(source) { | ||
47 | long totalBytesRead = 0L; | ||
48 | @Override | ||
49 | public long read(Buffer sink, long byteCount) { | ||
50 | long bytesRead = 0; | ||
51 | try { | ||
52 | bytesRead = super.read(sink, byteCount); | ||
53 | }catch (final Exception e){ | ||
54 | e.printStackTrace(); | ||
55 | if (null != mDownloadListener) { | ||
56 | MainHandler.getInstance().post(new Runnable() { | ||
57 | @Override | ||
58 | public void run() { | ||
59 | mDownloadListener.onError(e); | ||
60 | } | ||
61 | }); | ||
62 | |||
63 | } | ||
64 | } | ||
65 | totalBytesRead += bytesRead != -1 ? bytesRead : 0; | ||
66 | // LogUtil.e("download", "read: "+ (int) (totalBytesRead * 100 / responseBody.contentLength())); | ||
67 | if (null != mDownloadListener) { | ||
68 | if (bytesRead != -1) { | ||
69 | mDownloadListener.onProgress((int) (totalBytesRead * 100 / responseBody.contentLength())); | ||
70 | }else{ | ||
71 | mDownloadListener.onDownloadComplete(); | ||
72 | } | ||
73 | } | ||
74 | return bytesRead; | ||
75 | } | ||
76 | }; | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * length 文件总大小 | ||
82 | * | ||
83 | * progress 已下载进度 | ||
84 | */ | ||
85 | public interface DownloadListener { | ||
86 | void onStartDownload(long length); | ||
87 | void onProgress(int progress); | ||
88 | void onDownloadComplete(); | ||
89 | void onError(Exception e); | ||
90 | } | ||
91 | } | ||
92 |
libs/common/src/main/java/com/prws/common/net/DownloadUtils.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; | ||
4 | |||
5 | import java.util.concurrent.TimeUnit; | ||
6 | |||
7 | import io.reactivex.Observable; | ||
8 | import io.reactivex.Observer; | ||
9 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
10 | import io.reactivex.schedulers.Schedulers; | ||
11 | import okhttp3.OkHttpClient; | ||
12 | import okhttp3.ResponseBody; | ||
13 | import retrofit2.Retrofit; | ||
14 | import retrofit2.http.GET; | ||
15 | import retrofit2.http.Streaming; | ||
16 | import retrofit2.http.Url; | ||
17 | |||
18 | /** | ||
19 | * @author | ||
20 | * | ||
21 | * 描述:DownloadUtils | ||
22 | */ | ||
23 | public class DownloadUtils { | ||
24 | private static final String TAG = "DownloadUtils"; | ||
25 | private static final int DEFAULT_TIMEOUT = 15; | ||
26 | private static final int DOWNLOAD_TIMEOUT = 25; | ||
27 | private Retrofit retrofit; | ||
28 | |||
29 | interface DownloadService { | ||
30 | @Streaming | ||
31 | @GET | ||
32 | Observable<ResponseBody> download(@Url String url); | ||
33 | } | ||
34 | |||
35 | public DownloadUtils(String url,DownloadResponseBody.DownloadListener listener) { | ||
36 | DownloadInterceptor mInterceptor = new DownloadInterceptor(listener); | ||
37 | OkHttpClient httpClient = new OkHttpClient.Builder() | ||
38 | .addInterceptor(mInterceptor) | ||
39 | .retryOnConnectionFailure(true) | ||
40 | //这里的超时包含了正在下载的时间,未完全区分,所以增加超时时间 | ||
41 | .connectTimeout(DOWNLOAD_TIMEOUT, TimeUnit.SECONDS) | ||
42 | .build(); | ||
43 | |||
44 | retrofit = new Retrofit.Builder() | ||
45 | .baseUrl(url+"/") | ||
46 | .client(httpClient) | ||
47 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | ||
48 | .build(); | ||
49 | } | ||
50 | |||
51 | public void downloadFile(String url,Observer<ResponseBody> observer) { | ||
52 | setSubscribe(retrofit.create(DownloadService.class).download(url), observer); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * 插入观 | ||
57 | * | ||
58 | * @param observable | ||
59 | * @param observer | ||
60 | * @param <T> | ||
61 | */ | ||
62 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | ||
63 | observable.subscribeOn(Schedulers.io()) | ||
64 | .subscribeOn(Schedulers.newThread())//子线程访 | ||
65 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | ||
66 | .subscribe(observer); | ||
67 | } | ||
68 | |||
69 | |||
70 | // /** | ||
71 | // * 开始下载 | ||
72 | // * @param url | ||
73 | // * @param file | ||
74 | // * @param subscriber | ||
75 | // */ | ||
76 | // public void download(@NonNull String url, final File file, Subscriber subscriber) { | ||
77 | // retrofit.create(NetWorks.DownloadService.class) | ||
78 | // .download(url) | ||
79 | // .subscribeOn(Schedulers.io()).unsubscribeOn(Schedulers.io()) | ||
80 | // .map(new Function<ResponseBody, InputStream>() { | ||
81 | // | ||
82 | // @Override | ||
83 | // public InputStream call(ResponseBody responseBody) { | ||
84 | // return responseBody.byteStream(); | ||
85 | // } | ||
86 | // }) | ||
87 | // .observeOn(Schedulers.computation()) // 用于计算任务 | ||
88 | // .doOnNext(new Act<InputStream>() { | ||
89 | // @Override | ||
90 | // public void call(InputStream inputStream) { | ||
91 | // FileUtil.writeToDisk(inputStream, file); | ||
92 | // } | ||
93 | // }) | ||
94 | // .observeOn(AndroidSchedulers.mainThread()) | ||
95 | // .subscribe(subscriber); | ||
96 | // | ||
97 | // } | ||
98 | } | ||
99 |
libs/common/src/main/java/com/prws/common/net/FileProgressRequestBody.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import java.io.File; | ||
4 | import java.io.IOException; | ||
5 | |||
6 | import okhttp3.MediaType; | ||
7 | import okhttp3.RequestBody; | ||
8 | import okhttp3.internal.Util; | ||
9 | import okio.BufferedSink; | ||
10 | import okio.Okio; | ||
11 | import okio.Source; | ||
12 | |||
13 | public class FileProgressRequestBody extends RequestBody { | ||
14 | |||
15 | public interface ProgressListener { | ||
16 | /** | ||
17 | * | ||
18 | * @param upload 当前上传 | ||
19 | * @param totalUpload 总上传 | ||
20 | */ | ||
21 | void progress(long upload,long totalUpload); | ||
22 | } | ||
23 | |||
24 | public static final int SEGMENT_SIZE = 2*1024; | ||
25 | |||
26 | protected File file; | ||
27 | protected ProgressListener listener; | ||
28 | protected String contentType; | ||
29 | |||
30 | public FileProgressRequestBody(File file, String contentType, ProgressListener listener) { | ||
31 | this.file = file; | ||
32 | this.contentType = contentType; | ||
33 | this.listener = listener; | ||
34 | } | ||
35 | |||
36 | protected FileProgressRequestBody() {} | ||
37 | |||
38 | @Override | ||
39 | public long contentLength() { | ||
40 | return file.length(); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public MediaType contentType() { | ||
45 | return MediaType.parse(contentType); | ||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public void writeTo(BufferedSink sink) throws IOException { | ||
50 | Source source = null; | ||
51 | try { | ||
52 | source = Okio.source(file); | ||
53 | long total = 0; | ||
54 | long read; | ||
55 | //每一块,循环读取,写文件流 | ||
56 | while ((read = source.read(sink.buffer(), SEGMENT_SIZE)) != -1) { | ||
57 | total += read; | ||
58 | sink.flush(); | ||
59 | if (listener != null) | ||
60 | this.listener.progress(read,total); | ||
61 | } | ||
62 | } finally { | ||
63 | Util.closeQuietly(source); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | } |
libs/common/src/main/java/com/prws/common/net/INetEvent.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | /** | ||
4 | * @author | ||
5 | * | ||
6 | * 描述:INetEvent | ||
7 | */ | ||
8 | public interface INetEvent { | ||
9 | void onNetChange(int netWorkState); | ||
10 | } | ||
11 |
libs/common/src/main/java/com/prws/common/net/LoggingInterceptor.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import static okhttp3.internal.Util.UTF_8; | ||
4 | |||
5 | import android.content.Context; | ||
6 | import android.content.pm.ApplicationInfo; | ||
7 | import android.util.Log; | ||
8 | |||
9 | |||
10 | import com.prws.common.CommonApplication; | ||
11 | |||
12 | import java.io.IOException; | ||
13 | import java.nio.charset.Charset; | ||
14 | |||
15 | import okhttp3.FormBody; | ||
16 | import okhttp3.Interceptor; | ||
17 | import okhttp3.MediaType; | ||
18 | import okhttp3.Request; | ||
19 | import okhttp3.RequestBody; | ||
20 | import okhttp3.Response; | ||
21 | import okhttp3.ResponseBody; | ||
22 | import okio.Buffer; | ||
23 | |||
24 | /** | ||
25 | * Created by developer on 2019/12/14. | ||
26 | */ | ||
27 | |||
28 | public class LoggingInterceptor implements Interceptor { | ||
29 | @Override | ||
30 | public Response intercept(Chain chain) throws IOException { | ||
31 | //这个chain里面包含了request和response,所以你要什么都可以从这里拿 | ||
32 | Request request = chain.request(); | ||
33 | long t1 = System.nanoTime();//请求发起的时间 | ||
34 | if (isApkInDebug(CommonApplication.getAppContext())){ | ||
35 | printRequestMessage(request); | ||
36 | } | ||
37 | String method = request.method(); | ||
38 | if ("POST".equals(method)) { | ||
39 | StringBuilder sb = new StringBuilder(); | ||
40 | if (request.body() instanceof FormBody) { | ||
41 | FormBody body = (FormBody) request.body(); | ||
42 | for (int i = 0; i < body.size(); i++) { | ||
43 | sb.append(body.encodedName(i) + "=" + body.encodedValue(i) + ","); | ||
44 | } | ||
45 | sb.delete(sb.length() - 1, sb.length()); | ||
46 | Log.d("CSDN_LQR",String.format("发送请求 %s on %s %n%s %nRequestParams:{%s}", | ||
47 | request.url(), chain.connection(), request.headers(), sb.toString())); | ||
48 | } | ||
49 | } else { | ||
50 | Log.d("CSDN_LQR",String.format("发送请求 %s on %s%n%s", | ||
51 | request.url(), chain.connection(), request.headers())); | ||
52 | } | ||
53 | Response response = chain.proceed(request); | ||
54 | long t2 = System.nanoTime();//收到响应的时间 | ||
55 | //这里不能直接使用response.body().string()的方式输出日志 | ||
56 | //因为response.body().string()之后,response中的流会被关闭,程序会报错,我们需要创建出一 | ||
57 | //个新的response给应用层处理 | ||
58 | ResponseBody responseBody = response.peekBody(1024 * 1024); | ||
59 | Log.d("CSDN_LQR", | ||
60 | String.format("接收响应: [%s] %n返回json:【%s】 %.1fms %n%s", | ||
61 | response.request().url(), | ||
62 | responseBody.string(), | ||
63 | (t2 - t1) / 1e6d, | ||
64 | response.headers() | ||
65 | )); | ||
66 | return response; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * 打印请求消息 | ||
71 | * | ||
72 | * @param request 请求的对象 | ||
73 | */ | ||
74 | private void printRequestMessage(Request request) { | ||
75 | if (request == null) { | ||
76 | return; | ||
77 | } | ||
78 | Log.i("CSDN_LQR", "Url : " + request.url().toString() | ||
79 | + "\nMethod : " + request.method() | ||
80 | + "\nHeads : " + request.headers()); | ||
81 | RequestBody requestBody = request.body(); | ||
82 | if (requestBody == null) { | ||
83 | return; | ||
84 | } | ||
85 | |||
86 | try { | ||
87 | Buffer bufferedSink = new Buffer(); | ||
88 | requestBody.writeTo(bufferedSink); | ||
89 | Charset charset = UTF_8; | ||
90 | |||
91 | MediaType contentType = requestBody.contentType(); | ||
92 | if (contentType != null) { | ||
93 | charset = contentType.charset(); | ||
94 | if (charset == null) { | ||
95 | charset = UTF_8; | ||
96 | } | ||
97 | } | ||
98 | Log.d("CSDN_LQR", "Params: " + bufferedSink.readString(charset)); | ||
99 | } catch (IOException e) { | ||
100 | e.printStackTrace(); | ||
101 | } | ||
102 | } | ||
103 | /** | ||
104 | * 判断当前应用是否是debug状态 | ||
105 | */ | ||
106 | public static boolean isApkInDebug(Context context) { | ||
107 | try { | ||
108 | ApplicationInfo info = context.getApplicationInfo(); | ||
109 | return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; | ||
110 | } catch (Exception e) { | ||
111 | return false; | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 |
libs/common/src/main/java/com/prws/common/net/NetWorks.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | |||
4 | |||
5 | |||
6 | import com.google.gson.Gson; | ||
7 | import com.prws.common.BuildConfig; | ||
8 | import com.prws.common.bean.BaseEntity; | ||
9 | |||
10 | import java.io.File; | ||
11 | import java.util.List; | ||
12 | import java.util.Map; | ||
13 | |||
14 | import io.reactivex.Observable; | ||
15 | import io.reactivex.Observer; | ||
16 | import io.reactivex.android.schedulers.AndroidSchedulers; | ||
17 | import io.reactivex.schedulers.Schedulers; | ||
18 | import okhttp3.MediaType; | ||
19 | import okhttp3.MultipartBody; | ||
20 | import okhttp3.RequestBody; | ||
21 | import okhttp3.ResponseBody; | ||
22 | import retrofit2.Call; | ||
23 | import retrofit2.http.Body; | ||
24 | import retrofit2.http.DELETE; | ||
25 | import retrofit2.http.FieldMap; | ||
26 | import retrofit2.http.FormUrlEncoded; | ||
27 | import retrofit2.http.GET; | ||
28 | import retrofit2.http.Headers; | ||
29 | import retrofit2.http.Multipart; | ||
30 | import retrofit2.http.POST; | ||
31 | import retrofit2.http.Part; | ||
32 | import retrofit2.http.Path; | ||
33 | import retrofit2.http.Query; | ||
34 | import retrofit2.http.QueryMap; | ||
35 | import retrofit2.http.Streaming; | ||
36 | import retrofit2.http.Url; | ||
37 | |||
38 | /** | ||
39 | * 类名称:NetWorks | ||
40 | * 创建人: | ||
41 | * | ||
42 | * 类描述:网络请求的操作类 | ||
43 | */ | ||
44 | public class NetWorks extends RetrofitUtils { | ||
45 | //服务器路径 | ||
46 | public static final NetService service_url = getMachineRetrofit(BuildConfig.SERVER_URL).create(NetService.class); | ||
47 | |||
48 | //设缓存有效期为1天 | ||
49 | protected static final long CACHE_STALE_SEC = 60 * 60 * 24 * 1; | ||
50 | //查询缓存的Cache-Control设置,使用缓存 | ||
51 | protected static final String CACHE_CONTROL_CACHE = "only-if-cached, max-stale=" + CACHE_STALE_SEC; | ||
52 | //查询网络的Cache-Control设置。不使用缓存 | ||
53 | protected static final String CACHE_CONTROL_NETWORK = "max-age=0"; | ||
54 | |||
55 | |||
56 | private interface NetService{ | ||
57 | |||
58 | |||
59 | @GET("/api/v1/user/logout") | ||
60 | Observable<ResponseBody> logout(); | ||
61 | |||
62 | @Multipart | ||
63 | @POST("/api/v1/user/upLoadAvatar") | ||
64 | Observable<ResponseBody> upLoadAvatar(@Part List<MultipartBody.Part> partLis); | ||
65 | |||
66 | |||
67 | @Headers("Content-Type: application/json") | ||
68 | @POST("/api/v1/user/editUser") | ||
69 | Observable<ResponseBody> editUser(@Body RequestBody body); | ||
70 | |||
71 | @Headers("Content-Type: application/json") | ||
72 | @POST("/api/v1/user/changePassword") | ||
73 | Observable<ResponseBody> changePassword(@Body RequestBody body); | ||
74 | |||
75 | |||
76 | @GET("/api/v1/user/searchById?") | ||
77 | Observable<ResponseBody> searchById(@Query("userId") String userId); | ||
78 | |||
79 | |||
80 | @Headers("Content-Type: application/json") | ||
81 | @POST("/api/v1/auth/login") | ||
82 | Observable<ResponseBody> login(@Body RequestBody body); | ||
83 | |||
84 | @GET("/api/v1/resource/listGradeAndSubject") | ||
85 | Observable<ResponseBody> listGradeAndSubject(); | ||
86 | |||
87 | |||
88 | @GET("/api/v1/manager/generalQrCode") | ||
89 | Observable<ResponseBody> generalQrCode(); | ||
90 | |||
91 | @GET("/api/v1/parent/scanAndLogin?") | ||
92 | Observable<ResponseBody> scanAndLogin(@Query("code") String code); | ||
93 | |||
94 | @GET("/api/v1/parent/getChildrenList") | ||
95 | Observable<ResponseBody> getChildrenList(); | ||
96 | |||
97 | |||
98 | @Headers("Content-Type: application/json") | ||
99 | @POST("/api/v1/parent/registerParent") | ||
100 | Observable<ResponseBody> registerParent(@Body RequestBody body); | ||
101 | |||
102 | |||
103 | @GET("/api/v1/parent/listChildren") | ||
104 | Observable<ResponseBody> listChildren(); | ||
105 | |||
106 | |||
107 | @Headers("Content-Type: application/json") | ||
108 | @POST("/api/v1/parent/registerStudent") | ||
109 | Observable<ResponseBody> registerStudent(@Body RequestBody body); | ||
110 | |||
111 | @Headers("Content-Type: application/json") | ||
112 | @POST("/api/v1/parent/bindTeacher") | ||
113 | Observable<ResponseBody> bindTeacher(@Body RequestBody body); | ||
114 | |||
115 | |||
116 | |||
117 | |||
118 | |||
119 | } | ||
120 | |||
121 | |||
122 | |||
123 | public static void logout(Observer<ResponseBody> observer) { | ||
124 | setSubscribe(service_url.logout(),observer); | ||
125 | } | ||
126 | |||
127 | |||
128 | |||
129 | public static void upLoadAvatar(List<MultipartBody.Part> partLis,Observer<ResponseBody> observer) { | ||
130 | setSubscribe(service_url.upLoadAvatar(partLis),observer); | ||
131 | } | ||
132 | |||
133 | |||
134 | public static void editUser(RequestBody body,Observer<ResponseBody> observer) { | ||
135 | setSubscribe(service_url.editUser(body),observer); | ||
136 | } | ||
137 | |||
138 | public static void changePassword(RequestBody body,Observer<ResponseBody> observer) { | ||
139 | setSubscribe(service_url.changePassword(body),observer); | ||
140 | } | ||
141 | |||
142 | |||
143 | public static void searchById(String userId,Observer<ResponseBody> observer) { | ||
144 | setSubscribe(service_url.searchById(userId),observer); | ||
145 | } | ||
146 | |||
147 | |||
148 | public static void login(RequestBody body,Observer<ResponseBody> observer) { | ||
149 | setSubscribe(service_url.login(body),observer); | ||
150 | } | ||
151 | |||
152 | public static void listGradeAndSubject(Observer<ResponseBody> observer) { | ||
153 | setSubscribe(service_url.listGradeAndSubject(),observer); | ||
154 | } | ||
155 | |||
156 | |||
157 | public static void scanAndLogin(String code,Observer<ResponseBody> observer) { | ||
158 | setSubscribe(service_url.scanAndLogin(code),observer); | ||
159 | } | ||
160 | |||
161 | public static void getChildrenList(Observer<ResponseBody> observer) { | ||
162 | setSubscribe(service_url.getChildrenList(),observer); | ||
163 | } | ||
164 | |||
165 | |||
166 | public static void registerParent(RequestBody body,Observer<ResponseBody> observer) { | ||
167 | setSubscribe(service_url.registerParent(body),observer); | ||
168 | } | ||
169 | |||
170 | |||
171 | public static void listChildren(Observer<ResponseBody> observer) { | ||
172 | setSubscribe(service_url.listChildren(),observer); | ||
173 | } | ||
174 | |||
175 | |||
176 | public static void registerStudent(RequestBody body,Observer<ResponseBody> observer) { | ||
177 | setSubscribe(service_url.registerStudent(body),observer); | ||
178 | } | ||
179 | |||
180 | public static void bindTeacher(RequestBody body,Observer<ResponseBody> observer) { | ||
181 | setSubscribe(service_url.bindTeacher(body),observer); | ||
182 | } | ||
183 | |||
184 | |||
185 | public static RequestBody getMapRequestBody(Map map) { | ||
186 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(map)); | ||
187 | } | ||
188 | |||
189 | public static RequestBody getArrayRequestBody(List list){ | ||
190 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(list)); | ||
191 | } | ||
192 | |||
193 | public static RequestBody getFileRequestBody(File file) { | ||
194 | return RequestBody.create(MediaType.parse("application/octet-stream"), file); | ||
195 | } | ||
196 | public static RequestBody getFileRequestBody(byte[] bytes) { | ||
197 | return RequestBody.create(MediaType.parse("multipart/form-data"), bytes); | ||
198 | } | ||
199 | |||
200 | public static RequestBody getObjectRequestBody(Object obj) { | ||
201 | return RequestBody.create(MediaType.parse("text/plain"), new Gson().toJson(obj)); | ||
202 | } | ||
203 | public static RequestBody getStringRequestBody(String str) { | ||
204 | return RequestBody.create(MediaType.parse("text/plain"), str); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * 插入观察者 | ||
209 | * | ||
210 | * @param observable | ||
211 | * @param observer | ||
212 | * @param <T> | ||
213 | */ | ||
214 | public static <T> void setSubscribe(Observable<T> observable, Observer<T> observer) { | ||
215 | observable.subscribeOn(Schedulers.io())//子线程访问网络 | ||
216 | .observeOn(AndroidSchedulers.mainThread())//回调到主线程 | ||
217 | .subscribe(observer); | ||
218 | } | ||
219 | |||
220 | } | ||
221 |
libs/common/src/main/java/com/prws/common/net/OkHttp3Utils.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.net.ConnectivityManager; | ||
5 | import android.net.NetworkInfo; | ||
6 | import android.util.Log; | ||
7 | |||
8 | |||
9 | import com.prws.common.CommonApplication; | ||
10 | |||
11 | import java.io.File; | ||
12 | import java.io.IOException; | ||
13 | import java.util.List; | ||
14 | import java.util.concurrent.TimeUnit; | ||
15 | |||
16 | import okhttp3.Cache; | ||
17 | import okhttp3.CacheControl; | ||
18 | import okhttp3.Cookie; | ||
19 | import okhttp3.CookieJar; | ||
20 | import okhttp3.HttpUrl; | ||
21 | import okhttp3.Interceptor; | ||
22 | import okhttp3.OkHttpClient; | ||
23 | import okhttp3.Request; | ||
24 | import okhttp3.Response; | ||
25 | |||
26 | /** | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | public class OkHttp3Utils { | ||
31 | |||
32 | private static OkHttpClient mOkHttpClient; | ||
33 | |||
34 | //设置缓存目录 | ||
35 | private static File cacheDirectory = new File(CommonApplication.getAppContext().getApplicationContext().getCacheDir().getAbsolutePath(), "MyCache"); | ||
36 | private static Cache cache = new Cache(cacheDirectory, 10 * 1024 * 1024); | ||
37 | |||
38 | |||
39 | /** | ||
40 | * 获取OkHttpClient对象 | ||
41 | * | ||
42 | * @return | ||
43 | */ | ||
44 | public static OkHttpClient getOkHttpClient() { | ||
45 | if (null == mOkHttpClient) { | ||
46 | |||
47 | //同样okhttp3后也使用build设计模式 | ||
48 | mOkHttpClient = new OkHttpClient.Builder() | ||
49 | //设置一个自动管理cookies的管理器 | ||
50 | .cookieJar(new CookiesManager()) | ||
51 | .cache(cache) | ||
52 | .addInterceptor(new SignInterceptor()) | ||
53 | //添加拦截器 | ||
54 | .addInterceptor(new MyIntercepter()) | ||
55 | .addInterceptor(new LoggingInterceptor()) | ||
56 | .addInterceptor(new OkHttpRetryInterceptor.Builder() | ||
57 | // .buildRetryCount(3)//最大重试次数 | ||
58 | .buildRetryInterval(0)//重试时间间隔 | ||
59 | .build()) | ||
60 | //添加网络连接器 | ||
61 | // .addNetworkInterceptor(new CookiesInterceptor(MyApplication.getInstance().getApplicationContext())) | ||
62 | //设置请求读写的超时时间 | ||
63 | .connectTimeout(10, TimeUnit.SECONDS) | ||
64 | .writeTimeout(10, TimeUnit.SECONDS) | ||
65 | .readTimeout(10, TimeUnit.SECONDS) | ||
66 | .build(); | ||
67 | |||
68 | } | ||
69 | |||
70 | |||
71 | return mOkHttpClient; | ||
72 | } | ||
73 | |||
74 | |||
75 | /** | ||
76 | * 拦截器 | ||
77 | */ | ||
78 | private static class MyIntercepter implements Interceptor { | ||
79 | @Override | ||
80 | public Response intercept(Chain chain) throws IOException { | ||
81 | Request request = chain.request(); | ||
82 | if (!isNetworkReachable(CommonApplication.getAppContext().getApplicationContext())) { | ||
83 | request = request.newBuilder() | ||
84 | .cacheControl(CacheControl.FORCE_CACHE)//无网络时只从缓存中读取 | ||
85 | .build(); | ||
86 | Log.e("缓存目录====>",cacheDirectory.getAbsolutePath()); | ||
87 | } | ||
88 | |||
89 | Response response = chain.proceed(request); | ||
90 | if (isNetworkReachable(CommonApplication.getAppContext().getApplicationContext())) { | ||
91 | int maxAge = 60 * 60; // 有网络时 设置缓存超时时间1个小时 | ||
92 | response.newBuilder() | ||
93 | .removeHeader("Pragma") | ||
94 | .removeHeader("Cache-Control") | ||
95 | .header("Cache-Control", "public, max-age=" + maxAge) | ||
96 | .build(); | ||
97 | } else { | ||
98 | int maxStale = 60 * 60 * 24 * 28; // 无网络时,设置超时为4周 | ||
99 | response.newBuilder() | ||
100 | .removeHeader("Pragma") | ||
101 | .removeHeader("Cache-Control") | ||
102 | .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale) | ||
103 | .build(); | ||
104 | } | ||
105 | return response; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | |||
110 | /** | ||
111 | * 自动管理Cookies | ||
112 | */ | ||
113 | private static class CookiesManager implements CookieJar { | ||
114 | private final PersistentCookieStore cookieStore = new PersistentCookieStore(CommonApplication.getAppContext().getApplicationContext()); | ||
115 | |||
116 | @Override | ||
117 | public void saveFromResponse(HttpUrl url, List<Cookie> cookies) { | ||
118 | if (cookies != null && cookies.size() > 0) { | ||
119 | for (Cookie item : cookies) { | ||
120 | cookieStore.add(url, item); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | @Override | ||
126 | public List<Cookie> loadForRequest(HttpUrl url) { | ||
127 | List<Cookie> cookies = cookieStore.get(url); | ||
128 | return cookies; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * 判断网络是否可用 | ||
134 | * | ||
135 | * @param context Context对象 | ||
136 | */ | ||
137 | public static Boolean isNetworkReachable(Context context) { | ||
138 | ConnectivityManager cm = (ConnectivityManager) context | ||
139 | .getSystemService(Context.CONNECTIVITY_SERVICE); | ||
140 | NetworkInfo current = cm.getActiveNetworkInfo(); | ||
141 | if (current == null) { | ||
142 | return false; | ||
143 | } | ||
144 | return (current.isAvailable()); | ||
145 | } | ||
146 | } | ||
147 |
libs/common/src/main/java/com/prws/common/net/OkHttpRetryInterceptor.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import java.io.IOException; | ||
4 | |||
5 | import okhttp3.Interceptor; | ||
6 | import okhttp3.Request; | ||
7 | import okhttp3.Response; | ||
8 | |||
9 | /** | ||
10 | * @author | ||
11 | * | ||
12 | * 描述:OkHttpRetryInterceptor | ||
13 | */ | ||
14 | public class OkHttpRetryInterceptor implements Interceptor{ | ||
15 | |||
16 | private int mMaxRetryCount; | ||
17 | private long mRetryInterval; | ||
18 | |||
19 | public OkHttpRetryInterceptor(int maxRetryCount, long retryInterval) { | ||
20 | mMaxRetryCount = maxRetryCount; | ||
21 | mRetryInterval = retryInterval; | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public Response intercept(Chain chain) throws IOException { | ||
26 | Request request = chain.request(); | ||
27 | Response response = doRequest(chain, request); | ||
28 | int retryNum = 1; | ||
29 | while(((response==null)||!response.isSuccessful())&&retryNum<=mMaxRetryCount){ | ||
30 | try { | ||
31 | Thread.sleep(mRetryInterval); | ||
32 | } catch (InterruptedException e) { | ||
33 | e.printStackTrace(); | ||
34 | } | ||
35 | retryNum++; | ||
36 | response = doRequest(chain, request); | ||
37 | |||
38 | } | ||
39 | return response; | ||
40 | } | ||
41 | |||
42 | private Response doRequest(Chain chain, Request request) { | ||
43 | try { | ||
44 | return chain.proceed(request); | ||
45 | } catch (IOException e) { | ||
46 | e.printStackTrace(); | ||
47 | } | ||
48 | return null; | ||
49 | } | ||
50 | |||
51 | public static class Builder { | ||
52 | |||
53 | private int mRetryCount = 1; | ||
54 | private long mRetryInterval = 1000; | ||
55 | |||
56 | public Builder buildRetryCount(int retryCount){ | ||
57 | this.mRetryCount = retryCount; | ||
58 | return this; | ||
59 | } | ||
60 | |||
61 | public Builder buildRetryInterval(long retryInterval){ | ||
62 | this.mRetryInterval = retryInterval; | ||
63 | return this; | ||
64 | } | ||
65 | |||
66 | public OkHttpRetryInterceptor build(){ | ||
67 | return new OkHttpRetryInterceptor(mRetryCount,mRetryInterval); | ||
68 | } | ||
69 | |||
70 | } | ||
71 | |||
72 | } | ||
73 |
libs/common/src/main/java/com/prws/common/net/PersistentCookieStore.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.SharedPreferences; | ||
5 | import android.text.TextUtils; | ||
6 | import android.util.Log; | ||
7 | |||
8 | import java.io.ByteArrayInputStream; | ||
9 | import java.io.ByteArrayOutputStream; | ||
10 | import java.io.IOException; | ||
11 | import java.io.ObjectInputStream; | ||
12 | import java.io.ObjectOutputStream; | ||
13 | import java.util.ArrayList; | ||
14 | import java.util.HashMap; | ||
15 | import java.util.List; | ||
16 | import java.util.Locale; | ||
17 | import java.util.Map; | ||
18 | import java.util.concurrent.ConcurrentHashMap; | ||
19 | |||
20 | import okhttp3.Cookie; | ||
21 | import okhttp3.HttpUrl; | ||
22 | |||
23 | /** | ||
24 | * 持久化cookies | ||
25 | * Created by Administrator on 2016-5-9. | ||
26 | */ | ||
27 | public class PersistentCookieStore { | ||
28 | private static final String COOKIE_PREFS = "Cookies_Prefs"; | ||
29 | private static final String LOG_TAG = "PersistentCookieStore"; | ||
30 | private final SharedPreferences cookiePrefs; | ||
31 | private final HashMap<String, ConcurrentHashMap<String, Cookie>> cookies; | ||
32 | |||
33 | public PersistentCookieStore(Context context) { | ||
34 | cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0); | ||
35 | cookies = new HashMap<>(); | ||
36 | |||
37 | //将持久化的cookies缓存到内存中,即map中 | ||
38 | Map<String, ?> prefsMap = cookiePrefs.getAll(); | ||
39 | for (Map.Entry<String, ?> entry : prefsMap.entrySet()) { | ||
40 | String[] cookieNames = TextUtils.split((String) entry.getValue(), ","); | ||
41 | |||
42 | for (String name : cookieNames) { | ||
43 | String encodedCookie = cookiePrefs.getString(name, null); | ||
44 | |||
45 | if (!TextUtils.isEmpty(encodedCookie)) { | ||
46 | Cookie decodeCookie = decodeCookie(encodedCookie); | ||
47 | if (null != decodeCookie) { | ||
48 | cookies.put(entry.getKey(), new ConcurrentHashMap<String, Cookie>()); | ||
49 | } | ||
50 | cookies.get(entry.getKey()).put(name, decodeCookie); | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | |||
56 | } | ||
57 | |||
58 | |||
59 | /** | ||
60 | * 获取cookieToken | ||
61 | * | ||
62 | * @param cookie | ||
63 | * @return | ||
64 | */ | ||
65 | protected String getCookieToken(Cookie cookie) { | ||
66 | return cookie.name() + "@" + cookie.domain(); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * 添加到持久化 | ||
71 | * | ||
72 | * @param url | ||
73 | * @param cookie | ||
74 | */ | ||
75 | public void add(HttpUrl url, Cookie cookie) { | ||
76 | String name = getCookieToken(cookie); | ||
77 | |||
78 | //将cookies缓存到内存中,如果缓存过期,就重置此cookie | ||
79 | if (!cookie.persistent()) { | ||
80 | if (!cookies.containsKey(url.host())) { | ||
81 | cookies.put(url.host(), new ConcurrentHashMap<String, Cookie>()); | ||
82 | } | ||
83 | cookies.get(url.host()).put(name, cookie); | ||
84 | } else { | ||
85 | if (cookies.containsKey(url.host())) { | ||
86 | cookies.get(url.host()).remove(name); | ||
87 | } | ||
88 | } | ||
89 | //将cookies持久化到本地 | ||
90 | SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); | ||
91 | prefsWriter.putString(url.host(), TextUtils.join(",", cookies.get(url.host()).keySet())); | ||
92 | prefsWriter.putString(name, encodeCookie(new SerializableOkHttpCookies(cookie))); | ||
93 | prefsWriter.apply(); | ||
94 | |||
95 | } | ||
96 | |||
97 | /** | ||
98 | * 通过url得到存储cookie集合 | ||
99 | * | ||
100 | * @param url | ||
101 | * @return | ||
102 | */ | ||
103 | public List<Cookie> get(HttpUrl url) { | ||
104 | ArrayList<Cookie> ret = new ArrayList<>(); | ||
105 | if (cookies.containsKey(url.host())) | ||
106 | ret.addAll(cookies.get(url.host()).values()); | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * 清除cookies本地持久化 | ||
112 | * | ||
113 | * @return | ||
114 | */ | ||
115 | public boolean removeAll() { | ||
116 | SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); | ||
117 | prefsWriter.clear(); | ||
118 | prefsWriter.apply(); | ||
119 | cookies.clear(); | ||
120 | return true; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * 获取cookie集合 | ||
125 | * | ||
126 | * @return | ||
127 | */ | ||
128 | public List<Cookie> getCookies() { | ||
129 | ArrayList<Cookie> ret = new ArrayList<>(); | ||
130 | for (String key : cookies.keySet()) | ||
131 | ret.addAll(cookies.get(key).values()); | ||
132 | |||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * cookies 序列化成 string | ||
138 | * | ||
139 | * @param cookie 要序列化的cookie | ||
140 | * @return 序列化之后的string | ||
141 | */ | ||
142 | protected String encodeCookie(SerializableOkHttpCookies cookie) { | ||
143 | if (cookie == null) | ||
144 | return null; | ||
145 | ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
146 | try { | ||
147 | ObjectOutputStream outputStream = new ObjectOutputStream(os); | ||
148 | outputStream.writeObject(cookie); | ||
149 | } catch (IOException e) { | ||
150 | Log.d(LOG_TAG, "IOException in encodeCookie", e); | ||
151 | return null; | ||
152 | } | ||
153 | |||
154 | return byteArrayToHexString(os.toByteArray()); | ||
155 | } | ||
156 | |||
157 | /** | ||
158 | * 将字符串反序列化成cookies | ||
159 | * | ||
160 | * @param cookieString cookies string | ||
161 | * @return cookie object | ||
162 | */ | ||
163 | protected Cookie decodeCookie(String cookieString) { | ||
164 | byte[] bytes = hexStringToByteArray(cookieString); | ||
165 | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); | ||
166 | Cookie cookie = null; | ||
167 | try { | ||
168 | ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); | ||
169 | cookie = ((SerializableOkHttpCookies) objectInputStream.readObject()).getCookies(); | ||
170 | } catch (IOException e) { | ||
171 | Log.d(LOG_TAG, "IOException in decodeCookie", e); | ||
172 | } catch (ClassNotFoundException e) { | ||
173 | Log.d(LOG_TAG, "ClassNotFoundException in decodeCookie", e); | ||
174 | } | ||
175 | |||
176 | return cookie; | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * 二进制数组转十六进制字符串 | ||
181 | * | ||
182 | * @param bytes byte array to be converted | ||
183 | * @return string containing hex values | ||
184 | */ | ||
185 | protected String byteArrayToHexString(byte[] bytes) { | ||
186 | StringBuilder sb = new StringBuilder(bytes.length * 2); | ||
187 | for (byte element : bytes) { | ||
188 | int v = element & 0xff; | ||
189 | if (v < 16) { | ||
190 | sb.append('0'); | ||
191 | } | ||
192 | sb.append(Integer.toHexString(v)); | ||
193 | } | ||
194 | return sb.toString().toUpperCase(Locale.US); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * 十六进制字符串转二进制数组 | ||
199 | * | ||
200 | * @param hexString string of hex-encoded values | ||
201 | * @return decoded byte array | ||
202 | */ | ||
203 | protected byte[] hexStringToByteArray(String hexString) { | ||
204 | int len = hexString.length(); | ||
205 | byte[] data = new byte[len / 2]; | ||
206 | for (int i = 0; i < len; i += 2) { | ||
207 | data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4) + Character.digit(hexString.charAt(i + 1), 16)); | ||
208 | } | ||
209 | return data; | ||
210 | } | ||
211 | |||
212 | } | ||
213 |
libs/common/src/main/java/com/prws/common/net/ResponseCode.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | public class ResponseCode { | ||
4 | /** | ||
5 | * 无网络 | ||
6 | */ | ||
7 | public static final int RESPONSE_NETWORK_ERROR = -1; | ||
8 | |||
9 | /** | ||
10 | * 接口请求成功 | ||
11 | */ | ||
12 | public static final int RESPONSE_SUCCESS = 200; | ||
13 | } | ||
14 |
libs/common/src/main/java/com/prws/common/net/RetrofitUtils.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import com.google.gson.Gson; | ||
4 | import com.google.gson.GsonBuilder; | ||
5 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; | ||
6 | import com.prws.common.utils.LogUtil; | ||
7 | |||
8 | import io.reactivex.schedulers.Schedulers; | ||
9 | import okhttp3.OkHttpClient; | ||
10 | import retrofit2.Retrofit; | ||
11 | import retrofit2.converter.gson.GsonConverterFactory; | ||
12 | |||
13 | /** | ||
14 | * 类名称:RetrofitUtils | ||
15 | * 创建人: | ||
16 | * | ||
17 | * 类描述:封装一个retrofit集成0kHttp3的抽象基类 | ||
18 | */ | ||
19 | public abstract class RetrofitUtils { | ||
20 | |||
21 | private static Retrofit prwsCloudRetrofit; | ||
22 | private static OkHttpClient prwsCloudOkHttpClient; | ||
23 | private static Retrofit mStaRetrofit; | ||
24 | private static OkHttpClient mStaOkHttpClient; | ||
25 | private static Retrofit nginxRetrofit; | ||
26 | private static OkHttpClient nginxOkHttpClient; | ||
27 | |||
28 | |||
29 | |||
30 | private static Retrofit mWebRetrofit; | ||
31 | private static OkHttpClient mWebOkHttpClient; | ||
32 | |||
33 | /** | ||
34 | * 获取Retrofit对象 | ||
35 | * | ||
36 | * @return | ||
37 | */ | ||
38 | |||
39 | protected static Retrofit getMachineRetrofit(String API_SERVER) { | ||
40 | |||
41 | if (null == mStaRetrofit) { | ||
42 | |||
43 | if (null == mStaOkHttpClient) { | ||
44 | mStaOkHttpClient = OkHttp3Utils.getOkHttpClient(); | ||
45 | } | ||
46 | |||
47 | //Retrofit2后使用build设计模式 | ||
48 | mStaRetrofit = new Retrofit.Builder() | ||
49 | //设置服务器路径 | ||
50 | .baseUrl( API_SERVER +"/") | ||
51 | //添加转化库,默认是Gson | ||
52 | .addConverterFactory(GsonConverterFactory.create()) | ||
53 | //添加回调库,采用RxJava | ||
54 | .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) | ||
55 | //设置使用okhttp网络请求 | ||
56 | .client(mStaOkHttpClient) | ||
57 | .build(); | ||
58 | |||
59 | } | ||
60 | |||
61 | return mStaRetrofit; | ||
62 | } | ||
63 | protected static Retrofit getNginxRetrofit(String API_SERVER) { | ||
64 | |||
65 | if (null == nginxRetrofit) { | ||
66 | |||
67 | if (null == nginxOkHttpClient) { | ||
68 | nginxOkHttpClient = OkHttp3Utils.getOkHttpClient(); | ||
69 | } | ||
70 | |||
71 | //Retrofit2后使用build设计模式 | ||
72 | nginxRetrofit = new Retrofit.Builder() | ||
73 | //设置服务器路径 | ||
74 | .baseUrl( API_SERVER +"/") | ||
75 | //添加转化库,默认是Gson | ||
76 | .addConverterFactory(GsonConverterFactory.create()) | ||
77 | //添加回调库,采用RxJava | ||
78 | .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) | ||
79 | //设置使用okhttp网络请求 | ||
80 | .client(nginxOkHttpClient) | ||
81 | .build(); | ||
82 | |||
83 | } | ||
84 | |||
85 | return nginxRetrofit; | ||
86 | } | ||
87 | |||
88 | |||
89 | |||
90 | protected static Retrofit getPrwsCloudRetrofit(String API_SERVER,boolean isReInit) { | ||
91 | |||
92 | if (isReInit){ | ||
93 | prwsCloudRetrofit = null; | ||
94 | } | ||
95 | |||
96 | if (null == prwsCloudRetrofit) { | ||
97 | |||
98 | if (null == prwsCloudOkHttpClient) { | ||
99 | prwsCloudOkHttpClient = OkHttp3Utils.getOkHttpClient(); | ||
100 | } | ||
101 | |||
102 | LogUtil.i("RetrofitUtils","url:"+API_SERVER); | ||
103 | //Retrofit2后使用build设计模式 | ||
104 | prwsCloudRetrofit = new Retrofit.Builder() | ||
105 | //设置服务器路径 | ||
106 | .baseUrl( API_SERVER +"/") | ||
107 | //添加转化库,默认是Gson | ||
108 | .addConverterFactory(GsonConverterFactory.create()) | ||
109 | //添加回调库,采用RxJava | ||
110 | .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io())) | ||
111 | //设置使用okhttp网络请求 | ||
112 | .client(prwsCloudOkHttpClient) | ||
113 | .build(); | ||
114 | |||
115 | } | ||
116 | |||
117 | return prwsCloudRetrofit; | ||
118 | } | ||
119 | |||
120 | |||
121 | |||
122 | // protected static Retrofit getWebViewRetrofit(String API_SERVER) { | ||
123 | // | ||
124 | // if (null == mWebRetrofit) { | ||
125 | // | ||
126 | // if (null == mWebOkHttpClient) { | ||
127 | // mWebOkHttpClient = OkHttp3Utils.getOkHttpClient(); | ||
128 | // } | ||
129 | // | ||
130 | // //Retrofit2后使用build设计模式 | ||
131 | // mWebRetrofit = new Retrofit.Builder() | ||
132 | // //设置服务器路径 | ||
133 | // .baseUrl( API_SERVER +"/") | ||
134 | // //添加转化库,默认是Gson | ||
135 | // .addConverterFactory(GsonConverterFactory.create()) | ||
136 | // //添加回调库,采用RxJava | ||
137 | // .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | ||
138 | // //设置使用okhttp网络请求 | ||
139 | // .client(mWebOkHttpClient) | ||
140 | // .build(); | ||
141 | // | ||
142 | // } | ||
143 | // | ||
144 | // return mWebRetrofit; | ||
145 | // } | ||
146 | |||
147 | } | ||
148 |
libs/common/src/main/java/com/prws/common/net/SerializableOkHttpCookies.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import java.io.IOException; | ||
4 | import java.io.ObjectInputStream; | ||
5 | import java.io.ObjectOutputStream; | ||
6 | import java.io.Serializable; | ||
7 | |||
8 | import okhttp3.Cookie; | ||
9 | |||
10 | /** | ||
11 | * Created by Administrator on 2016-5-4. | ||
12 | */ | ||
13 | public class SerializableOkHttpCookies implements Serializable { | ||
14 | |||
15 | private transient final Cookie cookies; | ||
16 | private transient Cookie clientCookies; | ||
17 | |||
18 | public SerializableOkHttpCookies(Cookie cookies) { | ||
19 | this.cookies = cookies; | ||
20 | } | ||
21 | |||
22 | public Cookie getCookies() { | ||
23 | Cookie bestCookies = cookies; | ||
24 | if (null != clientCookies) { | ||
25 | bestCookies = clientCookies; | ||
26 | } | ||
27 | return bestCookies; | ||
28 | } | ||
29 | |||
30 | private void writeObject(ObjectOutputStream out) throws IOException { | ||
31 | out.writeObject(cookies.name()); | ||
32 | out.writeObject(cookies.value()); | ||
33 | out.writeLong(cookies.expiresAt()); | ||
34 | out.writeObject(cookies.domain()); | ||
35 | out.writeObject(cookies.path()); | ||
36 | out.writeBoolean(cookies.secure()); | ||
37 | out.writeBoolean(cookies.httpOnly()); | ||
38 | out.writeBoolean(cookies.hostOnly()); | ||
39 | out.writeBoolean(cookies.persistent()); | ||
40 | } | ||
41 | |||
42 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { | ||
43 | String name = (String) in.readObject(); | ||
44 | String value = (String) in.readObject(); | ||
45 | long expiresAt = in.readLong(); | ||
46 | String domain = (String) in.readObject(); | ||
47 | String path = (String) in.readObject(); | ||
48 | boolean secure = in.readBoolean(); | ||
49 | boolean httpOnly = in.readBoolean(); | ||
50 | boolean hostOnly = in.readBoolean(); | ||
51 | boolean persistent = in.readBoolean(); | ||
52 | Cookie.Builder builder = new Cookie.Builder(); | ||
53 | builder = builder.name(name); | ||
54 | builder = builder.value(value); | ||
55 | builder = builder.expiresAt(expiresAt); | ||
56 | builder = hostOnly ? builder.hostOnlyDomain(domain) : builder.domain(domain); | ||
57 | builder = builder.path(path); | ||
58 | builder = secure ? builder.secure() : builder; | ||
59 | builder = httpOnly ? builder.httpOnly() : builder; | ||
60 | clientCookies = builder.build(); | ||
61 | } | ||
62 | } | ||
63 |
libs/common/src/main/java/com/prws/common/net/SignInterceptor.java
File was created | 1 | package com.prws.common.net; | |
2 | |||
3 | import com.prws.common.utils.SharedPreferencesUtil; | ||
4 | |||
5 | import org.apache.commons.codec.binary.Hex; | ||
6 | import org.apache.commons.codec.digest.DigestUtils; | ||
7 | |||
8 | import java.io.IOException; | ||
9 | import java.util.Date; | ||
10 | import java.util.Random; | ||
11 | |||
12 | import okhttp3.Interceptor; | ||
13 | import okhttp3.Request; | ||
14 | import okhttp3.Response; | ||
15 | |||
16 | public class SignInterceptor implements Interceptor { | ||
17 | @Override | ||
18 | public Response intercept(Chain chain) throws IOException { | ||
19 | // String appId = "1"; | ||
20 | // String APP_SECRET = "a839c40e04477d43705a64ba9db23b0dba969df360c3e428add85a6f5b8d0622"; | ||
21 | // String timestamp = String.valueOf(new Date().getTime()); | ||
22 | // String nonce = String.valueOf(new Random().nextInt(10000)); | ||
23 | // String sign = DigestUtils.md5Hex(appId + APP_SECRET + timestamp + nonce); // yidao板子报错 采用如下代码 | ||
24 | // byte[] signBytes = DigestUtils.md5(appId + APP_SECRET + timestamp + nonce); | ||
25 | // String sign = new String(Hex.encodeHex(signBytes)); | ||
26 | String token = (String) SharedPreferencesUtil.getData("token",""); | ||
27 | Request.Builder requestBuilder = chain.request().newBuilder(); | ||
28 | if (token != null && token.length() > 0) { | ||
29 | requestBuilder = chain.request().newBuilder() | ||
30 | .header("Authorization", token); | ||
31 | } | ||
32 | // .header("Content-Type","application/json"); | ||
33 | |||
34 | return chain.proceed(requestBuilder.build()); | ||
35 | } | ||
36 | } | ||
37 |
libs/common/src/main/java/com/prws/common/opc/OpcCheckResult.java
File was created | 1 | package com.prws.common.opc; | |
2 | |||
3 | import java.sql.Date; | ||
4 | import java.text.SimpleDateFormat; | ||
5 | import java.util.List; | ||
6 | import java.util.Locale; | ||
7 | |||
8 | public class OpcCheckResult { | ||
9 | |||
10 | private List<PmReadingRecord> readingRecordList; //读数数据 | ||
11 | |||
12 | private String areaName;//区域名称 | ||
13 | |||
14 | private String checkPointName;//采集点名称 | ||
15 | |||
16 | private String mapName;//地图名称 | ||
17 | |||
18 | private String checkTime;//检测时间 | ||
19 | |||
20 | private boolean isThousandStandardValidate;//千级标准是否通过 | ||
21 | |||
22 | private boolean isTenThousandStandardValidate;//万级标准是否通过 | ||
23 | |||
24 | public OpcCheckResult() { | ||
25 | this.checkTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date(System.currentTimeMillis())); | ||
26 | } | ||
27 | |||
28 | public List<PmReadingRecord> getReadingRecordList() { | ||
29 | return readingRecordList; | ||
30 | } | ||
31 | |||
32 | public void setReadingRecordList(List<PmReadingRecord> readingRecordList) { | ||
33 | this.readingRecordList = readingRecordList; | ||
34 | } | ||
35 | |||
36 | public String getAreaName() { | ||
37 | return areaName; | ||
38 | } | ||
39 | |||
40 | public void setAreaName(String areaName) { | ||
41 | this.areaName = areaName; | ||
42 | } | ||
43 | |||
44 | public String getMapName() { | ||
45 | return mapName; | ||
46 | } | ||
47 | |||
48 | public void setMapName(String mapName) { | ||
49 | this.mapName = mapName; | ||
50 | } | ||
51 | |||
52 | public String getCheckPointName() { | ||
53 | return checkPointName; | ||
54 | } | ||
55 | |||
56 | public void setCheckPointName(String checkPointName) { | ||
57 | this.checkPointName = checkPointName; | ||
58 | } | ||
59 | |||
60 | public String getCheckTime() { | ||
61 | return checkTime; | ||
62 | } | ||
63 | |||
64 | public void setCheckTime(String checkTime) { | ||
65 | this.checkTime = checkTime; | ||
66 | } | ||
67 | |||
68 | public boolean isThousandStandardValidate() { | ||
69 | return isThousandStandardValidate; | ||
70 | } | ||
71 | |||
72 | public void setThousandStandardValidate(boolean thousandStandardValidate) { | ||
73 | isThousandStandardValidate = thousandStandardValidate; | ||
74 | } | ||
75 | |||
76 | public boolean isTenThousandStandardValidate() { | ||
77 | return isTenThousandStandardValidate; | ||
78 | } | ||
79 | |||
80 | public void setTenThousandStandardValidate(boolean tenThousandStandardValidate) { | ||
81 | isTenThousandStandardValidate = tenThousandStandardValidate; | ||
82 | } | ||
83 | |||
84 | @Override | ||
85 | public String toString() { | ||
86 | return "OpcCheckResult{" + | ||
87 | "readingRecordList=" + readingRecordList + | ||
88 | ", areaName='" + areaName + '\'' + | ||
89 | ", mapName='" + mapName + '\'' + | ||
90 | ", checkTime='" + checkTime + '\'' + | ||
91 | ", isThousandStandardValidate=" + isThousandStandardValidate + | ||
92 | ", isTenThousandStandardValidate=" + isTenThousandStandardValidate + | ||
93 | '}'; | ||
94 | } | ||
95 | } | ||
96 |
libs/common/src/main/java/com/prws/common/opc/OpcHelper.java
File was created | 1 | package com.prws.common.opc; | |
2 | |||
3 | |||
4 | import java.util.Timer; | ||
5 | |||
6 | public class OpcHelper { | ||
7 | private static String TAG = "OpcHelper"; | ||
8 | private static OpcHelper opcHelper; | ||
9 | // private Map<String, CallBack> callbackGroup = new HashMap<>(); | ||
10 | // private Map<String, CallBack> timerCallbackGroup = new HashMap<>(); | ||
11 | private Timer dateTimer; | ||
12 | private boolean isReading = false; | ||
13 | |||
14 | //轮询颗粒物读数 | ||
15 | // public void getParticulateMatterDataWithInterval(int interval,CallBack callback){ | ||
16 | // String uuid = UUID.randomUUID().toString(); | ||
17 | // byte[] dd = CRC16Utils.getData("01","04","00","03","00","15"); | ||
18 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
19 | // if(callback!=null){ | ||
20 | // timerCallbackGroup.put(uuid,callback); | ||
21 | // } | ||
22 | // try{ | ||
23 | // if(!isReading){ | ||
24 | // if(dateTimer==null){ | ||
25 | // dateTimer = new Timer(); | ||
26 | // isReading = true; | ||
27 | // dateTimer.schedule(new TimerTask() { | ||
28 | // @Override | ||
29 | // public void run() { | ||
30 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
31 | // } | ||
32 | // },0,interval); | ||
33 | // } | ||
34 | // } | ||
35 | // }catch (Exception e){ | ||
36 | // e.printStackTrace(); | ||
37 | // } | ||
38 | // | ||
39 | // } | ||
40 | // | ||
41 | // public void cancelReadingPmData(){ | ||
42 | // if(dateTimer !=null){ | ||
43 | // dateTimer.cancel(); | ||
44 | // dateTimer = null; | ||
45 | // } | ||
46 | // timerCallbackGroup.clear(); | ||
47 | // isReading = false; | ||
48 | // } | ||
49 | // | ||
50 | // | ||
51 | // | ||
52 | // //获取颗粒物读数 | ||
53 | // public void getParticulateMatterData(CallBack callback){ | ||
54 | // | ||
55 | // String uuid = UUID.randomUUID().toString(); | ||
56 | // byte[] dd = CRC16Utils.getData("01","04","00","03","00","15"); | ||
57 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
58 | // if(callback!=null){ | ||
59 | // callbackGroup.put(uuid,callback); | ||
60 | // } | ||
61 | // Log.d(TAG, "读取采集器,taskID: "+uuid+",code:"+param); | ||
62 | // LogUtil.logUploadFile(2,TAG,"读取采集器,taskID: "+uuid+",code:"+param); | ||
63 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
64 | // } | ||
65 | // | ||
66 | // //获取单位 | ||
67 | // public void getUnit(CallBack callback){ | ||
68 | // String uuid = UUID.randomUUID().toString(); | ||
69 | // byte[] dd = CRC16Utils.getData("01","03","00","13","00","01"); | ||
70 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
71 | // if(callback!=null){ | ||
72 | // callbackGroup.put(uuid,callback); | ||
73 | // } | ||
74 | // | ||
75 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
76 | // } | ||
77 | // | ||
78 | // public void setUnit(int type){ | ||
79 | // setUnit(type,null); | ||
80 | // } | ||
81 | // | ||
82 | // public void setUnit(int type,CallBack callback){ | ||
83 | // int df1 = 0,df2 = type; | ||
84 | // String uuid = UUID.randomUUID().toString(); | ||
85 | // byte[] dd = CRC16Utils.getData("01","06","00","13",CRC16Utils.byteTo16StringwithoutSpace(df1),CRC16Utils.byteTo16StringwithoutSpace(df2)); | ||
86 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
87 | // if(callback!=null){ | ||
88 | // callbackGroup.put(uuid,callback); | ||
89 | // } | ||
90 | // | ||
91 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
92 | // } | ||
93 | // | ||
94 | // //设置工作间隔 | ||
95 | // public void setWorkInterval(int minute,CallBack callback){ | ||
96 | // int df1 = 0,df2 = 0; | ||
97 | // if(minute >255){ | ||
98 | // df1 = (int) Math.floor(minute/256); | ||
99 | // df2 = minute % 256; | ||
100 | // }else{ | ||
101 | // df2 = minute; | ||
102 | // } | ||
103 | // String uuid = UUID.randomUUID().toString(); | ||
104 | // | ||
105 | // byte[] dd = CRC16Utils.getData("01","06","00","0D",CRC16Utils.byteTo16StringwithoutSpace(df1),CRC16Utils.byteTo16StringwithoutSpace(df2)); | ||
106 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
107 | // if(callback!=null){ | ||
108 | // callbackGroup.put(uuid,callback); | ||
109 | // } | ||
110 | // | ||
111 | // Log.d(TAG, "setWorkInterval: minute:"+minute+",param:"+param+",df1、df2:"+CRC16Utils.byteTo16StringwithoutSpace(df1)+"、"+CRC16Utils.byteTo16StringwithoutSpace(df2)); | ||
112 | // | ||
113 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
114 | // | ||
115 | // } | ||
116 | // | ||
117 | // public void getWorkInterval(CallBack callback){ | ||
118 | // | ||
119 | // String uuid = UUID.randomUUID().toString(); | ||
120 | // byte[] dd = CRC16Utils.getData("01","03","00","0D","00","01"); | ||
121 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
122 | // if(callback!=null){ | ||
123 | // callbackGroup.put(uuid,callback); | ||
124 | // } | ||
125 | // | ||
126 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
127 | // | ||
128 | // } | ||
129 | // | ||
130 | // /** | ||
131 | // * 启动粒子采集器 | ||
132 | // * @param callBack | ||
133 | // */ | ||
134 | // public void startOpc(CallBack callBack){ | ||
135 | // String uuid = UUID.randomUUID().toString(); | ||
136 | // byte[] dd = CRC16Utils.getData("01","05","00","10","00","01"); | ||
137 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
138 | // if(callBack!=null){ | ||
139 | // callbackGroup.put(uuid,callBack); | ||
140 | // } | ||
141 | // Log.d(TAG, "启动采集器,taskID: "+uuid+",code:"+param); | ||
142 | // LogUtil.logUploadFile(2,TAG,"启动采集器,taskID: "+uuid+",code:"+param); | ||
143 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
144 | // } | ||
145 | // | ||
146 | // /** | ||
147 | // * 关闭粒子采集器 | ||
148 | // * @param callBack | ||
149 | // */ | ||
150 | // public void stopOpc(CallBack callBack){ | ||
151 | // String uuid = UUID.randomUUID().toString(); | ||
152 | // byte[] dd = CRC16Utils.getData("01","05","00","10","00","00"); | ||
153 | // int[] param = CRC16Utils.byteToIntArray(dd); | ||
154 | // if(callBack!=null){ | ||
155 | // callbackGroup.put(uuid,callBack); | ||
156 | // } | ||
157 | // Log.d(TAG, "关闭采集器,taskID: "+uuid+",code:"+param); | ||
158 | // LogUtil.logUploadFile(2,TAG,"关闭采集器,taskID: "+uuid+",code:"+param); | ||
159 | // InstructionsFactory.getOpcController().sendCode(uuid,param); | ||
160 | // | ||
161 | // } | ||
162 | // | ||
163 | // public void getParticulateMatterDataDelay(CallBack dataCallBack){ | ||
164 | // | ||
165 | // startOpc(new CallBack() { | ||
166 | // @Override | ||
167 | // public void onGetData(List<Integer> code) { | ||
168 | // Log.d(TAG, "启动完成,onGetData: "+code); | ||
169 | // LogUtil.logUploadFile(2,TAG,"启动完成,onGetData: "+code); | ||
170 | // } | ||
171 | // }); | ||
172 | // Timer timer = new Timer(); | ||
173 | // int opcTime = (int) SharedPreferencesUtil.getData("collectorTime",60); | ||
174 | // timer.schedule(new TimerTask() { | ||
175 | // @Override | ||
176 | // public void run() { | ||
177 | //// repeatGetData(dataCallBack); | ||
178 | // getDataAfterStop(dataCallBack); | ||
179 | // } | ||
180 | // },opcTime*1000); | ||
181 | // | ||
182 | // } | ||
183 | // | ||
184 | // /** | ||
185 | // * 此方法的逻辑是先停下机器,等待3秒后再读取数据 | ||
186 | // * @param dataCallBack | ||
187 | // */ | ||
188 | // private void getDataAfterStop(CallBack dataCallBack){ | ||
189 | // stopOpc(new CallBack() { | ||
190 | // @Override | ||
191 | // public void onGetData(List<Integer> code) { | ||
192 | // Log.d(TAG, "关闭成功,onGetData: "+code); | ||
193 | // LogUtil.logUploadFile(2,TAG,"关闭成功,onGetData: "+code); | ||
194 | // Timer timer = new Timer(); | ||
195 | // timer.schedule(new TimerTask() { | ||
196 | // @Override | ||
197 | // public void run() { | ||
198 | // getParticulateMatterData(new CallBack() { | ||
199 | // @Override | ||
200 | // public void onGetData(List<Integer> code) { | ||
201 | // LogUtil.logUploadFile(2,TAG,"读取成功,onGetData: "+code); | ||
202 | // PmNumericalReading reading = OpcUtils.getPmNumericalReadingUseCode(code); | ||
203 | // if(dataCallBack!=null){ | ||
204 | // dataCallBack.onGetData(code); | ||
205 | // } | ||
206 | // } | ||
207 | // }); | ||
208 | // } | ||
209 | // },3000); | ||
210 | // } | ||
211 | // }); | ||
212 | // | ||
213 | // } | ||
214 | // | ||
215 | // /** | ||
216 | // * 此方法的逻辑是如果获取到的数据为0,则重复读取,最多10次 | ||
217 | // */ | ||
218 | // private int repeatCount = 0; | ||
219 | // private void repeatGetData(CallBack dataCallBack){ | ||
220 | // repeatCount++; | ||
221 | // getParticulateMatterData(new CallBack() { | ||
222 | // @Override | ||
223 | // public void onGetData(List<Integer> code) { | ||
224 | // LogUtil.logUploadFile(2,TAG,"读取成功,onGetData: "+code); | ||
225 | // PmNumericalReading reading = OpcUtils.getPmNumericalReadingUseCode(code); | ||
226 | // if(reading.isAllDataZero() && repeatCount<=10 && false){ | ||
227 | // repeatGetData(dataCallBack); | ||
228 | // }else{ | ||
229 | // repeatCount = 0; | ||
230 | // if(dataCallBack!=null){ | ||
231 | // dataCallBack.onGetData(code); | ||
232 | // } | ||
233 | // stopOpc(new CallBack() { | ||
234 | // @Override | ||
235 | // public void onGetData(List<Integer> code) { | ||
236 | // Log.d(TAG, "关闭成功,onGetData: "+code); | ||
237 | // LogUtil.logUploadFile(2,TAG,"关闭成功,onGetData: "+code); | ||
238 | // } | ||
239 | // }); | ||
240 | // } | ||
241 | // } | ||
242 | // }); | ||
243 | // } | ||
244 | // | ||
245 | // | ||
246 | // public static OpcHelper getInstance(){ | ||
247 | // if(opcHelper==null){ | ||
248 | // opcHelper = new OpcHelper(); | ||
249 | // } | ||
250 | // return opcHelper; | ||
251 | // } | ||
252 | // | ||
253 | // private OpcHelper(){ | ||
254 | // EcuState.getInstance().addObserver(new Observer() { | ||
255 | // @Override | ||
256 | // public void update(Observable o, Object arg) { | ||
257 | // | ||
258 | // if (!(o instanceof EcuState))return; | ||
259 | // EcuState ecuState = (EcuState) o; | ||
260 | // | ||
261 | // if (!(arg instanceof EcuState.UPDATE))return; | ||
262 | // EcuState.UPDATE type = (EcuState.UPDATE) arg; | ||
263 | // | ||
264 | // if(type == EcuState.UPDATE.COLLECTOR){ | ||
265 | // Log.d(TAG, "update: "+ecuState.getTaskUUID()); | ||
266 | // Log.d(TAG, "update: "+ecuState.getCollectorData().toString()); | ||
267 | // dispatchData(ecuState.getTaskUUID(), ecuState.getCollectorData()); | ||
268 | // } | ||
269 | // | ||
270 | // } | ||
271 | // },false); | ||
272 | // } | ||
273 | // | ||
274 | // private void dispatchData(String taskUUID, List<Integer> data){ | ||
275 | // String tempTaskUUID = null ; | ||
276 | // for (Map.Entry<String, CallBack> entry:callbackGroup.entrySet()){ | ||
277 | // if(entry.getKey().equals(taskUUID)){ | ||
278 | // CallBack callBack = entry.getValue(); | ||
279 | // callBack.onGetData(data); | ||
280 | // tempTaskUUID = taskUUID; | ||
281 | // } | ||
282 | // } | ||
283 | // | ||
284 | // if(tempTaskUUID!=null){ | ||
285 | // callbackGroup.remove(tempTaskUUID); | ||
286 | // } | ||
287 | // | ||
288 | // for (Map.Entry<String, CallBack> entry:timerCallbackGroup.entrySet()){ | ||
289 | // if(entry.getKey().equals(taskUUID)){ | ||
290 | // CallBack callBack = entry.getValue(); | ||
291 | // callBack.onGetData(data); | ||
292 | // tempTaskUUID = taskUUID; | ||
293 | // } | ||
294 | // } | ||
295 | // } | ||
296 | // | ||
297 | // | ||
298 | // // | ||
299 | // | ||
300 | // public interface CallBack{ | ||
301 | // public void onGetData(List<Integer> code); | ||
302 | // } | ||
303 | // | ||
304 | // public boolean isReading() { | ||
305 | // return isReading; | ||
306 | // } | ||
307 | } | ||
308 |
libs/common/src/main/java/com/prws/common/opc/OpcUtils.java
File was created | 1 | package com.prws.common.opc; | |
2 | |||
3 | import android.util.Log; | ||
4 | |||
5 | import com.prws.common.utils.LogUtil; | ||
6 | import com.prws.common.utils.SharedPreferencesUtil; | ||
7 | |||
8 | |||
9 | import java.util.ArrayList; | ||
10 | import java.util.List; | ||
11 | |||
12 | public class OpcUtils { | ||
13 | |||
14 | private static String TAG = "OpcUtils"; | ||
15 | private static boolean isTTA = true; | ||
16 | |||
17 | /** | ||
18 | * 将寄存器读数转为颗粒物读数 | ||
19 | * @param data 粒子计数器寄存器读数 | ||
20 | * @return PmNumericalReading | ||
21 | */ | ||
22 | public static PmNumericalReading getPmNumericalReadingUseCode(List<Integer> data){ | ||
23 | |||
24 | PmNumericalReading pmNumericalReading = new PmNumericalReading(); | ||
25 | int i = 1; | ||
26 | try { | ||
27 | i = Integer.valueOf((String) SharedPreferencesUtil.getData("swyias","1")); | ||
28 | }catch (Exception e){} | ||
29 | if (i != 1 && i != 2) | ||
30 | isTTA = false; | ||
31 | if (isTTA){ | ||
32 | pmNumericalReading.setZeroPointThree(countReading2(data.get(16),data.get(17),data.get(18),data.get(19))); | ||
33 | pmNumericalReading.setZeroPointFive(countReading2(data.get(22),data.get(23),data.get(24),data.get(25))); | ||
34 | pmNumericalReading.setOnePointZero(countReading2(data.get(28),data.get(29),data.get(30),data.get(31))); | ||
35 | |||
36 | pmNumericalReading.setTwoPointFive(countReading2(data.get(34),data.get(35),data.get(36),data.get(37))); | ||
37 | pmNumericalReading.setFivePointZero(countReading2(data.get(40),data.get(41),data.get(42),data.get(43))); | ||
38 | |||
39 | |||
40 | |||
41 | |||
42 | Double wd = Integer.parseInt(Integer.toHexString(data.get(8)) | ||
43 | +( Integer.toHexString(data.get(9)).length() == 2 ?Integer.toHexString(data.get(9)) : "0"+Integer.toHexString(data.get(9))) | ||
44 | ,16)* 0.1; | ||
45 | |||
46 | Double sd = Integer.parseInt(Integer.toHexString(data.get(12)) | ||
47 | +( Integer.toHexString(data.get(13)).length() == 2 ?Integer.toHexString(data.get(13)) : "0"+Integer.toHexString(data.get(13))) | ||
48 | ,16)* 0.1; | ||
49 | |||
50 | pmNumericalReading.setWd(wd); | ||
51 | pmNumericalReading.setSd(sd); | ||
52 | |||
53 | }else { | ||
54 | pmNumericalReading.setZeroPointThree(countReading(data.get(3),data.get(4),data.get(5),data.get(6))); | ||
55 | pmNumericalReading.setZeroPointFive(countReading(data.get(7),data.get(8),data.get(9),data.get(10))); | ||
56 | pmNumericalReading.setOnePointZero(countReading(data.get(11),data.get(12),data.get(13),data.get(14))); | ||
57 | pmNumericalReading.setTwoPointFive(countReading(data.get(15),data.get(16),data.get(17),data.get(18))); | ||
58 | pmNumericalReading.setFivePointZero(countReading(data.get(19),data.get(20),data.get(21),data.get(22))); | ||
59 | pmNumericalReading.setTenPointZero(countReading(data.get(23),data.get(24),data.get(25),data.get(26))); | ||
60 | } | ||
61 | Log.d(TAG, "getPmNumericalReadingUseCode: "+pmNumericalReading.toString()); | ||
62 | |||
63 | |||
64 | return pmNumericalReading; | ||
65 | } | ||
66 | |||
67 | |||
68 | public static long countReading(int df1,int df2,int df3,int df4){ | ||
69 | float ratio = (float) SharedPreferencesUtil.getData("opcRatio",1f); | ||
70 | return (long) ((df1 * (long) Math.pow(256,3) + df2 * Math.pow(256,2) + df3 * 256 + df4) * ratio); | ||
71 | } | ||
72 | public static long countReading2(int df1,int df2,int df3,int df4){ | ||
73 | float ratio = (float) SharedPreferencesUtil.getData("topcRatio",35.3f); | ||
74 | return (long) ((df1 * (long) Math.pow(256,3) + df2 * Math.pow(256,2) + df3 * 256 + df4) * ratio); | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * 返回一组数据中根据不同标准是否验证通过,只要有一个数据不通过则返回false | ||
79 | * @param list | ||
80 | * @param checkStandard | ||
81 | * @return | ||
82 | */ | ||
83 | public static boolean checkResult(List<PmReadingRecord> list,CheckStandard checkStandard){ | ||
84 | |||
85 | switch (checkStandard){ | ||
86 | case STANDARD_B_THOUSAND: | ||
87 | for(int i=0;i<list.size();i++){ | ||
88 | PmNumericalReading reading = list.get(i).getReading(); | ||
89 | if( | ||
90 | // reading.getZeroPointOne((long) SharedPreferencesUtil.getData("zeroPointOneOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointOneOffset",10200l) || | ||
91 | reading.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointThreeOffset",10200l) || | ||
92 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointFiveOffset",3520l)|| | ||
93 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >=(long) SharedPreferencesUtil.getData("bfivePointZeroOffset",29l) ){ | ||
94 | return false; | ||
95 | |||
96 | } | ||
97 | } | ||
98 | break; | ||
99 | |||
100 | case STANDARD_THOUSAND: | ||
101 | for(int i=0;i<list.size();i++){ | ||
102 | PmNumericalReading reading = list.get(i).getReading(); | ||
103 | |||
104 | |||
105 | if(reading.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointThreeOffset",102000l) || | ||
106 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointFiveOffset",35200l)|| | ||
107 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("qfivePointZeroOffset",293l)){ | ||
108 | return false; | ||
109 | } | ||
110 | } | ||
111 | break; | ||
112 | case STANDARD_TEN_THOUSAND: | ||
113 | for(int i=0;i<list.size();i++){ | ||
114 | |||
115 | PmNumericalReading reading = list.get(i).getReading(); | ||
116 | if( reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("wzeroPointFiveOffset",352000l)|| | ||
117 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("wfivePointZeroOffset",2930l)){ | ||
118 | return false; | ||
119 | } | ||
120 | } | ||
121 | // | ||
122 | break; | ||
123 | case STANDARD_TEN_TEN_THOUSAND: | ||
124 | for(int i=0;i<list.size();i++){ | ||
125 | PmNumericalReading reading = list.get(i).getReading(); | ||
126 | if( reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("szeroPointFiveOffset",3520000l)|| | ||
127 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("sfivePointZeroOffset",29300l)){ | ||
128 | return false; | ||
129 | } | ||
130 | } | ||
131 | break; | ||
132 | } | ||
133 | |||
134 | return true; | ||
135 | } | ||
136 | |||
137 | public static ArrayList<String> checkResult2(List<PmReadingRecord> list,CheckStandard checkStandard){ | ||
138 | |||
139 | ArrayList<String> alist = new ArrayList<>(); | ||
140 | switch (checkStandard){ | ||
141 | case STANDARD_B_THOUSAND: | ||
142 | for(int i=0;i<list.size();i++){ | ||
143 | PmNumericalReading reading = list.get(i).getReading(); | ||
144 | if( | ||
145 | // reading.getZeroPointOne((long) SharedPreferencesUtil.getData("zeroPointOneOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointOneOffset",10200l) || | ||
146 | reading.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointThreeOffset",10200l) || | ||
147 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointFiveOffset",3520l)|| | ||
148 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >=(long) SharedPreferencesUtil.getData("bfivePointZeroOffset",29l) ){ | ||
149 | |||
150 | alist.add(i+""); | ||
151 | LogUtil.e(TAG,"百级增加 "+alist.size()); | ||
152 | } | ||
153 | } | ||
154 | break; | ||
155 | |||
156 | case STANDARD_THOUSAND: | ||
157 | for(int i=0;i<list.size();i++){ | ||
158 | PmNumericalReading reading = list.get(i).getReading(); | ||
159 | if(reading.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointThreeOffset",102000l) || | ||
160 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointFiveOffset",35200l)|| | ||
161 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("qfivePointZeroOffset",293l)){ | ||
162 | alist.add(i+""); | ||
163 | LogUtil.e(TAG,"千级增加 "+alist.size()); | ||
164 | } | ||
165 | } | ||
166 | break; | ||
167 | case STANDARD_TEN_THOUSAND: | ||
168 | for(int i=0;i<list.size();i++){ | ||
169 | PmNumericalReading reading = list.get(i).getReading(); | ||
170 | if( | ||
171 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("wzeroPointFiveOffset",352000l)|| | ||
172 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("wfivePointZeroOffset",2930l) | ||
173 | ){ | ||
174 | |||
175 | LogUtil.e(TAG," getZeroPointFive "+reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l))); | ||
176 | LogUtil.e(TAG," 比较 "+(long) SharedPreferencesUtil.getData("wzeroPointFiveOffset",352000l)); | ||
177 | LogUtil.e(TAG," getZeroPointFive "+reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l))); | ||
178 | LogUtil.e(TAG," 比较 "+(long) SharedPreferencesUtil.getData("wfivePointZeroOffset",2930l)); | ||
179 | |||
180 | |||
181 | alist.add(i+""); | ||
182 | LogUtil.e(TAG,"万级增加 "+alist.size()); | ||
183 | } | ||
184 | } | ||
185 | // | ||
186 | break; | ||
187 | case STANDARD_TEN_TEN_THOUSAND: | ||
188 | for(int i=0;i<list.size();i++){ | ||
189 | PmNumericalReading reading = list.get(i).getReading(); | ||
190 | if( reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("szeroPointFiveOffset",3520000l)|| | ||
191 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("sfivePointZeroOffset",29300l)){ | ||
192 | alist.add(i+""); | ||
193 | LogUtil.e(TAG,"十万级增加 "+alist.size()); | ||
194 | } | ||
195 | } | ||
196 | break; | ||
197 | } | ||
198 | |||
199 | return alist; | ||
200 | } | ||
201 | |||
202 | public static boolean checkResult(PmReadingRecord readingRecord,CheckStandard checkStandard){ | ||
203 | |||
204 | switch (checkStandard){ | ||
205 | case STANDARD_B_THOUSAND: | ||
206 | PmNumericalReading reading0 = readingRecord.getReading(); | ||
207 | if( | ||
208 | // reading0.getZeroPointOne((long) SharedPreferencesUtil.getData("zeroPointOneOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointOneOffset",10200l) || | ||
209 | reading0.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointThreeOffset",10200l) || | ||
210 | reading0.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("bzeroPointFiveOffset",3520l)|| | ||
211 | reading0.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >=(long) SharedPreferencesUtil.getData("bfivePointZeroOffset",29l) ){ | ||
212 | return false; | ||
213 | } | ||
214 | |||
215 | break; | ||
216 | case STANDARD_THOUSAND: | ||
217 | PmNumericalReading reading = readingRecord.getReading(); | ||
218 | if(reading.getZeroPointThree((long) SharedPreferencesUtil.getData("zeroPointThreeOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointThreeOffset",102000l) || | ||
219 | reading.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("qzeroPointFiveOffset",35200l)|| | ||
220 | reading.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("qfivePointZeroOffset",293l)){ | ||
221 | return false; | ||
222 | } | ||
223 | break; | ||
224 | case STANDARD_TEN_THOUSAND: | ||
225 | PmNumericalReading reading1 = readingRecord.getReading(); | ||
226 | if( reading1.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("wzeroPointFiveOffset",352000l)|| | ||
227 | reading1.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("wfivePointZeroOffset",2930l)){ | ||
228 | LogUtil.e(TAG," getZeroPointFive "+reading1.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l))); | ||
229 | LogUtil.e(TAG," 比较 "+(long) SharedPreferencesUtil.getData("wzeroPointFiveOffset",352000l)); | ||
230 | LogUtil.e(TAG," getZeroPointFive "+reading1.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l))); | ||
231 | LogUtil.e(TAG," 比较 "+(long) SharedPreferencesUtil.getData("wfivePointZeroOffset",2930l)); | ||
232 | |||
233 | LogUtil.e(TAG,"返回 false"); | ||
234 | return false; | ||
235 | } | ||
236 | break; | ||
237 | case STANDARD_TEN_TEN_THOUSAND: | ||
238 | PmNumericalReading reading2 = readingRecord.getReading(); | ||
239 | if( reading2.getZeroPointFive((long) SharedPreferencesUtil.getData("zeroPointFiveOffset",0l)) >= (long) SharedPreferencesUtil.getData("szeroPointFiveOffset",3520000l)|| | ||
240 | reading2.getFivePointZero((long) SharedPreferencesUtil.getData("fivePointZeroOffset",0l)) >= (long) SharedPreferencesUtil.getData("sfivePointZeroOffset",29300l)){ | ||
241 | return false; | ||
242 | } | ||
243 | break; | ||
244 | } | ||
245 | LogUtil.e(TAG,"返回 true"); | ||
246 | return true; | ||
247 | } | ||
248 | |||
249 | |||
250 | |||
251 | public enum CheckStandard{ | ||
252 | |||
253 | STANDARD_B_THOUSAND, | ||
254 | /** | ||
255 | * 千级 | ||
256 | */ | ||
257 | STANDARD_THOUSAND, | ||
258 | /** | ||
259 | * 千级 | ||
260 | */ | ||
261 | STANDARD_TEN_TEN_THOUSAND, | ||
262 | /** | ||
263 | * 万级 | ||
264 | */ | ||
265 | STANDARD_TEN_THOUSAND; | ||
266 | |||
267 | |||
268 | } | ||
269 | |||
270 | |||
271 | |||
272 | } | ||
273 |
libs/common/src/main/java/com/prws/common/opc/PmNumericalReading.java
File was created | 1 | package com.prws.common.opc; | |
2 | |||
3 | import com.prws.common.utils.LogUtil; | ||
4 | import com.prws.common.utils.SharedPreferencesUtil; | ||
5 | |||
6 | /** | ||
7 | * 存放不同类型的颗粒物读数 | ||
8 | */ | ||
9 | public class PmNumericalReading { | ||
10 | private long zeroPointOne; | ||
11 | //>0.3μm | ||
12 | private long zeroPointThree; | ||
13 | |||
14 | //>0.5μm | ||
15 | private long zeroPointFive; | ||
16 | |||
17 | //>1.0μm | ||
18 | private long onePointZero; | ||
19 | |||
20 | //>2.5μm | ||
21 | private long twoPointFive; | ||
22 | |||
23 | //>5.0μm | ||
24 | private long fivePointZero; | ||
25 | |||
26 | //>10.0μm | ||
27 | private long tenPointZero; | ||
28 | |||
29 | private double wd; | ||
30 | private double sd; | ||
31 | |||
32 | public long getZeroPointOne() { | ||
33 | return zeroPointOne; | ||
34 | } | ||
35 | |||
36 | |||
37 | public long getZeroPointOne( long offset) { | ||
38 | String strxs = (String) SharedPreferencesUtil.getData("cjcjxs", "1.0"); | ||
39 | double xs = 1.0; | ||
40 | if (strxs != null && strxs.length() > 0) { | ||
41 | try { | ||
42 | xs = Double.valueOf(strxs); | ||
43 | } catch (Exception e) { | ||
44 | e.printStackTrace(); | ||
45 | } | ||
46 | } | ||
47 | return (long) ((double) zeroPointOne * xs) + offset; | ||
48 | } | ||
49 | public void setZeroPointOne(long zeroPointOne) { | ||
50 | this.zeroPointOne = zeroPointOne; | ||
51 | } | ||
52 | |||
53 | public double getSd() { | ||
54 | return sd; | ||
55 | } | ||
56 | |||
57 | public double getWd() { | ||
58 | return wd; | ||
59 | } | ||
60 | |||
61 | public void setSd(double sd) { | ||
62 | this.sd = sd; | ||
63 | } | ||
64 | |||
65 | public void setWd(double wd) { | ||
66 | this.wd = wd; | ||
67 | } | ||
68 | |||
69 | public long getZeroPointThree() { | ||
70 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
71 | double xs = 1.0; | ||
72 | if (strxs != null && strxs.length() > 0) { | ||
73 | try { | ||
74 | xs = Double.valueOf(strxs); | ||
75 | } catch (Exception e) { | ||
76 | e.printStackTrace(); | ||
77 | } | ||
78 | } | ||
79 | LogUtil.e("PmNumericalReading","系数:"+xs+"---zeroPointThree:"+zeroPointThree+"--改变后:"+(long) ((double)zeroPointThree * xs)); | ||
80 | |||
81 | return (long) ((double)zeroPointThree * xs); | ||
82 | } | ||
83 | |||
84 | public long getZeroPointThree(long offset){ | ||
85 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
86 | double xs = 1.0; | ||
87 | if (strxs != null && strxs.length() > 0) { | ||
88 | try { | ||
89 | xs = Double.valueOf(strxs); | ||
90 | } catch (Exception e) { | ||
91 | e.printStackTrace(); | ||
92 | } | ||
93 | } | ||
94 | return (long) ((double)zeroPointThree*xs) + offset; | ||
95 | } | ||
96 | |||
97 | public void setZeroPointThree(long zeroPointThree) { | ||
98 | |||
99 | this.zeroPointThree = zeroPointThree; | ||
100 | } | ||
101 | |||
102 | public long getZeroPointFive() { | ||
103 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
104 | double xs = 1.0; | ||
105 | if (strxs != null && strxs.length() > 0) { | ||
106 | try { | ||
107 | xs = Double.valueOf(strxs); | ||
108 | } catch (Exception e) { | ||
109 | e.printStackTrace(); | ||
110 | } | ||
111 | } | ||
112 | return (long) ((double)zeroPointFive*xs); | ||
113 | } | ||
114 | |||
115 | public long getZeroPointFive(long offset) { | ||
116 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
117 | double xs = 1.0; | ||
118 | if (strxs != null && strxs.length() > 0) { | ||
119 | try { | ||
120 | xs = Double.valueOf(strxs); | ||
121 | } catch (Exception e) { | ||
122 | e.printStackTrace(); | ||
123 | } | ||
124 | } | ||
125 | return (long) ((double)zeroPointFive*xs) + offset; | ||
126 | } | ||
127 | |||
128 | public void setZeroPointFive(long zeroPointFive) { | ||
129 | |||
130 | this.zeroPointFive = zeroPointFive; | ||
131 | } | ||
132 | |||
133 | public long getOnePointZero() { | ||
134 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
135 | double xs = 1.0; | ||
136 | if (strxs != null && strxs.length() > 0) { | ||
137 | try { | ||
138 | xs = Double.valueOf(strxs); | ||
139 | } catch (Exception e) { | ||
140 | e.printStackTrace(); | ||
141 | } | ||
142 | } | ||
143 | return (long) ((double)onePointZero*xs); | ||
144 | } | ||
145 | |||
146 | public long getOnePointZero(long offset) { | ||
147 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
148 | double xs = 1.0; | ||
149 | if (strxs != null && strxs.length() > 0) { | ||
150 | try { | ||
151 | xs = Double.valueOf(strxs); | ||
152 | } catch (Exception e) { | ||
153 | e.printStackTrace(); | ||
154 | } | ||
155 | } | ||
156 | return (long) ((double)onePointZero*xs) + offset; | ||
157 | } | ||
158 | |||
159 | public void setOnePointZero(long onePointZero) { | ||
160 | this.onePointZero = onePointZero; | ||
161 | } | ||
162 | |||
163 | public long getTwoPointFive() { | ||
164 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
165 | double xs = 1.0; | ||
166 | if (strxs != null && strxs.length() > 0) { | ||
167 | try { | ||
168 | xs = Double.valueOf(strxs); | ||
169 | } catch (Exception e) { | ||
170 | e.printStackTrace(); | ||
171 | } | ||
172 | } | ||
173 | return (long) ((double)twoPointFive*xs); | ||
174 | } | ||
175 | |||
176 | public long getTwoPointFive(long offset) { | ||
177 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
178 | double xs = 1.0; | ||
179 | if (strxs != null && strxs.length() > 0) { | ||
180 | try { | ||
181 | xs = Double.valueOf(strxs); | ||
182 | } catch (Exception e) { | ||
183 | e.printStackTrace(); | ||
184 | } | ||
185 | } | ||
186 | return (long) ((double)twoPointFive*xs) + offset; | ||
187 | } | ||
188 | |||
189 | public void setTwoPointFive(long twoPointFive) { | ||
190 | this.twoPointFive = twoPointFive; | ||
191 | } | ||
192 | |||
193 | public long getFivePointZero() { | ||
194 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
195 | double xs = 1.0; | ||
196 | if (strxs != null && strxs.length() > 0) { | ||
197 | try { | ||
198 | xs = Double.valueOf(strxs); | ||
199 | } catch (Exception e) { | ||
200 | e.printStackTrace(); | ||
201 | } | ||
202 | } | ||
203 | return (long) ((double)fivePointZero*xs); | ||
204 | } | ||
205 | |||
206 | public long getFivePointZero(long offset) { | ||
207 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
208 | double xs = 1.0; | ||
209 | if (strxs != null && strxs.length() > 0) { | ||
210 | try { | ||
211 | xs = Double.valueOf(strxs); | ||
212 | } catch (Exception e) { | ||
213 | e.printStackTrace(); | ||
214 | } | ||
215 | } | ||
216 | return (long) ((double)fivePointZero*xs) + offset; | ||
217 | } | ||
218 | |||
219 | public void setFivePointZero(long fivePointZero) { | ||
220 | this.fivePointZero = fivePointZero; | ||
221 | } | ||
222 | |||
223 | public long getTenPointZero() { | ||
224 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
225 | double xs = 1.0; | ||
226 | if (strxs != null && strxs.length() > 0) { | ||
227 | try { | ||
228 | xs = Double.valueOf(strxs); | ||
229 | } catch (Exception e) { | ||
230 | e.printStackTrace(); | ||
231 | } | ||
232 | } | ||
233 | return (long) ((double)tenPointZero*xs); | ||
234 | } | ||
235 | |||
236 | public long getTenPointZero(long offset) { | ||
237 | String strxs= (String) SharedPreferencesUtil.getData("cjcjxs","1.0"); | ||
238 | double xs = 1.0; | ||
239 | if (strxs != null && strxs.length() > 0) { | ||
240 | try { | ||
241 | xs = Double.valueOf(strxs); | ||
242 | } catch (Exception e) { | ||
243 | e.printStackTrace(); | ||
244 | } | ||
245 | } | ||
246 | return (long) ((double)tenPointZero*xs) + offset; | ||
247 | } | ||
248 | |||
249 | public void setTenPointZero(long tenPointZero) { | ||
250 | this.tenPointZero = tenPointZero; | ||
251 | } | ||
252 | |||
253 | @Override | ||
254 | public String toString() { | ||
255 | return "PmNumericalReading{" + | ||
256 | "zeroPointThree=" + zeroPointThree + | ||
257 | ", zeroPointFive=" + zeroPointFive + | ||
258 | ", onePointZero=" + onePointZero + | ||
259 | ", twoPointFive=" + twoPointFive + | ||
260 | ", fivePointZero=" + fivePointZero + | ||
261 | ", tenPointZero=" + tenPointZero + | ||
262 | '}'; | ||
263 | } | ||
264 | |||
265 | public boolean isAllDataZero(){ | ||
266 | return zeroPointThree==0&&zeroPointFive==0&&onePointZero==0&&twoPointFive==0&&fivePointZero==0&&tenPointZero==0; | ||
267 | } | ||
268 | } | ||
269 |
libs/common/src/main/java/com/prws/common/opc/PmReadingRecord.java
File was created | 1 | package com.prws.common.opc; | |
2 | |||
3 | import java.sql.Date; | ||
4 | import java.text.SimpleDateFormat; | ||
5 | import java.util.Locale; | ||
6 | |||
7 | public class PmReadingRecord { | ||
8 | |||
9 | private PmNumericalReading reading; | ||
10 | private String recordTime; | ||
11 | |||
12 | |||
13 | public PmReadingRecord() { | ||
14 | |||
15 | } | ||
16 | |||
17 | public PmReadingRecord(PmNumericalReading reading) { | ||
18 | this.reading = reading; | ||
19 | this.recordTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date(System.currentTimeMillis())); | ||
20 | } | ||
21 | |||
22 | public PmNumericalReading getReading() { | ||
23 | return reading; | ||
24 | } | ||
25 | |||
26 | |||
27 | public void setReading(PmNumericalReading reading) { | ||
28 | this.reading = reading; | ||
29 | this.recordTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date(System.currentTimeMillis())); | ||
30 | } | ||
31 | |||
32 | public String getRecordTime() { | ||
33 | return recordTime; | ||
34 | } | ||
35 | |||
36 | public void setRecordTime(String recordTime) { | ||
37 | this.recordTime = recordTime; | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public String toString() { | ||
42 | return "PmReadingRecord{" + | ||
43 | "reading=" + reading + | ||
44 | ", recordTime='" + recordTime + '\'' + | ||
45 | '}'; | ||
46 | } | ||
47 | } | ||
48 |
libs/common/src/main/java/com/prws/common/router/RouterConfig.java
File was created | 1 | package com.prws.common.router; | |
2 | |||
3 | public interface RouterConfig { | ||
4 | |||
5 | String MAP = "/app/map"; | ||
6 | String MENU = "/paimo/menu"; | ||
7 | String TASK = "/app/task"; | ||
8 | String SETTING = "/setting/setting"; | ||
9 | |||
10 | |||
11 | String REMOTE = "/remote/remote"; | ||
12 | |||
13 | String PAIWEE_SETTING = "/paiwee/setting2"; | ||
14 | String PAIWEE_REMOTE = "/paiwee/remote"; | ||
15 | |||
16 | |||
17 | |||
18 | |||
19 | String PAIMO_MAIN = "/paimo/main"; | ||
20 | String PAIMO_MENU = "/paimo/menu"; | ||
21 | String PAIWEE_MENU = "/paiwee/menu"; | ||
22 | String PAIPO_MENU = "/paipo/menu"; | ||
23 | |||
24 | |||
25 | String PAIPO_MAIN = "/paipo/main"; | ||
26 | String PAIPO_MAP = "/paipo/map"; | ||
27 | |||
28 | String PAISAM_MAIN = "/paisam/main"; | ||
29 | String PAISAM_MAP = "/paisam/map"; | ||
30 | |||
31 | |||
32 | String TEST = "/template/test"; | ||
33 | |||
34 | String PAIMO_TEST = "/paimo/test"; | ||
35 | |||
36 | String PAIPO_TEST = "/paimo/test"; | ||
37 | |||
38 | |||
39 | /******************************fragment***********************************/ | ||
40 | /**************** settingActivity ***********/ | ||
41 | String FRAGMENT_SPEEK = "/setting/speekFragment"; | ||
42 | String FRAGMENT_WORK = "/setting/workFragment"; | ||
43 | String FRAGMENT_WIFI = "/setting/wifiFragment"; | ||
44 | String FRAGMENT_ACCOUNT = "/setting/accountFragment"; | ||
45 | String FRAGMENT_ALARM = "/setting/alarmFragment"; | ||
46 | String FRAGMENT_VOICE = "/setting/voiceFragment"; | ||
47 | String FRAGMENT_PWD = "/setting/pwdFragment"; | ||
48 | String FRAGMENT_RUN = "/setting/runFragment"; | ||
49 | String FRAGMENT_LANGUAGE = "/setting/languageFragment"; | ||
50 | String FRAGMENT_MACHINE = "/setting/MachineFragment"; | ||
51 | String FRAGMENT_WASH_SWEEP_SETTING = "/setting/washSweepSettingFragment"; | ||
52 | String FRAGMENT_TASK = "/setting/taskFragment"; | ||
53 | String FRAGMENT_CAI = "/setting/caiFragment"; | ||
54 | String FRAGMENT_SHUI = "/setting/shuiFragment"; | ||
55 | String FRAGMENT_XDS = "/setting/xdFragment"; | ||
56 | String FRAGMENT_XDSA = "/setting/xdaFragment"; | ||
57 | |||
58 | |||
59 | /***************** remoteActivity*****************/ | ||
60 | String FRAGMENT_DUST = "/remote/dustFragment"; | ||
61 | String FRAGMENT_DISINFECT = "/remote/disinfectFragment"; | ||
62 | String FRAGMENT_SIDE_PUSH = "/remote/sidePushFragment"; | ||
63 | String FRAGMENT_WASH_SWEEP = "/remote/washSweepFragment"; | ||
64 | String FRAGMENT_CHARGE = "/app/chargeFragment"; | ||
65 | String FRAGMENT_PENLIN = "/remote/penlinFragment"; | ||
66 | String FRAGMENT_GS = "/remote/gsFragment"; | ||
67 | String FRAGMENT_XC = "/remote/xcFragment"; | ||
68 | String FRAGMENT_CJ = "/remote/cjFragment"; | ||
69 | String FRAGMENT_JH = "/remote/jhFragment"; | ||
70 | String FRAGMENT_WSJ = "/remote/wsjFragment"; | ||
71 | String FRAGMENT_XDAB = "/remote/xdFragment"; | ||
72 | String FRAGMENT_PD = "/remote/pdFragment"; | ||
73 | String MAP_ACTY_TEST = "/map/mapTestActivity"; | ||
74 | String MAP_LIST = "/map/mapListActivity"; | ||
75 | String MAP_EDIT = "/app/editMapActivity"; | ||
76 | String MAP_CREATE = "/map/createMapActivity"; | ||
77 | |||
78 | |||
79 | |||
80 | |||
81 | } | ||
82 |
libs/common/src/main/java/com/prws/common/router/RouterFragmentUtils.java
File was created | 1 | package com.prws.common.router; | |
2 | |||
3 | import androidx.fragment.app.Fragment; | ||
4 | |||
5 | import com.alibaba.android.arouter.launcher.ARouter; | ||
6 | |||
7 | public class RouterFragmentUtils { | ||
8 | /****************************** SettingActivity *********************/ | ||
9 | public static Fragment getSpeekFragment() { | ||
10 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SPEEK).navigation(); | ||
11 | } | ||
12 | |||
13 | public static Fragment getWorkFragment() { | ||
14 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WORK).navigation(); | ||
15 | } | ||
16 | |||
17 | public static Fragment getWifiFragment() { | ||
18 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WIFI).navigation(); | ||
19 | } | ||
20 | |||
21 | public static Fragment getAccountFragment() { | ||
22 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_ACCOUNT).navigation(); | ||
23 | } | ||
24 | |||
25 | public static Fragment getAlarmFragment() { | ||
26 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_ALARM).navigation(); | ||
27 | } | ||
28 | |||
29 | public static Fragment getVoiceFragment() { | ||
30 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_VOICE).navigation(); | ||
31 | } | ||
32 | |||
33 | public static Fragment getPwdFragment() { | ||
34 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PWD).navigation(); | ||
35 | } | ||
36 | |||
37 | public static Fragment getRunFragment() { | ||
38 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_RUN).navigation(); | ||
39 | } | ||
40 | |||
41 | public static Fragment getLanguageFragment() { | ||
42 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_LANGUAGE).navigation(); | ||
43 | } | ||
44 | public static Fragment getWashSweepSettingFragment(){ | ||
45 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WASH_SWEEP_SETTING).navigation(); | ||
46 | } | ||
47 | |||
48 | public static Fragment getMachineFragment() { | ||
49 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_MACHINE).navigation(); | ||
50 | } | ||
51 | |||
52 | public static Fragment getTaskFragment() { | ||
53 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_TASK).navigation(); | ||
54 | } | ||
55 | public static Fragment getCaiFragment() { | ||
56 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CAI).navigation(); | ||
57 | } | ||
58 | public static Fragment getShuiFragment() { | ||
59 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SHUI).navigation(); | ||
60 | } | ||
61 | public static Fragment getxdFragment() { | ||
62 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDS).navigation(); | ||
63 | } | ||
64 | public static Fragment getxdaFragment() { | ||
65 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDSA).navigation(); | ||
66 | } | ||
67 | |||
68 | |||
69 | /******************************** RemoteActivity *************************/ | ||
70 | public static Fragment getWashSweepFragment(){ | ||
71 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WASH_SWEEP).navigation(); | ||
72 | } | ||
73 | public static Fragment getDustFragment() { | ||
74 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_DUST).navigation(); | ||
75 | } | ||
76 | |||
77 | public static Fragment getDisinfectFragment() { | ||
78 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_DISINFECT).navigation(); | ||
79 | } | ||
80 | |||
81 | public static Fragment getSidePushFragment() { | ||
82 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_SIDE_PUSH).navigation(); | ||
83 | } | ||
84 | |||
85 | public static Fragment getChargeFragment() { | ||
86 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CHARGE).navigation(); | ||
87 | } | ||
88 | |||
89 | public static Fragment getPenLinFragment() { | ||
90 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PENLIN).navigation(); | ||
91 | } | ||
92 | public static Fragment getGSFragment() { | ||
93 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_GS).navigation(); | ||
94 | } | ||
95 | public static Fragment getXCFragment() { | ||
96 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XC).navigation(); | ||
97 | } | ||
98 | public static Fragment getCJFragment() { | ||
99 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_CJ).navigation(); | ||
100 | } | ||
101 | public static Fragment getJHFragment() { | ||
102 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_JH).navigation(); | ||
103 | } | ||
104 | public static Fragment getWSJFragment() { | ||
105 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_WSJ).navigation(); | ||
106 | } | ||
107 | public static Fragment getPDFragment() { | ||
108 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_PD).navigation(); | ||
109 | } | ||
110 | public static Fragment getXDABFragment() { | ||
111 | return (Fragment) ARouter.getInstance().build(RouterConfig.FRAGMENT_XDAB).navigation(); | ||
112 | } | ||
113 | |||
114 | } | ||
115 |
libs/common/src/main/java/com/prws/common/router/RouterUtils.java
File was created | 1 | package com.prws.common.router; | |
2 | |||
3 | import android.content.pm.ApplicationInfo; | ||
4 | import android.content.pm.PackageManager; | ||
5 | import com.prws.common.CommonApplication; | ||
6 | |||
7 | import com.alibaba.android.arouter.launcher.ARouter; | ||
8 | |||
9 | import java.util.ArrayList; | ||
10 | |||
11 | |||
12 | public class RouterUtils { | ||
13 | |||
14 | public static void goTestActivity(){ | ||
15 | if (isPaimo()) | ||
16 | ARouter.getInstance().build(RouterConfig.PAIMO_TEST).navigation(); | ||
17 | else | ||
18 | ARouter.getInstance().build(RouterConfig.TEST).navigation(); | ||
19 | } | ||
20 | |||
21 | public static void getMapTestActivity(){ | ||
22 | ARouter.getInstance().build(RouterConfig.MAP_ACTY_TEST).navigation(); | ||
23 | } | ||
24 | |||
25 | public static void goMapListActivity(){ | ||
26 | ARouter.getInstance().build(RouterConfig.MAP_LIST).navigation(); | ||
27 | } | ||
28 | public static void goMapCreateActivity(ArrayList<String> mapNameList){ | ||
29 | ARouter.getInstance().build(RouterConfig.MAP_CREATE) | ||
30 | .withStringArrayList("mapNameList",mapNameList) | ||
31 | .navigation(); | ||
32 | } | ||
33 | |||
34 | public static void goEditMapActivity(String projectId,String mapMd5){ | ||
35 | ARouter.getInstance().build(RouterConfig.MAP_EDIT) | ||
36 | .withString("projectId",projectId) | ||
37 | .withString("mapMd5",mapMd5) | ||
38 | .navigation(); | ||
39 | } | ||
40 | |||
41 | public static void goMenuActivity(){ | ||
42 | |||
43 | if (isPaiwee()) | ||
44 | ARouter.getInstance().build(RouterConfig.PAIWEE_MENU).navigation(); | ||
45 | else if (isPaipo()) | ||
46 | ARouter.getInstance().build(RouterConfig.PAIPO_MENU).navigation(); | ||
47 | else | ||
48 | ARouter.getInstance().build(RouterConfig.PAIMO_MENU).navigation(); | ||
49 | |||
50 | } | ||
51 | public static void goTaskActivity(){ | ||
52 | ARouter.getInstance().build(RouterConfig.TASK).navigation(); | ||
53 | } | ||
54 | public static void goRemoteActivity(){ | ||
55 | if (isPaiwee()) | ||
56 | ARouter.getInstance().build(RouterConfig.PAIWEE_REMOTE).navigation(); | ||
57 | else | ||
58 | ARouter.getInstance().build(RouterConfig.REMOTE).navigation(); | ||
59 | } | ||
60 | |||
61 | public static void goSettingActivity(){ | ||
62 | |||
63 | if (isPaiwee()) | ||
64 | ARouter.getInstance().build(RouterConfig.PAIWEE_SETTING).navigation(); | ||
65 | else | ||
66 | ARouter.getInstance().build(RouterConfig.SETTING).navigation(); | ||
67 | |||
68 | } | ||
69 | |||
70 | public static void goMainActivity(){ | ||
71 | if (isPaimo()){ | ||
72 | |||
73 | }else if (isPaipo()){ | ||
74 | |||
75 | }else if (isPaisam()){ | ||
76 | |||
77 | } | ||
78 | |||
79 | // if (BuildConfig.PROJECT_NAME.equals("paimo")) | ||
80 | // ARouter.getInstance().build(RouterConfig.PAIMO_MAIN).navigation(); | ||
81 | // else if (BuildConfig.PROJECT_NAME.equals("paipo")) | ||
82 | // ARouter.getInstance().build(RouterConfig.PAIPO_MAIN).navigation(); | ||
83 | // else if (BuildConfig.PROJECT_NAME.equals("paisam")) | ||
84 | // ARouter.getInstance().build(RouterConfig.PAISAM_MAIN).navigation(); | ||
85 | } | ||
86 | |||
87 | |||
88 | |||
89 | /************************* 判断项目类型 **********************************/ | ||
90 | |||
91 | public static boolean isPaimo(){ return getProjectName().equals("paimo"); } | ||
92 | private static boolean isPaipo(){ | ||
93 | return getProjectName().equals("paipo"); | ||
94 | } | ||
95 | private static boolean isPaisam(){ | ||
96 | return getProjectName().equals("paisam"); | ||
97 | } | ||
98 | public static boolean isPaiwee(){ | ||
99 | return getProjectName().equals("paiwee"); | ||
100 | } | ||
101 | |||
102 | |||
103 | public static String getProjectName(){ | ||
104 | // ApplicationInfo applicationInfo = null; | ||
105 | // try { | ||
106 | // applicationInfo = CommonApplication.getAppContext().getPackageManager().getApplicationInfo(CommonApplication.getAppContext().getPackageName(), PackageManager.GET_META_DATA); | ||
107 | // } catch (PackageManager.NameNotFoundException e) { | ||
108 | // e.printStackTrace(); | ||
109 | // } | ||
110 | // if (applicationInfo == null)return ""; | ||
111 | // return applicationInfo.metaData.getString("PROJECT_NAME"); | ||
112 | return "paicu"; | ||
113 | } | ||
114 | |||
115 | |||
116 | } | ||
117 |
libs/common/src/main/java/com/prws/common/utils/Base64E.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | //import com.aisimba.clearcar.util.aess.AESUtil; | ||
4 | //import com.aisimba.clearcar.util.sdk.utils.encoder.BASE64Encoder; | ||
5 | //import com.alibaba.fastjson.JSONObject; | ||
6 | |||
7 | import java.io.*; | ||
8 | import java.util.ArrayList; | ||
9 | import java.util.Base64; | ||
10 | import java.util.List; | ||
11 | |||
12 | public class Base64E { | ||
13 | private static char[] SIXTY_FOUR_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray(); | ||
14 | private static final int[] REVERSE_MAPPING = new int[123]; | ||
15 | |||
16 | public Base64E() { | ||
17 | } | ||
18 | |||
19 | public void str(String str){ | ||
20 | SIXTY_FOUR_CHARS=str.toCharArray(); | ||
21 | } | ||
22 | |||
23 | public String encode(byte[] input) { | ||
24 | List<StringBuffer> buffers = new ArrayList<>(); | ||
25 | |||
26 | StringBuffer result = new StringBuffer(); | ||
27 | int outputCharCount = 0; | ||
28 | |||
29 | for (int i = 0; i < input.length; i += 3) { | ||
30 | int remaining = Math.min(3, input.length - i); | ||
31 | int oneBigNumber = (input[i] & 255) << 16 | (remaining <= 1 ? 0 : input[i + 1] & 255) << 8 | (remaining <= 2 ? 0 : input[i + 2] & 255); | ||
32 | |||
33 | for (int j = 0; j < 4; ++j) { | ||
34 | result.append(remaining + 1 > j ? SIXTY_FOUR_CHARS[63 & oneBigNumber >> 6 * (3 - j)] : '='); | ||
35 | } | ||
36 | |||
37 | outputCharCount += 4; | ||
38 | if (outputCharCount % 76 == 0) { | ||
39 | result.append('\n'); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | return result.toString(); | ||
44 | } | ||
45 | |||
46 | public byte[] decode(String input) { | ||
47 | try { | ||
48 | ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
49 | StringReader in = new StringReader(input); | ||
50 | |||
51 | for (int i = 0; i < input.length(); i += 4) { | ||
52 | int[] a = new int[]{this.mapCharToInt(in), this.mapCharToInt(in), this.mapCharToInt(in), this.mapCharToInt(in)}; | ||
53 | int oneBigNumber = (a[0] & 63) << 18 | (a[1] & 63) << 12 | (a[2] & 63) << 6 | a[3] & 63; | ||
54 | |||
55 | for (int j = 0; j < 3; ++j) { | ||
56 | if (a[j + 1] >= 0) { | ||
57 | out.write(255 & oneBigNumber >> 8 * (2 - j)); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | return out.toByteArray(); | ||
63 | } catch (IOException var8) { | ||
64 | throw new Error(var8 + ": " + var8.getMessage()); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | private int mapCharToInt(Reader input) throws IOException { | ||
69 | while (true) { | ||
70 | int c; | ||
71 | if ((c = input.read()) != -1) { | ||
72 | int result = REVERSE_MAPPING[c]; | ||
73 | if (result != 0) { | ||
74 | return result - 1; | ||
75 | } | ||
76 | |||
77 | if (c != 61) { | ||
78 | continue; | ||
79 | } | ||
80 | |||
81 | return -1; | ||
82 | } | ||
83 | |||
84 | return -1; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | static { | ||
89 | for (int i = 0; i < SIXTY_FOUR_CHARS.length; ++i) { | ||
90 | REVERSE_MAPPING[SIXTY_FOUR_CHARS[i]] = i + 1; | ||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | } | ||
96 |
libs/common/src/main/java/com/prws/common/utils/BeanPropertiesUtil.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import java.io.ByteArrayInputStream; | ||
4 | import java.io.ByteArrayOutputStream; | ||
5 | import java.io.IOException; | ||
6 | import java.io.ObjectInputStream; | ||
7 | import java.io.ObjectOutputStream; | ||
8 | import java.lang.reflect.Method; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.List; | ||
12 | |||
13 | /** | ||
14 | * FileName: CloneObjectUtils | ||
15 | * Author: zhikai.jin | ||
16 | * Date: 2021/6/4 9:48 | ||
17 | * Description: 克隆属性值到另一类 | ||
18 | */ | ||
19 | public class BeanPropertiesUtil { | ||
20 | /** | ||
21 | * 利用反射实现对象之间属性复制 | ||
22 | * | ||
23 | * @param from | ||
24 | * @param to | ||
25 | */ | ||
26 | public static void copyProperties(Object from, Object to) throws Exception { | ||
27 | copyPropertiesExclude(from, to, null, false); | ||
28 | } | ||
29 | |||
30 | public static void copyProperties(Object from, Object to, Boolean ignoreErr) throws Exception { | ||
31 | copyPropertiesExclude(from, to, null, ignoreErr); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * 复制对象属性 | ||
36 | * | ||
37 | * @param from | ||
38 | * @param to | ||
39 | * @param excludsArray 排除属性列表 | ||
40 | * @throws Exception | ||
41 | */ | ||
42 | @SuppressWarnings("unchecked") | ||
43 | public static void copyPropertiesExclude(Object from, Object to, String[] excludsArray, Boolean ignoreErr) throws Exception { | ||
44 | List<String> excludesList = null; | ||
45 | if (excludsArray != null && excludsArray.length > 0) { | ||
46 | excludesList = Arrays.asList(excludsArray); //构造列表对象 | ||
47 | } | ||
48 | Method[] fromMethods = from.getClass().getDeclaredMethods(); | ||
49 | Method[] toMethods = to.getClass().getDeclaredMethods(); | ||
50 | Method fromMethod = null, toMethod = null; | ||
51 | String fromMethodName = null, toMethodName = null; | ||
52 | for (int i = 0; i < fromMethods.length; i++) { | ||
53 | fromMethod = fromMethods[i]; | ||
54 | fromMethodName = fromMethod.getName(); | ||
55 | if (!fromMethodName.contains("get") || fromMethodName.contains("getId")) | ||
56 | continue; | ||
57 | //排除列表检测 | ||
58 | if (excludesList != null && excludesList.contains(fromMethodName.substring(3).toLowerCase())) { | ||
59 | continue; | ||
60 | } | ||
61 | toMethodName = "set" + fromMethodName.substring(3); | ||
62 | toMethod = findMethodByName(toMethods, toMethodName); | ||
63 | if (toMethod == null) | ||
64 | continue; | ||
65 | Object value = fromMethod.invoke(from, new Object[0]); | ||
66 | if (value == null) | ||
67 | continue; | ||
68 | //集合类判空处理 | ||
69 | if (value instanceof Collection) { | ||
70 | Collection newValue = (Collection) value; | ||
71 | if (newValue.size() <= 0) | ||
72 | continue; | ||
73 | } | ||
74 | try { | ||
75 | toMethod.invoke(to, new Object[]{value}); | ||
76 | } catch (Exception e) { | ||
77 | if (!ignoreErr) { | ||
78 | throw e; | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * 对象属性值复制,仅复制指定名称的属性值 | ||
86 | * | ||
87 | * @param from | ||
88 | * @param to | ||
89 | * @param includsArray | ||
90 | * @throws Exception | ||
91 | */ | ||
92 | @SuppressWarnings("unchecked") | ||
93 | public static void copyPropertiesInclude(Object from, Object to, String[] includsArray) throws Exception { | ||
94 | List<String> includesList = null; | ||
95 | if (includsArray != null && includsArray.length > 0) { | ||
96 | includesList = Arrays.asList(includsArray); //构造列表对象 | ||
97 | } else { | ||
98 | return; | ||
99 | } | ||
100 | Method[] fromMethods = from.getClass().getDeclaredMethods(); | ||
101 | Method[] toMethods = to.getClass().getDeclaredMethods(); | ||
102 | Method fromMethod = null, toMethod = null; | ||
103 | String fromMethodName = null, toMethodName = null; | ||
104 | for (int i = 0; i < fromMethods.length; i++) { | ||
105 | fromMethod = fromMethods[i]; | ||
106 | fromMethodName = fromMethod.getName(); | ||
107 | if (!fromMethodName.contains("get")) | ||
108 | continue; | ||
109 | //排除列表检测 | ||
110 | String str = fromMethodName.substring(3); | ||
111 | if (!includesList.contains(str.substring(0, 1).toLowerCase() + str.substring(1))) { | ||
112 | continue; | ||
113 | } | ||
114 | toMethodName = "set" + fromMethodName.substring(3); | ||
115 | toMethod = findMethodByName(toMethods, toMethodName); | ||
116 | if (toMethod == null) | ||
117 | continue; | ||
118 | Object value = fromMethod.invoke(from, new Object[0]); | ||
119 | if (value == null) | ||
120 | continue; | ||
121 | //集合类判空处理 | ||
122 | if (value instanceof Collection) { | ||
123 | Collection newValue = (Collection) value; | ||
124 | if (newValue.size() <= 0) | ||
125 | continue; | ||
126 | } | ||
127 | toMethod.invoke(to, new Object[]{value}); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | |||
132 | /** | ||
133 | * 从方法数组中获取指定名称的方法 | ||
134 | * | ||
135 | * @param methods | ||
136 | * @param name | ||
137 | * @return | ||
138 | */ | ||
139 | public static Method findMethodByName(Method[] methods, String name) { | ||
140 | for (int j = 0; j < methods.length; j++) { | ||
141 | if (methods[j].getName().equals(name)) | ||
142 | return methods[j]; | ||
143 | } | ||
144 | return null; | ||
145 | } | ||
146 | |||
147 | } | ||
148 | |||
149 |
libs/common/src/main/java/com/prws/common/utils/Common.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.Dialog; | ||
5 | import android.content.Context; | ||
6 | import android.net.ConnectivityManager; | ||
7 | import android.net.NetworkInfo; | ||
8 | import android.os.Handler; | ||
9 | import android.os.Looper; | ||
10 | import android.view.View; | ||
11 | import android.view.inputmethod.InputMethodManager; | ||
12 | |||
13 | import androidx.annotation.StringRes; | ||
14 | import androidx.fragment.app.FragmentManager; | ||
15 | |||
16 | import com.prws.common.CommonApplication; | ||
17 | import com.prws.common.utils.acmanager.ActivityManager; | ||
18 | |||
19 | |||
20 | import java.io.BufferedReader; | ||
21 | import java.io.InputStreamReader; | ||
22 | import java.lang.reflect.Field; | ||
23 | import java.lang.reflect.InvocationTargetException; | ||
24 | import java.text.DateFormat; | ||
25 | import java.text.SimpleDateFormat; | ||
26 | import java.util.Calendar; | ||
27 | import java.util.Date; | ||
28 | import java.util.Map; | ||
29 | import java.util.TimeZone; | ||
30 | import java.util.Timer; | ||
31 | import java.util.TimerTask; | ||
32 | import java.util.regex.Matcher; | ||
33 | import java.util.regex.Pattern; | ||
34 | |||
35 | public class Common { | ||
36 | |||
37 | // static AdvertisementDialog dialog; | ||
38 | // public static void showAdvertisement(FragmentManager manager){ | ||
39 | // try { | ||
40 | // if (dialog!=null){ | ||
41 | //// dialog.dismiss(); | ||
42 | //// dialog = null; | ||
43 | // dialog.show(manager,"tag"); | ||
44 | // return; | ||
45 | // } | ||
46 | // dialog = new AdvertisementDialog(); | ||
47 | // dialog.show(manager,"tag"); | ||
48 | // | ||
49 | // ScreenUtils.hideDialogBottomUIMenu(dialog); | ||
50 | //// ScreenUtils.hideBottomUIMenu(Common.getGlobleActivity()); | ||
51 | // } catch (Exception e) { | ||
52 | // e.printStackTrace(); | ||
53 | // } | ||
54 | // | ||
55 | // | ||
56 | // } | ||
57 | |||
58 | public static byte[] hexStrToBinaryStr(String hexString) { | ||
59 | if (hexString == null) { | ||
60 | return null; | ||
61 | } | ||
62 | hexString = hexString.replaceAll(" ", ""); | ||
63 | |||
64 | int len = hexString.length(); | ||
65 | int index = 0; | ||
66 | |||
67 | byte[] bytes = new byte[len / 2]; | ||
68 | |||
69 | while (index < len) { | ||
70 | String sub = hexString.substring(index, index + 2); | ||
71 | bytes[index / 2] = (byte) Integer.parseInt(sub, 16); | ||
72 | index += 2; | ||
73 | } | ||
74 | return bytes; | ||
75 | } | ||
76 | |||
77 | public static String doubleArrToString(Double[] arr) { | ||
78 | String str = ""; | ||
79 | if (arr != null && arr.length > 0) { | ||
80 | for (Double d : arr) { | ||
81 | if (str.length() > 0) | ||
82 | str += ","; | ||
83 | str += String.format("%.2f", d); | ||
84 | } | ||
85 | } | ||
86 | return str; | ||
87 | } | ||
88 | |||
89 | public static byte[] byteMerger(byte[] bt1, byte[] bt2) { | ||
90 | byte[] bt3 = new byte[bt1.length + bt2.length]; | ||
91 | System.arraycopy(bt1, 0, bt3, 0, bt1.length); | ||
92 | System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length); | ||
93 | return bt3; | ||
94 | } | ||
95 | |||
96 | |||
97 | /** | ||
98 | * 传入Data类型日期,返回字符串类型时间(ISO8601标准时间) | ||
99 | * | ||
100 | * @param date | ||
101 | * @return | ||
102 | */ | ||
103 | public static String getISO8601Timestamp(Date date) { | ||
104 | TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); | ||
105 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); | ||
106 | df.setTimeZone(tz); | ||
107 | String nowAsISO = df.format(date); | ||
108 | return nowAsISO; | ||
109 | } | ||
110 | |||
111 | |||
112 | |||
113 | |||
114 | |||
115 | |||
116 | /** | ||
117 | * 判断是否包含中文 | ||
118 | * | ||
119 | * @param ssid | ||
120 | * @return | ||
121 | */ | ||
122 | public static boolean isContainChinese(String ssid) { | ||
123 | String regEx = "[\u4e00-\u9fa5]"; | ||
124 | Pattern pattern = Pattern.compile(regEx); | ||
125 | Matcher m = pattern.matcher(ssid); | ||
126 | if (m.find()) { | ||
127 | return true; | ||
128 | } | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | public static boolean isNumber(String str) { | ||
133 | String reg = "^[0-9]+(.[0-9]+)?$"; | ||
134 | return str.matches(reg); | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * 日期转中文字符串 | ||
139 | * 月和日 不包含年 | ||
140 | */ | ||
141 | private static final String[] CN_NUMBER_NAME = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"}; | ||
142 | |||
143 | public static String getCNDateStr(Date date) { | ||
144 | if (date == null) | ||
145 | date = new Date(); | ||
146 | |||
147 | Calendar cal = Calendar.getInstance(); // 使用日历类 | ||
148 | cal.setTime(date); | ||
149 | String year = String.valueOf(cal.get(Calendar.YEAR)); // 得到年 | ||
150 | String month = String.valueOf(cal.get(Calendar.MONTH) + 1); // 得到月,因为从0开始的,所以要加1 | ||
151 | String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); // 得到天 | ||
152 | |||
153 | StringBuilder cnDate = new StringBuilder(); | ||
154 | // for (int i = 0; i < year.length(); i++) { | ||
155 | // cnDate.append(CN_NUMBER_NAME[Integer.valueOf(String.valueOf(year.charAt(i)))]); | ||
156 | // } | ||
157 | // | ||
158 | // cnDate.append("年"); | ||
159 | |||
160 | for (int i = 0; i < month.length(); i++) { | ||
161 | cnDate.append(CN_NUMBER_NAME[Integer.valueOf(String.valueOf(month.charAt(i)))]); | ||
162 | } | ||
163 | |||
164 | cnDate.append("月"); | ||
165 | |||
166 | if (day.length() == 2) { | ||
167 | Integer value = Integer.valueOf(String.valueOf(day.charAt(0))); | ||
168 | if (!value.equals(1)) { | ||
169 | cnDate.append(CN_NUMBER_NAME[value]); | ||
170 | } | ||
171 | cnDate.append("十"); | ||
172 | if (!String.valueOf(day.charAt(1)).equals("0")) { | ||
173 | cnDate.append(CN_NUMBER_NAME[Integer.valueOf(String.valueOf(day.charAt(1)))]); | ||
174 | } | ||
175 | } else { | ||
176 | cnDate.append(CN_NUMBER_NAME[Integer.valueOf(String.valueOf(day.charAt(0)))]); | ||
177 | } | ||
178 | |||
179 | cnDate.append("日"); | ||
180 | return cnDate.toString(); | ||
181 | } | ||
182 | |||
183 | public static Activity getGlobleActivity() throws ClassNotFoundException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchFieldException { | ||
184 | Class activityThreadClass = Class.forName("android.app.ActivityThread"); | ||
185 | Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); | ||
186 | Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); | ||
187 | activitiesField.setAccessible(true); | ||
188 | Map activities = (Map) activitiesField.get(activityThread); | ||
189 | for (Object activityRecord : activities.values()) { | ||
190 | Class activityRecordClass = activityRecord.getClass(); | ||
191 | Field pausedField = activityRecordClass.getDeclaredField("paused"); | ||
192 | pausedField.setAccessible(true); | ||
193 | if (!pausedField.getBoolean(activityRecord)) { | ||
194 | Field activityField = activityRecordClass.getDeclaredField("activity"); | ||
195 | activityField.setAccessible(true); | ||
196 | Activity activity = (Activity) activityField.get(activityRecord); | ||
197 | return activity; | ||
198 | } | ||
199 | } | ||
200 | return null; | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * 判断当前显示的activity是否为哪个 | ||
205 | * 可用于测温 | ||
206 | * @param clazz 例如:Common.class | ||
207 | * @return | ||
208 | */ | ||
209 | public static boolean isTopActivity(Class clazz){ | ||
210 | if (ActivityManager.getInstance().getCurrentActivity() == null)return false; | ||
211 | return ActivityManager.getInstance().getCurrentActivity().getClass().getSimpleName().equals(clazz.getSimpleName()); | ||
212 | } | ||
213 | |||
214 | |||
215 | public static String getString(@StringRes int strId){ | ||
216 | if (ActivityManager.getInstance().getCurrentActivity() == null) return ""; | ||
217 | return ActivityManager.getInstance().getCurrentActivity().getString(strId); | ||
218 | } | ||
219 | |||
220 | |||
221 | |||
222 | |||
223 | public static String getFromAssets(String fileName) { | ||
224 | try { | ||
225 | InputStreamReader inputReader = new InputStreamReader(CommonApplication.getAppContext().getAssets().open(fileName)); | ||
226 | BufferedReader bufReader = new BufferedReader(inputReader); | ||
227 | String line = ""; | ||
228 | String Result = ""; | ||
229 | while ((line = bufReader.readLine()) != null) | ||
230 | Result += line; | ||
231 | return Result; | ||
232 | } catch (Exception e) { | ||
233 | e.printStackTrace(); | ||
234 | } | ||
235 | return null; | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * 此方法只是关闭软键盘 | ||
240 | */ | ||
241 | public static void hideSoftKeyboard() { | ||
242 | try { | ||
243 | Activity activity = getGlobleActivity(); | ||
244 | InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); | ||
245 | if (imm.isActive() && activity.getCurrentFocus() != null) { | ||
246 | if (activity.getCurrentFocus().getWindowToken() != null) { | ||
247 | imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), | ||
248 | InputMethodManager.HIDE_NOT_ALWAYS); | ||
249 | } | ||
250 | } | ||
251 | } catch (Exception e) { | ||
252 | |||
253 | } | ||
254 | } | ||
255 | |||
256 | /** | ||
257 | * 判断网络是否连接 | ||
258 | */ | ||
259 | public static boolean isNetworkAvailable() { | ||
260 | ConnectivityManager connectivityManager = (ConnectivityManager) CommonApplication.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE); | ||
261 | NetworkInfo info = connectivityManager.getActiveNetworkInfo(); | ||
262 | if (info != null && info.isAvailable()) { | ||
263 | return true; | ||
264 | } else { | ||
265 | return false; | ||
266 | } | ||
267 | } | ||
268 | |||
269 | public static Boolean isAppInstalled(String packageName) { | ||
270 | try { | ||
271 | CommonApplication.getAppContext().getPackageManager().getPackageInfo(packageName, 0); | ||
272 | return true; | ||
273 | } catch (Exception e) { | ||
274 | e.printStackTrace(); | ||
275 | return false; | ||
276 | } | ||
277 | } | ||
278 | |||
279 | } | ||
280 |
libs/common/src/main/java/com/prws/common/utils/FileIOUtils.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import java.io.BufferedOutputStream; | ||
4 | import java.io.BufferedReader; | ||
5 | import java.io.BufferedWriter; | ||
6 | import java.io.ByteArrayOutputStream; | ||
7 | import java.io.Closeable; | ||
8 | import java.io.File; | ||
9 | import java.io.FileInputStream; | ||
10 | import java.io.FileOutputStream; | ||
11 | import java.io.FileWriter; | ||
12 | import java.io.IOException; | ||
13 | import java.io.InputStream; | ||
14 | import java.io.InputStreamReader; | ||
15 | import java.io.OutputStream; | ||
16 | import java.io.RandomAccessFile; | ||
17 | import java.nio.ByteBuffer; | ||
18 | import java.nio.MappedByteBuffer; | ||
19 | import java.nio.channels.FileChannel; | ||
20 | import java.util.ArrayList; | ||
21 | import java.util.List; | ||
22 | |||
23 | /** | ||
24 | * Created by kermitye on 2018/3/21. | ||
25 | */ | ||
26 | |||
27 | public final class FileIOUtils { | ||
28 | |||
29 | private FileIOUtils() { | ||
30 | throw new UnsupportedOperationException("u can't instantiate me..."); | ||
31 | } | ||
32 | |||
33 | private static final String LINE_SEP = System.getProperty("line.separator"); | ||
34 | |||
35 | private static int sBufferSize = 8192; | ||
36 | |||
37 | /** | ||
38 | * Write file from input stream. | ||
39 | * | ||
40 | * @param filePath The path of file. | ||
41 | * @param is The input stream. | ||
42 | * @return {@code true}: success<br>{@code false}: fail | ||
43 | */ | ||
44 | public static boolean writeFileFromIS(final String filePath, final InputStream is) { | ||
45 | return writeFileFromIS(getFileByPath(filePath), is, false); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * Write file from input stream. | ||
50 | * | ||
51 | * @param filePath The path of file. | ||
52 | * @param is The input stream. | ||
53 | * @param append True to append, false otherwise. | ||
54 | * @return {@code true}: success<br>{@code false}: fail | ||
55 | */ | ||
56 | public static boolean writeFileFromIS(final String filePath, | ||
57 | final InputStream is, | ||
58 | final boolean append) { | ||
59 | return writeFileFromIS(getFileByPath(filePath), is, append); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Write file from input stream. | ||
64 | * | ||
65 | * @param file The file. | ||
66 | * @param is The input stream. | ||
67 | * @return {@code true}: success<br>{@code false}: fail | ||
68 | */ | ||
69 | public static boolean writeFileFromIS(final File file, final InputStream is) { | ||
70 | return writeFileFromIS(file, is, false); | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * Write file from input stream. | ||
75 | * | ||
76 | * @param file The file. | ||
77 | * @param is The input stream. | ||
78 | * @param append True to append, false otherwise. | ||
79 | * @return {@code true}: success<br>{@code false}: fail | ||
80 | */ | ||
81 | public static boolean writeFileFromIS(final File file, | ||
82 | final InputStream is, | ||
83 | final boolean append) { | ||
84 | if (!createOrExistsFile(file) || is == null) return false; | ||
85 | OutputStream os = null; | ||
86 | try { | ||
87 | os = new BufferedOutputStream(new FileOutputStream(file, append)); | ||
88 | byte data[] = new byte[sBufferSize]; | ||
89 | int len; | ||
90 | while ((len = is.read(data, 0, sBufferSize)) != -1) { | ||
91 | os.write(data, 0, len); | ||
92 | } | ||
93 | return true; | ||
94 | } catch (IOException e) { | ||
95 | e.printStackTrace(); | ||
96 | return false; | ||
97 | } finally { | ||
98 | closeIO(is, os); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * Write file from bytes by stream. | ||
104 | * | ||
105 | * @param filePath The path of file. | ||
106 | * @param bytes The bytes. | ||
107 | * @return {@code true}: success<br>{@code false}: fail | ||
108 | */ | ||
109 | public static boolean writeFileFromBytesByStream(final String filePath, final byte[] bytes) { | ||
110 | return writeFileFromBytesByStream(getFileByPath(filePath), bytes, false); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * Write file from bytes by stream. | ||
115 | * | ||
116 | * @param filePath The path of file. | ||
117 | * @param bytes The bytes. | ||
118 | * @param append True to append, false otherwise. | ||
119 | * @return {@code true}: success<br>{@code false}: fail | ||
120 | */ | ||
121 | public static boolean writeFileFromBytesByStream(final String filePath, | ||
122 | final byte[] bytes, | ||
123 | final boolean append) { | ||
124 | return writeFileFromBytesByStream(getFileByPath(filePath), bytes, append); | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * Write file from bytes by stream. | ||
129 | * | ||
130 | * @param file The file. | ||
131 | * @param bytes The bytes. | ||
132 | * @return {@code true}: success<br>{@code false}: fail | ||
133 | */ | ||
134 | public static boolean writeFileFromBytesByStream(final File file, final byte[] bytes) { | ||
135 | return writeFileFromBytesByStream(file, bytes, false); | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * Write file from bytes by stream. | ||
140 | * | ||
141 | * @param file The file. | ||
142 | * @param bytes The bytes. | ||
143 | * @param append True to append, false otherwise. | ||
144 | * @return {@code true}: success<br>{@code false}: fail | ||
145 | */ | ||
146 | public static boolean writeFileFromBytesByStream(final File file, | ||
147 | final byte[] bytes, | ||
148 | final boolean append) { | ||
149 | if (bytes == null || !createOrExistsFile(file)) return false; | ||
150 | BufferedOutputStream bos = null; | ||
151 | try { | ||
152 | bos = new BufferedOutputStream(new FileOutputStream(file, append)); | ||
153 | bos.write(bytes); | ||
154 | return true; | ||
155 | } catch (IOException e) { | ||
156 | e.printStackTrace(); | ||
157 | return false; | ||
158 | } finally { | ||
159 | closeIO(bos); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * Write file from bytes by channel. | ||
165 | * | ||
166 | * @param filePath The path of file. | ||
167 | * @param bytes The bytes. | ||
168 | * @param isForce 是否写入文件 | ||
169 | * @return {@code true}: success<br>{@code false}: fail | ||
170 | */ | ||
171 | public static boolean writeFileFromBytesByChannel(final String filePath, | ||
172 | final byte[] bytes, | ||
173 | final boolean isForce) { | ||
174 | return writeFileFromBytesByChannel(getFileByPath(filePath), bytes, false, isForce); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * Write file from bytes by channel. | ||
179 | * | ||
180 | * @param filePath The path of file. | ||
181 | * @param bytes The bytes. | ||
182 | * @param append True to append, false otherwise. | ||
183 | * @param isForce True to force write file, false otherwise. | ||
184 | * @return {@code true}: success<br>{@code false}: fail | ||
185 | */ | ||
186 | public static boolean writeFileFromBytesByChannel(final String filePath, | ||
187 | final byte[] bytes, | ||
188 | final boolean append, | ||
189 | final boolean isForce) { | ||
190 | return writeFileFromBytesByChannel(getFileByPath(filePath), bytes, append, isForce); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * Write file from bytes by channel. | ||
195 | * | ||
196 | * @param file The file. | ||
197 | * @param bytes The bytes. | ||
198 | * @param isForce True to force write file, false otherwise. | ||
199 | * @return {@code true}: success<br>{@code false}: fail | ||
200 | */ | ||
201 | public static boolean writeFileFromBytesByChannel(final File file, | ||
202 | final byte[] bytes, | ||
203 | final boolean isForce) { | ||
204 | return writeFileFromBytesByChannel(file, bytes, false, isForce); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * Write file from bytes by channel. | ||
209 | * | ||
210 | * @param file The file. | ||
211 | * @param bytes The bytes. | ||
212 | * @param append True to append, false otherwise. | ||
213 | * @param isForce True to force write file, false otherwise. | ||
214 | * @return {@code true}: success<br>{@code false}: fail | ||
215 | */ | ||
216 | public static boolean writeFileFromBytesByChannel(final File file, | ||
217 | final byte[] bytes, | ||
218 | final boolean append, | ||
219 | final boolean isForce) { | ||
220 | if (bytes == null) return false; | ||
221 | FileChannel fc = null; | ||
222 | try { | ||
223 | fc = new FileOutputStream(file, append).getChannel(); | ||
224 | fc.position(fc.size()); | ||
225 | fc.write(ByteBuffer.wrap(bytes)); | ||
226 | if (isForce) fc.force(true); | ||
227 | return true; | ||
228 | } catch (IOException e) { | ||
229 | e.printStackTrace(); | ||
230 | return false; | ||
231 | } finally { | ||
232 | closeIO(fc); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * Write file from bytes by map. | ||
238 | * | ||
239 | * @param filePath The path of file. | ||
240 | * @param bytes The bytes. | ||
241 | * @param isForce True to force write file, false otherwise. | ||
242 | * @return {@code true}: success<br>{@code false}: fail | ||
243 | */ | ||
244 | public static boolean writeFileFromBytesByMap(final String filePath, | ||
245 | final byte[] bytes, | ||
246 | final boolean isForce) { | ||
247 | return writeFileFromBytesByMap(filePath, bytes, false, isForce); | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * Write file from bytes by map. | ||
252 | * | ||
253 | * @param filePath The path of file. | ||
254 | * @param bytes The bytes. | ||
255 | * @param append True to append, false otherwise. | ||
256 | * @param isForce True to force write file, false otherwise. | ||
257 | * @return {@code true}: success<br>{@code false}: fail | ||
258 | */ | ||
259 | public static boolean writeFileFromBytesByMap(final String filePath, | ||
260 | final byte[] bytes, | ||
261 | final boolean append, | ||
262 | final boolean isForce) { | ||
263 | return writeFileFromBytesByMap(getFileByPath(filePath), bytes, append, isForce); | ||
264 | } | ||
265 | |||
266 | /** | ||
267 | * Write file from bytes by map. | ||
268 | * | ||
269 | * @param file The file. | ||
270 | * @param bytes The bytes. | ||
271 | * @param isForce True to force write file, false otherwise. | ||
272 | * @return {@code true}: success<br>{@code false}: fail | ||
273 | */ | ||
274 | public static boolean writeFileFromBytesByMap(final File file, | ||
275 | final byte[] bytes, | ||
276 | final boolean isForce) { | ||
277 | return writeFileFromBytesByMap(file, bytes, false, isForce); | ||
278 | } | ||
279 | |||
280 | /** | ||
281 | * Write file from bytes by map. | ||
282 | * | ||
283 | * @param file The file. | ||
284 | * @param bytes The bytes. | ||
285 | * @param append True to append, false otherwise. | ||
286 | * @param isForce True to force write file, false otherwise. | ||
287 | * @return {@code true}: success<br>{@code false}: fail | ||
288 | */ | ||
289 | public static boolean writeFileFromBytesByMap(final File file, | ||
290 | final byte[] bytes, | ||
291 | final boolean append, | ||
292 | final boolean isForce) { | ||
293 | if (bytes == null || !createOrExistsFile(file)) return false; | ||
294 | FileChannel fc = null; | ||
295 | try { | ||
296 | fc = new FileOutputStream(file, append).getChannel(); | ||
297 | MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_WRITE, fc.size(), bytes.length); | ||
298 | mbb.put(bytes); | ||
299 | if (isForce) mbb.force(); | ||
300 | return true; | ||
301 | } catch (IOException e) { | ||
302 | e.printStackTrace(); | ||
303 | return false; | ||
304 | } finally { | ||
305 | closeIO(fc); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * Write file from string. | ||
311 | * 将字符串写入文件 | ||
312 | * | ||
313 | * @param filePath The path of file. | ||
314 | * @param content The string of content. | ||
315 | * @return {@code true}: success<br>{@code false}: fail | ||
316 | */ | ||
317 | public static boolean writeFileFromString(final String filePath, final String content) { | ||
318 | return writeFileFromString(getFileByPath(filePath), content, false); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * Write file from string. | ||
323 | * | ||
324 | * @param filePath The path of file. | ||
325 | * @param content The string of content. | ||
326 | * @param append True to append, false otherwise. | ||
327 | * @return {@code true}: success<br>{@code false}: fail | ||
328 | */ | ||
329 | public static boolean writeFileFromString(final String filePath, | ||
330 | final String content, | ||
331 | final boolean append) { | ||
332 | return writeFileFromString(getFileByPath(filePath), content, append); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * Write file from string. | ||
337 | * | ||
338 | * @param file The file. | ||
339 | * @param content The string of content. | ||
340 | * @return {@code true}: success<br>{@code false}: fail | ||
341 | */ | ||
342 | public static boolean writeFileFromString(final File file, final String content) { | ||
343 | return writeFileFromString(file, content, false); | ||
344 | } | ||
345 | |||
346 | /** | ||
347 | * Write file from string. | ||
348 | * | ||
349 | * @param file The file. | ||
350 | * @param content The string of content. | ||
351 | * @param append True to append, false otherwise. | ||
352 | * @return {@code true}: success<br>{@code false}: fail | ||
353 | */ | ||
354 | public static boolean writeFileFromString(final File file, | ||
355 | final String content, | ||
356 | final boolean append) { | ||
357 | if (file == null || content == null) return false; | ||
358 | if (!createOrExistsFile(file)) return false; | ||
359 | BufferedWriter bw = null; | ||
360 | try { | ||
361 | bw = new BufferedWriter(new FileWriter(file, append)); | ||
362 | bw.write(content); | ||
363 | return true; | ||
364 | } catch (IOException e) { | ||
365 | e.printStackTrace(); | ||
366 | return false; | ||
367 | } finally { | ||
368 | closeIO(bw); | ||
369 | } | ||
370 | } | ||
371 | |||
372 | /////////////////////////////////////////////////////////////////////////// | ||
373 | // the divide line of write and read | ||
374 | /////////////////////////////////////////////////////////////////////////// | ||
375 | |||
376 | /** | ||
377 | * Return the lines in file. | ||
378 | * | ||
379 | * @param filePath The path of file. | ||
380 | * @return the lines in file | ||
381 | */ | ||
382 | public static List<String> readFile2List(final String filePath) { | ||
383 | return readFile2List(getFileByPath(filePath), null); | ||
384 | } | ||
385 | |||
386 | /** | ||
387 | * Return the lines in file. | ||
388 | * | ||
389 | * @param filePath The path of file. | ||
390 | * @param charsetName The name of charset. | ||
391 | * @return the lines in file | ||
392 | */ | ||
393 | public static List<String> readFile2List(final String filePath, final String charsetName) { | ||
394 | return readFile2List(getFileByPath(filePath), charsetName); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Return the lines in file. | ||
399 | * | ||
400 | * @param file The file. | ||
401 | * @return the lines in file | ||
402 | */ | ||
403 | public static List<String> readFile2List(final File file) { | ||
404 | return readFile2List(file, 0, 0x7FFFFFFF, null); | ||
405 | } | ||
406 | |||
407 | /** | ||
408 | * Return the lines in file. | ||
409 | * | ||
410 | * @param file The file. | ||
411 | * @param charsetName The name of charset. | ||
412 | * @return the lines in file | ||
413 | */ | ||
414 | public static List<String> readFile2List(final File file, final String charsetName) { | ||
415 | return readFile2List(file, 0, 0x7FFFFFFF, charsetName); | ||
416 | } | ||
417 | |||
418 | /** | ||
419 | * Return the lines in file. | ||
420 | * | ||
421 | * @param filePath The path of file. | ||
422 | * @param st The line's index of start. | ||
423 | * @param end The line's index of end. | ||
424 | * @return the lines in file | ||
425 | */ | ||
426 | public static List<String> readFile2List(final String filePath, final int st, final int end) { | ||
427 | return readFile2List(getFileByPath(filePath), st, end, null); | ||
428 | } | ||
429 | |||
430 | /** | ||
431 | * Return the lines in file. | ||
432 | * | ||
433 | * @param filePath The path of file. | ||
434 | * @param st The line's index of start. | ||
435 | * @param end The line's index of end. | ||
436 | * @param charsetName The name of charset. | ||
437 | * @return the lines in file | ||
438 | */ | ||
439 | public static List<String> readFile2List(final String filePath, | ||
440 | final int st, | ||
441 | final int end, | ||
442 | final String charsetName) { | ||
443 | return readFile2List(getFileByPath(filePath), st, end, charsetName); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * Return the lines in file. | ||
448 | * | ||
449 | * @param file The file. | ||
450 | * @param st The line's index of start. | ||
451 | * @param end The line's index of end. | ||
452 | * @return the lines in file | ||
453 | */ | ||
454 | public static List<String> readFile2List(final File file, final int st, final int end) { | ||
455 | return readFile2List(file, st, end, null); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * Return the lines in file. | ||
460 | * | ||
461 | * @param file The file. | ||
462 | * @param st The line's index of start. | ||
463 | * @param end The line's index of end. | ||
464 | * @param charsetName The name of charset. | ||
465 | * @return the lines in file | ||
466 | */ | ||
467 | public static List<String> readFile2List(final File file, | ||
468 | final int st, | ||
469 | final int end, | ||
470 | final String charsetName) { | ||
471 | if (!isFileExists(file)) return null; | ||
472 | if (st > end) return null; | ||
473 | BufferedReader reader = null; | ||
474 | try { | ||
475 | String line; | ||
476 | int curLine = 1; | ||
477 | List<String> list = new ArrayList<>(); | ||
478 | if (isSpace(charsetName)) { | ||
479 | reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); | ||
480 | } else { | ||
481 | reader = new BufferedReader( | ||
482 | new InputStreamReader(new FileInputStream(file), charsetName) | ||
483 | ); | ||
484 | } | ||
485 | while ((line = reader.readLine()) != null) { | ||
486 | if (curLine > end) break; | ||
487 | if (st <= curLine && curLine <= end) list.add(line); | ||
488 | ++curLine; | ||
489 | } | ||
490 | return list; | ||
491 | } catch (IOException e) { | ||
492 | e.printStackTrace(); | ||
493 | return null; | ||
494 | } finally { | ||
495 | closeIO(reader); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Return the string in file. | ||
501 | * 读取文件到字符串中 | ||
502 | * | ||
503 | * @param filePath The path of file. | ||
504 | * @return the string in file | ||
505 | */ | ||
506 | public static String readFile2String(final String filePath) { | ||
507 | return readFile2String(getFileByPath(filePath), null); | ||
508 | } | ||
509 | |||
510 | /** | ||
511 | * Return the string in file. | ||
512 | * | ||
513 | * @param filePath The path of file. | ||
514 | * @param charsetName The name of charset. | ||
515 | * @return the string in file | ||
516 | */ | ||
517 | public static String readFile2String(final String filePath, final String charsetName) { | ||
518 | return readFile2String(getFileByPath(filePath), charsetName); | ||
519 | } | ||
520 | |||
521 | /** | ||
522 | * Return the string in file. | ||
523 | * | ||
524 | * @param file The file. | ||
525 | * @return the string in file | ||
526 | */ | ||
527 | public static String readFile2String(final File file) { | ||
528 | return readFile2String(file, null); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Return the string in file. | ||
533 | * | ||
534 | * @param file The file. | ||
535 | * @param charsetName The name of charset. | ||
536 | * @return the string in file | ||
537 | */ | ||
538 | public static String readFile2String(final File file, final String charsetName) { | ||
539 | if (!isFileExists(file)) return null; | ||
540 | BufferedReader reader = null; | ||
541 | try { | ||
542 | StringBuilder sb = new StringBuilder(); | ||
543 | if (isSpace(charsetName)) { | ||
544 | reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); | ||
545 | } else { | ||
546 | reader = new BufferedReader( | ||
547 | new InputStreamReader(new FileInputStream(file), charsetName) | ||
548 | ); | ||
549 | } | ||
550 | String line; | ||
551 | if ((line = reader.readLine()) != null) { | ||
552 | sb.append(line); | ||
553 | while ((line = reader.readLine()) != null) { | ||
554 | sb.append(LINE_SEP).append(line); | ||
555 | } | ||
556 | } | ||
557 | return sb.toString(); | ||
558 | } catch (IOException e) { | ||
559 | e.printStackTrace(); | ||
560 | return null; | ||
561 | } finally { | ||
562 | closeIO(reader); | ||
563 | } | ||
564 | } | ||
565 | |||
566 | /** | ||
567 | * Return the bytes in file by stream. | ||
568 | * | ||
569 | * @param filePath The path of file. | ||
570 | * @return the bytes in file | ||
571 | */ | ||
572 | public static byte[] readFile2BytesByStream(final String filePath) { | ||
573 | return readFile2BytesByStream(getFileByPath(filePath)); | ||
574 | } | ||
575 | |||
576 | /** | ||
577 | * Return the bytes in file by stream. | ||
578 | * | ||
579 | * @param file The file. | ||
580 | * @return the bytes in file | ||
581 | */ | ||
582 | public static byte[] readFile2BytesByStream(final File file) { | ||
583 | if (!isFileExists(file)) return null; | ||
584 | FileInputStream fis = null; | ||
585 | ByteArrayOutputStream os = null; | ||
586 | try { | ||
587 | fis = new FileInputStream(file); | ||
588 | os = new ByteArrayOutputStream(); | ||
589 | byte[] b = new byte[sBufferSize]; | ||
590 | int len; | ||
591 | while ((len = fis.read(b, 0, sBufferSize)) != -1) { | ||
592 | os.write(b, 0, len); | ||
593 | } | ||
594 | return os.toByteArray(); | ||
595 | } catch (IOException e) { | ||
596 | e.printStackTrace(); | ||
597 | return null; | ||
598 | } finally { | ||
599 | closeIO(fis, os); | ||
600 | } | ||
601 | } | ||
602 | |||
603 | /** | ||
604 | * Return the bytes in file by channel. | ||
605 | * | ||
606 | * @param filePath The path of file. | ||
607 | * @return the bytes in file | ||
608 | */ | ||
609 | public static byte[] readFile2BytesByChannel(final String filePath) { | ||
610 | return readFile2BytesByChannel(getFileByPath(filePath)); | ||
611 | } | ||
612 | |||
613 | /** | ||
614 | * Return the bytes in file by channel. | ||
615 | * | ||
616 | * @param file The file. | ||
617 | * @return the bytes in file | ||
618 | */ | ||
619 | public static byte[] readFile2BytesByChannel(final File file) { | ||
620 | if (!isFileExists(file)) return null; | ||
621 | FileChannel fc = null; | ||
622 | try { | ||
623 | fc = new RandomAccessFile(file, "r").getChannel(); | ||
624 | ByteBuffer byteBuffer = ByteBuffer.allocate((int) fc.size()); | ||
625 | while (true) { | ||
626 | if (!((fc.read(byteBuffer)) > 0)) break; | ||
627 | } | ||
628 | return byteBuffer.array(); | ||
629 | } catch (IOException e) { | ||
630 | e.printStackTrace(); | ||
631 | return null; | ||
632 | } finally { | ||
633 | closeIO(fc); | ||
634 | } | ||
635 | } | ||
636 | |||
637 | /** | ||
638 | * Return the bytes in file by map. | ||
639 | * | ||
640 | * @param filePath The path of file. | ||
641 | * @return the bytes in file | ||
642 | */ | ||
643 | public static byte[] readFile2BytesByMap(final String filePath) { | ||
644 | return readFile2BytesByMap(getFileByPath(filePath)); | ||
645 | } | ||
646 | |||
647 | /** | ||
648 | * Return the bytes in file by map. | ||
649 | * | ||
650 | * @param file The file. | ||
651 | * @return the bytes in file | ||
652 | */ | ||
653 | public static byte[] readFile2BytesByMap(final File file) { | ||
654 | if (!isFileExists(file)) return null; | ||
655 | FileChannel fc = null; | ||
656 | try { | ||
657 | fc = new RandomAccessFile(file, "r").getChannel(); | ||
658 | int size = (int) fc.size(); | ||
659 | MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, size).load(); | ||
660 | byte[] result = new byte[size]; | ||
661 | mbb.get(result, 0, size); | ||
662 | return result; | ||
663 | } catch (IOException e) { | ||
664 | e.printStackTrace(); | ||
665 | return null; | ||
666 | } finally { | ||
667 | closeIO(fc); | ||
668 | } | ||
669 | } | ||
670 | |||
671 | /** | ||
672 | * Set the buffer's size. | ||
673 | * <p>Default size equals 8192 bytes.</p> | ||
674 | * | ||
675 | * @param bufferSize The buffer's size. | ||
676 | */ | ||
677 | public static void setBufferSize(final int bufferSize) { | ||
678 | sBufferSize = bufferSize; | ||
679 | } | ||
680 | |||
681 | private static File getFileByPath(final String filePath) { | ||
682 | return isSpace(filePath) ? null : new File(filePath); | ||
683 | } | ||
684 | |||
685 | private static boolean createOrExistsFile(final String filePath) { | ||
686 | return createOrExistsFile(getFileByPath(filePath)); | ||
687 | } | ||
688 | |||
689 | private static boolean createOrExistsFile(final File file) { | ||
690 | if (file == null) return false; | ||
691 | if (file.exists()) return file.isFile(); | ||
692 | if (!createOrExistsDir(file.getParentFile())) return false; | ||
693 | try { | ||
694 | return file.createNewFile(); | ||
695 | } catch (IOException e) { | ||
696 | e.printStackTrace(); | ||
697 | return false; | ||
698 | } | ||
699 | } | ||
700 | |||
701 | private static boolean createOrExistsDir(final File file) { | ||
702 | return file != null && (file.exists() ? file.isDirectory() : file.mkdirs()); | ||
703 | } | ||
704 | |||
705 | private static boolean isFileExists(final File file) { | ||
706 | return file != null && file.exists(); | ||
707 | } | ||
708 | |||
709 | private static boolean isSpace(final String s) { | ||
710 | if (s == null) return true; | ||
711 | for (int i = 0, len = s.length(); i < len; ++i) { | ||
712 | if (!Character.isWhitespace(s.charAt(i))) { | ||
713 | return false; | ||
714 | } | ||
715 | } | ||
716 | return true; | ||
717 | } | ||
718 | |||
719 | |||
720 | public static void closeIO(final Closeable... closeables) { | ||
721 | if (closeables == null) return; | ||
722 | for (Closeable closeable : closeables) { | ||
723 | if (closeable != null) { | ||
724 | try { | ||
725 | closeable.close(); | ||
726 | } catch (IOException e) { | ||
727 | e.printStackTrace(); | ||
728 | } | ||
729 | } | ||
730 | } | ||
731 | } | ||
732 | |||
733 | } | ||
734 |
libs/common/src/main/java/com/prws/common/utils/FileUtils.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import com.prws.common.CommonApplication; | ||
4 | |||
5 | import java.io.BufferedOutputStream; | ||
6 | import java.io.BufferedReader; | ||
7 | import java.io.ByteArrayOutputStream; | ||
8 | import java.io.File; | ||
9 | import java.io.FileInputStream; | ||
10 | import java.io.FileNotFoundException; | ||
11 | import java.io.FileOutputStream; | ||
12 | import java.io.FileWriter; | ||
13 | import java.io.IOException; | ||
14 | import java.io.InputStreamReader; | ||
15 | import java.io.PrintWriter; | ||
16 | import java.io.RandomAccessFile; | ||
17 | import java.util.ArrayList; | ||
18 | import java.util.List; | ||
19 | |||
20 | public class FileUtils { | ||
21 | public static String getFromAssets(String fileName) { | ||
22 | try { | ||
23 | InputStreamReader inputReader = new InputStreamReader(CommonApplication.getAppContext().getAssets().open(fileName)); | ||
24 | BufferedReader bufReader = new BufferedReader(inputReader); | ||
25 | String line = ""; | ||
26 | String Result = ""; | ||
27 | while ((line = bufReader.readLine()) != null) | ||
28 | Result += line; | ||
29 | return Result; | ||
30 | } catch (Exception e) { | ||
31 | e.printStackTrace(); | ||
32 | } | ||
33 | return null; | ||
34 | } | ||
35 | |||
36 | public static boolean writeFile(String filePath, String content, boolean append) { | ||
37 | if (content == null || content.length() == 0) { | ||
38 | return false; | ||
39 | } else { | ||
40 | FileWriter fileWriter = null; | ||
41 | |||
42 | boolean var4; | ||
43 | try { | ||
44 | fileWriter = new FileWriter(filePath, append); | ||
45 | fileWriter.write(content); | ||
46 | var4 = true; | ||
47 | } catch (IOException var13) { | ||
48 | throw new RuntimeException("IOException occurred. ", var13); | ||
49 | } finally { | ||
50 | if (fileWriter != null) { | ||
51 | try { | ||
52 | fileWriter.close(); | ||
53 | } catch (IOException var12) { | ||
54 | var12.printStackTrace(); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | } | ||
59 | |||
60 | return var4; | ||
61 | } | ||
62 | } | ||
63 | public static boolean writeFile(String filePath,Throwable e) { | ||
64 | |||
65 | FileWriter fileWriter = null; | ||
66 | |||
67 | boolean var4; | ||
68 | try { | ||
69 | fileWriter = new FileWriter(filePath, true); | ||
70 | // fileWriter.write(e); | ||
71 | e.printStackTrace(new PrintWriter(fileWriter)); | ||
72 | var4 = true; | ||
73 | } catch (IOException var13) { | ||
74 | throw new RuntimeException("IOException occurred. ", var13); | ||
75 | } finally { | ||
76 | if (fileWriter != null) { | ||
77 | try { | ||
78 | fileWriter.close(); | ||
79 | } catch (IOException var12) { | ||
80 | var12.printStackTrace(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | } | ||
85 | |||
86 | return var4; | ||
87 | |||
88 | } | ||
89 | |||
90 | /** | ||
91 | * 分割文件 | ||
92 | * | ||
93 | * @param filePath 要分割的文件路径 | ||
94 | * @param num 要分割成多少份 | ||
95 | * @return | ||
96 | */ | ||
97 | public static List<File> split(String filePath, int num) { | ||
98 | File file = new File(filePath); | ||
99 | long lon = file.length() / num; | ||
100 | List<File> chunk = new ArrayList<>(); | ||
101 | try { | ||
102 | RandomAccessFile src = new RandomAccessFile(file, "r"); | ||
103 | byte[] bytes = new byte[1024]; | ||
104 | int len; | ||
105 | for (int i = 0; i < num; i++) { | ||
106 | //分割添加索引,后台根据索引顺序依次合并 | ||
107 | String name = getFileBegin(filePath) + "_" + (i + 1) + getFileSuff(filePath); | ||
108 | File temp = new File(name); | ||
109 | RandomAccessFile target = new RandomAccessFile(temp, "rw"); | ||
110 | while ((len = src.read(bytes)) != -1) { | ||
111 | target.write(bytes, 0, len); | ||
112 | if (target.length() > lon)// 当生成的新文件字节数大于lon时,结束循环 | ||
113 | break; | ||
114 | } | ||
115 | chunk.add(temp); | ||
116 | target.close(); | ||
117 | } | ||
118 | src.close(); | ||
119 | } catch (Exception e) { | ||
120 | e.printStackTrace(); | ||
121 | } | ||
122 | return chunk; | ||
123 | } | ||
124 | /** | ||
125 | * 获取文件除后缀名外的名字 | ||
126 | * | ||
127 | * @param filePath | ||
128 | */ | ||
129 | public static String getFileBegin(String filePath) { | ||
130 | String i = getFileSuff(filePath); | ||
131 | int index = filePath.indexOf(i); | ||
132 | return filePath.substring(0, index); | ||
133 | } | ||
134 | /** | ||
135 | * 获取文件后缀名 | ||
136 | * | ||
137 | * @param filePath | ||
138 | */ | ||
139 | public static String getFileSuff(String filePath) { | ||
140 | int start = filePath.lastIndexOf("."); | ||
141 | int end = filePath.length(); | ||
142 | return filePath.substring(start, end); | ||
143 | } | ||
144 | public static boolean isFileExist(String filePath) { | ||
145 | return (new File(filePath)).exists(); | ||
146 | } | ||
147 | |||
148 | |||
149 | /** | ||
150 | * 将Byte数组转换成文件 | ||
151 | * | ||
152 | * @param bytes byte数组 | ||
153 | * @param filePath 文件路径 如 D://test/ 最后“/”结尾 | ||
154 | * @param fileName 文件名 | ||
155 | */ | ||
156 | public static void saveFileFromBytes(byte[] bytes, String filePath, String fileName) { | ||
157 | BufferedOutputStream bos = null; | ||
158 | FileOutputStream fos = null; | ||
159 | File file = null; | ||
160 | try { | ||
161 | file = new File(filePath + fileName); | ||
162 | if (!file.getParentFile().exists()) { | ||
163 | //文件夹不存在 生成 | ||
164 | file.getParentFile().mkdirs(); | ||
165 | } | ||
166 | fos = new FileOutputStream(file); | ||
167 | bos = new BufferedOutputStream(fos); | ||
168 | bos.write(bytes); | ||
169 | } catch (Exception e) { | ||
170 | e.printStackTrace(); | ||
171 | } finally { | ||
172 | if (bos != null) { | ||
173 | try { | ||
174 | bos.close(); | ||
175 | } catch (IOException e) { | ||
176 | e.printStackTrace(); | ||
177 | } | ||
178 | } | ||
179 | if (fos != null) { | ||
180 | try { | ||
181 | fos.close(); | ||
182 | } catch (IOException e) { | ||
183 | e.printStackTrace(); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | } | ||
188 | } | ||
189 | |||
190 | |||
191 | public static byte[] file2buf(File fobj) { | ||
192 | byte[] buffer = null; | ||
193 | try { | ||
194 | if (!fobj.exists()) { | ||
195 | return null; | ||
196 | } | ||
197 | |||
198 | FileInputStream fis = new FileInputStream(fobj); | ||
199 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); | ||
200 | byte[] b = new byte[1024]; | ||
201 | int len = -1; | ||
202 | while ((len = fis.read(b)) != -1) { | ||
203 | bos.write(b, 0, len); | ||
204 | } | ||
205 | fis.close(); | ||
206 | bos.close(); | ||
207 | buffer = bos.toByteArray(); | ||
208 | } catch (FileNotFoundException e) { | ||
209 | e.printStackTrace(); | ||
210 | } catch (IOException e) { | ||
211 | e.printStackTrace(); | ||
212 | } | ||
213 | return buffer; | ||
214 | } | ||
215 | |||
216 | } | ||
217 |
libs/common/src/main/java/com/prws/common/utils/GlideHelper.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.widget.ImageView; | ||
5 | |||
6 | import com.bumptech.glide.Glide; | ||
7 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
8 | |||
9 | import java.io.File; | ||
10 | |||
11 | /** | ||
12 | * @author zhiqun.tang | ||
13 | * @Description: Glide 工具类 | ||
14 | * @date 2022/8/10 | ||
15 | */ | ||
16 | public class GlideHelper { | ||
17 | /** | ||
18 | * 加载图片Url | ||
19 | * | ||
20 | * @param mContext | ||
21 | * @param url | ||
22 | * @param imageView | ||
23 | */ | ||
24 | public static void loadUrl(Context mContext, String url, ImageView imageView) { | ||
25 | if (mContext != null) { | ||
26 | Glide.with(mContext.getApplicationContext()) | ||
27 | .load(url) | ||
28 | // .format(DecodeFormat.PREFER_RGB_565) | ||
29 | // 取消动画,防止第一次加载不出来 | ||
30 | .dontAnimate() | ||
31 | //加载缩略图 | ||
32 | .thumbnail(0.3f) | ||
33 | .skipMemoryCache(true) | ||
34 | .diskCacheStrategy(DiskCacheStrategy.ALL) | ||
35 | .into(imageView); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * 加载图片Url | ||
41 | * | ||
42 | * @param mContext | ||
43 | * @param resourceId | ||
44 | * @param imageView | ||
45 | */ | ||
46 | public static void loadUrl(Context mContext, int resourceId, ImageView imageView) { | ||
47 | if (mContext != null) { | ||
48 | Glide.with(mContext.getApplicationContext()) | ||
49 | .load(resourceId) | ||
50 | // .format(DecodeFormat.PREFER_RGB_565) | ||
51 | // 取消动画,防止第一次加载不出来 | ||
52 | .dontAnimate() | ||
53 | //加载缩略图 | ||
54 | .thumbnail(0.3f) | ||
55 | .skipMemoryCache(true) | ||
56 | .diskCacheStrategy(DiskCacheStrategy.ALL) | ||
57 | .into(imageView); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | |||
62 | |||
63 | /** | ||
64 | * 加载图片Url | ||
65 | * | ||
66 | * @param mContext | ||
67 | * @param url | ||
68 | * @param imageView | ||
69 | */ | ||
70 | public static void loadSmollUrl(Context mContext, String url, int w, int h, ImageView imageView) { | ||
71 | if (mContext != null) { | ||
72 | Glide.with(mContext.getApplicationContext()) | ||
73 | .load(url) | ||
74 | .override(w, h) | ||
75 | // .format(DecodeFormat.PREFER_RGB_565) | ||
76 | // 取消动画,防止第一次加载不出来 | ||
77 | .dontAnimate() | ||
78 | //加载缩略图 | ||
79 | .thumbnail(0.3f) | ||
80 | .skipMemoryCache(true) | ||
81 | .diskCacheStrategy(DiskCacheStrategy.ALL) | ||
82 | .into(imageView); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * 加载图片File | ||
88 | * | ||
89 | * @param mContext | ||
90 | * @param file | ||
91 | * @param imageView | ||
92 | */ | ||
93 | public static void loadFile(Context mContext, File file, ImageView imageView) { | ||
94 | if (mContext != null) { | ||
95 | Glide.with(mContext.getApplicationContext()) | ||
96 | .load(file) | ||
97 | // 取消动画,防止第一次加载不出来 | ||
98 | .dontAnimate() | ||
99 | //加载缩略图 | ||
100 | .thumbnail(0.3f) | ||
101 | .skipMemoryCache(true) | ||
102 | .diskCacheStrategy(DiskCacheStrategy.ALL) | ||
103 | .into(imageView); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | } | ||
108 |
libs/common/src/main/java/com/prws/common/utils/GsonUtil.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import com.google.gson.Gson; | ||
4 | import com.google.gson.JsonArray; | ||
5 | import com.google.gson.JsonElement; | ||
6 | import com.google.gson.JsonParser; | ||
7 | import com.google.gson.reflect.TypeToken; | ||
8 | |||
9 | import org.json.JSONObject; | ||
10 | |||
11 | import java.util.ArrayList; | ||
12 | import java.util.List; | ||
13 | import java.util.Map; | ||
14 | |||
15 | /** | ||
16 | * Description: This's GsonUtil | ||
17 | * Time: 2018/5/10 20:15 | ||
18 | * | ||
19 | * @author lishiting | ||
20 | */ | ||
21 | public class GsonUtil { | ||
22 | private static Gson gson = null; | ||
23 | |||
24 | static { | ||
25 | if (gson == null) { | ||
26 | gson = new Gson(); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | private GsonUtil() { | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * 转成json | ||
35 | * | ||
36 | * @param object | ||
37 | * @return | ||
38 | */ | ||
39 | public static String GsonString(Object object) { | ||
40 | String gsonString = null; | ||
41 | if (gson != null) { | ||
42 | gsonString = gson.toJson(object); | ||
43 | } | ||
44 | return gsonString; | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * 转成bean | ||
49 | * | ||
50 | * @param gsonString | ||
51 | * @param cls | ||
52 | * @return | ||
53 | */ | ||
54 | public static <T> T GsonToBean(String gsonString, Class<T> cls) { | ||
55 | T t = null; | ||
56 | if (gson != null) { | ||
57 | t = gson.fromJson(gsonString, cls); | ||
58 | } | ||
59 | return t; | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * 转成list | ||
64 | * 泛型在编译期类型被擦除导致报错 | ||
65 | * | ||
66 | * @param gsonString | ||
67 | * @param cls | ||
68 | * @return | ||
69 | */ | ||
70 | public static <T> List<T> GsonToList(String gsonString, Class<T> cls) { | ||
71 | List<T> list = null; | ||
72 | if (gson != null) { | ||
73 | list = gson.fromJson(gsonString, new TypeToken<List<T>>() { | ||
74 | }.getType()); | ||
75 | } | ||
76 | return list; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * 转成list | ||
81 | * 解决泛型问题 | ||
82 | * | ||
83 | * @param json | ||
84 | * @param cls | ||
85 | * @param <T> | ||
86 | * @return | ||
87 | */ | ||
88 | public static <T> List<T> jsonToList(String json, Class<T> cls) { | ||
89 | Gson gson = new Gson(); | ||
90 | List<T> list = new ArrayList<T>(); | ||
91 | JsonArray array = new JsonParser().parse(json).getAsJsonArray(); | ||
92 | for (final JsonElement elem : array) { | ||
93 | list.add(gson.fromJson(elem, cls)); | ||
94 | } | ||
95 | return list; | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * 转成list中有map的 | ||
101 | * | ||
102 | * @param gsonString | ||
103 | * @return | ||
104 | */ | ||
105 | public static <T> List<Map<String, T>> GsonToListMaps(String gsonString) { | ||
106 | List<Map<String, T>> list = null; | ||
107 | if (gson != null) { | ||
108 | list = gson.fromJson(gsonString, | ||
109 | new TypeToken<List<Map<String, T>>>() { | ||
110 | }.getType()); | ||
111 | } | ||
112 | return list; | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * 转成map的 | ||
117 | * | ||
118 | * @param gsonString | ||
119 | * @return | ||
120 | */ | ||
121 | public static <T> Map<String, T> GsonToMaps(String gsonString) { | ||
122 | Map<String, T> map = null; | ||
123 | if (gson != null) { | ||
124 | map = gson.fromJson(gsonString, new TypeToken<Map<String, T>>() { | ||
125 | }.getType()); | ||
126 | } | ||
127 | return map; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * 判断json | ||
132 | * @param content | ||
133 | * @return | ||
134 | */ | ||
135 | public static boolean isJson(String content) { | ||
136 | |||
137 | try { | ||
138 | JSONObject jsonObject = new JSONObject(content); | ||
139 | return true; | ||
140 | } catch (Exception e) { | ||
141 | return false; | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 |
libs/common/src/main/java/com/prws/common/utils/LogUtil.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.os.Environment; | ||
5 | import android.util.Log; | ||
6 | import android.util.TimeUtils; | ||
7 | import android.widget.Toast; | ||
8 | |||
9 | import com.prws.common.CommonApplication; | ||
10 | |||
11 | import java.io.File; | ||
12 | import java.io.IOException; | ||
13 | import java.sql.Date; | ||
14 | import java.text.SimpleDateFormat; | ||
15 | import java.util.Locale; | ||
16 | |||
17 | |||
18 | /** | ||
19 | * @Author | ||
20 | * @Describe:Log日志级别打印相关工具类 | ||
21 | */ | ||
22 | public class LogUtil { | ||
23 | |||
24 | private LogUtil() { | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * 打印的信息日志信息 | ||
29 | */ | ||
30 | private final static String INFO = "☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻: "; | ||
31 | |||
32 | /** | ||
33 | * 打印的错误日志信息 | ||
34 | */ | ||
35 | private final static String ERROR = "✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖✖: "; | ||
36 | |||
37 | /** | ||
38 | * 打印的调试日志信息 | ||
39 | */ | ||
40 | private final static String DEBUG = "☠☠☠☠☠☠☠☠☠☠☠☠☠☠☠: "; | ||
41 | |||
42 | /** | ||
43 | * 打印的全面日志信息 | ||
44 | */ | ||
45 | private final static String VERBOSE = "▂▂▂▃▃▄▄▅▅▆▆▆▇▇: "; | ||
46 | |||
47 | /** | ||
48 | * 打印的警告日志信息 | ||
49 | */ | ||
50 | private final static String WARN = "!!!!!!!!!!!!!!!!!!!!!!!!!!: "; | ||
51 | |||
52 | /** | ||
53 | * 打印information日志 | ||
54 | * | ||
55 | * @param tag 标签 | ||
56 | * @param msg 日志信息 | ||
57 | */ | ||
58 | public static void i(String tag, String msg) { | ||
59 | |||
60 | Log.i(tag, INFO + msg); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * 打印information日志 | ||
65 | * | ||
66 | * @param tag 标签 | ||
67 | * @param msg 日志信息 | ||
68 | * @param throwable 异常 | ||
69 | */ | ||
70 | public static void i(String tag, String msg, Throwable throwable) { | ||
71 | Log.i(tag, INFO + msg, throwable); | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * 打印verbose日志 | ||
76 | * | ||
77 | * @param tag 标签 | ||
78 | * @param msg 日志信息 | ||
79 | */ | ||
80 | public static void v(String tag, String msg) { | ||
81 | Log.v(tag, VERBOSE + msg); | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * 打印verbose日志 | ||
86 | * | ||
87 | * @param tag 标签 | ||
88 | * @param msg 日志信息 | ||
89 | * @param throwable 异常 | ||
90 | */ | ||
91 | public static void v(String tag, String msg, Throwable throwable) { | ||
92 | Log.v(tag, VERBOSE + msg, throwable); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * 打印debug信息 | ||
97 | * | ||
98 | * @param tag 标签信息 | ||
99 | * @param msg 日志信息 | ||
100 | */ | ||
101 | public static void d(String tag, String msg) { | ||
102 | Log.d(tag, DEBUG + msg); | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * 打印debug日志 | ||
107 | * | ||
108 | * @param tag 标签信息 | ||
109 | * @param msg 日志信息 | ||
110 | * @param throwable 异常 | ||
111 | */ | ||
112 | public static void d(String tag, String msg, Throwable throwable) { | ||
113 | Log.d(tag, DEBUG + msg, throwable); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * 打印warn日志 | ||
118 | * | ||
119 | * @param tag 标签信息 | ||
120 | * @param msg 日志信息 | ||
121 | */ | ||
122 | public static void w(String tag, String msg) { | ||
123 | Log.w(tag, WARN + msg); | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * 打印warn日志 | ||
128 | * | ||
129 | * @param tag 标签信息 | ||
130 | * @param msg 日志信息 | ||
131 | * @param throwable 异常 | ||
132 | */ | ||
133 | public static void w(String tag, String msg, Throwable throwable) { | ||
134 | Log.w(tag, WARN + msg, throwable); | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * 打印error日志 | ||
139 | * | ||
140 | * @param tag | ||
141 | * @param msg 标签 | ||
142 | */ | ||
143 | public static void e(String tag, String msg) { | ||
144 | Log.e(tag, ERROR + msg); | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * 打印error日志 | ||
149 | * | ||
150 | * @param tag 标签 | ||
151 | * @param msg 日志信息 | ||
152 | * @param throwable 异常 | ||
153 | */ | ||
154 | public static void e(String tag, String msg, Throwable throwable) { | ||
155 | Log.e(tag, ERROR + msg, throwable); | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * 吐司提示 | ||
160 | * | ||
161 | * @param msg | ||
162 | */ | ||
163 | public static void toast(Context mContext, String msg) { | ||
164 | Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * 吐司提示 | ||
169 | * | ||
170 | * @param msg | ||
171 | */ | ||
172 | public static boolean toast(String msg) { | ||
173 | Toast.makeText(CommonApplication.getAppContext(), msg, Toast.LENGTH_SHORT).show(); | ||
174 | return true; | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * 吐司提示 | ||
179 | * | ||
180 | * @param msg | ||
181 | */ | ||
182 | public static void toast(Context mContext, int msg) { | ||
183 | Toast.makeText(mContext, mContext.getResources().getString(msg), Toast.LENGTH_SHORT).show(); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * 吐司提示 long类型 | ||
188 | * | ||
189 | * @param msg | ||
190 | */ | ||
191 | public static void toastL(Context mContext, String msg) { | ||
192 | Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show(); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * 吐司提示 自定义时间类型 | ||
197 | * | ||
198 | * @param msg | ||
199 | */ | ||
200 | public static void toastD(Context mContext, String msg, int duration) { | ||
201 | Toast.makeText(mContext, msg, duration).show(); | ||
202 | } | ||
203 | |||
204 | public static void logUploadFile(int type, String tagStr, Object obj) { | ||
205 | |||
206 | |||
207 | long currTime = System.currentTimeMillis(); | ||
208 | String tag = tagStr == null ? "DLog" : tagStr; | ||
209 | StringBuilder stringBuilder = new StringBuilder(); | ||
210 | |||
211 | // 2022-06-24 17:10:32.824 | ||
212 | String currentDateTimeString = | ||
213 | new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date(System.currentTimeMillis())); | ||
214 | |||
215 | stringBuilder.append(" ").append(currentDateTimeString).append(" # "); | ||
216 | |||
217 | String msg; | ||
218 | if (obj == null) { | ||
219 | msg = "Log with null Object"; | ||
220 | } else { | ||
221 | msg = obj.toString(); | ||
222 | } | ||
223 | |||
224 | if (msg != null) { | ||
225 | stringBuilder.append(msg); | ||
226 | } | ||
227 | |||
228 | String logStr = stringBuilder.toString(); | ||
229 | |||
230 | String timeStr = new Date(currTime).getMonth()+1 + "-" + new Date(currTime).getDate() + ""; | ||
231 | |||
232 | String logFilePath = Environment.getExternalStorageDirectory() + "/" + "prws" + "/" + timeStr + "-log.txt"; | ||
233 | createPath(logFilePath); | ||
234 | try { | ||
235 | FileUtils.writeFile(logFilePath, tag + " : " + logStr + "\n", true); | ||
236 | } catch (Exception e) { | ||
237 | e.printStackTrace(); | ||
238 | } | ||
239 | |||
240 | |||
241 | } | ||
242 | |||
243 | public static void saveFileMessage(Throwable e) { | ||
244 | Date date = new Date(System.currentTimeMillis()); | ||
245 | String logFilePath = CommonApplication.getAppContext().getFilesDir().getAbsolutePath() + "/" + "prws" + "/logs/" +date.getMonth()+"-"+date.getDay() + ".txt"; | ||
246 | LogUtil.i("TAG","logFilePath:"+logFilePath); | ||
247 | createPath(logFilePath); | ||
248 | FileUtils.writeFile(logFilePath, e); | ||
249 | |||
250 | } | ||
251 | |||
252 | private static void createPath(String path) { | ||
253 | File fileDir = new File(path.substring(0, path.lastIndexOf("/"))); | ||
254 | if (!fileDir.exists()) { | ||
255 | fileDir.mkdirs(); | ||
256 | } | ||
257 | File zipFile = new File(path); | ||
258 | if (!zipFile.exists()) { | ||
259 | try { | ||
260 | zipFile.createNewFile(); | ||
261 | } catch (IOException e) { | ||
262 | e.printStackTrace(); | ||
263 | } | ||
264 | } | ||
265 | } | ||
266 | } | ||
267 | |||
268 |
libs/common/src/main/java/com/prws/common/utils/LogcatHelper.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.os.Environment; | ||
5 | import android.util.Log; | ||
6 | |||
7 | import com.developer.wang.utils.DateUtil; | ||
8 | |||
9 | import java.io.BufferedReader; | ||
10 | import java.io.File; | ||
11 | import java.io.FileNotFoundException; | ||
12 | import java.io.FileOutputStream; | ||
13 | import java.io.IOException; | ||
14 | import java.io.InputStreamReader; | ||
15 | import java.nio.file.Files; | ||
16 | import java.nio.file.Path; | ||
17 | import java.nio.file.attribute.BasicFileAttributes; | ||
18 | import java.text.ParseException; | ||
19 | import java.text.SimpleDateFormat; | ||
20 | import java.time.Instant; | ||
21 | import java.util.Date; | ||
22 | |||
23 | public class LogcatHelper { | ||
24 | |||
25 | private static LogcatHelper INSTANCE = null; | ||
26 | private static String PATH_LOGCAT; | ||
27 | private LogDumper mLogDumper = null; | ||
28 | private int mPId; | ||
29 | |||
30 | /** | ||
31 | * 初始化目录 | ||
32 | */ | ||
33 | public void init(Context context) { | ||
34 | if (Environment.getExternalStorageState().equals( | ||
35 | Environment.MEDIA_MOUNTED)) {// 优先保存到SD卡中 | ||
36 | PATH_LOGCAT = Environment.getExternalStorageDirectory() | ||
37 | .getAbsolutePath() + File.separator + "aLog"; | ||
38 | } else {// 如果SD卡不存在,就保存到本应用的目录下 | ||
39 | PATH_LOGCAT = context.getFilesDir().getAbsolutePath() | ||
40 | + File.separator + "aaLog"; | ||
41 | } | ||
42 | File file = new File(PATH_LOGCAT); | ||
43 | |||
44 | |||
45 | LogUtil.i("LogcatHelper", "存储位置:" + PATH_LOGCAT); | ||
46 | if (!file.exists()) { | ||
47 | file.mkdirs(); | ||
48 | } | ||
49 | |||
50 | if (file.isDirectory()) { | ||
51 | File[] files = file.listFiles(); | ||
52 | if (files.length > 3) { | ||
53 | //记录最小的创建时间文件 | ||
54 | File minTimeFile = null; | ||
55 | for (File file1 : files) { | ||
56 | String fileName = file1.getName().substring(4, 14); | ||
57 | LogUtil.e("LogcatHelper", "fileName:" + fileName); | ||
58 | if (minTimeFile == null) { | ||
59 | minTimeFile = file1; | ||
60 | continue; | ||
61 | } else { | ||
62 | String minFileName = minTimeFile.getName().substring(4, 14); | ||
63 | long minTime = getLongTime(minFileName); | ||
64 | long curTime = getLongTime(fileName); | ||
65 | LogUtil.e("LogcatHelper", "minFileName:" + minFileName + "--minTime:" + minTime + "--curTime:" + curTime); | ||
66 | if (curTime < minTime) | ||
67 | minTimeFile = file1; | ||
68 | } | ||
69 | } | ||
70 | if (minTimeFile != null) { | ||
71 | boolean isDelete = minTimeFile.delete(); | ||
72 | LogUtil.e("LogcatHelper", "isDelete:" + isDelete); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | LogUtil.i("LogcatHelper", "文件是否存在:" + new File(PATH_LOGCAT).exists()); | ||
78 | } | ||
79 | |||
80 | public static long getLongTime(String dateTime) { | ||
81 | try { | ||
82 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
83 | Date startDate = sdf.parse(dateTime); | ||
84 | return startDate.getTime(); | ||
85 | } catch (ParseException e) { | ||
86 | e.printStackTrace(); | ||
87 | } | ||
88 | return -1; | ||
89 | } | ||
90 | |||
91 | |||
92 | public static LogcatHelper getInstance(Context context) { | ||
93 | if (INSTANCE == null) { | ||
94 | INSTANCE = new LogcatHelper(context); | ||
95 | } | ||
96 | return INSTANCE; | ||
97 | } | ||
98 | |||
99 | private LogcatHelper(Context context) { | ||
100 | init(context); | ||
101 | mPId = android.os.Process.myPid(); | ||
102 | } | ||
103 | |||
104 | public void start() { | ||
105 | if (mLogDumper == null) | ||
106 | mLogDumper = new LogDumper(String.valueOf(mPId), PATH_LOGCAT); | ||
107 | mLogDumper.start(); | ||
108 | } | ||
109 | |||
110 | public void stop() { | ||
111 | if (mLogDumper != null) { | ||
112 | mLogDumper.stopLogs(); | ||
113 | mLogDumper = null; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | private class LogDumper extends Thread { | ||
118 | private Process logcatProc; | ||
119 | private BufferedReader mReader = null; | ||
120 | private boolean mRunning = true; | ||
121 | String cmds = null; | ||
122 | private String mPID; | ||
123 | private FileOutputStream out = null; | ||
124 | |||
125 | public LogDumper(String pid, String dir) { | ||
126 | mPID = pid; | ||
127 | try { | ||
128 | out = new FileOutputStream(new File(dir, "log-" | ||
129 | + getFileName() + ".log"),true); | ||
130 | } catch (FileNotFoundException e) { | ||
131 | // TODO Auto-generated catch block | ||
132 | e.printStackTrace(); | ||
133 | } | ||
134 | /** | ||
135 | * | ||
136 | * 日志等级:*:v , *:d , *:w , *:e , *:f , *:s | ||
137 | * | ||
138 | * 显示当前mPID程序的 E和W等级的日志. | ||
139 | * | ||
140 | * */ | ||
141 | // cmds = "logcat *:e *:w | grep \"(" + mPID + ")\""; | ||
142 | // cmds = "logcat | grep \"(" + mPID + ")\"";//打印所有日志信息 | ||
143 | // cmds = "logcat -s way";//打印标签过滤信息 | ||
144 | // cmds = "logcat *:e *:i | grep \"(" + mPID + ")\""; | ||
145 | cmds = "logcat | grep \"(" + mPID + ")\""; | ||
146 | |||
147 | } | ||
148 | |||
149 | public void stopLogs() { | ||
150 | mRunning = false; | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public void run() { | ||
155 | try { | ||
156 | logcatProc = Runtime.getRuntime().exec(cmds); | ||
157 | mReader = new BufferedReader(new InputStreamReader( | ||
158 | logcatProc.getInputStream()), 1024); | ||
159 | String line = null; | ||
160 | while (mRunning && (line = mReader.readLine()) != null) { | ||
161 | if (!mRunning) { | ||
162 | break; | ||
163 | } | ||
164 | if (line.length() == 0) { | ||
165 | continue; | ||
166 | } | ||
167 | if (out != null && line.contains(mPID)) { | ||
168 | out.write((line + "\n").getBytes()); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | } catch (IOException e) { | ||
173 | e.printStackTrace(); | ||
174 | } finally { | ||
175 | if (logcatProc != null) { | ||
176 | logcatProc.destroy(); | ||
177 | logcatProc = null; | ||
178 | } | ||
179 | if (mReader != null) { | ||
180 | try { | ||
181 | mReader.close(); | ||
182 | mReader = null; | ||
183 | } catch (IOException e) { | ||
184 | e.printStackTrace(); | ||
185 | } | ||
186 | } | ||
187 | if (out != null) { | ||
188 | try { | ||
189 | out.close(); | ||
190 | } catch (IOException e) { | ||
191 | e.printStackTrace(); | ||
192 | } | ||
193 | out = null; | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | |||
199 | public String getFileName() { | ||
200 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
201 | String date = format.format(new Date(System.currentTimeMillis())); | ||
202 | return date; | ||
203 | } | ||
204 | } |
libs/common/src/main/java/com/prws/common/utils/NetUtil.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.net.wifi.WifiManager; | ||
5 | import android.util.Log; | ||
6 | |||
7 | import java.net.InetAddress; | ||
8 | import java.net.NetworkInterface; | ||
9 | import java.util.Collections; | ||
10 | import java.util.List; | ||
11 | import java.util.Timer; | ||
12 | import java.util.TimerTask; | ||
13 | |||
14 | public class NetUtil { | ||
15 | |||
16 | private NetUtil(){} | ||
17 | |||
18 | public static boolean isEthConnect(){ | ||
19 | return hasDisplay("eth"); | ||
20 | } | ||
21 | |||
22 | public static boolean isWifiConnect(){ | ||
23 | return hasDisplay("wlan"); | ||
24 | } | ||
25 | |||
26 | public static boolean is4GConnect(){ | ||
27 | return hasDisplay("usb"); | ||
28 | } | ||
29 | |||
30 | private static boolean hasDisplay(String displayName){ | ||
31 | try { | ||
32 | List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); | ||
33 | for (NetworkInterface intf : interfaces) { | ||
34 | String displayNameStr = intf.getDisplayName(); | ||
35 | if(displayNameStr.contains(displayName)){ | ||
36 | List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); | ||
37 | for (InetAddress addr : addrs) { | ||
38 | if (!addr.isLoopbackAddress()) { | ||
39 | String sAddr = addr.getHostAddress(); | ||
40 | boolean isIPv4 = sAddr.indexOf(':')<0; | ||
41 | if(isIPv4){ | ||
42 | return true; //检查到设备并且有设备ipv4的地址信息 | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | }else{ | ||
47 | continue; | ||
48 | } | ||
49 | } | ||
50 | } catch (Exception e) { | ||
51 | e.printStackTrace(); | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | |||
56 | public static boolean isWifiDisabled(Context context){ | ||
57 | try{ | ||
58 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | ||
59 | return wifiManager.getWifiState()==WifiManager.WIFI_STATE_DISABLED; | ||
60 | }catch (Exception e){ | ||
61 | e.printStackTrace(); | ||
62 | } | ||
63 | return false; | ||
64 | } | ||
65 | |||
66 | public static void closeWifi(Context context,WifiChangeCallback callback){ | ||
67 | try{ | ||
68 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | ||
69 | if(wifiManager.getWifiState()== WifiManager.WIFI_STATE_ENABLED){//wifi打开 | ||
70 | wifiManager.setWifiEnabled(false); | ||
71 | Timer timer = new Timer(); | ||
72 | timer.schedule(new TimerTask() { | ||
73 | @Override | ||
74 | public void run() { | ||
75 | if(wifiManager.getWifiState()== WifiManager.WIFI_STATE_DISABLED){ | ||
76 | callback.onWifiClosed(); | ||
77 | timer.cancel(); | ||
78 | } | ||
79 | |||
80 | } | ||
81 | },0,500); | ||
82 | } | ||
83 | }catch (Exception e){ | ||
84 | e.printStackTrace(); | ||
85 | } | ||
86 | |||
87 | } | ||
88 | |||
89 | public static void openWifi(Context context){ | ||
90 | try{ | ||
91 | WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | ||
92 | if(wifiManager.getWifiState()== WifiManager.WIFI_STATE_DISABLED){//wifi打开 | ||
93 | wifiManager.setWifiEnabled(true); | ||
94 | } | ||
95 | }catch (Exception e){ | ||
96 | e.printStackTrace(); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | public interface WifiChangeCallback{ | ||
101 | public void onWifiClosed(); | ||
102 | public void onWifiOpened(); | ||
103 | } | ||
104 | |||
105 | public static void printNetInfo(){ | ||
106 | try { | ||
107 | List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); | ||
108 | for (NetworkInterface intf : interfaces) { | ||
109 | List<InetAddress> addrs = Collections.list(intf.getInetAddresses()); | ||
110 | for (InetAddress addr : addrs) { | ||
111 | if (!addr.isLoopbackAddress()) { | ||
112 | String sAddr = addr.getHostAddress(); | ||
113 | Log.e("printNetInfo", "printNetInfo: "+sAddr ); | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } catch (Exception ex) { } | ||
118 | } | ||
119 | } | ||
120 |
libs/common/src/main/java/com/prws/common/utils/ScreenUtils.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.Dialog; | ||
5 | import android.view.View; | ||
6 | import android.view.Window; | ||
7 | import android.view.WindowManager; | ||
8 | |||
9 | import androidx.fragment.app.DialogFragment; | ||
10 | |||
11 | |||
12 | |||
13 | import java.util.Objects; | ||
14 | |||
15 | public class ScreenUtils { | ||
16 | private static final int SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED = 0x00004000; | ||
17 | |||
18 | /** | ||
19 | * 隐藏虚拟按键,并且全屏 | ||
20 | */ | ||
21 | public static void hideBottomUIMenu(Activity activity) { | ||
22 | // 隐藏虚拟按键,并且全屏 | ||
23 | // for new api versions. | ||
24 | View decorView = activity.getWindow().getDecorView(); | ||
25 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
26 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | ||
27 | | View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
28 | // | SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED; | ||
29 | decorView.setSystemUiVisibility(uiOptions); | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * 隐藏虚拟按键,并且全屏 | ||
34 | */ | ||
35 | public static void hideBottomUIMenuAuto(Activity activity) { | ||
36 | // 隐藏虚拟按键,并且全屏 | ||
37 | // for new api versions. | ||
38 | View decorView = activity.getWindow().getDecorView(); | ||
39 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
40 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | ||
41 | | View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
42 | decorView.setSystemUiVisibility(uiOptions); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * 隐藏虚拟按键,并且全屏 | ||
47 | */ | ||
48 | public static void showBottomUIMenu(Activity activity) { | ||
49 | // 显示虚拟键 | ||
50 | View decorView = activity.getWindow().getDecorView(); | ||
51 | int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; | ||
52 | decorView.setSystemUiVisibility(uiOptions); | ||
53 | } | ||
54 | |||
55 | |||
56 | /** | ||
57 | * 隐藏虚拟按键,并且全屏 | ||
58 | */ | ||
59 | public static void hideDialogBottomUIMenuAuto(Dialog dialog) { | ||
60 | // 隐藏虚拟按键,并且全屏 | ||
61 | // for new api versions. | ||
62 | Window window = dialog.getWindow(); | ||
63 | assert window != null; | ||
64 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
65 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
66 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
67 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
68 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
69 | | View.SYSTEM_UI_FLAG_IMMERSIVE | ||
70 | | View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
71 | window.getDecorView().setSystemUiVisibility(uiOptions); | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * 隐藏虚拟按键,并且全屏 | ||
76 | */ | ||
77 | public static void showDialogBottomUIMenu(Dialog dialog) { | ||
78 | // 显示虚拟键 | ||
79 | Window window = dialog.getWindow(); | ||
80 | int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; | ||
81 | assert window != null; | ||
82 | window.getDecorView().setSystemUiVisibility(uiOptions); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * 隐藏虚拟按键,并且全屏 | ||
87 | */ | ||
88 | public static void hideDialogBottomUIMenu(Dialog dialog) { | ||
89 | // 隐藏虚拟按键,并且全屏 | ||
90 | // for new api versions. | ||
91 | Window window = dialog.getWindow(); | ||
92 | assert window != null; | ||
93 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
94 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
95 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
96 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
97 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
98 | | View.SYSTEM_UI_FLAG_IMMERSIVE | ||
99 | | View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
100 | // | SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED; | ||
101 | window.getDecorView().setSystemUiVisibility(uiOptions); | ||
102 | } | ||
103 | |||
104 | public static void hideDialogBottomUIMenu(DialogFragment dialog) { | ||
105 | if (dialog == null)return; | ||
106 | // 隐藏虚拟按键,并且全屏 | ||
107 | // for new api versions. | ||
108 | Window window = dialog.getDialog().getWindow(); | ||
109 | assert window != null; | ||
110 | window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
111 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
112 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
113 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
114 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
115 | | View.SYSTEM_UI_FLAG_IMMERSIVE | ||
116 | | View.SYSTEM_UI_FLAG_FULLSCREEN; | ||
117 | // | SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED; | ||
118 | window.getDecorView().setSystemUiVisibility(uiOptions); | ||
119 | } | ||
120 | } | ||
121 |
libs/common/src/main/java/com/prws/common/utils/SharedPreferencesUtil.java
File was created | 1 | package com.prws.common.utils; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.SharedPreferences; | ||
5 | import android.util.Log; | ||
6 | |||
7 | import com.google.gson.Gson; | ||
8 | import com.google.gson.JsonArray; | ||
9 | import com.google.gson.JsonElement; | ||
10 | import com.google.gson.JsonObject; | ||
11 | import com.google.gson.JsonParser; | ||
12 | |||
13 | import java.util.ArrayList; | ||
14 | import java.util.HashMap; | ||
15 | import java.util.List; | ||
16 | import java.util.Map; | ||
17 | import java.util.Set; | ||
18 | |||
19 | /** | ||
20 | * Description: This's SharedPreferencesUtil | ||
21 | * Time: 2018/7/10 15:05 | ||
22 | * | ||
23 | * @author lishiting | ||
24 | */ | ||
25 | public class SharedPreferencesUtil { | ||
26 | private static SharedPreferencesUtil util; | ||
27 | private static SharedPreferences sp; | ||
28 | |||
29 | private SharedPreferencesUtil(Context context, String name) { | ||
30 | sp = context.getSharedPreferences(name, Context.MODE_PRIVATE); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * 初始化SharedPreferencesUtil,只需要初始化一次,建议在Application中初始化 | ||
35 | * | ||
36 | * @param context 上下文对象 | ||
37 | * @param name SharedPreferences Name | ||
38 | */ | ||
39 | public static void getInstance(Context context, String name) { | ||
40 | if (util == null) { | ||
41 | util = new SharedPreferencesUtil(context, name); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * 保存数据到SharedPreferences | ||
47 | * | ||
48 | * @param key 键 | ||
49 | * @param value 需要保存的数据 | ||
50 | * @return 保存结果 | ||
51 | */ | ||
52 | public static boolean putData(String key, Object value) { | ||
53 | boolean result; | ||
54 | SharedPreferences.Editor editor = sp.edit(); | ||
55 | String type = value.getClass().getSimpleName(); | ||
56 | try { | ||
57 | switch (type) { | ||
58 | case "Boolean": | ||
59 | editor.putBoolean(key, (Boolean) value); | ||
60 | break; | ||
61 | case "Long": | ||
62 | editor.putLong(key, (Long) value); | ||
63 | break; | ||
64 | case "Float": | ||
65 | editor.putFloat(key, (Float) value); | ||
66 | break; | ||
67 | case "String": | ||
68 | editor.putString(key, (String) value); | ||
69 | break; | ||
70 | case "Integer": | ||
71 | editor.putInt(key, (Integer) value); | ||
72 | break; | ||
73 | default: | ||
74 | Gson gson = new Gson(); | ||
75 | String json = gson.toJson(value); | ||
76 | editor.putString(key, json); | ||
77 | break; | ||
78 | } | ||
79 | result = true; | ||
80 | } catch (Exception e) { | ||
81 | result = false; | ||
82 | e.printStackTrace(); | ||
83 | } | ||
84 | editor.apply(); | ||
85 | return result; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * 获取SharedPreferences中保存的数据 | ||
90 | * | ||
91 | * @param key 键 | ||
92 | * @param defaultValue 获取失败默认值 | ||
93 | * @return 从SharedPreferences读取的数据 | ||
94 | */ | ||
95 | public static Object getData(String key, Object defaultValue) { | ||
96 | Object result; | ||
97 | String type = defaultValue.getClass().getSimpleName(); | ||
98 | try { | ||
99 | switch (type) { | ||
100 | case "Boolean": | ||
101 | result = sp.getBoolean(key, (Boolean) defaultValue); | ||
102 | break; | ||
103 | case "Long": | ||
104 | result = sp.getLong(key, (Long) defaultValue); | ||
105 | break; | ||
106 | case "Float": | ||
107 | result = sp.getFloat(key, (Float) defaultValue); | ||
108 | break; | ||
109 | case "String": | ||
110 | result = sp.getString(key, (String) defaultValue); | ||
111 | break; | ||
112 | case "Integer": | ||
113 | result = sp.getInt(key, (Integer) defaultValue); | ||
114 | break; | ||
115 | default: | ||
116 | Gson gson = new Gson(); | ||
117 | String json = sp.getString(key, ""); | ||
118 | if (!json.equals("") && json.length() > 0) { | ||
119 | result = gson.fromJson(json, defaultValue.getClass()); | ||
120 | } else { | ||
121 | result = defaultValue; | ||
122 | } | ||
123 | break; | ||
124 | } | ||
125 | } catch (Exception e) { | ||
126 | result = null; | ||
127 | e.printStackTrace(); | ||
128 | } | ||
129 | return result; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * 用于保存集合 | ||
134 | * | ||
135 | * @param key key | ||
136 | * @param list 集合数据 | ||
137 | * @return 保存结果 | ||
138 | */ | ||
139 | public static <T> boolean putListData(String key, List<T> list) { | ||
140 | boolean result; | ||
141 | String type = list.get(0).getClass().getSimpleName(); | ||
142 | SharedPreferences.Editor editor = sp.edit(); | ||
143 | JsonArray array = new JsonArray(); | ||
144 | try { | ||
145 | switch (type) { | ||
146 | case "Boolean": | ||
147 | for (int i = 0; i < list.size(); i++) { | ||
148 | array.add((Boolean) list.get(i)); | ||
149 | } | ||
150 | break; | ||
151 | case "Long": | ||
152 | for (int i = 0; i < list.size(); i++) { | ||
153 | array.add((Long) list.get(i)); | ||
154 | } | ||
155 | break; | ||
156 | case "Float": | ||
157 | for (int i = 0; i < list.size(); i++) { | ||
158 | array.add((Float) list.get(i)); | ||
159 | } | ||
160 | break; | ||
161 | case "String": | ||
162 | for (int i = 0; i < list.size(); i++) { | ||
163 | array.add((String) list.get(i)); | ||
164 | } | ||
165 | break; | ||
166 | case "Integer": | ||
167 | for (int i = 0; i < list.size(); i++) { | ||
168 | array.add((Integer) list.get(i)); | ||
169 | } | ||
170 | break; | ||
171 | default: | ||
172 | Gson gson = new Gson(); | ||
173 | for (int i = 0; i < list.size(); i++) { | ||
174 | JsonElement obj = gson.toJsonTree(list.get(i)); | ||
175 | array.add(obj); | ||
176 | } | ||
177 | break; | ||
178 | } | ||
179 | editor.putString(key, array.toString()); | ||
180 | result = true; | ||
181 | } catch (Exception e) { | ||
182 | result = false; | ||
183 | e.printStackTrace(); | ||
184 | } | ||
185 | editor.apply(); | ||
186 | return result; | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * 获取保存的List | ||
191 | * | ||
192 | * @param key key | ||
193 | * @return 对应的Lis集合 | ||
194 | */ | ||
195 | public static <T> List<T> getListData(String key, Class<T> cls) { | ||
196 | List<T> list = new ArrayList<>(); | ||
197 | String json = sp.getString(key, ""); | ||
198 | if (!json.equals("") && json.length() > 0) { | ||
199 | Gson gson = new Gson(); | ||
200 | JsonArray array = new JsonParser().parse(json).getAsJsonArray(); | ||
201 | for (JsonElement elem : array) { | ||
202 | list.add(gson.fromJson(elem, cls)); | ||
203 | } | ||
204 | } | ||
205 | return list; | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * 获删除数据 | ||
210 | * | ||
211 | * @param key key | ||
212 | */ | ||
213 | public static void delData(String key) { | ||
214 | SharedPreferences.Editor editor = sp.edit(); | ||
215 | editor.remove(key); | ||
216 | editor.apply(); | ||
217 | } | ||
218 | |||
219 | |||
220 | /** | ||
221 | * 用于保存集合 | ||
222 | * | ||
223 | * @param key key | ||
224 | * @param map map数据 | ||
225 | * @return 保存结果 | ||
226 | */ | ||
227 | public static <K, V> boolean putHashMapData(String key, Map<K, V> map) { | ||
228 | boolean result; | ||
229 | SharedPreferences.Editor editor = sp.edit(); | ||
230 | try { | ||
231 | Gson gson = new Gson(); | ||
232 | String json = gson.toJson(map); | ||
233 | editor.putString(key, json); | ||
234 | result = true; | ||
235 | } catch (Exception e) { | ||
236 | result = false; | ||
237 | e.printStackTrace(); | ||
238 | } | ||
239 | editor.apply(); | ||
240 | return result; | ||
241 | } | ||
242 | |||
243 | /** | ||
244 | * 用于保存集合 | ||
245 | * | ||
246 | * @param key key | ||
247 | * @return HashMap | ||
248 | */ | ||
249 | public static <V> HashMap<String, V> getHashMapData(String key, Class<V> clsV) { | ||
250 | String json = sp.getString(key, ""); | ||
251 | HashMap<String, V> map = new HashMap<>(); | ||
252 | Gson gson = new Gson(); | ||
253 | JsonObject obj = new JsonParser().parse(json).getAsJsonObject(); | ||
254 | Set<Map.Entry<String, JsonElement>> entrySet = obj.entrySet(); | ||
255 | for (Map.Entry<String, JsonElement> entry : entrySet) { | ||
256 | String entryKey = entry.getKey(); | ||
257 | JsonObject value = (JsonObject) entry.getValue(); | ||
258 | map.put(entryKey, gson.fromJson(value, clsV)); | ||
259 | } | ||
260 | Log.e("SharedPreferencesUtil", obj.toString()); | ||
261 | return map; | ||
262 | |||
263 | } | ||
264 | |||
265 | } | ||
266 |
libs/common/src/main/java/com/prws/common/utils/acmanager/ActivityManager.java
File was created | 1 | package com.prws.common.utils.acmanager; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.Application; | ||
5 | import android.util.Log; | ||
6 | |||
7 | import java.util.ArrayList; | ||
8 | |||
9 | /** | ||
10 | * Created by developer on 2018/4/19. | ||
11 | */ | ||
12 | |||
13 | public class ActivityManager { | ||
14 | private static ActivityManager mInstance; | ||
15 | |||
16 | private final ArrayList<Activity> mActivityStack = new ArrayList<>(); | ||
17 | |||
18 | private ActivityManager() { | ||
19 | } | ||
20 | |||
21 | public static ActivityManager getInstance() { | ||
22 | synchronized (ActivityManager.class) { | ||
23 | if (mInstance == null) { | ||
24 | mInstance = new ActivityManager(); | ||
25 | } | ||
26 | } | ||
27 | return mInstance; | ||
28 | } | ||
29 | |||
30 | public void register(Application application, LifecycleCallbackImpl callback) { | ||
31 | application.registerActivityLifecycleCallbacks(callback.setListener(new LifecycleCallbackImpl.LifecycleListener() { | ||
32 | @Override | ||
33 | public void setBuriedPointMessage(String currentPath, String lastPath, long duration, long startTime) { | ||
34 | |||
35 | } | ||
36 | })); | ||
37 | } | ||
38 | |||
39 | public void register(Application application) { | ||
40 | register(application, new LifecycleCallbackImpl()); | ||
41 | } | ||
42 | |||
43 | public void addActivity(Activity activity) { | ||
44 | if (mActivityStack.size()>0 | ||
45 | && activity.getClass().getSimpleName().equals(mActivityStack.get(mActivityStack.size()-1).getClass().getSimpleName()))return; | ||
46 | mActivityStack.add(activity); | ||
47 | } | ||
48 | |||
49 | public void removeActivity(Activity activity) { | ||
50 | mActivityStack.remove(activity); | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * finish对应class的所有activity | ||
55 | * | ||
56 | * @param cls 要关闭的Activity Class | ||
57 | */ | ||
58 | public void finishActivity(Class<? extends Activity>... cls) { | ||
59 | for (int i = mActivityStack.size() - 1; i >= 0; i--) { | ||
60 | Activity activity = mActivityStack.get(i); | ||
61 | for (Class<? extends Activity> c : cls) { | ||
62 | if (c.getName().equals(activity.getClass().getName())) { | ||
63 | finishActivity(activity); | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | |||
70 | /** | ||
71 | * 关闭栈顶的Activity | ||
72 | */ | ||
73 | public void finishTopActivity() { | ||
74 | Activity pop = mActivityStack.get(mActivityStack.size()-1); | ||
75 | if (!pop.isFinishing()) { | ||
76 | pop.finish(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | |||
81 | /** | ||
82 | * finish除白名单以外的所有activity | ||
83 | * | ||
84 | * @param activityWhitelist 要保留的activity | ||
85 | */ | ||
86 | public void finishAllActivityByWhitelist(Class<? extends Activity>... activityWhitelist) { | ||
87 | for (int i = mActivityStack.size() - 1; i >= 0; i--) { | ||
88 | Activity activity = mActivityStack.get(i); | ||
89 | for (Class<? extends Activity> c : activityWhitelist) { | ||
90 | if (c.getName().equals(activity.getClass().getName())) { | ||
91 | break; | ||
92 | } else { | ||
93 | finishActivity(activity); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
101 | * finish所有activity | ||
102 | */ | ||
103 | public void finishAllActivity() { | ||
104 | for (int i = mActivityStack.size() - 1; i >= 0; i--) { | ||
105 | Activity activity = mActivityStack.get(i); | ||
106 | finishActivity(activity); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | |||
111 | private void finishActivity(Activity activity) { | ||
112 | if (activity != null) { | ||
113 | if (!activity.isFinishing()) { | ||
114 | activity.finish(); | ||
115 | mActivityStack.remove(activity); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | public ArrayList<Activity> getActivityStack() { | ||
121 | return mActivityStack; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * @param activity | ||
126 | * @return 是否存在此activity | ||
127 | */ | ||
128 | public boolean isContainsActivity(Activity activity) { | ||
129 | return mActivityStack.contains(activity); | ||
130 | } | ||
131 | |||
132 | |||
133 | public boolean isContainsActivity(String activityName) { | ||
134 | ArrayList<Activity> list = new ArrayList(mActivityStack); | ||
135 | for (Activity activity : list) { | ||
136 | if (activity.getClass().getSimpleName().equals(activityName)) { | ||
137 | return true; | ||
138 | } | ||
139 | } | ||
140 | return false; | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * @return 已经打开activity的数量 | ||
146 | */ | ||
147 | public int getActivityCount() { | ||
148 | return mActivityStack.size(); | ||
149 | } | ||
150 | |||
151 | |||
152 | /** | ||
153 | * 获取当前栈顶Activity | ||
154 | * | ||
155 | * @return 当前栈顶Activity | ||
156 | */ | ||
157 | public Activity getCurrentActivity() { | ||
158 | if (mActivityStack != null && getActivityCount() > 0) { | ||
159 | return mActivityStack.get(mActivityStack.size()-1); | ||
160 | } | ||
161 | return null; | ||
162 | } | ||
163 | |||
164 | public Activity getPreActivity(){ | ||
165 | if (mActivityStack != null && getActivityCount()>0){ | ||
166 | for (Activity ac:mActivityStack){ | ||
167 | Log.e("TAG","ac-->"+ac.getClass().getSimpleName()); | ||
168 | } | ||
169 | Activity activity1 = mActivityStack.get(mActivityStack.size()-1); | ||
170 | Log.e("TAG",activity1.getClass().getSimpleName()); | ||
171 | Activity activity = mActivityStack.get(mActivityStack.size()-2); | ||
172 | Log.e("TAG",activity.getClass().getSimpleName()); | ||
173 | return activity; | ||
174 | } | ||
175 | return null; | ||
176 | } | ||
177 | |||
178 | //当前Activity的上一个Activity,即是刚销毁的Activity | ||
179 | private Activity lastPreviousActivity; | ||
180 | |||
181 | public void setLastPreviousActivity(Activity lastPreviousActivity) { | ||
182 | this.lastPreviousActivity = lastPreviousActivity; | ||
183 | } | ||
184 | |||
185 | public Activity getLastPreviousActivity() { | ||
186 | return lastPreviousActivity; | ||
187 | } | ||
188 | |||
189 | |||
190 | } | ||
191 |
libs/common/src/main/java/com/prws/common/utils/acmanager/ActivityName.java
File was created | 1 | package com.prws.common.utils.acmanager; | |
2 | |||
3 | /** | ||
4 | * Created by developer on 2018/7/23. | ||
5 | */ | ||
6 | |||
7 | public class ActivityName { | ||
8 | |||
9 | private static ActivityName name; | ||
10 | |||
11 | private ActivityName() { | ||
12 | } | ||
13 | |||
14 | public static ActivityName getInstance() { | ||
15 | if (name == null) | ||
16 | name = new ActivityName(); | ||
17 | return name; | ||
18 | } | ||
19 | |||
20 | |||
21 | public String getBuriedPointName(String activityName){ | ||
22 | |||
23 | return activityName; | ||
24 | } | ||
25 | |||
26 | } | ||
27 |
libs/common/src/main/java/com/prws/common/utils/acmanager/LifecycleCallbackImpl.java
File was created | 1 | package com.prws.common.utils.acmanager; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.Application; | ||
5 | import android.os.Bundle; | ||
6 | |||
7 | /** | ||
8 | * Created by developer on 2018/4/19. | ||
9 | */ | ||
10 | |||
11 | public class LifecycleCallbackImpl implements Application.ActivityLifecycleCallbacks { | ||
12 | |||
13 | long startTime; | ||
14 | String currentActivity; | ||
15 | String lastActivity; | ||
16 | |||
17 | @Override | ||
18 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) { | ||
19 | ActivityManager.getInstance().addActivity(activity); | ||
20 | } | ||
21 | |||
22 | @Override | ||
23 | public void onActivityStarted(Activity activity) { | ||
24 | |||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public void onActivityResumed(Activity activity) { | ||
29 | currentActivity = ActivityName.getInstance().getBuriedPointName(activity.getClass().getSimpleName()); | ||
30 | startTime = System.currentTimeMillis(); | ||
31 | } | ||
32 | |||
33 | @Override | ||
34 | public void onActivityPaused(Activity activity) { | ||
35 | ActivityManager.getInstance().setLastPreviousActivity(activity); | ||
36 | if (currentActivity.equals(""))return; | ||
37 | long durationTime = System.currentTimeMillis() - startTime; | ||
38 | if (listener != null) | ||
39 | listener.setBuriedPointMessage(currentActivity,lastActivity,durationTime,startTime); | ||
40 | lastActivity = ActivityName.getInstance().getBuriedPointName(activity.getClass().getSimpleName()); | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public void onActivityStopped(Activity activity) { | ||
45 | |||
46 | } | ||
47 | |||
48 | @Override | ||
49 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { | ||
50 | |||
51 | } | ||
52 | |||
53 | @Override | ||
54 | public void onActivityDestroyed(Activity activity) { | ||
55 | ActivityManager.getInstance().removeActivity(activity); | ||
56 | } | ||
57 | private LifecycleListener listener; | ||
58 | public LifecycleCallbackImpl setListener(LifecycleListener lifecycleListener){ | ||
59 | this.listener = lifecycleListener; | ||
60 | return this; | ||
61 | } | ||
62 | |||
63 | public interface LifecycleListener{ | ||
64 | void setBuriedPointMessage(String currentPath,String lastPath,long duration,long startTime); | ||
65 | } | ||
66 | |||
67 | } | ||
68 |
libs/common/src/main/java/com/prws/common/utils/crash/ActivityKillerV15_V20.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.content.Intent; | ||
5 | import android.os.IBinder; | ||
6 | import android.os.Message; | ||
7 | |||
8 | import java.lang.reflect.Field; | ||
9 | import java.lang.reflect.Method; | ||
10 | |||
11 | /** | ||
12 | * Created by wanjian on 2018/5/24. | ||
13 | * <p> | ||
14 | */ | ||
15 | |||
16 | public class ActivityKillerV15_V20 implements IActivityKiller { | ||
17 | |||
18 | |||
19 | @Override | ||
20 | public void finishLaunchActivity(Message message) { | ||
21 | try { | ||
22 | Object activityClientRecord = message.obj; | ||
23 | |||
24 | Field tokenField = activityClientRecord.getClass().getDeclaredField("token"); | ||
25 | |||
26 | tokenField.setAccessible(true); | ||
27 | IBinder binder = (IBinder) tokenField.get(activityClientRecord); | ||
28 | finish(binder); | ||
29 | } catch (Exception e) { | ||
30 | e.printStackTrace(); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | |||
35 | @Override | ||
36 | public void finishResumeActivity(Message message) { | ||
37 | |||
38 | try { | ||
39 | finish((IBinder) message.obj); | ||
40 | } catch (Exception e) { | ||
41 | e.printStackTrace(); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | |||
46 | @Override | ||
47 | public void finishPauseActivity(Message message) { | ||
48 | |||
49 | try { | ||
50 | finish((IBinder) message.obj); | ||
51 | } catch (Exception e) { | ||
52 | e.printStackTrace(); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public void finishStopActivity(Message message) { | ||
58 | try { | ||
59 | finish((IBinder) message.obj); | ||
60 | } catch (Exception e) { | ||
61 | e.printStackTrace(); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | |||
66 | private void finish(IBinder binder) throws Exception { | ||
67 | |||
68 | Class activityManagerNativeClass = Class.forName("android.app.ActivityManagerNative"); | ||
69 | |||
70 | Method getDefaultMethod = activityManagerNativeClass.getDeclaredMethod("getDefault"); | ||
71 | |||
72 | Object activityManager = getDefaultMethod.invoke(null); | ||
73 | |||
74 | |||
75 | Method finishActivityMethod = activityManager.getClass().getDeclaredMethod("finishActivity", IBinder.class, int.class, Intent.class); | ||
76 | finishActivityMethod.invoke(activityManager, binder, Activity.RESULT_CANCELED, null); | ||
77 | |||
78 | } | ||
79 | |||
80 | } | ||
81 |
libs/common/src/main/java/com/prws/common/utils/crash/ActivityKillerV21_V23.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.content.Intent; | ||
5 | import android.os.IBinder; | ||
6 | import android.os.Message; | ||
7 | |||
8 | import java.lang.reflect.Field; | ||
9 | import java.lang.reflect.Method; | ||
10 | |||
11 | /** | ||
12 | * Created by wanjian on 2018/5/24. | ||
13 | * <p> | ||
14 | */ | ||
15 | |||
16 | public class ActivityKillerV21_V23 implements IActivityKiller { | ||
17 | |||
18 | |||
19 | @Override | ||
20 | public void finishLaunchActivity(Message message) { | ||
21 | try { | ||
22 | Object activityClientRecord = message.obj; | ||
23 | |||
24 | Field tokenField = activityClientRecord.getClass().getDeclaredField("token"); | ||
25 | |||
26 | tokenField.setAccessible(true); | ||
27 | IBinder binder = (IBinder) tokenField.get(activityClientRecord); | ||
28 | finish(binder); | ||
29 | } catch (Exception e) { | ||
30 | e.printStackTrace(); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | |||
35 | @Override | ||
36 | public void finishResumeActivity(Message message) { | ||
37 | |||
38 | try { | ||
39 | finish((IBinder) message.obj); | ||
40 | } catch (Exception e) { | ||
41 | e.printStackTrace(); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | |||
46 | @Override | ||
47 | public void finishPauseActivity(Message message) { | ||
48 | |||
49 | try { | ||
50 | finish((IBinder) message.obj); | ||
51 | } catch (Exception e) { | ||
52 | e.printStackTrace(); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | @Override | ||
57 | public void finishStopActivity(Message message) { | ||
58 | try { | ||
59 | finish((IBinder) message.obj); | ||
60 | } catch (Exception e) { | ||
61 | e.printStackTrace(); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | |||
66 | private void finish(IBinder binder) throws Exception { | ||
67 | |||
68 | Class activityManagerNativeClass = Class.forName("android.app.ActivityManagerNative"); | ||
69 | |||
70 | Method getDefaultMethod = activityManagerNativeClass.getDeclaredMethod("getDefault"); | ||
71 | |||
72 | Object activityManager = getDefaultMethod.invoke(null); | ||
73 | |||
74 | |||
75 | Method finishActivityMethod = activityManager.getClass().getDeclaredMethod("finishActivity", IBinder.class, int.class, Intent.class, boolean.class); | ||
76 | finishActivityMethod.invoke(activityManager, binder, Activity.RESULT_CANCELED, null, false); | ||
77 | |||
78 | } | ||
79 | |||
80 | } | ||
81 |
libs/common/src/main/java/com/prws/common/utils/crash/ActivityKillerV24_V25.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.content.Intent; | ||
5 | import android.os.IBinder; | ||
6 | import android.os.Message; | ||
7 | |||
8 | import java.lang.reflect.Field; | ||
9 | import java.lang.reflect.Method; | ||
10 | |||
11 | /** | ||
12 | * Created by wanjian on 2018/5/24. | ||
13 | * <p> | ||
14 | * android 7.1.1 | ||
15 | * <p> | ||
16 | * ActivityManagerNative.getDefault().finishActivity(mToken, resultCode, resultData, finishTask)) | ||
17 | */ | ||
18 | |||
19 | public class ActivityKillerV24_V25 implements IActivityKiller { | ||
20 | |||
21 | |||
22 | @Override | ||
23 | public void finishLaunchActivity(Message message) { | ||
24 | try { | ||
25 | Object activityClientRecord = message.obj; | ||
26 | |||
27 | Field tokenField = activityClientRecord.getClass().getDeclaredField("token"); | ||
28 | |||
29 | tokenField.setAccessible(true); | ||
30 | IBinder binder = (IBinder) tokenField.get(activityClientRecord); | ||
31 | finish(binder); | ||
32 | } catch (Exception e) { | ||
33 | e.printStackTrace(); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | |||
38 | @Override | ||
39 | public void finishResumeActivity(Message message) { | ||
40 | |||
41 | finishSomeArgs(message); | ||
42 | } | ||
43 | |||
44 | |||
45 | @Override | ||
46 | public void finishPauseActivity(Message message) { | ||
47 | |||
48 | finishSomeArgs(message); | ||
49 | } | ||
50 | |||
51 | @Override | ||
52 | public void finishStopActivity(Message message) { | ||
53 | finishSomeArgs(message); | ||
54 | } | ||
55 | |||
56 | |||
57 | private void finishSomeArgs(Message message) { | ||
58 | try { | ||
59 | Object someArgs = message.obj; | ||
60 | Field arg1Field = someArgs.getClass().getDeclaredField("arg1"); | ||
61 | arg1Field.setAccessible(true); | ||
62 | IBinder binder = (IBinder) arg1Field.get(someArgs); | ||
63 | finish(binder); | ||
64 | } catch (Throwable throwable) { | ||
65 | throwable.printStackTrace(); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | private void finish(IBinder binder) throws Exception { | ||
70 | |||
71 | /* | ||
72 | |||
73 | ActivityManagerNative.getDefault() | ||
74 | .finishActivity(r.token, Activity.RESULT_CANCELED, null, Activity.DONT_FINISH_TASK_WITH_ACTIVITY); | ||
75 | */ | ||
76 | Class activityManagerNativeClass = Class.forName("android.app.ActivityManagerNative"); | ||
77 | |||
78 | Method getDefaultMethod = activityManagerNativeClass.getDeclaredMethod("getDefault"); | ||
79 | |||
80 | Object activityManager = getDefaultMethod.invoke(null); | ||
81 | |||
82 | |||
83 | Method finishActivityMethod = activityManager.getClass().getDeclaredMethod("finishActivity", IBinder.class, int.class, Intent.class, int.class); | ||
84 | int DONT_FINISH_TASK_WITH_ACTIVITY = 0; | ||
85 | finishActivityMethod.invoke(activityManager, binder, Activity.RESULT_CANCELED, null, DONT_FINISH_TASK_WITH_ACTIVITY); | ||
86 | |||
87 | } | ||
88 | |||
89 | } | ||
90 |
libs/common/src/main/java/com/prws/common/utils/crash/ActivityKillerV26.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.ActivityManager; | ||
5 | import android.content.Intent; | ||
6 | import android.os.IBinder; | ||
7 | import android.os.Message; | ||
8 | |||
9 | import java.lang.reflect.Field; | ||
10 | import java.lang.reflect.Method; | ||
11 | |||
12 | /** | ||
13 | * Created by wanjian on 2018/5/24. | ||
14 | * <p> | ||
15 | * <p> | ||
16 | * handleDestroyActivity((IBinder)msg.obj, msg.arg1 != 0,msg.arg2, false); | ||
17 | * ActivityManager.getService().finishActivity(mToken, resultCode, resultData, finishTask) | ||
18 | */ | ||
19 | |||
20 | public class ActivityKillerV26 implements IActivityKiller { | ||
21 | |||
22 | |||
23 | @Override | ||
24 | public void finishLaunchActivity(Message message) { | ||
25 | try { | ||
26 | Object activityClientRecord = message.obj; | ||
27 | |||
28 | Field tokenField = activityClientRecord.getClass().getDeclaredField("token"); | ||
29 | |||
30 | tokenField.setAccessible(true); | ||
31 | IBinder binder = (IBinder) tokenField.get(activityClientRecord); | ||
32 | finish(binder); | ||
33 | } catch (Exception e) { | ||
34 | e.printStackTrace(); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | |||
39 | @Override | ||
40 | public void finishResumeActivity(Message message) { | ||
41 | |||
42 | finishSomeArgs(message); | ||
43 | } | ||
44 | |||
45 | |||
46 | @Override | ||
47 | public void finishPauseActivity(Message message) { | ||
48 | |||
49 | finishSomeArgs(message); | ||
50 | } | ||
51 | |||
52 | @Override | ||
53 | public void finishStopActivity(Message message) { | ||
54 | finishSomeArgs(message); | ||
55 | } | ||
56 | |||
57 | |||
58 | private void finishSomeArgs(Message message) { | ||
59 | try { | ||
60 | Object someArgs = message.obj; | ||
61 | Field arg1Field = someArgs.getClass().getDeclaredField("arg1"); | ||
62 | arg1Field.setAccessible(true); | ||
63 | IBinder binder = (IBinder) arg1Field.get(someArgs); | ||
64 | finish(binder); | ||
65 | } catch (Throwable throwable) { | ||
66 | throwable.printStackTrace(); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | private void finish(IBinder binder) throws Exception { | ||
71 | Method getServiceMethod = ActivityManager.class.getDeclaredMethod("getService"); | ||
72 | Object activityManager = getServiceMethod.invoke(null); | ||
73 | |||
74 | Method finishActivityMethod = activityManager.getClass().getDeclaredMethod("finishActivity", IBinder.class, int.class, Intent.class, int.class); | ||
75 | finishActivityMethod.setAccessible(true); | ||
76 | int DONT_FINISH_TASK_WITH_ACTIVITY = 0; | ||
77 | finishActivityMethod.invoke(activityManager, binder, Activity.RESULT_CANCELED, null, DONT_FINISH_TASK_WITH_ACTIVITY); | ||
78 | |||
79 | } | ||
80 | } | ||
81 |
libs/common/src/main/java/com/prws/common/utils/crash/ActivityKillerV28.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.ActivityManager; | ||
5 | |||
6 | import android.content.Intent; | ||
7 | import android.os.IBinder; | ||
8 | import android.os.Message; | ||
9 | |||
10 | |||
11 | import java.lang.reflect.Field; | ||
12 | import java.lang.reflect.Method; | ||
13 | |||
14 | |||
15 | public class ActivityKillerV28 implements IActivityKiller { | ||
16 | |||
17 | |||
18 | @Override | ||
19 | public void finishLaunchActivity(Message message) { | ||
20 | |||
21 | try { | ||
22 | tryFinish1(message); | ||
23 | return; | ||
24 | } catch (Throwable throwable) { | ||
25 | throwable.printStackTrace(); | ||
26 | } | ||
27 | |||
28 | try { | ||
29 | tryFinish2(message); | ||
30 | return; | ||
31 | } catch (Throwable throwable) { | ||
32 | throwable.printStackTrace(); | ||
33 | } | ||
34 | |||
35 | try { | ||
36 | tryFinish3(message); | ||
37 | return; | ||
38 | } catch (Throwable throwable) { | ||
39 | throwable.printStackTrace(); | ||
40 | } | ||
41 | |||
42 | } | ||
43 | |||
44 | private void tryFinish1(Message message) throws Throwable { | ||
45 | // ClientTransaction clientTransaction = (ClientTransaction) message.obj; | ||
46 | // IBinder binder = clientTransaction.getActivityToken(); | ||
47 | // finish(binder); | ||
48 | } | ||
49 | |||
50 | private void tryFinish3(Message message) throws Throwable { | ||
51 | Object clientTransaction = message.obj; | ||
52 | Field mActivityTokenField = clientTransaction.getClass().getDeclaredField("mActivityToken"); | ||
53 | IBinder binder = (IBinder) mActivityTokenField.get(clientTransaction); | ||
54 | finish(binder); | ||
55 | } | ||
56 | |||
57 | private void tryFinish2(Message message) throws Throwable { | ||
58 | Object clientTransaction = message.obj; | ||
59 | Method getActivityTokenMethod = clientTransaction.getClass().getDeclaredMethod("getActivityToken"); | ||
60 | IBinder binder = (IBinder) getActivityTokenMethod.invoke(clientTransaction); | ||
61 | finish(binder); | ||
62 | } | ||
63 | |||
64 | |||
65 | @Override | ||
66 | public void finishResumeActivity(Message message) { | ||
67 | |||
68 | } | ||
69 | |||
70 | |||
71 | @Override | ||
72 | public void finishPauseActivity(Message message) { | ||
73 | |||
74 | } | ||
75 | |||
76 | @Override | ||
77 | public void finishStopActivity(Message message) { | ||
78 | } | ||
79 | |||
80 | private void finish(IBinder binder) throws Exception { | ||
81 | Method getServiceMethod = ActivityManager.class.getDeclaredMethod("getService"); | ||
82 | Object activityManager = getServiceMethod.invoke(null); | ||
83 | |||
84 | Method finishActivityMethod = activityManager.getClass().getDeclaredMethod("finishActivity", IBinder.class, int.class, Intent.class, int.class); | ||
85 | finishActivityMethod.setAccessible(true); | ||
86 | int DONT_FINISH_TASK_WITH_ACTIVITY = 0; | ||
87 | finishActivityMethod.invoke(activityManager, binder, Activity.RESULT_CANCELED, null, DONT_FINISH_TASK_WITH_ACTIVITY); | ||
88 | |||
89 | } | ||
90 | } | ||
91 |
libs/common/src/main/java/com/prws/common/utils/crash/Cockroach.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.os.Build; | ||
5 | import android.os.Handler; | ||
6 | import android.os.Looper; | ||
7 | import android.os.Message; | ||
8 | |||
9 | |||
10 | |||
11 | import java.lang.reflect.Field; | ||
12 | |||
13 | |||
14 | |||
15 | /** | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | public final class Cockroach { | ||
20 | |||
21 | private static IActivityKiller sActivityKiller; | ||
22 | private static ExceptionHandler sExceptionHandler; | ||
23 | private static boolean sInstalled = false;//标记位,避免重复安装卸载 | ||
24 | private static boolean sIsSafeMode; | ||
25 | |||
26 | private Cockroach() { | ||
27 | } | ||
28 | |||
29 | public static void install(Context ctx, ExceptionHandler exceptionHandler) { | ||
30 | if (sInstalled) { | ||
31 | return; | ||
32 | } | ||
33 | try { | ||
34 | //解除 android P 反射限制 | ||
35 | // Reflection.unseal(ctx); | ||
36 | } catch (Throwable throwable) { | ||
37 | throwable.printStackTrace(); | ||
38 | } | ||
39 | sInstalled = true; | ||
40 | sExceptionHandler = exceptionHandler; | ||
41 | |||
42 | initActivityKiller(); | ||
43 | |||
44 | Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
45 | @Override | ||
46 | public void uncaughtException(Thread t, Throwable e) { | ||
47 | if (sExceptionHandler != null) { | ||
48 | sExceptionHandler.uncaughtExceptionHappened(t, e); | ||
49 | } | ||
50 | if (t == Looper.getMainLooper().getThread()) { | ||
51 | isChoreographerException(e); | ||
52 | safeMode(); | ||
53 | } | ||
54 | } | ||
55 | }); | ||
56 | |||
57 | } | ||
58 | |||
59 | /** | ||
60 | * 替换ActivityThread.mH.mCallback,实现拦截Activity生命周期,直接忽略生命周期的异常的话会导致黑屏,目前 | ||
61 | * 会调用ActivityManager的finishActivity结束掉生命周期抛出异常的Activity | ||
62 | */ | ||
63 | private static void initActivityKiller() { | ||
64 | //各版本android的ActivityManager获取方式,finishActivity的参数,token(binder对象)的获取不一样 | ||
65 | if (Build.VERSION.SDK_INT >= 28) { | ||
66 | sActivityKiller = new ActivityKillerV28(); | ||
67 | } else if (Build.VERSION.SDK_INT >= 26) { | ||
68 | sActivityKiller = new ActivityKillerV26(); | ||
69 | } else if (Build.VERSION.SDK_INT == 25 || Build.VERSION.SDK_INT == 24) { | ||
70 | sActivityKiller = new ActivityKillerV24_V25(); | ||
71 | } else if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT <= 23) { | ||
72 | sActivityKiller = new ActivityKillerV21_V23(); | ||
73 | } else if (Build.VERSION.SDK_INT >= 15 && Build.VERSION.SDK_INT <= 20) { | ||
74 | sActivityKiller = new ActivityKillerV15_V20(); | ||
75 | } else if (Build.VERSION.SDK_INT < 15) { | ||
76 | sActivityKiller = new ActivityKillerV15_V20(); | ||
77 | } | ||
78 | |||
79 | try { | ||
80 | hookmH(); | ||
81 | } catch (Throwable e) { | ||
82 | e.printStackTrace(); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | private static void hookmH() throws Exception { | ||
87 | |||
88 | final int LAUNCH_ACTIVITY = 100; | ||
89 | final int PAUSE_ACTIVITY = 101; | ||
90 | final int PAUSE_ACTIVITY_FINISHING = 102; | ||
91 | final int STOP_ACTIVITY_HIDE = 104; | ||
92 | final int RESUME_ACTIVITY = 107; | ||
93 | final int DESTROY_ACTIVITY = 109; | ||
94 | final int NEW_INTENT = 112; | ||
95 | final int RELAUNCH_ACTIVITY = 126; | ||
96 | Class activityThreadClass = Class.forName("android.app.ActivityThread"); | ||
97 | Object activityThread = activityThreadClass.getDeclaredMethod("currentActivityThread").invoke(null); | ||
98 | |||
99 | Field mhField = activityThreadClass.getDeclaredField("mH"); | ||
100 | mhField.setAccessible(true); | ||
101 | final Handler mhHandler = (Handler) mhField.get(activityThread); | ||
102 | Field callbackField = Handler.class.getDeclaredField("mCallback"); | ||
103 | callbackField.setAccessible(true); | ||
104 | callbackField.set(mhHandler, new Handler.Callback() { | ||
105 | @Override | ||
106 | public boolean handleMessage(Message msg) { | ||
107 | if (Build.VERSION.SDK_INT >= 28) {//android P 生命周期全部走这 | ||
108 | final int EXECUTE_TRANSACTION = 159; | ||
109 | if (msg.what == EXECUTE_TRANSACTION) { | ||
110 | try { | ||
111 | mhHandler.handleMessage(msg); | ||
112 | } catch (Throwable throwable) { | ||
113 | sActivityKiller.finishLaunchActivity(msg); | ||
114 | notifyException(throwable); | ||
115 | } | ||
116 | return true; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | switch (msg.what) { | ||
121 | case LAUNCH_ACTIVITY:// startActivity--> activity.attach activity.onCreate r.activity!=null activity.onStart activity.onResume | ||
122 | try { | ||
123 | mhHandler.handleMessage(msg); | ||
124 | } catch (Throwable throwable) { | ||
125 | sActivityKiller.finishLaunchActivity(msg); | ||
126 | notifyException(throwable); | ||
127 | } | ||
128 | return true; | ||
129 | case RESUME_ACTIVITY://回到activity onRestart onStart onResume | ||
130 | try { | ||
131 | mhHandler.handleMessage(msg); | ||
132 | } catch (Throwable throwable) { | ||
133 | sActivityKiller.finishResumeActivity(msg); | ||
134 | notifyException(throwable); | ||
135 | } | ||
136 | return true; | ||
137 | case PAUSE_ACTIVITY_FINISHING://按返回键 onPause | ||
138 | try { | ||
139 | mhHandler.handleMessage(msg); | ||
140 | } catch (Throwable throwable) { | ||
141 | sActivityKiller.finishPauseActivity(msg); | ||
142 | notifyException(throwable); | ||
143 | } | ||
144 | return true; | ||
145 | case PAUSE_ACTIVITY://开启新页面时,旧页面执行 activity.onPause | ||
146 | try { | ||
147 | mhHandler.handleMessage(msg); | ||
148 | } catch (Throwable throwable) { | ||
149 | sActivityKiller.finishPauseActivity(msg); | ||
150 | notifyException(throwable); | ||
151 | } | ||
152 | return true; | ||
153 | case STOP_ACTIVITY_HIDE://开启新页面时,旧页面执行 activity.onStop | ||
154 | try { | ||
155 | mhHandler.handleMessage(msg); | ||
156 | } catch (Throwable throwable) { | ||
157 | sActivityKiller.finishStopActivity(msg); | ||
158 | notifyException(throwable); | ||
159 | } | ||
160 | return true; | ||
161 | case DESTROY_ACTIVITY:// 关闭activity onStop onDestroy | ||
162 | try { | ||
163 | mhHandler.handleMessage(msg); | ||
164 | } catch (Throwable throwable) { | ||
165 | notifyException(throwable); | ||
166 | } | ||
167 | return true; | ||
168 | } | ||
169 | return false; | ||
170 | } | ||
171 | }); | ||
172 | } | ||
173 | |||
174 | |||
175 | private static void notifyException(Throwable throwable) { | ||
176 | if (sExceptionHandler == null) { | ||
177 | return; | ||
178 | } | ||
179 | if (isSafeMode()) { | ||
180 | sExceptionHandler.bandageExceptionHappened(throwable); | ||
181 | } else { | ||
182 | sExceptionHandler.uncaughtExceptionHappened(Looper.getMainLooper().getThread(), throwable); | ||
183 | safeMode(); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | public static boolean isSafeMode() { | ||
188 | return sIsSafeMode; | ||
189 | } | ||
190 | |||
191 | private static void safeMode() { | ||
192 | sIsSafeMode = true; | ||
193 | if (sExceptionHandler != null) { | ||
194 | sExceptionHandler.enterSafeMode(); | ||
195 | } | ||
196 | while (true) { | ||
197 | try { | ||
198 | Looper.loop(); | ||
199 | } catch (Throwable e) { | ||
200 | isChoreographerException(e); | ||
201 | if (sExceptionHandler != null) { | ||
202 | sExceptionHandler.bandageExceptionHappened(e); | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * view measure layout draw时抛出异常会导致Choreographer挂掉 | ||
210 | * <p> | ||
211 | * 建议直接杀死app。以后的版本会只关闭黑屏的Activity | ||
212 | * | ||
213 | * @param e | ||
214 | */ | ||
215 | private static void isChoreographerException(Throwable e) { | ||
216 | if (e == null || sExceptionHandler == null) { | ||
217 | return; | ||
218 | } | ||
219 | StackTraceElement[] elements = e.getStackTrace(); | ||
220 | if (elements == null) { | ||
221 | return; | ||
222 | } | ||
223 | |||
224 | for (int i = elements.length - 1; i > -1; i--) { | ||
225 | if (elements.length - i > 20) { | ||
226 | return; | ||
227 | } | ||
228 | StackTraceElement element = elements[i]; | ||
229 | if ("android.view.Choreographer".equals(element.getClassName()) | ||
230 | && "Choreographer.java".equals(element.getFileName()) | ||
231 | && "doFrame".equals(element.getMethodName())) { | ||
232 | sExceptionHandler.mayBeBlackScreen(e); | ||
233 | return; | ||
234 | } | ||
235 | |||
236 | } | ||
237 | } | ||
238 | |||
239 | |||
240 | } | ||
241 |
libs/common/src/main/java/com/prws/common/utils/crash/ExceptionHandler.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | /** | ||
4 | * Created by wanjian on 2018/5/29. | ||
5 | */ | ||
6 | |||
7 | public abstract class ExceptionHandler { | ||
8 | final void uncaughtExceptionHappened(Thread thread, Throwable throwable) { | ||
9 | try {//捕获监听中异常,防止使用方代码抛出异常时导致的反复调用 | ||
10 | onUncaughtExceptionHappened(thread, throwable); | ||
11 | } catch (Throwable t) { | ||
12 | t.printStackTrace(); | ||
13 | } | ||
14 | } | ||
15 | |||
16 | |||
17 | final void bandageExceptionHappened(Throwable throwable) { | ||
18 | try {//捕获监听中异常,防止使用方代码抛出异常时导致的反复调用 | ||
19 | onBandageExceptionHappened(throwable); | ||
20 | } catch (Throwable e) { | ||
21 | e.printStackTrace(); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | final void enterSafeMode() { | ||
26 | try { | ||
27 | onEnterSafeMode(); | ||
28 | } catch (Throwable throwable) { | ||
29 | throwable.printStackTrace(); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | final void mayBeBlackScreen(Throwable e) { | ||
34 | try { | ||
35 | onMayBeBlackScreen(e); | ||
36 | } catch (Throwable throwable) { | ||
37 | throwable.printStackTrace(); | ||
38 | } | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * 子线程抛出异常时始终调用该方法。主线程只有第一次抛出异常时才会调用该方法,该方法中到的throwable都会上报到bugly。以后主线程的异常只调用 {@link #onBandageExceptionHappened(Throwable)} | ||
43 | * | ||
44 | * @param thread | ||
45 | * @param throwable | ||
46 | */ | ||
47 | protected abstract void onUncaughtExceptionHappened(Thread thread, Throwable throwable); | ||
48 | |||
49 | /** | ||
50 | * 当原本导致app崩溃的主线程异常发生后,主线程再次抛出导致app崩溃异常时会调用该方法。(自己try catch住的异常不会导致app崩溃) | ||
51 | * (该方法中到的throwable不会上报到bugly,也无需上报到bugly,因为本次异常可能是由于第一次主线程异常时app没有崩溃掉才发生的,只要修复了bug就不会发生该异常了) | ||
52 | * | ||
53 | * @param throwable 主线程的异常 | ||
54 | */ | ||
55 | protected abstract void onBandageExceptionHappened(Throwable throwable); | ||
56 | |||
57 | protected abstract void onEnterSafeMode(); | ||
58 | |||
59 | protected void onMayBeBlackScreen(Throwable e) { | ||
60 | |||
61 | } | ||
62 | } | ||
63 |
libs/common/src/main/java/com/prws/common/utils/crash/IActivityKiller.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import android.os.Message; | ||
4 | |||
5 | /** | ||
6 | * Created by wanjian on 2018/5/24. | ||
7 | */ | ||
8 | |||
9 | public interface IActivityKiller { | ||
10 | |||
11 | void finishLaunchActivity(Message message); | ||
12 | |||
13 | void finishResumeActivity(Message message); | ||
14 | |||
15 | void finishPauseActivity(Message message); | ||
16 | |||
17 | void finishStopActivity(Message message); | ||
18 | |||
19 | |||
20 | } | ||
21 |
libs/common/src/main/java/com/prws/common/utils/crash/PositionUtils.java
File was created | 1 | package com.prws.common.utils.crash; | |
2 | |||
3 | import java.util.Map; | ||
4 | |||
5 | public class PositionUtils { | ||
6 | /** | ||
7 | * 计算A->B点的theta | ||
8 | * x轴正方向为0° 逆时针 | ||
9 | */ | ||
10 | public static Double calculateTheta(Double x1, Double y1, Double x2, Double y2) { | ||
11 | Double pi = Math.PI; | ||
12 | Double x = Math.abs(x1 - x2); | ||
13 | Double y = Math.abs(y1 - y2); | ||
14 | Double z = Math.sqrt(x * x + y * y); | ||
15 | Double t = 0.0; | ||
16 | |||
17 | if (x2 == x1) { | ||
18 | t = -pi / 2; | ||
19 | if (y2 == y1) { | ||
20 | t = 0.0; | ||
21 | } else if (y2 < y1) { | ||
22 | t = pi / 2; | ||
23 | } | ||
24 | } else if (x2 > x1 && y2 > y1) { | ||
25 | t = -Math.asin(y / z); | ||
26 | } else if (x2 > x1 && y2 < y1) { | ||
27 | t = Math.asin(y / z); | ||
28 | } else if (x2 < x1 && y2 < y1) { | ||
29 | t = Math.asin(x / z) + pi / 2; | ||
30 | } else if (x2 < x1 && y2 > y1) { | ||
31 | t = Math.asin(y / z) + pi; | ||
32 | } | ||
33 | return -t; | ||
34 | } | ||
35 | |||
36 | |||
37 | /** | ||
38 | * 从xy出发,方向是theta,距离是distance,计算终点坐标 | ||
39 | * | ||
40 | * @param x | ||
41 | * @param y | ||
42 | * @param theta | ||
43 | * @param distance | ||
44 | * @return x, y, theta | ||
45 | */ | ||
46 | public static Double[] calculateDestination(Double x, Double y, Double theta, Double distance) { | ||
47 | Double pi = Math.PI; | ||
48 | Double t = theta % (2 * pi); | ||
49 | |||
50 | Double deltay = 0.0; | ||
51 | Double deltax = 0.0; | ||
52 | if (t < 0) | ||
53 | t += 2 * pi; | ||
54 | |||
55 | Double[] a = {0.0, 0.0, 0.0}; | ||
56 | if (t > 0 && t < pi / 2) { | ||
57 | deltay = Math.sin(t) * distance; | ||
58 | deltax = Math.cos(t) * distance; | ||
59 | a[0] = x + deltax; | ||
60 | a[1] = y + deltay; | ||
61 | a[2] = calculateTheta(x, y, x + deltax, y + deltay); | ||
62 | |||
63 | } else if (t > pi / 2 && t < pi) { | ||
64 | deltay = Math.sin(pi - t) * distance; | ||
65 | deltax = Math.cos(pi - t) * distance; | ||
66 | a[0] = x - deltax; | ||
67 | a[1] = y + deltay; | ||
68 | a[2] = calculateTheta(x, y, x - deltax, y + deltay); | ||
69 | } else if (t > pi && t < pi * 1.5) { | ||
70 | deltay = Math.sin(t - pi) * distance; | ||
71 | deltax = Math.cos(t - pi) * distance; | ||
72 | a[0] = x - deltax; | ||
73 | a[1] = y - deltay; | ||
74 | a[2] = calculateTheta(x, y, x - deltax, y - deltay); | ||
75 | } else if (t > pi * 1.5 && pi < 2 * pi) { | ||
76 | deltay = Math.sin(2 * pi - t) * distance; | ||
77 | deltax = Math.cos(2 * pi - t) * distance; | ||
78 | a[0] = x + deltax; | ||
79 | a[1] = y - deltay; | ||
80 | a[2] = calculateTheta(x, y, x + deltax, y - deltay); | ||
81 | } | ||
82 | return a; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * 计算面积 | ||
87 | */ | ||
88 | public static Double calculateArea(Map<Integer, Double[]> map) { | ||
89 | Double a = 0.0; | ||
90 | for (int i = 1; i < map.size() + 1; i++) { | ||
91 | Integer j = i + 1; | ||
92 | if (j > map.size()) { | ||
93 | j = 1; | ||
94 | } | ||
95 | a += map.get(i)[0] * map.get(j)[1] - map.get(j)[0] * map.get(i)[1]; | ||
96 | } | ||
97 | return 0.5 * Math.abs(a); | ||
98 | } | ||
99 | |||
100 | public static String doubleArrToString(Double[] arr) { | ||
101 | String str = ""; | ||
102 | if (arr != null && arr.length > 0) { | ||
103 | for (Double d : arr) { | ||
104 | if (str.length() > 0) | ||
105 | str += ","; | ||
106 | str += String.format("%.2f", d); | ||
107 | } | ||
108 | } | ||
109 | return str; | ||
110 | } | ||
111 | } | ||
112 |
libs/common/src/main/java/com/prws/common/utils/dialog/PopupButtonListener.java
File was created | 1 | package com.prws.common.utils.dialog; | |
2 | |||
3 | public interface PopupButtonListener { | ||
4 | |||
5 | void onContinueClick(Object... object); | ||
6 | void onCancelClick(Object... object); | ||
7 | |||
8 | } | ||
9 |
libs/common/src/main/java/com/prws/common/view/DialogView.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.app.Dialog; | ||
4 | import android.content.Context; | ||
5 | import android.view.Window; | ||
6 | import android.view.WindowManager; | ||
7 | |||
8 | /** | ||
9 | * @author zhiqun.tang | ||
10 | * @Description: | ||
11 | * @date 2022/9/26 | ||
12 | */ | ||
13 | public class DialogView extends Dialog { | ||
14 | public DialogView(Context mContext, int layout, int style, int gravity) { | ||
15 | super(mContext, style); | ||
16 | setContentView(layout); | ||
17 | Window window = getWindow(); | ||
18 | WindowManager.LayoutParams layoutParams = window.getAttributes(); | ||
19 | layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; | ||
20 | layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; | ||
21 | layoutParams.gravity = gravity; | ||
22 | window.setAttributes(layoutParams); | ||
23 | } | ||
24 | } | ||
25 |
libs/common/src/main/java/com/prws/common/view/LabelsView.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.res.ColorStateList; | ||
5 | import android.content.res.TypedArray; | ||
6 | import android.graphics.Color; | ||
7 | import android.graphics.drawable.ColorDrawable; | ||
8 | import android.graphics.drawable.Drawable; | ||
9 | import android.os.Bundle; | ||
10 | import android.os.Parcelable; | ||
11 | import android.util.AttributeSet; | ||
12 | import android.util.TypedValue; | ||
13 | import android.view.Gravity; | ||
14 | import android.view.View; | ||
15 | import android.view.ViewGroup; | ||
16 | import android.widget.TextView; | ||
17 | |||
18 | import com.prws.common.R; | ||
19 | |||
20 | import java.util.ArrayList; | ||
21 | import java.util.List; | ||
22 | |||
23 | /** | ||
24 | * 标签view | ||
25 | */ | ||
26 | public class LabelsView extends ViewGroup implements View.OnClickListener, View.OnLongClickListener { | ||
27 | |||
28 | private Context mContext; | ||
29 | |||
30 | private ColorStateList mTextColor; | ||
31 | private float mTextSize; | ||
32 | private Drawable mLabelBg; | ||
33 | private int mLabelWidth = -2; | ||
34 | private int mLabelHeight = -2; | ||
35 | private int mLabelGravity = Gravity.CENTER; | ||
36 | private int mTextPaddingLeft; | ||
37 | private int mTextPaddingTop; | ||
38 | private int mTextPaddingRight; | ||
39 | private int mTextPaddingBottom; | ||
40 | private int mWordMargin; | ||
41 | private int mLineMargin; | ||
42 | private SelectType mSelectType; | ||
43 | private int mMaxSelect; | ||
44 | private int mMinSelect; | ||
45 | private int mMaxLines; | ||
46 | private int mMaxColumns; | ||
47 | private boolean isSingleLine = false; | ||
48 | private boolean isTextBold = false; | ||
49 | |||
50 | private boolean isIndicator; //只能看,不能手动改变选中状态。 | ||
51 | |||
52 | //用于保存label数据的key | ||
53 | private static final int KEY_DATA = R.id.tag_key_data; | ||
54 | //用于保存label位置的key | ||
55 | private static final int KEY_POSITION = R.id.tag_key_position; | ||
56 | |||
57 | private ArrayList<Object> mLabels = new ArrayList<>(); | ||
58 | //保存选中的label的位置 | ||
59 | private ArrayList<Integer> mSelectLabels = new ArrayList<>(); | ||
60 | |||
61 | //保存必选项。在多选模式下,可以设置必选项,必选项默认选中,不能反选 | ||
62 | private ArrayList<Integer> mCompulsorys = new ArrayList<>(); | ||
63 | |||
64 | //当前的label行数,需要在layout完成之后才知道的,调用的时候需要在对应方法之后在调用post()来获取 | ||
65 | private int mLines; | ||
66 | |||
67 | private OnLabelClickListener mLabelClickListener; | ||
68 | private OnLabelLongClickListener mLabelLongClickListener; | ||
69 | private OnLabelSelectChangeListener mLabelSelectChangeListener; | ||
70 | private OnSelectChangeIntercept mOnSelectChangeIntercept; | ||
71 | |||
72 | /** | ||
73 | * Label的选择类型 | ||
74 | */ | ||
75 | public enum SelectType { | ||
76 | //不可选中,也不响应选中事件回调。(默认) | ||
77 | NONE(1), | ||
78 | //单选,可以反选。 | ||
79 | SINGLE(2), | ||
80 | //单选,不可以反选。这种模式下,至少有一个是选中的,默认是第一个 | ||
81 | SINGLE_IRREVOCABLY(3), | ||
82 | //多选 | ||
83 | MULTI(4); | ||
84 | |||
85 | int value; | ||
86 | |||
87 | SelectType(int value) { | ||
88 | this.value = value; | ||
89 | } | ||
90 | |||
91 | static SelectType get(int value) { | ||
92 | switch (value) { | ||
93 | case 1: | ||
94 | return NONE; | ||
95 | case 2: | ||
96 | return SINGLE; | ||
97 | case 3: | ||
98 | return SINGLE_IRREVOCABLY; | ||
99 | case 4: | ||
100 | return MULTI; | ||
101 | } | ||
102 | return NONE; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | public LabelsView(Context context) { | ||
107 | super(context); | ||
108 | mContext = context; | ||
109 | showEditPreview(); | ||
110 | } | ||
111 | |||
112 | public LabelsView(Context context, AttributeSet attrs) { | ||
113 | super(context, attrs); | ||
114 | mContext = context; | ||
115 | getAttrs(context, attrs); | ||
116 | showEditPreview(); | ||
117 | } | ||
118 | |||
119 | public LabelsView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
120 | super(context, attrs, defStyleAttr); | ||
121 | mContext = context; | ||
122 | getAttrs(context, attrs); | ||
123 | showEditPreview(); | ||
124 | } | ||
125 | |||
126 | private void getAttrs(Context context, AttributeSet attrs) { | ||
127 | if (attrs != null) { | ||
128 | TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.LabelsView); | ||
129 | int type = mTypedArray.getInt(R.styleable.LabelsView_selectType, 1); | ||
130 | mSelectType = SelectType.get(type); | ||
131 | |||
132 | mMaxSelect = mTypedArray.getInteger(R.styleable.LabelsView_maxSelect, 0); | ||
133 | mMinSelect = mTypedArray.getInteger(R.styleable.LabelsView_minSelect, 0); | ||
134 | mMaxLines = mTypedArray.getInteger(R.styleable.LabelsView_maxLines, 0); | ||
135 | mMaxColumns = mTypedArray.getInteger(R.styleable.LabelsView_maxColumns, 0); | ||
136 | isIndicator = mTypedArray.getBoolean(R.styleable.LabelsView_isIndicator, false); | ||
137 | |||
138 | mLabelGravity = mTypedArray.getInt(R.styleable.LabelsView_labelGravity, mLabelGravity); | ||
139 | mLabelWidth = mTypedArray.getLayoutDimension(R.styleable.LabelsView_labelTextWidth, mLabelWidth); | ||
140 | mLabelHeight = mTypedArray.getLayoutDimension(R.styleable.LabelsView_labelTextHeight, mLabelHeight); | ||
141 | |||
142 | if (mTypedArray.hasValue(R.styleable.LabelsView_labelTextColor)) { | ||
143 | mTextColor = mTypedArray.getColorStateList(R.styleable.LabelsView_labelTextColor); | ||
144 | } else { | ||
145 | mTextColor = ColorStateList.valueOf(0xFF000000); | ||
146 | } | ||
147 | |||
148 | mTextSize = mTypedArray.getDimension(R.styleable.LabelsView_labelTextSize, | ||
149 | sp2px(14)); | ||
150 | if (mTypedArray.hasValue(R.styleable.LabelsView_labelTextPadding)) { | ||
151 | int textPadding = mTypedArray.getDimensionPixelOffset( | ||
152 | R.styleable.LabelsView_labelTextPadding, 0); | ||
153 | mTextPaddingLeft = mTextPaddingTop = mTextPaddingRight = mTextPaddingBottom = textPadding; | ||
154 | } else { | ||
155 | mTextPaddingLeft = mTypedArray.getDimensionPixelOffset( | ||
156 | R.styleable.LabelsView_labelTextPaddingLeft, dp2px(10)); | ||
157 | mTextPaddingTop = mTypedArray.getDimensionPixelOffset( | ||
158 | R.styleable.LabelsView_labelTextPaddingTop, dp2px(5)); | ||
159 | mTextPaddingRight = mTypedArray.getDimensionPixelOffset( | ||
160 | R.styleable.LabelsView_labelTextPaddingRight, dp2px(10)); | ||
161 | mTextPaddingBottom = mTypedArray.getDimensionPixelOffset( | ||
162 | R.styleable.LabelsView_labelTextPaddingBottom, dp2px(5)); | ||
163 | } | ||
164 | |||
165 | mLineMargin = mTypedArray.getDimensionPixelOffset(R.styleable.LabelsView_lineMargin, dp2px(5)); | ||
166 | mWordMargin = mTypedArray.getDimensionPixelOffset(R.styleable.LabelsView_wordMargin, dp2px(5)); | ||
167 | if (mTypedArray.hasValue(R.styleable.LabelsView_labelBackground)) { | ||
168 | int labelBgResId = mTypedArray.getResourceId(R.styleable.LabelsView_labelBackground, 0); | ||
169 | if (labelBgResId != 0) { | ||
170 | mLabelBg = getResources().getDrawable(labelBgResId); | ||
171 | } else { | ||
172 | int labelBgColor = mTypedArray.getColor(R.styleable.LabelsView_labelBackground, Color.TRANSPARENT); | ||
173 | mLabelBg = new ColorDrawable(labelBgColor); | ||
174 | } | ||
175 | } else { | ||
176 | mLabelBg = getResources().getDrawable(R.drawable.default_label_bg); | ||
177 | } | ||
178 | |||
179 | isSingleLine = mTypedArray.getBoolean(R.styleable.LabelsView_singleLine, false); | ||
180 | isTextBold = mTypedArray.getBoolean(R.styleable.LabelsView_isTextBold, false); | ||
181 | |||
182 | mTypedArray.recycle(); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * 编辑预览 | ||
188 | */ | ||
189 | private void showEditPreview() { | ||
190 | if (isInEditMode()) { | ||
191 | // 测试的数据 | ||
192 | ArrayList<String> label = new ArrayList<>(); | ||
193 | label.add("Label 1"); | ||
194 | label.add("Label 2"); | ||
195 | label.add("Label 3"); | ||
196 | label.add("Label 4"); | ||
197 | label.add("Label 5"); | ||
198 | label.add("Label 6"); | ||
199 | label.add("Label 7"); | ||
200 | setLabels(label); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | @Override | ||
205 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
206 | if (isSingleLine) { | ||
207 | measureSingleLine(widthMeasureSpec, heightMeasureSpec); | ||
208 | } else { | ||
209 | measureMultiLine(widthMeasureSpec, heightMeasureSpec); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * 测量单行模式 | ||
215 | * | ||
216 | * @param widthMeasureSpec | ||
217 | * @param heightMeasureSpec | ||
218 | */ | ||
219 | private void measureSingleLine(int widthMeasureSpec, int heightMeasureSpec) { | ||
220 | int count = getChildCount(); | ||
221 | int contentWidth = 0; //记录内容的宽度 | ||
222 | int maxItemHeight = 0; //记录一行中item高度最大的高度 | ||
223 | for (int i = 0; i < count; i++) { | ||
224 | if ((mMaxColumns > 0 && i == mMaxColumns)) { | ||
225 | break; | ||
226 | } | ||
227 | |||
228 | View view = getChildAt(i); | ||
229 | measureChild(view, widthMeasureSpec, heightMeasureSpec); | ||
230 | contentWidth += view.getMeasuredWidth(); | ||
231 | if (i != count - 1) { | ||
232 | contentWidth += mWordMargin; | ||
233 | } | ||
234 | maxItemHeight = Math.max(maxItemHeight, view.getMeasuredHeight()); | ||
235 | } | ||
236 | setMeasuredDimension(measureSize(widthMeasureSpec, contentWidth + getPaddingLeft() + getPaddingRight()), | ||
237 | measureSize(heightMeasureSpec, maxItemHeight + getPaddingTop() + getPaddingBottom())); | ||
238 | |||
239 | // 如果count等于0,没有标签,则lines为0 | ||
240 | mLines = count > 0 ? 1 : 0; | ||
241 | } | ||
242 | |||
243 | /** | ||
244 | * 测量多行模式 | ||
245 | * | ||
246 | * @param widthMeasureSpec | ||
247 | * @param heightMeasureSpec | ||
248 | */ | ||
249 | private void measureMultiLine(int widthMeasureSpec, int heightMeasureSpec) { | ||
250 | int count = getChildCount(); | ||
251 | int maxWidth = MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight(); | ||
252 | |||
253 | int contentHeight = 0; //记录内容的高度 | ||
254 | int lineWidth = 0; //记录行的宽度 | ||
255 | int maxLineWidth = 0; //记录最宽的行宽 | ||
256 | int maxItemHeight = 0; //记录一行中item高度最大的高度 | ||
257 | int lineCount = 1; | ||
258 | int columnsCount = 0; | ||
259 | |||
260 | for (int i = 0; i < count; i++) { | ||
261 | View view = getChildAt(i); | ||
262 | measureChild(view, widthMeasureSpec, heightMeasureSpec); | ||
263 | |||
264 | if ((lineWidth + view.getMeasuredWidth() > maxWidth) | ||
265 | || (mMaxColumns > 0 && columnsCount == mMaxColumns)) { | ||
266 | lineCount++; | ||
267 | if (mMaxLines > 0 && lineCount > mMaxLines) { | ||
268 | lineCount--; | ||
269 | break; | ||
270 | } | ||
271 | contentHeight += mLineMargin; | ||
272 | contentHeight += maxItemHeight; | ||
273 | maxItemHeight = 0; | ||
274 | maxLineWidth = Math.max(maxLineWidth, lineWidth); | ||
275 | lineWidth = 0; | ||
276 | columnsCount = 0; | ||
277 | } | ||
278 | |||
279 | lineWidth += view.getMeasuredWidth(); | ||
280 | columnsCount++; | ||
281 | maxItemHeight = Math.max(maxItemHeight, view.getMeasuredHeight()); | ||
282 | |||
283 | if (i != count - 1) { | ||
284 | if (lineWidth + mWordMargin > maxWidth) { | ||
285 | // 换行 | ||
286 | lineCount++; | ||
287 | if (mMaxLines > 0 && lineCount > mMaxLines) { | ||
288 | lineCount--; | ||
289 | break; | ||
290 | } | ||
291 | contentHeight += mLineMargin; | ||
292 | contentHeight += maxItemHeight; | ||
293 | maxItemHeight = 0; | ||
294 | maxLineWidth = Math.max(maxLineWidth, lineWidth); | ||
295 | lineWidth = 0; | ||
296 | columnsCount = 0; | ||
297 | } else { | ||
298 | lineWidth += mWordMargin; | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | contentHeight += maxItemHeight; | ||
303 | maxLineWidth = Math.max(maxLineWidth, lineWidth); | ||
304 | |||
305 | setMeasuredDimension(measureSize(widthMeasureSpec, maxLineWidth + getPaddingLeft() + getPaddingRight()), | ||
306 | measureSize(heightMeasureSpec, contentHeight + getPaddingTop() + getPaddingBottom())); | ||
307 | |||
308 | // 如果count等于0,没有标签,则lines为0 | ||
309 | mLines = count > 0 ? lineCount : 0; | ||
310 | } | ||
311 | |||
312 | private int measureSize(int measureSpec, int size) { | ||
313 | int result = 0; | ||
314 | int specMode = MeasureSpec.getMode(measureSpec); | ||
315 | int specSize = MeasureSpec.getSize(measureSpec); | ||
316 | |||
317 | if (specMode == MeasureSpec.EXACTLY) { | ||
318 | result = specSize; | ||
319 | } else { | ||
320 | result = size; | ||
321 | if (specMode == MeasureSpec.AT_MOST) { | ||
322 | result = Math.min(result, specSize); | ||
323 | } | ||
324 | } | ||
325 | result = Math.max(result, getSuggestedMinimumWidth()); | ||
326 | result = resolveSizeAndState(result, measureSpec, 0); | ||
327 | return result; | ||
328 | } | ||
329 | |||
330 | @Override | ||
331 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) { | ||
332 | int x = getPaddingLeft(); | ||
333 | int y = getPaddingTop(); | ||
334 | |||
335 | int contentWidth = right - left; | ||
336 | int maxItemHeight = 0; | ||
337 | int lineCount = 1; | ||
338 | int columnsCount = 0; | ||
339 | |||
340 | int count = getChildCount(); | ||
341 | for (int i = 0; i < count; i++) { | ||
342 | View view = getChildAt(i); | ||
343 | |||
344 | if (!isSingleLine && (contentWidth < x + view.getMeasuredWidth() + getPaddingRight() | ||
345 | || (mMaxColumns > 0 && columnsCount == mMaxColumns))) { | ||
346 | lineCount++; | ||
347 | if (mMaxLines > 0 && lineCount > mMaxLines) { | ||
348 | break; | ||
349 | } | ||
350 | x = getPaddingLeft(); | ||
351 | y += mLineMargin; | ||
352 | y += maxItemHeight; | ||
353 | maxItemHeight = 0; | ||
354 | columnsCount = 0; | ||
355 | } | ||
356 | |||
357 | if (isSingleLine && (mMaxColumns > 0 && columnsCount == mMaxColumns)){ | ||
358 | break; | ||
359 | } | ||
360 | |||
361 | view.layout(x, y, x + view.getMeasuredWidth(), y + view.getMeasuredHeight()); | ||
362 | x += view.getMeasuredWidth(); | ||
363 | x += mWordMargin; | ||
364 | maxItemHeight = Math.max(maxItemHeight, view.getMeasuredHeight()); | ||
365 | columnsCount++; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | /* 用于保存View的信息的key */ | ||
370 | private static final String KEY_SUPER_STATE = "key_super_state"; | ||
371 | private static final String KEY_TEXT_COLOR_STATE = "key_text_color_state"; | ||
372 | private static final String KEY_TEXT_SIZE_STATE = "key_text_size_state"; | ||
373 | private static final String KEY_BG_RES_ID_STATE = "key_bg_res_id_state"; | ||
374 | private static final String KEY_PADDING_STATE = "key_padding_state"; | ||
375 | private static final String KEY_WORD_MARGIN_STATE = "key_word_margin_state"; | ||
376 | private static final String KEY_LINE_MARGIN_STATE = "key_line_margin_state"; | ||
377 | private static final String KEY_SELECT_TYPE_STATE = "key_select_type_state"; | ||
378 | private static final String KEY_MAX_SELECT_STATE = "key_max_select_state"; | ||
379 | private static final String KEY_MIN_SELECT_STATE = "key_min_select_state"; | ||
380 | private static final String KEY_MAX_LINES_STATE = "key_max_lines_state"; | ||
381 | private static final String KEY_MAX_COLUMNS_STATE = "key_max_columns_state"; | ||
382 | private static final String KEY_INDICATOR_STATE = "key_indicator_state"; | ||
383 | // 由于新版(1.4.0)的标签列表允许设置任何类型的数据,而不仅仅是String。并且标签显示的内容 | ||
384 | // 最终由LabelTextProvider提供,所以LabelsView不再在onSaveInstanceState()和onRestoreInstanceState() | ||
385 | // 中保存和恢复标签列表的数据。 | ||
386 | private static final String KEY_LABELS_STATE = "key_labels_state"; | ||
387 | private static final String KEY_SELECT_LABELS_STATE = "key_select_labels_state"; | ||
388 | private static final String KEY_COMPULSORY_LABELS_STATE = "key_select_compulsory_state"; | ||
389 | private static final String KEY_LABEL_WIDTH_STATE = "key_label_width_state"; | ||
390 | private static final String KEY_LABEL_HEIGHT_STATE = "key_label_height_state"; | ||
391 | private static final String KEY_LABEL_GRAVITY_STATE = "key_label_gravity_state"; | ||
392 | private static final String KEY_SINGLE_LINE_STATE = "key_single_line_state"; | ||
393 | private static final String KEY_TEXT_STYLE_STATE = "key_text_style_state"; | ||
394 | |||
395 | @Override | ||
396 | protected Parcelable onSaveInstanceState() { | ||
397 | |||
398 | Bundle bundle = new Bundle(); | ||
399 | //保存父类的信息 | ||
400 | bundle.putParcelable(KEY_SUPER_STATE, super.onSaveInstanceState()); | ||
401 | //保存标签文字颜色 | ||
402 | if (mTextColor != null) { | ||
403 | bundle.putParcelable(KEY_TEXT_COLOR_STATE, mTextColor); | ||
404 | } | ||
405 | //保存标签文字大小 | ||
406 | bundle.putFloat(KEY_TEXT_SIZE_STATE, mTextSize); | ||
407 | //保存标签背景 (由于背景改用Drawable,所以不能自动保存和恢复) | ||
408 | // bundle.putInt(KEY_BG_RES_ID_STATE, mLabelBgResId); | ||
409 | //保存标签宽高 | ||
410 | bundle.putInt(KEY_LABEL_WIDTH_STATE, mLabelWidth); | ||
411 | bundle.putInt(KEY_LABEL_HEIGHT_STATE, mLabelHeight); | ||
412 | //保存标签方向 | ||
413 | bundle.putInt(KEY_LABEL_GRAVITY_STATE, mLabelGravity); | ||
414 | //保存标签内边距 | ||
415 | bundle.putIntArray(KEY_PADDING_STATE, new int[]{mTextPaddingLeft, mTextPaddingTop, | ||
416 | mTextPaddingRight, mTextPaddingBottom}); | ||
417 | //保存标签间隔 | ||
418 | bundle.putInt(KEY_WORD_MARGIN_STATE, mWordMargin); | ||
419 | //保存行间隔 | ||
420 | bundle.putInt(KEY_LINE_MARGIN_STATE, mLineMargin); | ||
421 | //保存标签的选择类型 | ||
422 | bundle.putInt(KEY_SELECT_TYPE_STATE, mSelectType.value); | ||
423 | //保存标签的最大选择数量 | ||
424 | bundle.putInt(KEY_MAX_SELECT_STATE, mMaxSelect); | ||
425 | //保存标签的最少选择数量 | ||
426 | bundle.putInt(KEY_MIN_SELECT_STATE, mMinSelect); | ||
427 | //保存标签的最大行数 | ||
428 | bundle.putInt(KEY_MAX_LINES_STATE, mMaxLines); | ||
429 | //保存标签的最大列数 | ||
430 | bundle.putInt(KEY_MAX_COLUMNS_STATE, mMaxColumns); | ||
431 | //保存是否是指示器模式 | ||
432 | bundle.putBoolean(KEY_INDICATOR_STATE, isIndicator); | ||
433 | |||
434 | //保存标签列表 | ||
435 | // if (!mLabels.isEmpty()) { | ||
436 | // bundle.putStringArrayList(KEY_LABELS_STATE, mLabels); | ||
437 | // } | ||
438 | //保存已选择的标签列表 | ||
439 | if (!mSelectLabels.isEmpty()) { | ||
440 | bundle.putIntegerArrayList(KEY_SELECT_LABELS_STATE, mSelectLabels); | ||
441 | } | ||
442 | |||
443 | //保存必选项列表 | ||
444 | if (!mCompulsorys.isEmpty()) { | ||
445 | bundle.putIntegerArrayList(KEY_COMPULSORY_LABELS_STATE, mCompulsorys); | ||
446 | } | ||
447 | |||
448 | bundle.putBoolean(KEY_SINGLE_LINE_STATE, isSingleLine); | ||
449 | bundle.putBoolean(KEY_TEXT_STYLE_STATE, isTextBold); | ||
450 | |||
451 | return bundle; | ||
452 | } | ||
453 | |||
454 | @Override | ||
455 | protected void onRestoreInstanceState(Parcelable state) { | ||
456 | if (state instanceof Bundle) { | ||
457 | Bundle bundle = (Bundle) state; | ||
458 | //恢复父类信息 | ||
459 | super.onRestoreInstanceState(bundle.getParcelable(KEY_SUPER_STATE)); | ||
460 | |||
461 | //恢复标签文字颜色 | ||
462 | ColorStateList color = bundle.getParcelable(KEY_TEXT_COLOR_STATE); | ||
463 | if (color != null) { | ||
464 | setLabelTextColor(color); | ||
465 | } | ||
466 | //恢复标签文字大小 | ||
467 | setLabelTextSize(bundle.getFloat(KEY_TEXT_SIZE_STATE, mTextSize)); | ||
468 | // //恢复标签背景 (由于背景改用Drawable,所以不能自动保存和恢复) | ||
469 | // int resId = bundle.getInt(KEY_BG_RES_ID_STATE, mLabelBgResId); | ||
470 | // if (resId != 0) { | ||
471 | // setLabelBackgroundResource(resId); | ||
472 | // } | ||
473 | //恢复标签宽高 | ||
474 | mLabelWidth = bundle.getInt(KEY_LABEL_WIDTH_STATE, mLabelWidth); | ||
475 | mLabelHeight = bundle.getInt(KEY_LABEL_HEIGHT_STATE, mLabelHeight); | ||
476 | //恢复标签方向 | ||
477 | setLabelGravity(bundle.getInt(KEY_LABEL_GRAVITY_STATE, mLabelGravity)); | ||
478 | //恢复标签内边距 | ||
479 | int[] padding = bundle.getIntArray(KEY_PADDING_STATE); | ||
480 | if (padding != null && padding.length == 4) { | ||
481 | setLabelTextPadding(padding[0], padding[1], padding[2], padding[3]); | ||
482 | } | ||
483 | //恢复标签间隔 | ||
484 | setWordMargin(bundle.getInt(KEY_WORD_MARGIN_STATE, mWordMargin)); | ||
485 | //恢复行间隔 | ||
486 | setLineMargin(bundle.getInt(KEY_LINE_MARGIN_STATE, mLineMargin)); | ||
487 | //恢复标签的选择类型 | ||
488 | setSelectType(SelectType.get(bundle.getInt(KEY_SELECT_TYPE_STATE, mSelectType.value))); | ||
489 | //恢复标签的最大选择数量 | ||
490 | setMaxSelect(bundle.getInt(KEY_MAX_SELECT_STATE, mMaxSelect)); | ||
491 | //恢复标签的最少选择数量 | ||
492 | setMinSelect(bundle.getInt(KEY_MIN_SELECT_STATE, mMinSelect)); | ||
493 | //恢复标签的最大行数 | ||
494 | setMaxLines(bundle.getInt(KEY_MAX_LINES_STATE, mMaxLines)); | ||
495 | //恢复标签的最大列数 | ||
496 | setMaxLines(bundle.getInt(KEY_MAX_COLUMNS_STATE, mMaxColumns)); | ||
497 | //恢复是否是指示器模式 | ||
498 | setIndicator(bundle.getBoolean(KEY_INDICATOR_STATE, isIndicator)); | ||
499 | |||
500 | setSingleLine(bundle.getBoolean(KEY_SINGLE_LINE_STATE, isSingleLine)); | ||
501 | setTextBold(bundle.getBoolean(KEY_TEXT_STYLE_STATE, isTextBold)); | ||
502 | |||
503 | // //恢复标签列表 | ||
504 | // ArrayList<String> labels = bundle.getStringArrayList(KEY_LABELS_STATE); | ||
505 | // if (labels != null && !labels.isEmpty()) { | ||
506 | // setLabels(labels); | ||
507 | // } | ||
508 | //恢复必选项列表 | ||
509 | ArrayList<Integer> compulsory = bundle.getIntegerArrayList(KEY_COMPULSORY_LABELS_STATE); | ||
510 | if (compulsory != null && !compulsory.isEmpty()) { | ||
511 | setCompulsorys(compulsory); | ||
512 | } | ||
513 | //恢复已选择的标签列表 | ||
514 | ArrayList<Integer> selectLabel = bundle.getIntegerArrayList(KEY_SELECT_LABELS_STATE); | ||
515 | if (selectLabel != null && !selectLabel.isEmpty()) { | ||
516 | int size = selectLabel.size(); | ||
517 | int[] positions = new int[size]; | ||
518 | for (int i = 0; i < size; i++) { | ||
519 | positions[i] = selectLabel.get(i); | ||
520 | } | ||
521 | setSelects(positions); | ||
522 | } | ||
523 | return; | ||
524 | } | ||
525 | super.onRestoreInstanceState(state); | ||
526 | } | ||
527 | |||
528 | /** | ||
529 | * 设置标签列表 | ||
530 | * | ||
531 | * @param labels | ||
532 | */ | ||
533 | public void setLabels(List<String> labels) { | ||
534 | setLabels(labels, new LabelTextProvider<String>() { | ||
535 | @Override | ||
536 | public CharSequence getLabelText(TextView label, int position, String data) { | ||
537 | return data.trim(); | ||
538 | } | ||
539 | }); | ||
540 | } | ||
541 | |||
542 | /** | ||
543 | * 设置标签列表,标签列表的数据可以是任何类型的数据,它最终显示的内容由LabelTextProvider根据标签的数据提供。 | ||
544 | * | ||
545 | * @param labels | ||
546 | * @param provider | ||
547 | * @param <T> | ||
548 | */ | ||
549 | public <T> void setLabels(List<T> labels, LabelTextProvider<T> provider) { | ||
550 | //清空原有的标签 | ||
551 | innerClearAllSelect(); | ||
552 | removeAllViews(); | ||
553 | mLabels.clear(); | ||
554 | |||
555 | if (labels != null) { | ||
556 | mLabels.addAll(labels); | ||
557 | int size = labels.size(); | ||
558 | for (int i = 0; i < size; i++) { | ||
559 | addLabel(labels.get(i), i, provider); | ||
560 | } | ||
561 | ensureLabelClickable(); | ||
562 | } | ||
563 | |||
564 | if (mSelectType == SelectType.SINGLE_IRREVOCABLY) { | ||
565 | setSelects(0); | ||
566 | } | ||
567 | } | ||
568 | |||
569 | /** | ||
570 | * 获取标签列表 | ||
571 | * | ||
572 | * @return | ||
573 | */ | ||
574 | public <T> List<T> getLabels() { | ||
575 | return (List<T>) mLabels; | ||
576 | } | ||
577 | |||
578 | private <T> void addLabel(T data, int position, LabelTextProvider<T> provider) { | ||
579 | final TextView label = new TextView(mContext); | ||
580 | label.setPadding(mTextPaddingLeft, mTextPaddingTop, mTextPaddingRight, mTextPaddingBottom); | ||
581 | label.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); | ||
582 | label.setGravity(mLabelGravity); | ||
583 | label.setTextColor(mTextColor); | ||
584 | //设置给label的背景(Drawable)是一个Drawable对象的拷贝, | ||
585 | // 因为如果所有的标签都共用一个Drawable对象,会引起背景错乱。 | ||
586 | label.setBackgroundDrawable(mLabelBg.getConstantState().newDrawable()); | ||
587 | //label通过tag保存自己的数据(data)和位置(position) | ||
588 | label.setTag(KEY_DATA, data); | ||
589 | label.setTag(KEY_POSITION, position); | ||
590 | label.setOnClickListener(this); | ||
591 | label.setOnLongClickListener(this); | ||
592 | label.getPaint().setFakeBoldText(isTextBold); | ||
593 | addView(label, mLabelWidth, mLabelHeight); | ||
594 | label.setText(provider.getLabelText(label, position, data)); | ||
595 | } | ||
596 | |||
597 | /** | ||
598 | * 确保标签是否能响应事件,如果标签可选或者标签设置了点击事件监听,则响应事件。 | ||
599 | */ | ||
600 | private void ensureLabelClickable() { | ||
601 | int count = getChildCount(); | ||
602 | for (int i = 0; i < count; i++) { | ||
603 | TextView label = (TextView) getChildAt(i); | ||
604 | label.setClickable(mLabelClickListener != null || mLabelLongClickListener != null || mSelectType != SelectType.NONE); | ||
605 | } | ||
606 | } | ||
607 | |||
608 | @Override | ||
609 | public void onClick(View v) { | ||
610 | if (v instanceof TextView) { | ||
611 | TextView label = (TextView) v; | ||
612 | if (!isIndicator) { | ||
613 | if (mSelectType != SelectType.NONE) { | ||
614 | if (label.isSelected()) { | ||
615 | boolean irrevocable = mSelectType == SelectType.MULTI && mCompulsorys.contains((Integer) label.getTag(KEY_POSITION)); | ||
616 | irrevocable = irrevocable || (mSelectType == SelectType.MULTI && mSelectLabels.size() <= mMinSelect); | ||
617 | irrevocable = irrevocable || mSelectType == SelectType.SINGLE_IRREVOCABLY; | ||
618 | if (!irrevocable && !selectChangeIntercept(label)) { | ||
619 | setLabelSelect(label, false); | ||
620 | } | ||
621 | } else { | ||
622 | if (mSelectType == SelectType.SINGLE || mSelectType == SelectType.SINGLE_IRREVOCABLY) { | ||
623 | if (!selectChangeIntercept(label)) { | ||
624 | innerClearAllSelect(); | ||
625 | setLabelSelect(label, true); | ||
626 | } | ||
627 | } else if (mSelectType == SelectType.MULTI | ||
628 | && (mMaxSelect <= 0 || mMaxSelect > mSelectLabels.size())) { | ||
629 | if (!selectChangeIntercept(label)) { | ||
630 | setLabelSelect(label, true); | ||
631 | } | ||
632 | } | ||
633 | } | ||
634 | } | ||
635 | } | ||
636 | |||
637 | if (mLabelClickListener != null) { | ||
638 | mLabelClickListener.onLabelClick(label, label.getTag(KEY_DATA), (int) label.getTag(KEY_POSITION)); | ||
639 | } | ||
640 | } | ||
641 | } | ||
642 | |||
643 | @Override | ||
644 | public boolean onLongClick(View v) { | ||
645 | if (v instanceof TextView) { | ||
646 | TextView label = (TextView) v; | ||
647 | if (mLabelLongClickListener != null) { | ||
648 | return mLabelLongClickListener.onLabelLongClick(label, label.getTag(KEY_DATA), (int) label.getTag(KEY_POSITION)); | ||
649 | } | ||
650 | } | ||
651 | |||
652 | return false; | ||
653 | } | ||
654 | |||
655 | private void setLabelSelect(TextView label, boolean isSelect) { | ||
656 | if (label.isSelected() != isSelect) { | ||
657 | label.setSelected(isSelect); | ||
658 | if (isSelect) { | ||
659 | mSelectLabels.add((Integer) label.getTag(KEY_POSITION)); | ||
660 | } else { | ||
661 | mSelectLabels.remove((Integer) label.getTag(KEY_POSITION)); | ||
662 | } | ||
663 | if (mLabelSelectChangeListener != null) { | ||
664 | mLabelSelectChangeListener.onLabelSelectChange(label, label.getTag(KEY_DATA), | ||
665 | isSelect, (int) label.getTag(KEY_POSITION)); | ||
666 | } | ||
667 | } | ||
668 | } | ||
669 | |||
670 | private boolean selectChangeIntercept(TextView label) { | ||
671 | return mOnSelectChangeIntercept != null && mOnSelectChangeIntercept.onIntercept(label, | ||
672 | label.getTag(KEY_DATA), label.isSelected(), !label.isSelected(), | ||
673 | (int) label.getTag(KEY_POSITION)); | ||
674 | } | ||
675 | |||
676 | /** | ||
677 | * 取消所有选中的label | ||
678 | */ | ||
679 | public void clearAllSelect() { | ||
680 | if (mSelectType != SelectType.SINGLE_IRREVOCABLY) { | ||
681 | if (mSelectType == SelectType.MULTI && !mCompulsorys.isEmpty()) { | ||
682 | clearNotCompulsorySelect(); | ||
683 | } else { | ||
684 | innerClearAllSelect(); | ||
685 | } | ||
686 | } | ||
687 | } | ||
688 | |||
689 | private void innerClearAllSelect() { | ||
690 | int count = getChildCount(); | ||
691 | for (int i = 0; i < count; i++) { | ||
692 | setLabelSelect((TextView) getChildAt(i), false); | ||
693 | } | ||
694 | mSelectLabels.clear(); | ||
695 | } | ||
696 | |||
697 | private void clearNotCompulsorySelect() { | ||
698 | int count = getChildCount(); | ||
699 | List<Integer> temps = new ArrayList<>(); | ||
700 | for (int i = 0; i < count; i++) { | ||
701 | if (!mCompulsorys.contains(i)) { | ||
702 | setLabelSelect((TextView) getChildAt(i), false); | ||
703 | temps.add(i); | ||
704 | } | ||
705 | |||
706 | } | ||
707 | mSelectLabels.removeAll(temps); | ||
708 | } | ||
709 | |||
710 | /** | ||
711 | * 设置选中label | ||
712 | * | ||
713 | * @param positions | ||
714 | */ | ||
715 | public void setSelects(List<Integer> positions) { | ||
716 | if (positions != null) { | ||
717 | int size = positions.size(); | ||
718 | int[] ps = new int[size]; | ||
719 | for (int i = 0; i < size; i++) { | ||
720 | ps[i] = positions.get(i); | ||
721 | } | ||
722 | setSelects(ps); | ||
723 | } | ||
724 | } | ||
725 | |||
726 | /** | ||
727 | * 设置选中label | ||
728 | * | ||
729 | * @param positions | ||
730 | */ | ||
731 | public void setSelects(int... positions) { | ||
732 | if (mSelectType != SelectType.NONE) { | ||
733 | ArrayList<TextView> selectLabels = new ArrayList<>(); | ||
734 | int count = getChildCount(); | ||
735 | int size = mSelectType == SelectType.SINGLE || mSelectType == SelectType.SINGLE_IRREVOCABLY | ||
736 | ? 1 : mMaxSelect; | ||
737 | for (int p : positions) { | ||
738 | if (p < count) { | ||
739 | TextView label = (TextView) getChildAt(p); | ||
740 | if (!selectLabels.contains(label)) { | ||
741 | setLabelSelect(label, true); | ||
742 | selectLabels.add(label); | ||
743 | } | ||
744 | if (size > 0 && selectLabels.size() == size) { | ||
745 | break; | ||
746 | } | ||
747 | } | ||
748 | } | ||
749 | |||
750 | for (int i = 0; i < count; i++) { | ||
751 | TextView label = (TextView) getChildAt(i); | ||
752 | if (!selectLabels.contains(label)) { | ||
753 | setLabelSelect(label, false); | ||
754 | } | ||
755 | } | ||
756 | } | ||
757 | } | ||
758 | |||
759 | /** | ||
760 | * 设置必选项,只有在多项模式下,这个方法才有效 | ||
761 | * | ||
762 | * @param positions | ||
763 | */ | ||
764 | public void setCompulsorys(List<Integer> positions) { | ||
765 | if (mSelectType == SelectType.MULTI && positions != null) { | ||
766 | mCompulsorys.clear(); | ||
767 | mCompulsorys.addAll(positions); | ||
768 | //必选项发生改变,就要恢复到初始状态。 | ||
769 | innerClearAllSelect(); | ||
770 | setSelects(positions); | ||
771 | } | ||
772 | } | ||
773 | |||
774 | /** | ||
775 | * 设置必选项,只有在多项模式下,这个方法才有效 | ||
776 | * | ||
777 | * @param positions | ||
778 | */ | ||
779 | public void setCompulsorys(int... positions) { | ||
780 | if (mSelectType == SelectType.MULTI && positions != null) { | ||
781 | List<Integer> ps = new ArrayList<>(positions.length); | ||
782 | for (int i : positions) { | ||
783 | ps.add(i); | ||
784 | } | ||
785 | setCompulsorys(ps); | ||
786 | } | ||
787 | } | ||
788 | |||
789 | /** | ||
790 | * 获取必选项, | ||
791 | * | ||
792 | * @return | ||
793 | */ | ||
794 | public List<Integer> getCompulsorys() { | ||
795 | return mCompulsorys; | ||
796 | } | ||
797 | |||
798 | /** | ||
799 | * 清空必选项,只有在多项模式下,这个方法才有效 | ||
800 | */ | ||
801 | public void clearCompulsorys() { | ||
802 | if (mSelectType == SelectType.MULTI && !mCompulsorys.isEmpty()) { | ||
803 | mCompulsorys.clear(); | ||
804 | //必选项发生改变,就要恢复到初始状态。 | ||
805 | innerClearAllSelect(); | ||
806 | } | ||
807 | } | ||
808 | |||
809 | /** | ||
810 | * 获取选中的label(返回的是所有选中的标签的位置) | ||
811 | * | ||
812 | * @return | ||
813 | */ | ||
814 | public List<Integer> getSelectLabels() { | ||
815 | // 返回新的List对象,避免外部获取mSelectLabels后直接操作数据 | ||
816 | List<Integer> list = new ArrayList<>(); | ||
817 | list.addAll(mSelectLabels); | ||
818 | return list; | ||
819 | } | ||
820 | |||
821 | /** | ||
822 | * 获取选中的label(返回的是所头选中的标签的数据) | ||
823 | * | ||
824 | * @param <T> | ||
825 | * @return | ||
826 | */ | ||
827 | public <T> List<T> getSelectLabelDatas() { | ||
828 | List<T> list = new ArrayList<>(); | ||
829 | int size = mSelectLabels.size(); | ||
830 | for (int i = 0; i < size; i++) { | ||
831 | View label = getChildAt(mSelectLabels.get(i)); | ||
832 | Object data = label.getTag(KEY_DATA); | ||
833 | if (data != null) { | ||
834 | list.add((T) data); | ||
835 | } | ||
836 | } | ||
837 | return list; | ||
838 | } | ||
839 | |||
840 | /** | ||
841 | * 设置标签背景 | ||
842 | * | ||
843 | * @param resId | ||
844 | */ | ||
845 | public void setLabelBackgroundResource(int resId) { | ||
846 | setLabelBackgroundDrawable(getResources().getDrawable(resId)); | ||
847 | } | ||
848 | |||
849 | /** | ||
850 | * 设置标签背景 | ||
851 | * | ||
852 | * @param color | ||
853 | */ | ||
854 | public void setLabelBackgroundColor(int color) { | ||
855 | setLabelBackgroundDrawable(new ColorDrawable(color)); | ||
856 | } | ||
857 | |||
858 | /** | ||
859 | * 设置标签背景 | ||
860 | * | ||
861 | * @param drawable | ||
862 | */ | ||
863 | public void setLabelBackgroundDrawable(Drawable drawable) { | ||
864 | mLabelBg = drawable; | ||
865 | int count = getChildCount(); | ||
866 | for (int i = 0; i < count; i++) { | ||
867 | TextView label = (TextView) getChildAt(i); | ||
868 | label.setBackgroundDrawable(mLabelBg.getConstantState().newDrawable()); | ||
869 | } | ||
870 | } | ||
871 | |||
872 | /** | ||
873 | * 设置标签内边距 | ||
874 | * | ||
875 | * @param left | ||
876 | * @param top | ||
877 | * @param right | ||
878 | * @param bottom | ||
879 | */ | ||
880 | public void setLabelTextPadding(int left, int top, int right, int bottom) { | ||
881 | if (mTextPaddingLeft != left || mTextPaddingTop != top | ||
882 | || mTextPaddingRight != right || mTextPaddingBottom != bottom) { | ||
883 | mTextPaddingLeft = left; | ||
884 | mTextPaddingTop = top; | ||
885 | mTextPaddingRight = right; | ||
886 | mTextPaddingBottom = bottom; | ||
887 | int count = getChildCount(); | ||
888 | for (int i = 0; i < count; i++) { | ||
889 | TextView label = (TextView) getChildAt(i); | ||
890 | label.setPadding(left, top, right, bottom); | ||
891 | } | ||
892 | } | ||
893 | } | ||
894 | |||
895 | public int getTextPaddingLeft() { | ||
896 | return mTextPaddingLeft; | ||
897 | } | ||
898 | |||
899 | public int getTextPaddingTop() { | ||
900 | return mTextPaddingTop; | ||
901 | } | ||
902 | |||
903 | public int getTextPaddingRight() { | ||
904 | return mTextPaddingRight; | ||
905 | } | ||
906 | |||
907 | public int getTextPaddingBottom() { | ||
908 | return mTextPaddingBottom; | ||
909 | } | ||
910 | |||
911 | /** | ||
912 | * 设置标签的文字大小(单位是px) | ||
913 | * | ||
914 | * @param size | ||
915 | */ | ||
916 | public void setLabelTextSize(float size) { | ||
917 | if (mTextSize != size) { | ||
918 | mTextSize = size; | ||
919 | int count = getChildCount(); | ||
920 | for (int i = 0; i < count; i++) { | ||
921 | TextView label = (TextView) getChildAt(i); | ||
922 | label.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); | ||
923 | } | ||
924 | } | ||
925 | } | ||
926 | |||
927 | public float getLabelTextSize() { | ||
928 | return mTextSize; | ||
929 | } | ||
930 | |||
931 | /** | ||
932 | * 设置标签的文字颜色 | ||
933 | * | ||
934 | * @param color | ||
935 | */ | ||
936 | public void setLabelTextColor(int color) { | ||
937 | setLabelTextColor(ColorStateList.valueOf(color)); | ||
938 | } | ||
939 | |||
940 | /** | ||
941 | * 设置标签的文字颜色 | ||
942 | * | ||
943 | * @param color | ||
944 | */ | ||
945 | public void setLabelTextColor(ColorStateList color) { | ||
946 | mTextColor = color; | ||
947 | int count = getChildCount(); | ||
948 | for (int i = 0; i < count; i++) { | ||
949 | TextView label = (TextView) getChildAt(i); | ||
950 | label.setTextColor(mTextColor); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | public ColorStateList getLabelTextColor() { | ||
955 | return mTextColor; | ||
956 | } | ||
957 | |||
958 | /** | ||
959 | * 设置标签显示方向 | ||
960 | * | ||
961 | * @param gravity | ||
962 | */ | ||
963 | public void setLabelGravity(int gravity) { | ||
964 | if (mLabelGravity != gravity) { | ||
965 | mLabelGravity = gravity; | ||
966 | int count = getChildCount(); | ||
967 | for (int i = 0; i < count; i++) { | ||
968 | TextView label = (TextView) getChildAt(i); | ||
969 | label.setGravity(gravity); | ||
970 | } | ||
971 | } | ||
972 | } | ||
973 | |||
974 | public int getLabelGravity() { | ||
975 | return mLabelGravity; | ||
976 | } | ||
977 | |||
978 | /** | ||
979 | * 设置标签字体是否为粗体 | ||
980 | * | ||
981 | * @param isBold | ||
982 | */ | ||
983 | public void setTextBold(boolean isBold) { | ||
984 | if (this.isTextBold != isBold) { | ||
985 | this.isTextBold = isBold; | ||
986 | int count = getChildCount(); | ||
987 | for (int i = 0; i < count; i++) { | ||
988 | TextView label = (TextView) getChildAt(i); | ||
989 | label.getPaint().setFakeBoldText(isTextBold); | ||
990 | label.invalidate(); | ||
991 | } | ||
992 | } | ||
993 | } | ||
994 | |||
995 | public boolean isTextBold() { | ||
996 | return isTextBold; | ||
997 | } | ||
998 | |||
999 | /** | ||
1000 | * 设置行间隔 | ||
1001 | */ | ||
1002 | public void setLineMargin(int margin) { | ||
1003 | if (mLineMargin != margin) { | ||
1004 | mLineMargin = margin; | ||
1005 | requestLayout(); | ||
1006 | } | ||
1007 | } | ||
1008 | |||
1009 | public int getLineMargin() { | ||
1010 | return mLineMargin; | ||
1011 | } | ||
1012 | |||
1013 | /** | ||
1014 | * 设置标签的间隔 | ||
1015 | */ | ||
1016 | public void setWordMargin(int margin) { | ||
1017 | if (mWordMargin != margin) { | ||
1018 | mWordMargin = margin; | ||
1019 | requestLayout(); | ||
1020 | } | ||
1021 | } | ||
1022 | |||
1023 | public int getWordMargin() { | ||
1024 | return mWordMargin; | ||
1025 | } | ||
1026 | |||
1027 | /** | ||
1028 | * 设置标签的选择类型 | ||
1029 | * | ||
1030 | * @param selectType | ||
1031 | */ | ||
1032 | public void setSelectType(SelectType selectType) { | ||
1033 | if (mSelectType != selectType) { | ||
1034 | mSelectType = selectType; | ||
1035 | //选择类型发生改变,就要恢复到初始状态。 | ||
1036 | innerClearAllSelect(); | ||
1037 | |||
1038 | if (mSelectType == SelectType.SINGLE_IRREVOCABLY) { | ||
1039 | setSelects(0); | ||
1040 | } | ||
1041 | |||
1042 | if (mSelectType != SelectType.MULTI) { | ||
1043 | mCompulsorys.clear(); | ||
1044 | } | ||
1045 | |||
1046 | ensureLabelClickable(); | ||
1047 | } | ||
1048 | } | ||
1049 | |||
1050 | public SelectType getSelectType() { | ||
1051 | return mSelectType; | ||
1052 | } | ||
1053 | |||
1054 | /** | ||
1055 | * 设置最大的选择数量,只有selectType等于MULTI时有效。 | ||
1056 | * | ||
1057 | * @param maxSelect | ||
1058 | */ | ||
1059 | public void setMaxSelect(int maxSelect) { | ||
1060 | if (mMaxSelect != maxSelect) { | ||
1061 | mMaxSelect = maxSelect; | ||
1062 | if (mSelectType == SelectType.MULTI) { | ||
1063 | //最大选择数量发生改变,就要恢复到初始状态。 | ||
1064 | innerClearAllSelect(); | ||
1065 | } | ||
1066 | } | ||
1067 | } | ||
1068 | |||
1069 | public int getMaxSelect() { | ||
1070 | return mMaxSelect; | ||
1071 | } | ||
1072 | |||
1073 | /** | ||
1074 | * 设置最少的选择数量,只有selectType等于MULTI时有效。 | ||
1075 | * 注意:minSelect只限制用户手动点击取消选中时的效果。 | ||
1076 | * 调用setSelects()、clearAllSelect()等方法改变标签的选中状态时,不受minSelect影响。 | ||
1077 | * | ||
1078 | * @param minSelect | ||
1079 | */ | ||
1080 | public void setMinSelect(int minSelect) { | ||
1081 | this.mMinSelect = minSelect; | ||
1082 | } | ||
1083 | |||
1084 | public int getMinSelect() { | ||
1085 | return mMinSelect; | ||
1086 | } | ||
1087 | |||
1088 | /** | ||
1089 | * 设置最大行数,小于等于0则不限行数。 | ||
1090 | * | ||
1091 | * @param maxLines | ||
1092 | */ | ||
1093 | public void setMaxLines(int maxLines) { | ||
1094 | if (mMaxLines != maxLines) { | ||
1095 | mMaxLines = maxLines; | ||
1096 | requestLayout(); | ||
1097 | } | ||
1098 | } | ||
1099 | |||
1100 | public int getMaxLines() { | ||
1101 | return mMaxLines; | ||
1102 | } | ||
1103 | |||
1104 | /** | ||
1105 | * 设置最大列数,小于等于0则不限行数。 | ||
1106 | * | ||
1107 | * @param maxColumns | ||
1108 | */ | ||
1109 | public void setMaxColumns(int maxColumns) { | ||
1110 | if (mMaxColumns != maxColumns) { | ||
1111 | mMaxColumns = maxColumns; | ||
1112 | requestLayout(); | ||
1113 | } | ||
1114 | } | ||
1115 | |||
1116 | public int getMaxColumns() { | ||
1117 | return mMaxColumns; | ||
1118 | } | ||
1119 | |||
1120 | /** | ||
1121 | * 设置为指示器模式,只能看,不能手动操作。这种模式下,用户不能通过手动点击改变标签的选中状态。 | ||
1122 | * 但是仍然可以通过调用setSelects()、clearAllSelect()等方法改变标签的选中状态。 | ||
1123 | * | ||
1124 | * @param indicator | ||
1125 | */ | ||
1126 | public void setIndicator(boolean indicator) { | ||
1127 | isIndicator = indicator; | ||
1128 | } | ||
1129 | |||
1130 | public boolean isIndicator() { | ||
1131 | return isIndicator; | ||
1132 | } | ||
1133 | |||
1134 | /** | ||
1135 | * 设置单行显示 | ||
1136 | * | ||
1137 | * @param isSingleLine | ||
1138 | */ | ||
1139 | public void setSingleLine(boolean isSingleLine) { | ||
1140 | if (this.isSingleLine != isSingleLine) { | ||
1141 | this.isSingleLine = isSingleLine; | ||
1142 | requestLayout(); | ||
1143 | } | ||
1144 | } | ||
1145 | |||
1146 | public boolean isSingleLine() { | ||
1147 | return isSingleLine; | ||
1148 | } | ||
1149 | |||
1150 | /** | ||
1151 | * 需要在该View的layout完成之后调用,一般是使用view.post(Runable task)来获取 | ||
1152 | * 比如设置了新的labels之后需要获取新的lines就可以这样 | ||
1153 | * | ||
1154 | * @return | ||
1155 | */ | ||
1156 | public int getLines() { | ||
1157 | return this.mLines; | ||
1158 | } | ||
1159 | |||
1160 | /** | ||
1161 | * 设置标签的点击监听 | ||
1162 | * | ||
1163 | * @param l | ||
1164 | */ | ||
1165 | public void setOnLabelClickListener(OnLabelClickListener l) { | ||
1166 | mLabelClickListener = l; | ||
1167 | ensureLabelClickable(); | ||
1168 | } | ||
1169 | |||
1170 | /** | ||
1171 | * 设置标签的点击监听 | ||
1172 | * | ||
1173 | * @param l | ||
1174 | */ | ||
1175 | public void setOnLabelLongClickListener(OnLabelLongClickListener l) { | ||
1176 | mLabelLongClickListener = l; | ||
1177 | ensureLabelClickable(); | ||
1178 | } | ||
1179 | |||
1180 | /** | ||
1181 | * 设置标签的选择监听 | ||
1182 | * | ||
1183 | * @param l | ||
1184 | */ | ||
1185 | public void setOnLabelSelectChangeListener(OnLabelSelectChangeListener l) { | ||
1186 | mLabelSelectChangeListener = l; | ||
1187 | } | ||
1188 | |||
1189 | /** | ||
1190 | * 设置标签选中状态的点击改变拦截器 | ||
1191 | * | ||
1192 | * @param intercept | ||
1193 | */ | ||
1194 | public void setOnSelectChangeIntercept(OnSelectChangeIntercept intercept) { | ||
1195 | mOnSelectChangeIntercept = intercept; | ||
1196 | } | ||
1197 | |||
1198 | /** | ||
1199 | * sp转px | ||
1200 | */ | ||
1201 | private int sp2px(float spVal) { | ||
1202 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, | ||
1203 | spVal, getResources().getDisplayMetrics()); | ||
1204 | } | ||
1205 | |||
1206 | /** | ||
1207 | * dp转px | ||
1208 | */ | ||
1209 | private int dp2px(float dpVal) { | ||
1210 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, | ||
1211 | dpVal, getResources().getDisplayMetrics()); | ||
1212 | } | ||
1213 | |||
1214 | public interface OnLabelClickListener { | ||
1215 | |||
1216 | /** | ||
1217 | * @param label 标签 | ||
1218 | * @param data 标签对应的数据 | ||
1219 | * @param position 标签位置 | ||
1220 | */ | ||
1221 | void onLabelClick(TextView label, Object data, int position); | ||
1222 | } | ||
1223 | |||
1224 | public interface OnLabelLongClickListener { | ||
1225 | |||
1226 | /** | ||
1227 | * @param label 标签 | ||
1228 | * @param data 标签对应的数据 | ||
1229 | * @param position 标签位置 | ||
1230 | */ | ||
1231 | boolean onLabelLongClick(TextView label, Object data, int position); | ||
1232 | } | ||
1233 | |||
1234 | public interface OnLabelSelectChangeListener { | ||
1235 | |||
1236 | /** | ||
1237 | * @param label 标签 | ||
1238 | * @param data 标签对应的数据 | ||
1239 | * @param isSelect 是否选中 | ||
1240 | * @param position 标签位置 | ||
1241 | */ | ||
1242 | void onLabelSelectChange(TextView label, Object data, boolean isSelect, int position); | ||
1243 | } | ||
1244 | |||
1245 | /** | ||
1246 | * 点击选中/取消选中时,拦截事件,返回true时,表示事件被拦截,不会改变标签的选中状态。 | ||
1247 | * 当希望某个标签在特定条件下不被选中/取消选中时,可以使用事件拦截。 | ||
1248 | * 只有用户点击改变标签选中状态时才会回调拦截,用其他方法改变时不会回调这个方法,不会被拦截。 | ||
1249 | */ | ||
1250 | public interface OnSelectChangeIntercept { | ||
1251 | |||
1252 | /** | ||
1253 | * @param label 标签 | ||
1254 | * @param data 标签对应的数据 | ||
1255 | * @param oldSelect 旧选中状态 | ||
1256 | * @param newSelect 新选中状态 | ||
1257 | * @param position 标签位置 | ||
1258 | */ | ||
1259 | boolean onIntercept(TextView label, Object data, boolean oldSelect, boolean newSelect, int position); | ||
1260 | } | ||
1261 | |||
1262 | /** | ||
1263 | * 给标签提供最终需要显示的数据。因为LabelsView的列表可以设置任何类型的数据,而LabelsView里的每个item的是一 | ||
1264 | * 个TextView,只能显示CharSequence的数据,所以LabelTextProvider需要根据每个item的数据返回item最终要显示 | ||
1265 | * 的CharSequence。 | ||
1266 | * | ||
1267 | * @param <T> | ||
1268 | */ | ||
1269 | public interface LabelTextProvider<T> { | ||
1270 | |||
1271 | /** | ||
1272 | * 根据data和position返回label需要需要显示的数据。 | ||
1273 | * | ||
1274 | * @param label | ||
1275 | * @param position | ||
1276 | * @param data | ||
1277 | * @return | ||
1278 | */ | ||
1279 | CharSequence getLabelText(TextView label, int position, T data); | ||
1280 | } | ||
1281 | |||
1282 | /** | ||
1283 | * | ||
1284 | */ | ||
1285 | public interface Selectable { | ||
1286 | |||
1287 | void onSelected(boolean selected); | ||
1288 | |||
1289 | boolean isSelected(); | ||
1290 | |||
1291 | } | ||
1292 | |||
1293 | } | ||
1294 |
libs/common/src/main/java/com/prws/common/view/LoadingView.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.app.ProgressDialog; | ||
4 | import android.content.Context; | ||
5 | import android.graphics.drawable.AnimationDrawable; | ||
6 | import android.os.Bundle; | ||
7 | import android.view.View; | ||
8 | import android.view.WindowManager; | ||
9 | import android.widget.TextView; | ||
10 | |||
11 | import com.prws.common.R; | ||
12 | |||
13 | /** | ||
14 | * 加载中的view | ||
15 | */ | ||
16 | public class LoadingView extends ProgressDialog { | ||
17 | private Context mContext; | ||
18 | private View loadingView; | ||
19 | private WindowManager.LayoutParams params; | ||
20 | private String title; | ||
21 | |||
22 | |||
23 | public LoadingView(Context context) { | ||
24 | super(context); | ||
25 | mContext=context; | ||
26 | } | ||
27 | public LoadingView(Context context, int theme) { | ||
28 | super(context, theme); | ||
29 | mContext=context; | ||
30 | } | ||
31 | public LoadingView(Context context, int theme,String str) { | ||
32 | super(context, theme); | ||
33 | mContext=context; | ||
34 | title=str; | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | protected void onCreate(Bundle savedInstanceState) { | ||
39 | super.onCreate(savedInstanceState); | ||
40 | init(mContext); | ||
41 | } | ||
42 | |||
43 | private void init(Context context) { | ||
44 | setCancelable(true); | ||
45 | setCanceledOnTouchOutside(false); | ||
46 | // setContentView(R.layout.layout_null); | ||
47 | // params= getWindow().getAttributes(); | ||
48 | // params.width = WindowManager.LayoutParams.WRAP_CONTENT; | ||
49 | // params.height = WindowManager.LayoutParams.WRAP_CONTENT; | ||
50 | // getWindow().setAttributes(params); | ||
51 | // loadingView=View.inflate(context,R.layout.loading,null); | ||
52 | // AnimationDrawable animationDrawable = (AnimationDrawable) loadingView.findViewById(R.id.loading_iv).getBackground(); | ||
53 | // if (title != null) | ||
54 | // ((TextView)loadingView.findViewById(R.id.load_dialog_tv)).setText(title); | ||
55 | // //判断是否在运行 | ||
56 | // if(!animationDrawable.isRunning()){ | ||
57 | // //开启帧动画 | ||
58 | // animationDrawable.start(); | ||
59 | // } | ||
60 | addContentView(loadingView,params); | ||
61 | } | ||
62 | |||
63 | |||
64 | |||
65 | |||
66 | public LoadingView showDialog() { | ||
67 | super.show(); | ||
68 | return this; | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | public void dismiss() {//关闭 | ||
73 | super.dismiss(); | ||
74 | } | ||
75 | |||
76 | } | ||
77 |
libs/common/src/main/java/com/prws/common/view/MarqueeTextView.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.util.AttributeSet; | ||
5 | |||
6 | import androidx.annotation.Nullable; | ||
7 | |||
8 | /** | ||
9 | * 走马灯的TextView | ||
10 | */ | ||
11 | public class MarqueeTextView extends androidx.appcompat.widget.AppCompatTextView { | ||
12 | public MarqueeTextView(Context context) { | ||
13 | super(context); | ||
14 | } | ||
15 | |||
16 | public MarqueeTextView(Context context, @Nullable AttributeSet attrs) { | ||
17 | super(context, attrs); | ||
18 | } | ||
19 | |||
20 | public MarqueeTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | ||
21 | super(context, attrs, defStyleAttr); | ||
22 | } | ||
23 | |||
24 | |||
25 | |||
26 | @Override | ||
27 | public boolean isFocused() { | ||
28 | return true; | ||
29 | } | ||
30 | } | ||
31 |
libs/common/src/main/java/com/prws/common/view/MaxLimitRecyclerView.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.res.TypedArray; | ||
5 | import android.util.AttributeSet; | ||
6 | |||
7 | import androidx.annotation.Nullable; | ||
8 | import androidx.recyclerview.widget.RecyclerView; | ||
9 | |||
10 | import com.prws.common.R; | ||
11 | |||
12 | |||
13 | /** | ||
14 | * 设置最大高度的RecyclerView | ||
15 | */ | ||
16 | public class MaxLimitRecyclerView extends RecyclerView { | ||
17 | private int mMaxHeight; | ||
18 | private int mMaxWidth; | ||
19 | |||
20 | public MaxLimitRecyclerView(Context context) { | ||
21 | this(context, null); | ||
22 | } | ||
23 | |||
24 | public MaxLimitRecyclerView(Context context, @Nullable AttributeSet attrs) { | ||
25 | this(context, attrs, 0); | ||
26 | } | ||
27 | |||
28 | public MaxLimitRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { | ||
29 | super(context, attrs, defStyle); | ||
30 | inti(attrs); | ||
31 | } | ||
32 | |||
33 | private void inti(AttributeSet attrs) { | ||
34 | if (getContext() != null && attrs != null) { | ||
35 | TypedArray typedArray = null; | ||
36 | try { | ||
37 | typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.MaxLimitRecyclerView); | ||
38 | if (typedArray.hasValue(R.styleable.MaxLimitRecyclerView_limit_maxHeight)) { | ||
39 | mMaxHeight = typedArray.getDimensionPixelOffset(R.styleable.MaxLimitRecyclerView_limit_maxHeight, -1); | ||
40 | } | ||
41 | if (typedArray.hasValue(R.styleable.MaxLimitRecyclerView_limit_maxWidth)) { | ||
42 | mMaxWidth = typedArray.getDimensionPixelOffset(R.styleable.MaxLimitRecyclerView_limit_maxWidth, -1); | ||
43 | } | ||
44 | } catch (Exception e) { | ||
45 | e.printStackTrace(); | ||
46 | } finally { | ||
47 | if (typedArray != null) { | ||
48 | typedArray.recycle(); | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | @Override | ||
55 | protected void onMeasure(int widthSpec, int heightSpec) { | ||
56 | super.onMeasure(widthSpec, heightSpec); | ||
57 | boolean needLimit = false; | ||
58 | if (mMaxHeight >= 0 || mMaxWidth >= 0) { | ||
59 | needLimit = true; | ||
60 | } | ||
61 | if (needLimit) { | ||
62 | int limitHeight = getMeasuredHeight(); | ||
63 | // int limitWith = getMeasuredWidth(); | ||
64 | if (getMeasuredHeight() > mMaxHeight) { | ||
65 | limitHeight = mMaxHeight; | ||
66 | } | ||
67 | // if (getMeasuredWidth() > mMaxWidth) { | ||
68 | // limitWith = mMaxWidth; | ||
69 | // } | ||
70 | setMeasuredDimension(getMeasuredWidth(), limitHeight); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 |
libs/common/src/main/java/com/prws/common/view/RecycleViewDivider.java
File was created | 1 | package com.prws.common.view; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.content.res.TypedArray; | ||
5 | import android.graphics.Canvas; | ||
6 | import android.graphics.Paint; | ||
7 | import android.graphics.Rect; | ||
8 | import android.graphics.drawable.Drawable; | ||
9 | import android.view.View; | ||
10 | |||
11 | import androidx.core.content.ContextCompat; | ||
12 | import androidx.recyclerview.widget.LinearLayoutManager; | ||
13 | import androidx.recyclerview.widget.RecyclerView; | ||
14 | |||
15 | /** | ||
16 | * @author zhiqun.tang | ||
17 | * @Description: recyclerView 分割线 | ||
18 | * @date 2022/8/10 | ||
19 | */ | ||
20 | public class RecycleViewDivider extends RecyclerView.ItemDecoration { | ||
21 | private Paint mPaint; | ||
22 | private Drawable mDivider; | ||
23 | //分割线高度 | ||
24 | private int mDividerHeight = 2; | ||
25 | private int mOrientation; | ||
26 | private static final int[] ATTRS = new int[]{android.R.attr.listDivider}; | ||
27 | |||
28 | /** | ||
29 | * 默认分割线 | ||
30 | * | ||
31 | * @param context | ||
32 | * @param orientation 列表方向 | ||
33 | */ | ||
34 | public RecycleViewDivider(Context context, int orientation) { | ||
35 | if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) { | ||
36 | throw new IllegalArgumentException("请输入正确的参数!"); | ||
37 | } | ||
38 | mOrientation = orientation; | ||
39 | //使用TypeArray加载该系统资源 | ||
40 | final TypedArray a = context.obtainStyledAttributes(ATTRS); | ||
41 | mDivider = a.getDrawable(0); | ||
42 | a.recycle();//缓存 | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * 自定义分割线 | ||
47 | * | ||
48 | * @param context | ||
49 | * @param orientation 列表方向 | ||
50 | * @param drawableId 分割线图片 | ||
51 | */ | ||
52 | public RecycleViewDivider(Context context, int orientation, int drawableId) { | ||
53 | this(context, orientation); | ||
54 | mDivider = ContextCompat.getDrawable(context, drawableId); | ||
55 | mDividerHeight = mDivider.getIntrinsicHeight(); | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * 自定义分割线 | ||
60 | * | ||
61 | * @param context | ||
62 | * @param orientation 列表方向 | ||
63 | * @param dividerHeight 分割线高度 | ||
64 | * @param dividerColor 分割线颜色 | ||
65 | */ | ||
66 | public RecycleViewDivider(Context context, int orientation, int dividerHeight, int dividerColor) { | ||
67 | this(context, orientation); | ||
68 | mDividerHeight = dividerHeight; | ||
69 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
70 | mPaint.setColor(dividerColor); | ||
71 | mPaint.setStyle(Paint.Style.FILL); | ||
72 | } | ||
73 | |||
74 | |||
75 | //获取分割线尺寸 | ||
76 | @Override | ||
77 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { | ||
78 | super.getItemOffsets(outRect, view, parent, state); | ||
79 | outRect.set(0, 0, 0, mDividerHeight); | ||
80 | } | ||
81 | |||
82 | //绘制分割线 | ||
83 | @Override | ||
84 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { | ||
85 | super.onDraw(c, parent, state); | ||
86 | if (mOrientation == LinearLayoutManager.VERTICAL) { | ||
87 | drawVertical(c, parent); | ||
88 | } else { | ||
89 | drawHorizontal(c, parent); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | //绘制横向 item 分割线 | ||
94 | private void drawHorizontal(Canvas canvas, RecyclerView parent) { | ||
95 | final int left = parent.getPaddingLeft(); | ||
96 | final int right = parent.getMeasuredWidth() - parent.getPaddingRight(); | ||
97 | final int childSize = parent.getChildCount(); | ||
98 | for (int i = 0; i < childSize; i++) { | ||
99 | final View child = parent.getChildAt(i); | ||
100 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
101 | final int top = child.getBottom() + layoutParams.bottomMargin; | ||
102 | final int bottom = top + mDividerHeight; | ||
103 | if (mDivider != null) { | ||
104 | mDivider.setBounds(left, top, right, bottom); | ||
105 | mDivider.draw(canvas); | ||
106 | } | ||
107 | if (mPaint != null) { | ||
108 | canvas.drawRect(left, top, right, bottom, mPaint); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | //绘制纵向 item 分割线 | ||
114 | private void drawVertical(Canvas canvas, RecyclerView parent) { | ||
115 | final int top = parent.getPaddingTop(); | ||
116 | final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); | ||
117 | final int childSize = parent.getChildCount(); | ||
118 | for (int i = 0; i < childSize; i++) { | ||
119 | final View child = parent.getChildAt(i); | ||
120 | RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
121 | final int left = child.getRight() + layoutParams.rightMargin; | ||
122 | final int right = left + mDividerHeight; | ||
123 | if (mDivider != null) { | ||
124 | mDivider.setBounds(left, top, right, bottom); | ||
125 | mDivider.draw(canvas); | ||
126 | } | ||
127 | if (mPaint != null) { | ||
128 | canvas.drawRect(left, top, right, bottom, mPaint); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 |
libs/common/src/main/java/com/prws/common/widget/ProgressView.java
File was created | 1 | package com.prws.common.widget; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Bitmap; | ||
5 | import android.graphics.BitmapFactory; | ||
6 | import android.graphics.Canvas; | ||
7 | import android.graphics.Color; | ||
8 | import android.graphics.Paint; | ||
9 | import android.graphics.Rect; | ||
10 | import android.graphics.RectF; | ||
11 | import android.text.Layout; | ||
12 | import android.text.StaticLayout; | ||
13 | import android.text.TextPaint; | ||
14 | import android.view.MotionEvent; | ||
15 | import android.view.View; | ||
16 | |||
17 | |||
18 | |||
19 | public class ProgressView extends View { | ||
20 | |||
21 | public interface OnChangedListener { | ||
22 | void onChanged(Float value); // 0-1 | ||
23 | } | ||
24 | |||
25 | private Float progress = 0f; | ||
26 | private Bitmap bitmap; | ||
27 | |||
28 | private Float min = 0f; | ||
29 | private Float max = 1f; | ||
30 | |||
31 | private OnChangedListener onChangedListener; | ||
32 | |||
33 | private Paint p; | ||
34 | |||
35 | public ProgressView(Context context) { | ||
36 | super(context); | ||
37 | |||
38 | p = new Paint(); | ||
39 | p.setStyle(Paint.Style.FILL);//充满 | ||
40 | p.setAntiAlias(true);// 设置画笔的锯齿效果 | ||
41 | } | ||
42 | |||
43 | public void setOnChangedListener(OnChangedListener l) { | ||
44 | onChangedListener = l; | ||
45 | } | ||
46 | |||
47 | public void setProgress(Float p) { | ||
48 | this.progress = p; | ||
49 | } | ||
50 | |||
51 | public void setMin(Float min) { | ||
52 | this.min = min; | ||
53 | if (progress < min) | ||
54 | progress = min; | ||
55 | } | ||
56 | |||
57 | public void setMax(Float max) { | ||
58 | this.max = max; | ||
59 | if (progress > max) | ||
60 | progress = max; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | protected void onDraw(Canvas canvas) { | ||
65 | super.onDraw(canvas); | ||
66 | int w = getWidth(); | ||
67 | int h = getHeight(); | ||
68 | |||
69 | RectF oval3 = new RectF(0, 0, w, h); | ||
70 | |||
71 | p.setColor(Color.argb(183, 62, 87, 189)); | ||
72 | canvas.drawRoundRect(oval3, 20, 20, p);//第二个参数是x半径,第三个参数是y半径 | ||
73 | |||
74 | oval3.right = w * (progress - min) * (1F / (max - min)); | ||
75 | p.setColor(Color.argb(255, 56, 158, 252)); | ||
76 | canvas.drawRoundRect(oval3, 20, 20, p);//第二个参数是x半径,第三个参数是y半径 | ||
77 | |||
78 | if (bitmap != null) { | ||
79 | Rect srcRect = new Rect(); | ||
80 | RectF dstRecF = new RectF(); | ||
81 | |||
82 | srcRect.left = 0; | ||
83 | srcRect.right = bitmap.getWidth(); | ||
84 | srcRect.top = 0; | ||
85 | srcRect.bottom = bitmap.getHeight(); | ||
86 | |||
87 | dstRecF.left = 15; | ||
88 | dstRecF.right = bitmap.getWidth() + dstRecF.left; | ||
89 | dstRecF.top = h / 2 - bitmap.getHeight() / 2; | ||
90 | dstRecF.bottom = dstRecF.top + bitmap.getHeight(); | ||
91 | canvas.drawBitmap(bitmap, srcRect, dstRecF, p); | ||
92 | } | ||
93 | |||
94 | //绘制文字 | ||
95 | TextPaint textPaint = new TextPaint(); | ||
96 | textPaint.setColor(Color.WHITE); | ||
97 | textPaint.setStyle(Paint.Style.FILL); | ||
98 | textPaint.setTextSize(26); | ||
99 | StaticLayout staticLayout = new StaticLayout("\n"+getProgressStr(),textPaint,canvas.getWidth(), Layout.Alignment.ALIGN_CENTER,1.0f,0.0f,false); | ||
100 | staticLayout.draw(canvas); | ||
101 | // canvas.restore(); | ||
102 | |||
103 | } | ||
104 | |||
105 | int showType = 0; | ||
106 | public void setShowType(int type){ | ||
107 | showType = type; | ||
108 | } | ||
109 | |||
110 | private String getProgressStr(){ | ||
111 | if (showType == 0) { | ||
112 | return String.format("%.2f",progress); | ||
113 | } | ||
114 | return (int)(progress * 100)+"%"; | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public boolean onTouchEvent(MotionEvent event) { | ||
119 | float x = event.getX(); | ||
120 | progress = min + (max - min) * (x / getWidth()); | ||
121 | if (progress < min) | ||
122 | progress = min; | ||
123 | if (progress > max) | ||
124 | progress = max; | ||
125 | switch (event.getAction()) { | ||
126 | case MotionEvent.ACTION_UP: | ||
127 | case MotionEvent.ACTION_CANCEL: | ||
128 | if (onChangedListener != null) { | ||
129 | onChangedListener.onChanged(progress); | ||
130 | } | ||
131 | break; | ||
132 | } | ||
133 | invalidate(); | ||
134 | return true; | ||
135 | } | ||
136 | |||
137 | public Bitmap getBitmap() { | ||
138 | return bitmap; | ||
139 | } | ||
140 | |||
141 | public void setBitmap(Bitmap bitmap) { | ||
142 | this.bitmap = bitmap; | ||
143 | } | ||
144 | |||
145 | } | ||
146 | |||
147 |
libs/common/src/main/java/com/prws/common/widget/circleView/MatrixTranslateLayout.java
File was created | 1 | package com.prws.common.widget.circleView; | |
2 | |||
3 | import android.content.Context; | ||
4 | import android.graphics.Canvas; | ||
5 | import android.graphics.Matrix; | ||
6 | import android.util.AttributeSet; | ||
7 | import android.widget.LinearLayout; | ||
8 | |||
9 | public class MatrixTranslateLayout extends LinearLayout { | ||
10 | private int parentHeight = 0; | ||
11 | private int topOffset = 0; | ||
12 | |||
13 | public MatrixTranslateLayout(Context context, AttributeSet attrs) { | ||
14 | super(context, attrs); | ||
15 | } | ||
16 | |||
17 | public void setParentHeight(int height) { | ||
18 | parentHeight = height; | ||
19 | } | ||
20 | |||
21 | @Override | ||
22 | protected void dispatchDraw(Canvas canvas) { | ||
23 | canvas.save(); | ||
24 | if (topOffset == 0) { | ||
25 | topOffset = getHeight() / 2; | ||
26 | } | ||
27 | int top = getTop() + topOffset; | ||
28 | |||
29 | float tran = calculateTranslate(top, parentHeight); | ||
30 | |||
31 | Matrix m = canvas.getMatrix(); | ||
32 | m.setTranslate(tran, 0); | ||
33 | canvas.concat(m); | ||
34 | super.dispatchDraw(canvas); | ||
35 | canvas.restore(); | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
40 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
41 | } | ||
42 | |||
43 | |||
44 | private float calculateTranslate(int top, int h) { | ||
45 | float result = 0f; | ||
46 | int hh = h / 2; | ||
47 | result = Math.abs(top - hh) * -1; | ||
48 | return (float) (result / 2); | ||
49 | } | ||
50 | } | ||
51 |
libs/common/src/main/res/anim/cycle_interpolator.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:cycles="5" /> |
libs/common/src/main/res/anim/shanke.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <translate xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:fromXDelta="0" | ||
4 | android:toXDelta="2" | ||
5 | android:duration="500" | ||
6 | android:interpolator="@anim/cycle_interpolator" /> |
libs/common/src/main/res/drawable/bg_solid_white.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:shape="rectangle"> | ||
4 | |||
5 | <!-- <solid android:color="@color/white" />--> | ||
6 | |||
7 | <corners | ||
8 | android:radius="16dp" | ||
9 | /> | ||
10 | |||
11 | </shape> |
libs/common/src/main/res/drawable/default_label_bg.xml
File was created | 1 | <?xml version="1.0" encoding="UTF-8"?><!--<shape xmlns:android="http://schemas.android.com/apk/res/android">--><!--<stroke--><!--android:width="1dp"--><!--android:color="@color/divider_color" />--><!--<solid android:color="@color/pink_color" />--><!--<corners android:radius="4dp" />--><!--</shape>--> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <stroke | ||
4 | android:width="1dp" | ||
5 | android:color="#656565" /> | ||
6 | <corners android:radius="5dp" /> | ||
7 | <solid android:color="@android:color/white" /> | ||
8 | </shape> |
libs/common/src/main/res/drawable/loading_anim.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <animation-list xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | android:oneshot="false"> | ||
4 | <item | ||
5 | android:drawable="@mipmap/loading_00000" | ||
6 | android:duration="30"></item> | ||
7 | <item | ||
8 | android:drawable="@mipmap/loading_00001" | ||
9 | android:duration="30"></item> | ||
10 | <item | ||
11 | android:drawable="@mipmap/loading_00002" | ||
12 | android:duration="30"></item> | ||
13 | <item | ||
14 | android:drawable="@mipmap/loading_00003" | ||
15 | android:duration="30"></item> | ||
16 | <item | ||
17 | android:drawable="@mipmap/loading_00004" | ||
18 | android:duration="30"></item> | ||
19 | <item | ||
20 | android:drawable="@mipmap/loading_00005" | ||
21 | android:duration="30"></item> | ||
22 | <item | ||
23 | android:drawable="@mipmap/loading_00006" | ||
24 | android:duration="30"></item> | ||
25 | <item | ||
26 | android:drawable="@mipmap/loading_00007" | ||
27 | android:duration="30"></item> | ||
28 | <item | ||
29 | android:drawable="@mipmap/loading_00008" | ||
30 | android:duration="30"></item> | ||
31 | <item | ||
32 | android:drawable="@mipmap/loading_00009" | ||
33 | android:duration="30"></item> | ||
34 | <item | ||
35 | android:drawable="@mipmap/loading_00010" | ||
36 | android:duration="30"></item> | ||
37 | <item | ||
38 | android:drawable="@mipmap/loading_00011" | ||
39 | android:duration="30"></item> | ||
40 | <item | ||
41 | android:drawable="@mipmap/loading_00012" | ||
42 | android:duration="30"></item> | ||
43 | <item | ||
44 | android:drawable="@mipmap/loading_00013" | ||
45 | android:duration="30"></item> | ||
46 | <item | ||
47 | android:drawable="@mipmap/loading_00014" | ||
48 | android:duration="30"></item> | ||
49 | <item | ||
50 | android:drawable="@mipmap/loading_00015" | ||
51 | android:duration="30"></item> | ||
52 | <item | ||
53 | android:drawable="@mipmap/loading_00016" | ||
54 | android:duration="30"></item> | ||
55 | <item | ||
56 | android:drawable="@mipmap/loading_00017" | ||
57 | android:duration="30"></item> | ||
58 | <item | ||
59 | android:drawable="@mipmap/loading_00018" | ||
60 | android:duration="30"></item> | ||
61 | <item | ||
62 | android:drawable="@mipmap/loading_00019" | ||
63 | android:duration="30"></item> | ||
64 | <item | ||
65 | android:drawable="@mipmap/loading_00020" | ||
66 | android:duration="30"></item> | ||
67 | <item | ||
68 | android:drawable="@mipmap/loading_00021" | ||
69 | android:duration="30"></item> | ||
70 | <item | ||
71 | android:drawable="@mipmap/loading_00022" | ||
72 | android:duration="30"></item> | ||
73 | <item | ||
74 | android:drawable="@mipmap/loading_00023" | ||
75 | android:duration="30"></item> | ||
76 | <item | ||
77 | android:drawable="@mipmap/loading_00024" | ||
78 | android:duration="30"></item> | ||
79 | <item | ||
80 | android:drawable="@mipmap/loading_00025" | ||
81 | android:duration="30"></item> | ||
82 | <item | ||
83 | android:drawable="@mipmap/loading_00026" | ||
84 | android:duration="30"></item> | ||
85 | <item | ||
86 | android:drawable="@mipmap/loading_00027" | ||
87 | android:duration="30"></item> | ||
88 | <item | ||
89 | android:drawable="@mipmap/loading_00028" | ||
90 | android:duration="30"></item> | ||
91 | <item | ||
92 | android:drawable="@mipmap/loading_00029" | ||
93 | android:duration="30"></item> | ||
94 | <item | ||
95 | android:drawable="@mipmap/loading_00030" | ||
96 | android:duration="30"></item> | ||
97 | <item | ||
98 | android:drawable="@mipmap/loading_00031" | ||
99 | android:duration="30"></item> | ||
100 | <item | ||
101 | android:drawable="@mipmap/loading_00032" | ||
102 | android:duration="30"></item> | ||
103 | <item | ||
104 | android:drawable="@mipmap/loading_00033" | ||
105 | android:duration="30"></item> | ||
106 | <item | ||
107 | android:drawable="@mipmap/loading_00034" | ||
108 | android:duration="30"></item> | ||
109 | <item | ||
110 | android:drawable="@mipmap/loading_00035" | ||
111 | android:duration="30"></item> | ||
112 | <item | ||
113 | android:drawable="@mipmap/loading_00036" | ||
114 | android:duration="30"></item> | ||
115 | <item | ||
116 | android:drawable="@mipmap/loading_00037" | ||
117 | android:duration="30"></item> | ||
118 | <item | ||
119 | android:drawable="@mipmap/loading_00038" | ||
120 | android:duration="30"></item> | ||
121 | <item | ||
122 | android:drawable="@mipmap/loading_00039" | ||
123 | android:duration="30"></item> | ||
124 | <item | ||
125 | android:drawable="@mipmap/loading_00040" | ||
126 | android:duration="30"></item> | ||
127 | <item | ||
128 | android:drawable="@mipmap/loading_00041" | ||
129 | android:duration="30"></item> | ||
130 | <item | ||
131 | android:drawable="@mipmap/loading_00042" | ||
132 | android:duration="30"></item> | ||
133 | <item | ||
134 | android:drawable="@mipmap/loading_00043" | ||
135 | android:duration="30"></item> | ||
136 | <item | ||
137 | android:drawable="@mipmap/loading_00044" | ||
138 | android:duration="30"></item> | ||
139 | <item | ||
140 | android:drawable="@mipmap/loading_00045" | ||
141 | android:duration="30"></item> | ||
142 | <item | ||
143 | android:drawable="@mipmap/loading_00046" | ||
144 | android:duration="30"></item> | ||
145 | <item | ||
146 | android:drawable="@mipmap/loading_00047" | ||
147 | android:duration="30"></item> | ||
148 | <item | ||
149 | android:drawable="@mipmap/loading_00048" | ||
150 | android:duration="30"></item> | ||
151 | <item | ||
152 | android:drawable="@mipmap/loading_00049" | ||
153 | android:duration="30"></item> | ||
154 | |||
155 | </animation-list> |
libs/common/src/main/res/drawable/select_map_position_type.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | <!-- <item android:drawable="@mipmap/icon_workpic_choosen" android:state_checked="true"/>--> | ||
4 | <!-- <item android:drawable="@mipmap/icon_workpic_unchoosen" android:state_checked="false"/>--> | ||
5 | <!-- <item android:drawable="@mipmap/icon_workpic_unchoosen" />--> | ||
6 | </selector> |
libs/common/src/main/res/drawable/shape_dialog_bg.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" > | ||
3 | |||
4 | <corners android:radius="8dp" /> | ||
5 | <solid android:color="#66000000" /> | ||
6 | </shape> |
libs/common/src/main/res/mipmap-mdpi/icon_clean1.png
2.37 KB
libs/common/src/main/res/mipmap-mdpi/icon_shoudong_a.png
1.85 KB
libs/common/src/main/res/mipmap-mdpi/icon_zidong_a.png
1.95 KB
libs/common/src/main/res/mipmap-mdpi/js_1.png
626 Bytes
libs/common/src/main/res/mipmap-mdpi/js_2.png
561 Bytes
libs/common/src/main/res/mipmap-mdpi/loading_00000.png
12.4 KB
libs/common/src/main/res/mipmap-mdpi/loading_00001.png
12.5 KB
libs/common/src/main/res/mipmap-mdpi/loading_00002.png
11.5 KB
libs/common/src/main/res/mipmap-mdpi/loading_00003.png
10.9 KB
libs/common/src/main/res/mipmap-mdpi/loading_00004.png
10.8 KB
libs/common/src/main/res/mipmap-mdpi/loading_00005.png
11.1 KB
libs/common/src/main/res/mipmap-mdpi/loading_00006.png
11 KB
libs/common/src/main/res/mipmap-mdpi/loading_00007.png
10.8 KB
libs/common/src/main/res/mipmap-mdpi/loading_00008.png
10 KB
libs/common/src/main/res/mipmap-mdpi/loading_00009.png
9.24 KB
libs/common/src/main/res/mipmap-mdpi/loading_00010.png
8.7 KB
libs/common/src/main/res/mipmap-mdpi/loading_00011.png
7.09 KB
libs/common/src/main/res/mipmap-mdpi/loading_00012.png
5.41 KB
libs/common/src/main/res/mipmap-mdpi/loading_00013.png
4.6 KB
libs/common/src/main/res/mipmap-mdpi/loading_00014.png
4.71 KB
libs/common/src/main/res/mipmap-mdpi/loading_00015.png
4.45 KB
libs/common/src/main/res/mipmap-mdpi/loading_00016.png
3.91 KB
libs/common/src/main/res/mipmap-mdpi/loading_00017.png
3.54 KB
libs/common/src/main/res/mipmap-mdpi/loading_00018.png
2.99 KB
libs/common/src/main/res/mipmap-mdpi/loading_00019.png
2.87 KB
libs/common/src/main/res/mipmap-mdpi/loading_00020.png
2.95 KB
libs/common/src/main/res/mipmap-mdpi/loading_00021.png
3.03 KB
libs/common/src/main/res/mipmap-mdpi/loading_00022.png
2.87 KB
libs/common/src/main/res/mipmap-mdpi/loading_00023.png
2.79 KB
libs/common/src/main/res/mipmap-mdpi/loading_00024.png
2.73 KB
libs/common/src/main/res/mipmap-mdpi/loading_00025.png
2.5 KB
libs/common/src/main/res/mipmap-mdpi/loading_00026.png
2.71 KB
libs/common/src/main/res/mipmap-mdpi/loading_00027.png
2.72 KB
libs/common/src/main/res/mipmap-mdpi/loading_00028.png
2.81 KB
libs/common/src/main/res/mipmap-mdpi/loading_00029.png
2.92 KB
libs/common/src/main/res/mipmap-mdpi/loading_00030.png
2.9 KB
libs/common/src/main/res/mipmap-mdpi/loading_00031.png
2.83 KB
libs/common/src/main/res/mipmap-mdpi/loading_00032.png
3.08 KB
libs/common/src/main/res/mipmap-mdpi/loading_00033.png
3.54 KB
libs/common/src/main/res/mipmap-mdpi/loading_00034.png
3.96 KB
libs/common/src/main/res/mipmap-mdpi/loading_00035.png
4.32 KB
libs/common/src/main/res/mipmap-mdpi/loading_00036.png
4.53 KB
libs/common/src/main/res/mipmap-mdpi/loading_00037.png
4.22 KB
libs/common/src/main/res/mipmap-mdpi/loading_00038.png
4.75 KB
libs/common/src/main/res/mipmap-mdpi/loading_00039.png
5.94 KB
libs/common/src/main/res/mipmap-mdpi/loading_00040.png
7.37 KB
libs/common/src/main/res/mipmap-mdpi/loading_00041.png
8.1 KB
libs/common/src/main/res/mipmap-mdpi/loading_00042.png
8.93 KB
libs/common/src/main/res/mipmap-mdpi/loading_00043.png
10 KB
libs/common/src/main/res/mipmap-mdpi/loading_00044.png
10.8 KB
libs/common/src/main/res/mipmap-mdpi/loading_00045.png
11.3 KB
libs/common/src/main/res/mipmap-mdpi/loading_00046.png
11 KB
libs/common/src/main/res/mipmap-mdpi/loading_00047.png
11.2 KB
libs/common/src/main/res/mipmap-mdpi/loading_00048.png
11.7 KB
libs/common/src/main/res/mipmap-mdpi/loading_00049.png
12.6 KB
libs/common/src/main/res/mipmap-mdpi/ps_1.png
602 Bytes
libs/common/src/main/res/mipmap-mdpi/ps_22.png
681 Bytes
libs/common/src/main/res/values/attrs.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <resources> | ||
3 | <declare-styleable name="LabelsView"> | ||
4 | <attr name="selectType" format="enum"> | ||
5 | <enum name="NONE" value="1" /> | ||
6 | <enum name="SINGLE" value="2" /> | ||
7 | <enum name="SINGLE_IRREVOCABLY" value="3" /> | ||
8 | <enum name="MULTI" value="4" /> | ||
9 | </attr> | ||
10 | |||
11 | <attr name="labelGravity"> | ||
12 | <!-- Push object to the top of its container, not changing its size. --> | ||
13 | <flag name="top" value="0x30" /> | ||
14 | <!-- Push object to the bottom of its container, not changing its size. --> | ||
15 | <flag name="bottom" value="0x50" /> | ||
16 | <!-- Push object to the left of its container, not changing its size. --> | ||
17 | <flag name="left" value="0x03" /> | ||
18 | <!-- Push object to the right of its container, not changing its size. --> | ||
19 | <flag name="right" value="0x05" /> | ||
20 | <!-- Place object in the vertical center of its container, not changing its size. --> | ||
21 | <flag name="center_vertical" value="0x10" /> | ||
22 | <!-- Grow the vertical size of the object if needed so it completely fills its container. --> | ||
23 | <flag name="fill_vertical" value="0x70" /> | ||
24 | <!-- Place object in the horizontal center of its container, not changing its size. --> | ||
25 | <flag name="center_horizontal" value="0x01" /> | ||
26 | <!-- Grow the horizontal size of the object if needed so it completely fills its container. --> | ||
27 | <flag name="fill_horizontal" value="0x07" /> | ||
28 | <!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. --> | ||
29 | <flag name="center" value="0x11" /> | ||
30 | <!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. --> | ||
31 | <flag name="fill" value="0x77" /> | ||
32 | <!-- Additional option that can be set to have the top and/or bottom edges of | ||
33 | the child clipped to its container's bounds. | ||
34 | The clip will be based on the vertical gravity: a top gravity will clip the bottom | ||
35 | edge, a bottom gravity will clip the top edge, and neither will clip both edges. --> | ||
36 | <flag name="clip_vertical" value="0x80" /> | ||
37 | <!-- Additional option that can be set to have the left and/or right edges of | ||
38 | the child clipped to its container's bounds. | ||
39 | The clip will be based on the horizontal gravity: a left gravity will clip the right | ||
40 | edge, a right gravity will clip the left edge, and neither will clip both edges. --> | ||
41 | <flag name="clip_horizontal" value="0x08" /> | ||
42 | <!-- Push object to the beginning of its container, not changing its size. --> | ||
43 | <flag name="start" value="0x00800003" /> | ||
44 | <!-- Push object to the end of its container, not changing its size. --> | ||
45 | <flag name="end" value="0x00800005" /> | ||
46 | </attr> | ||
47 | |||
48 | <attr name="maxSelect" format="integer" /> | ||
49 | <attr name="minSelect" format="integer" /> | ||
50 | <attr name="maxLines" format="integer" /> | ||
51 | <attr name="maxColumns" format="integer" /> | ||
52 | <attr name="isIndicator" format="boolean" /> | ||
53 | <attr name="labelTextColor" format="reference|color" /> | ||
54 | <attr name="labelTextSize" format="dimension" /> | ||
55 | <attr name="labelTextWidth" format="dimension"> | ||
56 | <enum name="fill_parent" value="-1" /> | ||
57 | <enum name="match_parent" value="-1" /> | ||
58 | <enum name="wrap_content" value="-2" /> | ||
59 | </attr> | ||
60 | <attr name="labelTextHeight" format="dimension"> | ||
61 | <enum name="fill_parent" value="-1" /> | ||
62 | <enum name="match_parent" value="-1" /> | ||
63 | <enum name="wrap_content" value="-2" /> | ||
64 | </attr> | ||
65 | <attr name="labelTextPadding" format="dimension" /> | ||
66 | <attr name="labelTextPaddingLeft" format="dimension" /> | ||
67 | <attr name="labelTextPaddingTop" format="dimension" /> | ||
68 | <attr name="labelTextPaddingRight" format="dimension" /> | ||
69 | <attr name="labelTextPaddingBottom" format="dimension" /> | ||
70 | <attr name="lineMargin" format="dimension" /> | ||
71 | <attr name="wordMargin" format="dimension" /> | ||
72 | <attr name="labelBackground" format="reference|color" /> | ||
73 | <attr name="singleLine" format="boolean" /> | ||
74 | <attr name="isTextBold" format="boolean" /> | ||
75 | </declare-styleable> | ||
76 | <declare-styleable name="MaxLimitRecyclerView"> | ||
77 | <attr name="limit_maxHeight" format="reference|dimension" /> | ||
78 | <attr name="limit_maxWidth" format="reference|dimension" /> | ||
79 | </declare-styleable> | ||
80 | </resources> | ||
81 |
libs/common/src/main/res/values/strings.xml
File was created | 1 | <resources xmlns:tools="http://schemas.android.com/tools"> | |
2 | <item name="tag_key_data" type="id" /> | ||
3 | <item name="tag_key_position" type="id" /> | ||
4 | <string name="need_permission">需要权限</string> | ||
5 | <string name="need_permission_window">需要开启悬浮窗权限,是否开启?</string> | ||
6 | <string name="open">开启</string> | ||
7 | <string name="task">任务</string> | ||
8 | <string name="remote">遥控器</string> | ||
9 | <string name="map">地图</string> | ||
10 | <string name="thermometer">测温</string> | ||
11 | <string name="save">保存</string> | ||
12 | <string name="setting">设置</string> | ||
13 | <string name="basic">基础</string> | ||
14 | <string name="basic_setting">基础设置</string> | ||
15 | <string name="high_level">高级</string> | ||
16 | <string name="advanced_setting">高级设置</string> | ||
17 | <string name="speek_setting">语音调节</string> | ||
18 | <string name="work_setting">工作设置</string> | ||
19 | <string name="wifi_setting">Wi-Fi设置</string> | ||
20 | <string name="account_setting">账号设置</string> | ||
21 | <string name="alarm_setting">系统管理</string> | ||
22 | <string name="voice_setting">语音播报</string> | ||
23 | <string name="task_setting">任务设置</string> | ||
24 | <string name="caiji_setting">采集设置</string> | ||
25 | <string name="xd_setting">消毒设置</string> | ||
26 | <string name="xda_setting">洁净度\n标准设置</string> | ||
27 | <string name="shuizhan_setting">水站设置</string> | ||
28 | <string name="pwd_setting">修改密码</string> | ||
29 | <string name="run_setting">运动配置</string> | ||
30 | <string name="language_setting">语言设置</string> | ||
31 | <string name="language_select">选择语言</string> | ||
32 | <string name="language_system">跟随系统</string> | ||
33 | <string name="zhanghao">账号</string> | ||
34 | <string name="ip_dizhi">IP地址</string> | ||
35 | <string name="language_chinese">中文</string> | ||
36 | <string name="language_english">English</string> | ||
37 | <string name="language_german">Deutsch</string> | ||
38 | <string name="language_">德玛西亚语</string> | ||
39 | <string name="work_show_image_setting">图片设置(机器人工作时/锁屏)</string> | ||
40 | <string name="normal_emoji">默认表情</string> | ||
41 | <string name="custom_image_video">自定义广告图片或视频</string> | ||
42 | <string name="work_model_switch">模块开启</string> | ||
43 | <string name="side_push">边推</string> | ||
44 | <string name="lock_password">锁屏密码</string> | ||
45 | <string name="hight_setting_password">高级权限密码</string> | ||
46 | <string name="old_password">旧密码</string> | ||
47 | <string name="new_password">新密码</string> | ||
48 | <string name="password_is_not_null">密码不能为空</string> | ||
49 | <string name="password_old_error">原密码输入错误</string> | ||
50 | |||
51 | <string name="please_lock_password">请输入锁屏密码</string> | ||
52 | <string name="please_advanced_access_password">请输入高级权限密码</string> | ||
53 | |||
54 | <string name="account">账号</string> | ||
55 | <string name="address">地址</string> | ||
56 | <string name="leaseholder">租户</string> | ||
57 | <string name="low_battery_threshold">低电量阈值(百分比%)</string> | ||
58 | <string name="please_enter_min_battery">请输入最低电量数值</string> | ||
59 | <string name="dust_cloth_replacement_cycle">尘推布更换周期(天数)</string> | ||
60 | <string name="machine_stall_timeout">机器工作中停留超时(秒)</string> | ||
61 | <string name="blind_road">盲道</string> | ||
62 | <string name="carpet">地毯</string> | ||
63 | <string name="towel">毛巾</string> | ||
64 | <string name="raise_dust_mop">抬起尘推布</string> | ||
65 | <string name="bypass">绕行</string> | ||
66 | <string name="play_text">播放文本(还可继续添加%d个字)</string> | ||
67 | <string name="please_enter_text">请输入文本</string> | ||
68 | <string name="loop_play_time">循环播放时间(秒)</string> | ||
69 | <string name="bypass_switch">绕行开关</string> | ||
70 | <string name="bypass_at_obstacle">遇障绕行</string> | ||
71 | <string name="stop_in_case_of_obstacle">遇障停下</string> | ||
72 | <string name="running_speed">运行速度</string> | ||
73 | <string name="area_coverage">区域覆盖</string> | ||
74 | <string name="fast_planning">快速规划</string> | ||
75 | <string name="general_planning">通用规划</string> | ||
76 | <string name="detailed_planning">精细规划</string> | ||
77 | <!-- <string name="voice_adjustment">语音调节</string>--> | ||
78 | <string name="voice_volume">语音音量</string> | ||
79 | <!-- <string name="wifi_settings">Wi-Fi设置</string>--> | ||
80 | <string name="wireless_lan">无线局域网</string> | ||
81 | |||
82 | <string name="other_networks">其他网络</string> | ||
83 | <string name="work_settings">工作设置</string> | ||
84 | <string name="picture_settings_when_the_robot_is_working">机器人工作时图片设置</string> | ||
85 | <string name="none">无</string> | ||
86 | <string name="default_image">默认图片</string> | ||
87 | <string name="customize_advertisement_image">自定义广告图片</string> | ||
88 | <string name="enable_the_disinfecting_module">是否开启消杀模块?</string> | ||
89 | <!-- <string name="turn_on">开启</string>--> | ||
90 | <string name="running_status">运行状态</string> | ||
91 | <string name="normal_operation">正常运行</string> | ||
92 | <string name="repositioning">重新定位中</string> | ||
93 | <string name="power_on_self_checking">开机自检中</string> | ||
94 | <string name="emergency_stop_switch_turned_on">急停开关已打开</string> | ||
95 | <string name="positioning_lost">定位丢失</string> | ||
96 | <string name="charging">充电中</string> | ||
97 | <string name="drive_disconnection">驱动断开连接</string> | ||
98 | <string name="robot_abnormality">机器人异常</string> | ||
99 | <string name="navigating">导航中</string> | ||
100 | <string name="obstacle_avoidance">避障中</string> | ||
101 | <string name="navigation_failure">导航失败</string> | ||
102 | <string name="cleaning_time">清扫时长</string> | ||
103 | <string name="cleaning_area">清扫面积</string> | ||
104 | <string name="suspend_work">暂停工作</string> | ||
105 | <string name="start_working">开始工作</string> | ||
106 | <string name="subtasks">子任务</string> | ||
107 | <string name="dust_mop">尘推</string> | ||
108 | <string name="level_1">1级</string> | ||
109 | <string name="level_2">2级</string> | ||
110 | <string name="level_3">3级</string> | ||
111 | <string name="level_4">4级</string> | ||
112 | <string name="level_5">5级</string> | ||
113 | <string name="level_num">%d级</string> | ||
114 | <string name="no_1">第1</string> | ||
115 | <string name="no_2">第2</string> | ||
116 | <string name="no_3">第3</string> | ||
117 | <string name="no_4">第4</string> | ||
118 | <string name="no_5">第5</string> | ||
119 | <string name="num_1">1</string> | ||
120 | <string name="num_2">2</string> | ||
121 | <string name="num_3">3</string> | ||
122 | <string name="num_4">4</string> | ||
123 | <string name="num_5">5</string> | ||
124 | <string name="disinfection">消杀</string> | ||
125 | <string name="add_task">新增任务</string> | ||
126 | <string name="details">详情</string> | ||
127 | <string name="execute">执行</string> | ||
128 | <string name="edit">编辑</string> | ||
129 | |||
130 | <string name="schedule">定时</string> | ||
131 | <string name="starting_time">开始时间</string> | ||
132 | |||
133 | <string name="monday">星期一</string> | ||
134 | <string name="tuesday">星期二</string> | ||
135 | <string name="wednesday">星期三</string> | ||
136 | <string name="thursday">星期四</string> | ||
137 | <string name="friday">星期五</string> | ||
138 | <string name="saturday">星期六</string> | ||
139 | <string name="sunday">星期日</string> | ||
140 | |||
141 | <string name="new_task">新建任务</string> | ||
142 | <string name="new_subtasks">新建子任务</string> | ||
143 | <string name="please_enter_a_task_name">请输入任务名称</string> | ||
144 | <string name="character_limit_20">限制20个字符</string> | ||
145 | <string name="character_limit_10">限制10个字符</string> | ||
146 | <string name="next_step">下一步</string> | ||
147 | <string name="task_name">任务名称</string> | ||
148 | <string name="select_task">选择任务</string> | ||
149 | <string name="select_subtasks">选择子任务</string> | ||
150 | <string name="loop_route_repeat_timer">循环/定时/重复</string> | ||
151 | <string name="loop_route">循环</string> | ||
152 | |||
153 | <string name="repeat">重复</string> | ||
154 | <string name="section">区域</string> | ||
155 | <string name="navigation_point">导航点</string> | ||
156 | <string name="cleaning_point">清洁点</string> | ||
157 | <string name="select_gear">选择档位:</string> | ||
158 | |||
159 | |||
160 | <string name="select_area_or_point">选择区域或点:</string> | ||
161 | <string name="previous_step">上一步</string> | ||
162 | <string name="confirm">确定</string> | ||
163 | <string name="loop_route_task">循环任务</string> | ||
164 | <string name="please_select_a_loop_route_type">请选择循环类型</string> | ||
165 | <string name="frequency">次数</string> | ||
166 | <string name="duration">时长</string> | ||
167 | <string name="number_of_cycles_duration">循环次数/时长</string> | ||
168 | <string name="please_enter_number_of_loop_route">请输入循环次数</string> | ||
169 | <string name="please_enter_number_of_duration">请输入循环时长</string> | ||
170 | <string name="times">次</string> | ||
171 | |||
172 | <string name="create_schedule">创建定时</string> | ||
173 | <string name="is_it_scheduled">是否定时?</string> | ||
174 | <string name="yes">是</string> | ||
175 | <string name="no">否</string> | ||
176 | |||
177 | <string name="hour">时</string> | ||
178 | <string name="minute">分</string> | ||
179 | <string name="seconds">秒</string> | ||
180 | <string name="task_completed_and_return_to_the_point">任务结束返回点</string> | ||
181 | <string name="do_not_select">不选择</string> | ||
182 | <string name="stop_in_place_when_task_is_complete">任务结束后\n机器人将停在原地</string> | ||
183 | |||
184 | <string name="select">选择</string> | ||
185 | <string name="delete">删除</string> | ||
186 | |||
187 | <string name="upload">上传</string> | ||
188 | <string name="toggle">切换</string> | ||
189 | <string name="add_new_map">新增地图</string> | ||
190 | |||
191 | <string name="revoke">撤销</string> | ||
192 | <string name="add_area_or_point">添加区域或点</string> | ||
193 | <string name="delete_area_or_point">删除区域或点</string> | ||
194 | <string name="remove_noise_point">清躁点</string> | ||
195 | <string name="virtual_wall">虚拟墙</string> | ||
196 | <string name="area">区域</string> | ||
197 | <string name="starting_point">初始点</string> | ||
198 | <string name="charging_point">充电点</string> | ||
199 | <string name="navigating_point">导航点</string> | ||
200 | |||
201 | <string name="lift_control_point">梯控点</string> | ||
202 | <string name="map_toggle_point">地图切换点</string> | ||
203 | <string name="slope_area">斜坡区</string> | ||
204 | <string name="long_corridor">长走廊区</string> | ||
205 | <string name="blind_spot">盲道区</string> | ||
206 | <string name="obstacle_avoidance_area">避障区</string> | ||
207 | <string name="slow_speed_area">减速带区</string> | ||
208 | <string name="carpet_area">地毯区</string> | ||
209 | <string name="charging_auxiliary_point">充点辅助点</string> | ||
210 | <string name="qr_code_auxiliary_point">二维码辅助点</string> | ||
211 | <string name="bluetooth_auxiliary_point">蓝牙辅助点</string> | ||
212 | <string name="please_select_an_addition_type">请选择添加类型</string> | ||
213 | <string name="please_select_a_deletion_type">请选择删除类型</string> | ||
214 | <string name="add_virtual_wall">添加虚拟墙</string> | ||
215 | <string name="delete_virtual_wall">删除虚拟墙</string> | ||
216 | <string name="tip_remove_virtual_wall">提示:以对角线两点绘制正方形,连接点落在正方形区域内的虚拟墙会被整段删除</string> | ||
217 | <string name="tip_remove_noise_point">提示:清除噪点后,需要进行人工手动重定位!</string> | ||
218 | |||
219 | <string name="cancel">取消</string> | ||
220 | |||
221 | |||
222 | <string name="charge">充电</string> | ||
223 | <string name="dust_mop_mode">推尘模式</string> | ||
224 | <string name="self_cleaning_mode">自清洁模式</string> | ||
225 | <string name="cloth_change_mode">换布模式</string> | ||
226 | <string name="gear_1">一档</string> | ||
227 | <string name="gear_2">二档</string> | ||
228 | <string name="gear_3">三档</string> | ||
229 | <string name="gear_4">四档</string> | ||
230 | <string name="gear_5">五档</string> | ||
231 | <string name="gear">档位</string> | ||
232 | <string name="gear_control">档位控制</string> | ||
233 | <string name="constant_humidity">恒湿湿度</string> | ||
234 | <string name="humidity">湿度</string> | ||
235 | <string name="cancel_constant_humidity">取消恒湿</string> | ||
236 | <string name="set_schedule">定时</string> | ||
237 | <string name="set_2_hours">定时2小时</string> | ||
238 | <string name="hours">小时</string> | ||
239 | <string name="cancel_schedule">取消定时</string> | ||
240 | <string name="sleeping_mode">睡眠模式</string> | ||
241 | <string name="uv_light">紫外灯</string> | ||
242 | <string name="main_light">总灯</string> | ||
243 | <string name="light_1">灯 1</string> | ||
244 | <string name="light_2">灯 2</string> | ||
245 | <string name="light_3">灯 3</string> | ||
246 | <string name="light_4">灯 4</string> | ||
247 | <string name="light_num">灯 %d</string> | ||
248 | <string name="open_side_brush">边推放下</string> | ||
249 | <string name="close_side_brush">边推收起</string> | ||
250 | <string name="change_cloth_mode">换布模式</string> | ||
251 | <string name="proceed_to_charge">去充电</string> | ||
252 | |||
253 | <string name="the_battery_is_below">电量已低于%d %%</string> | ||
254 | <string name="please_charge_in_time">请及时充电</string> | ||
255 | <string name="please_replace_the_dust_mop_cloth_in_time">请及时更换尘推布</string> | ||
256 | <string name="the_machine_stalling_has_existed_configured_tim">机器已停留超时</string> | ||
257 | <string name="emergency_stop_button_pressed">急停按钮已按下</string> | ||
258 | <string name="emergency_stop_button_released">急停按钮已松开</string> | ||
259 | <string name="please_release_the_emergency_stop_button_first">请先松开急停按钮</string> | ||
260 | <string name="please_enter_a_name">请输入名称</string> | ||
261 | |||
262 | <string name="please_select_a_geolocation_method">请选择定位方式</string> | ||
263 | <string name="task_in_progress">进行中任务</string> | ||
264 | <string name="robot_controller_is_starting">机器人控制器启动中</string> | ||
265 | <string name="do_not_operate_while_the_robot_is_shutting_down">机器人关机中,请勿操作</string> | ||
266 | <string name="ethernet_connection_fails">以太网连接失败,请检查以太网设置,如果WiFi处于打开状态可以关闭WiFi来恢复以太网设置,操作完成后依然无法连接请检查网线连接是否正常</string> | ||
267 | <string name="disinfect_module_not_detected">未检测到消杀模组</string> | ||
268 | <string name="side_module_not_detected">未检测到边推模组</string> | ||
269 | <string name="confirm_delete_the_current_task">确定删除当前任务?</string> | ||
270 | <string name="confirm_delete_the_current_map">确定删除当前地图?</string> | ||
271 | <string name="dust_mop_cloth_has_been_replaced">已更换尘推布</string> | ||
272 | <string name="tip_change_cloth">现在可以更换尘推布了,更好完毕之后请务必将尘推杆推进去</string> | ||
273 | <string name="success">成功</string> | ||
274 | <string name="fail">失败</string> | ||
275 | <string name="cancel_cloth_change">取消换布</string> | ||
276 | |||
277 | <string name="cloth_change_completed">已完成换布</string> | ||
278 | <string name="side_brush_cloth_replaced">已更换边推布</string> | ||
279 | <string name="side_brush_cloth_can_be_changed_now">现在可以更换边推布了</string> | ||
280 | <string name="Are_you_sure_you_want_to_save_the_current_map">确认要保存当前地图吗?</string> | ||
281 | <string name="loading_data">正在加载数据</string> | ||
282 | <string name="make_current_point">确认要将机器人当前位置设为%s点吗</string> | ||
283 | <string name="have_x_point">已经有%s点,不可重复添加</string> | ||
284 | <string name="tip_add_area">添加区域必须处于当前使用的地图,如果增加,请先切换到对应地图</string> | ||
285 | <string name="tip_save_the_current_map">确认要保存当前地图吗?</string> | ||
286 | <string name="is_it_delete">是否删除?</string> | ||
287 | <string name="the_robot_is_currently_creating_the_map">机器人当前正在建图中</string> | ||
288 | <string name="create_map">去建图</string> | ||
289 | <string name="start_disinfection">是否开始消毒</string> | ||
290 | <string name="the_robot_has_a_network_failure">机器人发生网络故障,请联系工作人员</string> | ||
291 | <string name="delete_scheduled_tasks">是否删除定时任务</string> | ||
292 | <string name="the_location_is_lost">定位丢失啦,请联系工作人员</string> | ||
293 | <string name="the_robot_has_encountered_fault">机器人发生故障,请联系工作人员</string> | ||
294 | <string name="fault_cleared">故障已清除</string> | ||
295 | <string name="the_task_is_being_executed_pause_or_cancel">正在执行任务,是否暂停或取消</string> | ||
296 | <string name="pause_task">暂停任务</string> | ||
297 | <string name="cancel_task">取消任务</string> | ||
298 | <string name="are_you_sure_you_want_to_abort">确认要放弃吗</string> | ||
299 | <string name="are_you_sure_you_want_to_save">确认要保存吗?</string> | ||
300 | <string name="please_check_the_robot_status">请查看机器人状态,当前状态不能创建地图</string> | ||
301 | <string name="tip_delete_the_current_map">确认要删除当前地图吗?</string> | ||
302 | <string name="tip_set_this_as_the_current_map">确认要设置为当前地图吗?</string> | ||
303 | <string name="please_reset_the_robot_position_and_orientation">请重新设置机器人位置方向</string> | ||
304 | <string name="tip_cancel_the_map">机器人正在建图中,确认取消建图吗?</string> | ||
305 | <string name="tip_abort_map_editing">确认要放弃地图编辑吗?</string> | ||
306 | <string name="please_fill_in_address">请填写地址</string> | ||
307 | <string name="please_fill_in_leaseholder">请填写租户</string> | ||
308 | <string name="please_fill_in_the_speed">请填写速度</string> | ||
309 | <string name="the_audio_playback_interval_cannot_be_less_than_10_seconds">语音播放间隔不可小于10秒</string> | ||
310 | <string name="please_fill_in_the_play_time">请填写播放时间</string> | ||
311 | <string name="please_fill_in_the_play_text">请填写播放文本</string> | ||
312 | <string name="error_prompt">异常提示</string> | ||
313 | <string name="tip_automatic_map_error">自动加载地图异常,请到地图列表页面手动切换地图</string> | ||
314 | <string name="receive_cloud_map_data_accept">收到云端地图数据,是否接收?</string> | ||
315 | <string name="back_to_the_starting_point">回初始点</string> | ||
316 | <string name="an_abnormal_condition_is_detected">检测到异常状况,请联系专业人员</string> | ||
317 | <string name="remaining_amount_of_disinfectant_is_insufficient">消毒液余量不足,是否继续执行</string> | ||
318 | <string name="disinfecting_device_is_abnormal">消杀设备连接异常,请联系工作人员</string> | ||
319 | <string name="failed_to_load_map_data">加载地图数据失败</string> | ||
320 | <string name="no_availability_zones_spots">没有可用区域/点</string> | ||
321 | <string name="dust_mop_disinfect_choose_at_least_one">尘推/消杀至少选择一个</string> | ||
322 | <string name="nothing_to_save">没有可以保存的内容</string> | ||
323 | <string name="edit_map_name">修改地图名称</string> | ||
324 | <string name="failed_to_update_map_information">更新地图信息失败</string> | ||
325 | <string name="failed_to_switch_map_please_save_again">切换地图失败,请重新保存</string> | ||
326 | <string name="failed_to_load_virtual_wall">加载虚拟墙失败</string> | ||
327 | <string name="failed_to_save_please_save_again">保存失败,请重新保存</string> | ||
328 | <string name="there_is_currently_unsaved_content_please_save_it_first">当前有未保存的内容,请先处理</string> | ||
329 | <string name="the_current_map_has_no_relevant_content">当前地图没有相关的内容</string> | ||
330 | |||
331 | <string name="error">错误</string> | ||
332 | <string name="work_length">工作时长</string> | ||
333 | <string name="tip">提示</string> | ||
334 | <string name="select_action">请选择操作方式</string> | ||
335 | <string name="network_error_reset">网络异常,重连中</string> | ||
336 | <string name="name_is_none">名字不能为空</string> | ||
337 | <string name="level">级</string> | ||
338 | <string name="clean_switch">清空并切换</string> | ||
339 | <string name="cancel_switch">取消切换</string> | ||
340 | <string name="is_delete_task">确认删除当前任务吗?</string> | ||
341 | <string name="everyday">每日</string> | ||
342 | <string name="connect_setting">继续设置</string> | ||
343 | |||
344 | <string name="account_information">账号信息</string> | ||
345 | <string name="please_input_replacement_cycle">请输入更换周期</string> | ||
346 | <string name="please_input_expiration_time">请输入超时时间</string> | ||
347 | <string name="request_success_2">指令下发成功</string> | ||
348 | <string name="request_fail_2">指令下发失败</string> | ||
349 | <string name="request_success">请求成功</string> | ||
350 | <string name="request_fail">请求失败</string> | ||
351 | <string name="interval_length">间隔时长</string> | ||
352 | <string name="not_create_map_charging">机器充电中不能创建地图</string> | ||
353 | <string name="cannot_switch_the_map">无法切换地图</string> | ||
354 | <string name="map_switched_successfully">已经切换成功</string> | ||
355 | <string name="current_map_cannot_delete">当前地图不能删除</string> | ||
356 | <string name="delete_failed">删除失败</string> | ||
357 | <string name="please_enter_the_advanced_access_password_to_upload_map">上传地图,请输入高级权限密码</string> | ||
358 | <string name="wrong_password">密码错误</string> | ||
359 | <string name="repositioning_manully">手动重定位</string> | ||
360 | <string name="charging_2">正在充电</string> | ||
361 | <string name="cancel_charging">取消充电</string> | ||
362 | <string name="collision_detected">检测到了碰撞</string> | ||
363 | <string name="return_to_working_status">恢复为工作状态</string> | ||
364 | <string name="brief_report">简报</string> | ||
365 | <string name="map_list">地图列表</string> | ||
366 | <string name="task_list">任务列表</string> | ||
367 | <string name="this_task">此次任务</string> | ||
368 | <string name="to_do_list_for_today">今日后续</string> | ||
369 | <string name="no_more_tasks">暂无后续任务</string> | ||
370 | <string name="start">开始</string> | ||
371 | <string name="skip">跳过</string> | ||
372 | <string name="working_area_of_yesterday">昨日工作面积(平米)</string> | ||
373 | <string name="m_2">平米</string> | ||
374 | <string name="no_work_yesterday">昨日未工作</string> | ||
375 | <string name="working_duration_of_yesterday">昨日工作时长(分钟)</string> | ||
376 | <string name="mins">分钟</string> | ||
377 | <string name="set_parameter_value">设置参数值</string> | ||
378 | <string name="please_set_execute_time_for_scheduled_task">定时任务需要设置执行的时间</string> | ||
379 | <string name="please_enter_loop_route_type">请输入循环类型</string> | ||
380 | <string name="set_up_area_gear">设置区域/档位</string> | ||
381 | <string name="cannot_find_related_area">没有相关区域</string> | ||
382 | <string name="duration_2">持续时长</string> | ||
383 | <string name="expired">已失效</string> | ||
384 | <string name="charging_in_progress">充电任务执行中</string> | ||
385 | <string name="charging_pile_not_set_yet">还未设置充电桩</string> | ||
386 | <string name="work_completed_i_am_heading_to_charging_pile">工作已完成,我要回去充电了</string> | ||
387 | <string name="work_completed_backing_to_starting_point">工作已完成,即将返回初始点</string> | ||
388 | <string name="this_task_cannot_be_excuted_by_current_map">当前地图无法执行该任务</string> | ||
389 | <string name="task_is_executing">当前有任务正在执行</string> | ||
390 | <string name="cloth_changing_cannot_execute_the_task">正在换布,无法开始任务</string> | ||
391 | <string name="low_battery_cannot_execute_the_task">电量过低,无法开始任务</string> | ||
392 | <string name="cannot_execute_the_task">当前机器处于 %s 状态,无法开始任务</string> | ||
393 | <string name="task_failed">任务失败</string> | ||
394 | <string name="map_loading_incorrect">当前机器未正确加载地图</string> | ||
395 | <string name="working_status">工作状态</string> | ||
396 | <string name="free">空闲中</string> | ||
397 | <string name="error_2">出错</string> | ||
398 | <string name="system_initializing">系统初始化中</string> | ||
399 | <string name="mapping_starting">建图启动中</string> | ||
400 | <string name="mapping">建图中</string> | ||
401 | <string name="mapping_stopped">建图停止中</string> | ||
402 | <string name="map_switching">切换地图中</string> | ||
403 | <string name="map_loading">地图加载中</string> | ||
404 | <string name="coverage_path_generating">生成覆盖路径中</string> | ||
405 | <string name="initializing_position">初始化定位中</string> | ||
406 | <string name="task_executing">任务执行中</string> | ||
407 | <string name="task_suspending">任务暂停中</string> | ||
408 | <string name="unknown">未知</string> | ||
409 | <string name="path_planning_inaccessable">规划路径获取失败</string> | ||
410 | <string name="switch_map_delete_point">切换地图会导致已选(区域/点)被清空</string> | ||
411 | <string name="take_care_xiao_pai_is_coming">小派来了,请小心</string> | ||
412 | <string name="task_expired_cannot_save_successfully">存在已经失效的任务,不能保存</string> | ||
413 | <string name="the_number_of_task_cannot_be_empty">任务数量不能为0</string> | ||
414 | <string name="cannot_find_toggle_point">没有地图切换点(缺少对应梯控点)</string> | ||
415 | <string name="task_add_failed_this_task_is_expired">此任务已失效,不可添加</string> | ||
416 | <string name="daily">每日</string> | ||
417 | <string name="this_task_need_to_be_executed_manually">是否按照手动执行并执行一次的方式创建</string> | ||
418 | <string name="save_this_setting">保存此设置</string> | ||
419 | <string name="working_area">工作区域</string> | ||
420 | <string name="side_brush_area">边推区域</string> | ||
421 | <string name="positioning_auxiliary_point">定位辅助点</string> | ||
422 | <string name="exit_current_view">是否退出当前界面?</string> | ||
423 | <string name="exit">退出</string> | ||
424 | <string name="error_path_is_null">规划路径失败</string> | ||
425 | <string name="saved_successfully">保存成功</string> | ||
426 | <string name="save_failed">保存失败</string> | ||
427 | <string name="xiao_pai_controller">小派控制中心</string> | ||
428 | <string name="robot_msg">机器信息</string> | ||
429 | <string name="battery">当前电量</string> | ||
430 | <string name="position">位置</string> | ||
431 | <string name="use_current_coordinates">使用当前位置</string> | ||
432 | <string name="manually_dimension_coordinates">手动标注</string> | ||
433 | <string name="user_this_point">确认要将机器人当前位置设为充电点吗</string> | ||
434 | <string name="address_is_error">域名错误</string> | ||
435 | <string name="edit_map_ing">编辑地图进度条</string> | ||
436 | <string name="change_map_ing">切换地图进度条</string> | ||
437 | <string name="input_wifi_name">请输入Wi-Fi名称</string> | ||
438 | <string name="input_pwd">请输入密码</string> | ||
439 | <string name="wifi_error">以太网连接失败</string> | ||
440 | <string name="ok">确定</string> | ||
441 | <string name="tv_work">工作界面</string> | ||
442 | <string name="auxiliary_point_fail">重定位辅助点失败</string> | ||
443 | <string name="loading_progress">正在上传</string> | ||
444 | <string name="loading_progress_message">请耐心等待,马上就好哦...</string> | ||
445 | <string name="time_remaining">剩余时间</string> | ||
446 | <string name="execute_immediately">立即执行</string> | ||
447 | <string name="tip_dont_same_name">注意:同一张地图,区域/点 名称不可重复</string> | ||
448 | <string name="be_about_to_start_task">即将开始定时任务</string> | ||
449 | <string name="input_clean_name">请输入清洁点名称</string> | ||
450 | |||
451 | |||
452 | <!-- 以下的为洗扫的,暂时不做其他语言翻译--> | ||
453 | <string name="wash_sweep">洗扫</string> | ||
454 | <string name="change_side_brush">更换边刷</string> | ||
455 | <string name="down_side_brush">边刷放下</string> | ||
456 | <string name="up_side_brush">边刷收起</string> | ||
457 | <string name="wash_sweep_setting">洗扫设置</string> | ||
458 | <string name="turn_off">关闭</string> | ||
459 | <string name="spray">喷水</string> | ||
460 | <string name="side_brush">边刷</string> | ||
461 | <string name="put_down_the_washing_rake">放下洗水耙</string> | ||
462 | <string name="lifting">抬升</string> | ||
463 | <string name="air_duct">风道</string> | ||
464 | <string name="auto_drainage">自动排水</string> | ||
465 | <string name="auto_add_water">自动加水</string> | ||
466 | |||
467 | |||
468 | <!-- 以上的为洗扫的,暂时不做其他语言翻译 end--> | ||
469 | <string name="tv_RCU">RCU版本</string> | ||
470 | <string name="tv_CCU">CCU版本</string> | ||
471 | <string name="tv_ECU">ECU版本</string> | ||
472 | <string name="tv_IP">IP地址</string> | ||
473 | <string name="tv_machine_info">本机信息</string> | ||
474 | |||
475 | <string name="language_null">""</string> | ||
476 | <string name="language_english_1">(英语)</string> | ||
477 | <string name="language_japanese">日本語</string> | ||
478 | <string name="language_japanese_1">(日语)</string> | ||
479 | |||
480 | <string name="changing">切换中</string> | ||
481 | <string name="is_change_current_map">是否切换当前地图</string> | ||
482 | <string name="upload_cloud_error">上传云端异常 %s 请重试或者联系客服</string> | ||
483 | <string name="get_zip_file_error">获取压缩文件失败 %s 请重试或者联系客服</string> | ||
484 | <string name="compressed_zip_file_progress_error">获取压缩进度失败 %s 请重试或者联系客服</string> | ||
485 | <string name="compressed_zip_file_error">压缩失败 %s 请重试或者联系客服</string> | ||
486 | <string name="compressed_zip_file">压缩文件中..</string> | ||
487 | <string name="get_zip_file_ing">获取压缩地图中....</string> | ||
488 | <string name="upload_cloud">上传云端...</string> | ||
489 | <string name="get_file_error">获取文件失败</string> | ||
490 | <string name="input_new_map_name">请输入新建地图的名称</string> | ||
491 | <string name="retry">重试</string> | ||
492 | <string name="map_name_already_exists">地图名称已存在</string> | ||
493 | <string name="loading">加载中...</string> | ||
494 | <string name="task_run_error">该任务未完成</string> | ||
495 | <string name="same_file_name_please_delete">存在相同文件 %s,如需继续,请删除对应文件</string> | ||
496 | <string name="downloading_from_the_cloud">从云端下载中...</string> | ||
497 | <string name="failed_to_transfer_the_file">转存文件失败</string> | ||
498 | <string name="Start_storing_to_ccu">开始存储至CCU</string> | ||
499 | <string name="download_file_failed">下载文件失败</string> | ||
500 | <string name="start_extracting_files_ccu">CCU开始解压</string> | ||
501 | <string name="uploading_ccu_failed">上传CCU失败</string> | ||
502 | <string name="decompression_failed">解压失败</string> | ||
503 | <string name="download_succeeded">下载成功</string> | ||
504 | <string name="updating">更新中...</string> | ||
505 | <string name="name_cannot_be_duplicate">名称不可重复</string> | ||
506 | <string name="tv_wifi_status">已连接</string> | ||
507 | <string name="no_corresponding_content">没有相应的内容</string> | ||
508 | <string name="be_about_to_start_charge_task">即将开始充电任务</string> | ||
509 | <string name="be_battery_tips">电量不足,我要回去充电了</string> | ||
510 | <string name="other_txt">其他...</string> | ||
511 | <string name="hand_area">手绘区域路径</string> | ||
512 | <string name="machine_area">机器定位区域路径</string> | ||
513 | <string name="choose_text">选择路径位置:</string> | ||
514 | <string name="choose_text_start">第一点</string> | ||
515 | <string name="choose_text_end">第二点</string> | ||
516 | <string name="save_hand_path">保存失败,区域路径需要画两个点以上</string> | ||
517 | <string name="txt_robot">机器人\n正在关机...</string> | ||
518 | <string name="txt_machine_positioning_failed">机器人定位失败,请先重新定位!</string> | ||
519 | <string name="txt_machine_creating_map">正在建地图中,确定需要停止建图?</string> | ||
520 | |||
521 | </resources> | ||
522 |
libs/common/src/main/res/values/styles.xml
File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
2 | <resources> | ||
3 | |||
4 | <style name="CustomDialog" parent="Theme.AppCompat.Dialog"> | ||
5 | <item name="android:backgroundDimEnabled">false</item> | ||
6 | <item name="android:windowBackground">@android:color/transparent</item> | ||
7 | </style> | ||
8 | |||
9 | <!--DialogView Theme Style--> | ||
10 | <style name="Theme_Dialog" parent="Theme.AppCompat.Dialog"> | ||
11 | <item name="android:windowBackground">@android:color/transparent</item> | ||
12 | <item name="windowNoTitle">true</item> | ||
13 | </style> | ||
14 | |||
15 | |||
16 | </resources> |
libs/common/src/main/res/values/themes.xml
File was created | 1 | <resources> | |
2 | |||
3 | |||
4 | <style name="tv_set_wifi"> | ||
5 | <item name="android:layout_width">wrap_content</item> | ||
6 | <item name="android:layout_height">wrap_content</item> | ||
7 | <item name="android:textColor">@color/white</item> | ||
8 | <item name="android:textSize">32sp</item> | ||
9 | <item name="android:layout_marginStart">60dp</item> | ||
10 | </style> | ||
11 | |||
12 | </resources> |
settings.gradle
File was created | 1 | rootProject.name = "parent" | |
2 | include ':app' | ||
3 | include ':libs:common' | ||
4 |