├── settings.gradle
├── github
├── logo.png
├── screenshot_01.jpg
├── screenshot_02.jpg
└── screenshot_03.jpg
├── app
├── src
│ └── main
│ │ ├── res
│ │ ├── xml
│ │ │ ├── filepaths.xml
│ │ │ └── network_security_config.xml
│ │ ├── drawable
│ │ │ ├── into.png
│ │ │ ├── logo.png
│ │ │ ├── aliyun_qrcode.png
│ │ │ ├── side_nav_bar.jpg
│ │ │ ├── default_avatar.png
│ │ │ ├── info_small_icon.png
│ │ │ ├── ic_book_black_24dp.png
│ │ │ ├── ic_card_black_24dp.png
│ │ │ ├── ic_cet_black_24dp.png
│ │ │ ├── ic_home_black_24dp.png
│ │ │ ├── ic_lost_black_24dp.png
│ │ │ ├── fragment_index_card.png
│ │ │ ├── fragment_index_image.jpg
│ │ │ ├── gdeiassistant_qrcode.jpg
│ │ │ ├── ic_about_black_24dp.png
│ │ │ ├── ic_charge_black_24dp.png
│ │ │ ├── ic_class_black_24dp.png
│ │ │ ├── ic_grade_black_24dp.png
│ │ │ ├── ic_refresh_white_24dp.png
│ │ │ ├── tencentcloud_qrcode.jpeg
│ │ │ ├── checkcode_not_available.png
│ │ │ ├── fragment_index_schedule.png
│ │ │ ├── ic_evaluate_black_24dp.png
│ │ │ ├── ic_credit_card_black_24dp.png
│ │ │ ├── ic_exit_to_app_black_24dp.png
│ │ │ ├── ic_system_update_black_24dp.png
│ │ │ ├── ic_arrow_drop_down_white_24dp.png
│ │ │ ├── pressable_white_normal.xml
│ │ │ ├── pressable_white_pressed.xml
│ │ │ └── pressable_white_background.xml
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── menu
│ │ │ ├── options_menu.xml
│ │ │ ├── menu_toolbar.xml
│ │ │ └── activity_main_drawer.xml
│ │ ├── layout
│ │ │ ├── item_listview_number.xml
│ │ │ ├── item_gridview_date.xml
│ │ │ ├── progressdialog.xml
│ │ │ ├── activity_guide.xml
│ │ │ ├── content_main.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── app_bar_main.xml
│ │ │ ├── activity_webview.xml
│ │ │ ├── nav_header_main.xml
│ │ │ ├── grade_item.xml
│ │ │ ├── todayschedule_item.xml
│ │ │ ├── book_item.xml
│ │ │ ├── card_item.xml
│ │ │ ├── activity_lost.xml
│ │ │ ├── activity_evaluate.xml
│ │ │ ├── fragment_schedule.xml
│ │ │ └── activity_book.xml
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── values-v21
│ │ │ └── styles.xml
│ │ ├── java
│ │ └── cn
│ │ │ └── gdeiassistant
│ │ │ ├── Constant
│ │ │ ├── CetTagConstant.java
│ │ │ ├── IndexTagConstant.java
│ │ │ ├── EvaluateTagConstant.java
│ │ │ ├── ChangeAvatarOptionConstant.java
│ │ │ ├── NotificationIDConstant.java
│ │ │ ├── ChargeTagConstant.java
│ │ │ ├── PermissionRequestCodeConstant.java
│ │ │ ├── MainTagConstant.java
│ │ │ ├── ActivityRequestCodeConstant.java
│ │ │ ├── MainItemTagConstant.java
│ │ │ ├── RequestConstant.java
│ │ │ ├── NetWorkTimeoutConstant.java
│ │ │ └── ResultConstant.java
│ │ │ ├── Exception
│ │ │ └── ResponseStatusCodeException.java
│ │ │ ├── Pojo
│ │ │ ├── Entity
│ │ │ │ ├── EncryptedData.java
│ │ │ │ ├── Charge.java
│ │ │ │ ├── Profile.java
│ │ │ │ ├── Token.java
│ │ │ │ ├── Cookie.java
│ │ │ │ ├── Card.java
│ │ │ │ ├── CardInfo.java
│ │ │ │ ├── Book.java
│ │ │ │ ├── Cet.java
│ │ │ │ ├── Access.java
│ │ │ │ └── Grade.java
│ │ │ ├── Login
│ │ │ │ └── UserLoginResult.java
│ │ │ ├── Token
│ │ │ │ └── TokenRefreshResult.java
│ │ │ ├── JsonResult
│ │ │ │ ├── DataJsonResult.java
│ │ │ │ └── JsonResult.java
│ │ │ ├── CardQuery
│ │ │ │ └── CardQueryResult.java
│ │ │ ├── ScheduleQuery
│ │ │ │ └── ScheduleQueryResult.java
│ │ │ ├── Upgrade
│ │ │ │ └── CheckUpgradeResult.java
│ │ │ ├── OssFederationToken
│ │ │ │ └── OssFederationTokenResult.java
│ │ │ └── GradeQuery
│ │ │ │ └── GradeQueryResult.java
│ │ │ ├── Tools
│ │ │ ├── NetWorkUtils.java
│ │ │ ├── OkHttpUtils.java
│ │ │ ├── TimeUtils.java
│ │ │ ├── StringUtils.java
│ │ │ ├── TokenUtils.java
│ │ │ └── AESUtils.java
│ │ │ ├── Presenter
│ │ │ ├── WebViewPresenter.java
│ │ │ ├── BookDetailPresenter.java
│ │ │ ├── EvaluatePresenter.java
│ │ │ ├── LostPresenter.java
│ │ │ ├── BookPresenter.java
│ │ │ └── SchedulePresenter.java
│ │ │ ├── View
│ │ │ ├── ListView
│ │ │ │ └── ListViewForScrollView.java
│ │ │ ├── Dialog
│ │ │ │ └── ProgressDialogCreator.java
│ │ │ └── Adapter
│ │ │ │ ├── ListViewNumberAdapter.java
│ │ │ │ ├── GridViewDateAdapter.java
│ │ │ │ ├── GradeListViewAdapter.java
│ │ │ │ ├── BookListViewAdapter.java
│ │ │ │ └── TodayScheduleListViewAdapter.java
│ │ │ ├── NetWork
│ │ │ ├── EncryptionNetWork.java
│ │ │ ├── CheckUpgradeNetWork.java
│ │ │ ├── OSSNetWork.java
│ │ │ ├── LostNetWork.java
│ │ │ ├── EvaluateNetWork.java
│ │ │ ├── ProfileNetWork.java
│ │ │ ├── AccessNetWork.java
│ │ │ ├── TokenNetWork.java
│ │ │ ├── ScheduleQueryNetWork.java
│ │ │ ├── GradeQueryNetWork.java
│ │ │ ├── LoginNetWork.java
│ │ │ ├── ChargeNetWork.java
│ │ │ ├── CetQueryNetWork.java
│ │ │ ├── BookNetWork.java
│ │ │ └── CardQueryNetWork.java
│ │ │ ├── Activity
│ │ │ ├── AboutSoftWareActivity.java
│ │ │ ├── WebViewActivity.java
│ │ │ ├── GradeDetailActivity.java
│ │ │ ├── LostActivity.java
│ │ │ └── EvaluateActivity.java
│ │ │ └── Model
│ │ │ ├── LostModel.java
│ │ │ ├── BitmapFileModel.java
│ │ │ ├── EvaluateModel.java
│ │ │ ├── GuideModel.java
│ │ │ ├── GradeQueryModel.java
│ │ │ ├── ScheduleQueryModel.java
│ │ │ ├── LoginModel.java
│ │ │ └── CardQueryModel.java
│ │ └── AndroidManifest.xml
├── libs
│ └── aliyun-oss-sdk-android-2.4.3.jar
├── build.gradle
└── proguard-rules.pro
├── README.md
├── gradlew.bat
└── LICENSE.md
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/github/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/github/logo.png
--------------------------------------------------------------------------------
/github/screenshot_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/github/screenshot_01.jpg
--------------------------------------------------------------------------------
/github/screenshot_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/github/screenshot_02.jpg
--------------------------------------------------------------------------------
/github/screenshot_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/github/screenshot_03.jpg
--------------------------------------------------------------------------------
/app/src/main/res/xml/filepaths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/into.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/into.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/libs/aliyun-oss-sdk-android-2.4.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/libs/aliyun-oss-sdk-android-2.4.3.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/aliyun_qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/aliyun_qrcode.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/side_nav_bar.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/default_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/default_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/info_small_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/info_small_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_book_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_book_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_card_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_card_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_cet_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_cet_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_home_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_lost_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_lost_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fragment_index_card.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/fragment_index_card.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fragment_index_image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/fragment_index_image.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gdeiassistant_qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/gdeiassistant_qrcode.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_about_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_about_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_charge_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_charge_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_class_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_class_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_grade_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_grade_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_refresh_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_refresh_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/tencentcloud_qrcode.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/tencentcloud_qrcode.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/checkcode_not_available.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/checkcode_not_available.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fragment_index_schedule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/fragment_index_schedule.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_evaluate_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_evaluate_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_credit_card_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_credit_card_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_exit_to_app_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_exit_to_app_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_system_update_black_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_system_update_black_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GdeiAssistant/GdeiAssistant-Android/HEAD/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/CetTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class CetTagConstant {
4 |
5 | public static final int CHECK_CODE = 0;
6 |
7 | public static final int CET_QUERY = 1;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/IndexTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class IndexTagConstant {
4 |
5 | public static final int SCHEDULE_QUERY = 0;
6 |
7 | public static final int CARD_QUERY = 1;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/options_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/EvaluateTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class EvaluateTagConstant {
4 |
5 | public static final int NORMAL_SUBMIT = 0;
6 |
7 | public static final int DIRECTLY_SUBMIT = 1;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/ChangeAvatarOptionConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class ChangeAvatarOptionConstant {
4 |
5 | public static final int GET_PHOTO_FROM_ALBUM = 0;
6 |
7 | public static final int GET_PHOTO_FROM_CAMERA = 1;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/NotificationIDConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class NotificationIDConstant {
4 |
5 | public static final int PATCH_NOTIFICATION_ID = 2008;
6 |
7 | public static final int UPGRADE_NOTIFICATION_ID = 2018;
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pressable_white_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pressable_white_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/ChargeTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class ChargeTagConstant {
4 |
5 | //获取校园卡基本信息
6 | public static final int GET_CARD_INFO = 0;
7 |
8 | //提交充值请求
9 | public static final int SUBMIT_CHARGE = 1;
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/PermissionRequestCodeConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class PermissionRequestCodeConstant {
4 |
5 | public static final int PERMISSION_ALBUM = 0;
6 |
7 | public static final int PERMISSION_CAMERA = 1;
8 |
9 | public static final int LOAD_AVATAR = 2;
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pressable_white_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_listview_number.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/MainTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class MainTagConstant {
4 |
5 | public static final int DOWNLOAD_AVATAR = 0;
6 |
7 | public static final int UPLOAD_AVATAR = 1;
8 |
9 | public static final int GET_USER_PROFILE = 2;
10 |
11 | public static final int GET_USER_ACCESS = 3;
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_gridview_date.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 160dp
7 | 16dp
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Exception/ResponseStatusCodeException.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Exception;
2 |
3 | /**
4 | * 访问API接口时,返回的HTTP状态码不是200时,抛出该异常
5 | */
6 | public class ResponseStatusCodeException extends Exception {
7 |
8 | public ResponseStatusCodeException() {
9 |
10 | }
11 |
12 | public ResponseStatusCodeException(String message) {
13 | super(message);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/ActivityRequestCodeConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class ActivityRequestCodeConstant {
4 |
5 | public static final int RESULT_PHOTO_FROM_ALBUM = 0;
6 |
7 | public static final int RESULT_PHOTO_FROM_CAMERA = 1;
8 |
9 | public static final int RESULT_SAVE_PHOTO_TO_VIEW = 2;
10 |
11 | public static final int BROWSER_UPDATE_REQUEST_CODE = 3;
12 |
13 | public static final int RESULT_BOOK_RENEW = 4;
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 广东二师助手
4 |
5 | Open navigation drawer
6 | Close navigation drawer
7 |
8 |
9 | 7UnEVKNng3XV/eBcsL1/lRIANRfXcoPT
10 |
11 |
12 | https://gdeiassistant.azurewebsites.net/
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/MainItemTagConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class MainItemTagConstant {
4 |
5 | public static final int TAG_INDEX = 0;
6 |
7 | public static final int TAG_GRADE = 1;
8 |
9 | public static final int TAG_SCHEDULE = 2;
10 |
11 | public static final int TAG_CET = 3;
12 |
13 | public static final int TAG_EVALUATE = 4;
14 |
15 | public static final int TAG_CARD = 5;
16 |
17 | public static final int TAG_CHARGE = 6;
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/RequestConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class RequestConstant {
4 |
5 | public static final int REQUEST_TIMEOUT = 0;
6 |
7 | public static final int REQUEST_SUCCESS = 1;
8 |
9 | public static final int REQUEST_FAILURE = 2;
10 |
11 | public static final int CLIENT_ERROR = 3;
12 |
13 | public static final int SERVER_ERROR = 4;
14 |
15 | public static final int UNKNOWN_ERROR = 5;
16 |
17 | public static final int EMPTY_RESULT = 6;
18 |
19 | public static final int SHOW_PROGRESS = 7;
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/progressdialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/EncryptedData.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | @JsonIgnoreProperties(ignoreUnknown = true)
6 | public class EncryptedData {
7 |
8 | private String data;
9 |
10 | private String signature;
11 |
12 | public String getData() {
13 | return data;
14 | }
15 |
16 | public void setData(String data) {
17 | this.data = data;
18 | }
19 |
20 | public String getSignature() {
21 | return signature;
22 | }
23 |
24 | public void setSignature(String signature) {
25 | this.signature = signature;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/NetWorkUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | public class NetWorkUtils {
8 |
9 | /**
10 | * 检测现在手机是否使用WIFI
11 | *
12 | * @param context
13 | * @return
14 | */
15 | public static boolean IsUsingWifi(Context context) {
16 | ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
17 | NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
18 | return activeNetInfo != null && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/OkHttpUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.concurrent.TimeUnit;
6 |
7 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
8 | import okhttp3.OkHttpClient;
9 |
10 | public class OkHttpUtils {
11 |
12 | /**
13 | * 获取OkHttpClient对象
14 | *
15 | * @param timeout 超时时间,单位为秒
16 | * @param context
17 | * @return
18 | */
19 | public static OkHttpClient GetOkHttpClient(int timeout, Context context) {
20 | return new OkHttpClient.Builder()
21 | .connectTimeout(timeout, TimeUnit.SECONDS).readTimeout(timeout, TimeUnit.SECONDS)
22 | .writeTimeout(timeout, TimeUnit.SECONDS).cookieJar(((GdeiAssistantApplication) context).getCookieJar())
23 | .build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/WebViewPresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.content.Intent;
4 |
5 | import cn.gdeiassistant.Activity.WebViewActivity;
6 |
7 | public class WebViewPresenter {
8 |
9 | private WebViewActivity webViewActivity;
10 |
11 | public WebViewPresenter(WebViewActivity webViewActivity) {
12 | this.webViewActivity = webViewActivity;
13 | Init();
14 | }
15 |
16 | private void Init() {
17 | Intent intent = webViewActivity.getIntent();
18 | String title = intent.getStringExtra("title");
19 | String url = intent.getStringExtra("url");
20 | if (title != null) {
21 | webViewActivity.SetTitleName(title);
22 | }
23 | if (url != null) {
24 | webViewActivity.LoadWeb(url);
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Login/UserLoginResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Login;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | import cn.gdeiassistant.Pojo.Entity.Token;
8 |
9 | @JsonIgnoreProperties(ignoreUnknown = true)
10 | public class UserLoginResult implements Serializable {
11 |
12 | private Token accessToken;
13 |
14 | private Token refreshToken;
15 |
16 | public Token getAccessToken() {
17 | return accessToken;
18 | }
19 |
20 | public void setAccessToken(Token accessToken) {
21 | this.accessToken = accessToken;
22 | }
23 |
24 | public Token getRefreshToken() {
25 | return refreshToken;
26 | }
27 |
28 | public void setRefreshToken(Token refreshToken) {
29 | this.refreshToken = refreshToken;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Token/TokenRefreshResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Token;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | import cn.gdeiassistant.Pojo.Entity.Token;
8 |
9 | @JsonIgnoreProperties(ignoreUnknown = true)
10 | public class TokenRefreshResult implements Serializable {
11 |
12 | private Token accessToken;
13 |
14 | private Token refreshToken;
15 |
16 | public Token getAccessToken() {
17 | return accessToken;
18 | }
19 |
20 | public void setAccessToken(Token accessToken) {
21 | this.accessToken = accessToken;
22 | }
23 |
24 | public Token getRefreshToken() {
25 | return refreshToken;
26 | }
27 |
28 | public void setRefreshToken(Token refreshToken) {
29 | this.refreshToken = refreshToken;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/JsonResult/DataJsonResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.JsonResult;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | @JsonIgnoreProperties(ignoreUnknown = true)
6 | public class DataJsonResult extends JsonResult {
7 |
8 | private T data;
9 |
10 | public T getData() {
11 | return data;
12 | }
13 |
14 | public void setData(T data) {
15 | this.data = data;
16 | }
17 |
18 | public DataJsonResult() {
19 |
20 | }
21 |
22 | public DataJsonResult(Boolean success, T data) {
23 | super(success);
24 | this.data = data;
25 | }
26 |
27 | public DataJsonResult(Boolean success, String message) {
28 | super(success, message);
29 | }
30 |
31 | public DataJsonResult(Boolean success, Integer code, String message) {
32 | super(success, code, message);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/CardQuery/CardQueryResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.CardQuery;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 | import java.util.List;
7 |
8 | import cn.gdeiassistant.Pojo.Entity.Card;
9 | import cn.gdeiassistant.Pojo.Entity.CardInfo;
10 |
11 | @JsonIgnoreProperties(ignoreUnknown = true)
12 | public class CardQueryResult implements Serializable {
13 |
14 | private CardInfo cardInfo;
15 |
16 | private List cardList;
17 |
18 | public List getCardList() {
19 | return cardList;
20 | }
21 |
22 | public void setCardList(List cardList) {
23 | this.cardList = cardList;
24 | }
25 |
26 | public CardInfo getCardInfo() {
27 | return cardInfo;
28 | }
29 |
30 | public void setCardInfo(CardInfo cardInfo) {
31 | this.cardInfo = cardInfo;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Charge.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.alibaba.fastjson.annotation.JSONField;
4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5 |
6 | import java.io.Serializable;
7 | import java.util.List;
8 |
9 | @JsonIgnoreProperties(ignoreUnknown = true)
10 | public class Charge implements Serializable {
11 |
12 | @JSONField(ordinal = 1)
13 | private String alipayURL;
14 |
15 | @JSONField(ordinal = 2)
16 | private List cookieList;
17 |
18 | public List getCookieList() {
19 | return cookieList;
20 | }
21 |
22 | public void setCookieList(List cookieList) {
23 | this.cookieList = cookieList;
24 | }
25 |
26 | public String getAlipayURL() {
27 | return alipayURL;
28 | }
29 |
30 | public void setAlipayURL(String alipayURL) {
31 | this.alipayURL = alipayURL;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Profile.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Profile implements Serializable {
9 |
10 | private String avatarURL;
11 |
12 | private String username;
13 |
14 | private String nickname;
15 |
16 | public String getNickname() {
17 | return nickname;
18 | }
19 |
20 | public void setNickname(String nickname) {
21 | this.nickname = nickname;
22 | }
23 |
24 | public String getAvatarURL() {
25 | return avatarURL;
26 | }
27 |
28 | public void setAvatarURL(String avatarURL) {
29 | this.avatarURL = avatarURL;
30 | }
31 |
32 | public String getUsername() {
33 | return username;
34 | }
35 |
36 | public void setUsername(String username) {
37 | this.username = username;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/ListView/ListViewForScrollView.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.ListView;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.ListView;
6 |
7 | public class ListViewForScrollView extends ListView {
8 |
9 | public ListViewForScrollView(Context context) {
10 | super(context);
11 | }
12 |
13 | public ListViewForScrollView(Context context, AttributeSet attrs) {
14 | super(context, attrs);
15 | }
16 |
17 | public ListViewForScrollView(Context context, AttributeSet attrs, int defStyle) {
18 | super(context, attrs, defStyle);
19 | }
20 |
21 | /**
22 | * 重写该方法,达到使ListView适应ScrollView的效果
23 | */
24 | @Override
25 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
26 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
27 | super.onMeasure(widthMeasureSpec, expandSpec);
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/NetWorkTimeoutConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class NetWorkTimeoutConstant {
4 |
5 | public static final int CARD_QUERY_NETWORK_TIMEOUT = 15;
6 |
7 | public static final int CET_QUERY_NETWORK_TIMEOUT = 5;
8 |
9 | public static final int CHARGE_NETWORK_TIMEOUT = 15;
10 |
11 | public static final int CHECK_UPGRADE_NETWORK_TIMEOUT = 3;
12 |
13 | public static final int ENCRYPT_NETWORK_TIMEOUT = 3;
14 |
15 | public static final int EVALUATE_NETWORK_TIMEOUT = 15;
16 |
17 | public static final int BOOK_QUERY_NETWORK_TIMEOUT = 15;
18 |
19 | public static final int GRADE_QUERY_NETWORK_TIMEOUT = 15;
20 |
21 | public static final int LOGIN_NETWORK_TIMEOUT = 15;
22 |
23 | public static final int CARD_LOST_NETWORK_TIMEOUT = 15;
24 |
25 | public static final int OSS_NETWORK_TIMEOUT = 3;
26 |
27 | public static final int PROFILE_NETWORK_TIMEOUT = 3;
28 |
29 | public static final int SCHEDULE_QUERY_NETWORK_TIMEOUT = 15;
30 |
31 | public static final int TOKEN_NETWORK_TIMEOUT = 3;
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/ScheduleQuery/ScheduleQueryResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.ScheduleQuery;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 | import java.util.List;
7 |
8 | import cn.gdeiassistant.Pojo.Entity.Schedule;
9 |
10 | @JsonIgnoreProperties(ignoreUnknown = true)
11 | public class ScheduleQueryResult implements Serializable {
12 |
13 | private List scheduleList;
14 |
15 | private Integer week;
16 |
17 | public List getScheduleList() {
18 | return scheduleList;
19 | }
20 |
21 | public void setScheduleList(List scheduleList) {
22 | this.scheduleList = scheduleList;
23 | }
24 |
25 | public Integer getWeek() {
26 | return week;
27 | }
28 |
29 | public void setWeek(Integer week) {
30 | this.week = week;
31 | }
32 |
33 | public ScheduleQueryResult() {
34 | }
35 |
36 | public ScheduleQueryResult(List scheduleList, int week) {
37 | this.scheduleList = scheduleList;
38 | this.week = week;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Token.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Token implements Serializable {
9 |
10 | /**
11 | * 令牌签名
12 | */
13 | private String signature;
14 |
15 | /**
16 | * 创建时间戳
17 | */
18 | private Long createTime;
19 |
20 | /**
21 | * 过期时间戳
22 | */
23 | private Long expireTime;
24 |
25 | public Long getCreateTime() {
26 | return createTime;
27 | }
28 |
29 | public void setCreateTime(Long createTime) {
30 | this.createTime = createTime;
31 | }
32 |
33 | public String getSignature() {
34 | return signature;
35 | }
36 |
37 | public void setSignature(String signature) {
38 | this.signature = signature;
39 | }
40 |
41 | public Long getExpireTime() {
42 | return expireTime;
43 | }
44 |
45 | public void setExpireTime(Long expireTime) {
46 | this.expireTime = expireTime;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Cookie.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.alibaba.fastjson.annotation.JSONField;
4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5 |
6 | import java.io.Serializable;
7 |
8 | /**
9 | * Created by linguancheng on 2017/9/7.
10 | */
11 |
12 | @JsonIgnoreProperties(ignoreUnknown = true)
13 | public class Cookie implements Serializable {
14 |
15 | @JSONField(ordinal = 1)
16 | private String name;
17 |
18 | @JSONField(ordinal = 2)
19 | private String value;
20 |
21 | @JSONField(ordinal = 3)
22 | private String domain;
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getValue() {
33 | return value;
34 | }
35 |
36 | public void setValue(String value) {
37 | this.value = value;
38 | }
39 |
40 | public String getDomain() {
41 | return domain;
42 | }
43 |
44 | public void setDomain(String domain) {
45 | this.domain = domain;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
21 |
22 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Dialog/ProgressDialogCreator.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Dialog;
2 |
3 | import android.app.Activity;
4 | import android.app.Dialog;
5 | import android.content.Context;
6 | import android.graphics.Point;
7 | import android.support.v7.app.AlertDialog;
8 | import android.view.Display;
9 | import android.view.ViewGroup;
10 | import android.view.WindowManager;
11 |
12 | public class ProgressDialogCreator {
13 |
14 | /**
15 | * 创建ProgressDialog
16 | *
17 | * @param activity
18 | * @return
19 | */
20 | public Dialog GetProgressDialogCreator(Activity activity) {
21 | AlertDialog.Builder builder = new AlertDialog.Builder(activity);
22 | builder.setView(activity.getLayoutInflater().inflate(cn.gdeiassistant.R.layout.progressdialog, (ViewGroup) activity.findViewById(cn.gdeiassistant.R.id.progressDialog)));
23 | builder.setCancelable(false);
24 | AlertDialog dialog = builder.create();
25 | dialog.show();
26 | Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
27 | Point point = new Point();
28 | display.getSize(point);
29 | dialog.getWindow().setLayout(point.x / 2, point.y / 5);
30 | return dialog;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/TimeUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import java.util.Date;
4 |
5 | public class TimeUtils {
6 |
7 | public enum TimeUnit {
8 |
9 | SECOND(0), MINUTES(1), HOUR(2), DAY(3);
10 |
11 | TimeUnit(Integer unit) {
12 | this.unit = unit;
13 | }
14 |
15 | private Integer unit;
16 |
17 | public Integer getUnit() {
18 | return unit;
19 | }
20 | }
21 |
22 | /**
23 | * 两个时间间的时间戳计算函数
24 | *
25 | * @param beginDate
26 | * @param endDate
27 | * @param timeUnit
28 | * @return
29 | */
30 | public static long GetTimestampDifference(Date beginDate, Date endDate, TimeUnit timeUnit) {
31 | if (beginDate == null || endDate == null) {
32 | return 0;
33 | }
34 | long millisecond = endDate.getTime() - beginDate.getTime();
35 | switch (timeUnit.unit) {
36 | case 0:
37 | return (millisecond / 1000);
38 | case 1:
39 | return (millisecond / (1000 * 60));
40 | case 2:
41 | return (millisecond / (1000 * 60 * 60));
42 | case 3:
43 | return (millisecond / (1000 * 60 * 60 * 24));
44 | }
45 | return 0;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_webview.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/JsonResult/JsonResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.JsonResult;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class JsonResult implements Serializable {
9 |
10 | private Boolean success;
11 |
12 | private Integer code;
13 |
14 | private String message;
15 |
16 | public Boolean isSuccess() {
17 | return success;
18 | }
19 |
20 | public void setSuccess(Boolean success) {
21 | this.success = success;
22 | }
23 |
24 | public Integer getCode() {
25 | return code;
26 | }
27 |
28 | public void setCode(Integer code) {
29 | this.code = code;
30 | }
31 |
32 | public String getMessage() {
33 | return message;
34 | }
35 |
36 | public void setMessage(String message) {
37 | this.message = message;
38 | }
39 |
40 | public JsonResult() {
41 |
42 | }
43 |
44 | public JsonResult(Boolean success) {
45 | this.success = success;
46 | }
47 |
48 | public JsonResult(Boolean success, String message) {
49 | this.success = success;
50 | this.message = message;
51 | }
52 |
53 | public JsonResult(Boolean success, Integer code, String message) {
54 | this.success = success;
55 | this.code = code;
56 | this.message = message;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/EncryptionNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
11 | import cn.gdeiassistant.R;
12 | import cn.gdeiassistant.Tools.OkHttpUtils;
13 | import okhttp3.OkHttpClient;
14 | import okhttp3.Request;
15 | import okhttp3.Response;
16 |
17 | public class EncryptionNetWork {
18 |
19 | /**
20 | * 获取服务端RSA公钥
21 | *
22 | * @param context
23 | * @return
24 | * @throws Exception
25 | */
26 | public DataJsonResult GetServerPublicKey(Context context) throws Exception {
27 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.ENCRYPT_NETWORK_TIMEOUT, context);
28 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/encryption/rsa/publickey").build();
29 | Response response = okHttpClient.newCall(request).execute();
30 | if (response.isSuccessful()) {
31 | return new Gson().fromJson(response.body().string()
32 | , new TypeToken>() {
33 | }.getType());
34 | }
35 | throw new ResponseStatusCodeException("服务暂不可用");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
20 |
21 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/CheckUpgradeNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
11 | import cn.gdeiassistant.Pojo.Upgrade.CheckUpgradeResult;
12 | import cn.gdeiassistant.R;
13 | import cn.gdeiassistant.Tools.OkHttpUtils;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.Response;
17 |
18 | public class CheckUpgradeNetWork {
19 |
20 | /**
21 | * 检查更新网络请求
22 | *
23 | * @return
24 | */
25 | public DataJsonResult GetUpgradeInformation(Context context) throws Exception {
26 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CHECK_UPGRADE_NETWORK_TIMEOUT, context);
27 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/update/android").build();
28 | Response response = okHttpClient.newCall(request).execute();
29 | if (response.isSuccessful()) {
30 | return new Gson().fromJson(response.body().string()
31 | , new TypeToken>() {
32 | }.getType());
33 | }
34 | throw new ResponseStatusCodeException("服务暂不可用");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/OSSNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
11 | import cn.gdeiassistant.Pojo.OssFederationToken.OssFederationTokenResult;
12 | import cn.gdeiassistant.R;
13 | import cn.gdeiassistant.Tools.OkHttpUtils;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.Response;
17 |
18 | public class OSSNetWork {
19 |
20 | /**
21 | * 获取临时访问令牌
22 | *
23 | * @param context
24 | * @return
25 | * @throws Exception
26 | */
27 | public DataJsonResult GetOSSFederationToken(Context context) throws Exception {
28 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.OSS_NETWORK_TIMEOUT, context);
29 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/osstoken").build();
30 | Response response = okHttpClient.newCall(request).execute();
31 | if (response.isSuccessful()) {
32 | return new Gson().fromJson(response.body().string()
33 | , new TypeToken>() {
34 | }.getType());
35 | }
36 | throw new ResponseStatusCodeException("服务暂不可用");
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Upgrade/CheckUpgradeResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Upgrade;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class CheckUpgradeResult implements Serializable {
9 |
10 | private String downloadURL;
11 |
12 | private String versionInfo;
13 |
14 | private String versionCodeName;
15 |
16 | private String fileSize;
17 |
18 | private Integer versionCode;
19 |
20 | public String getDownloadURL() {
21 | return downloadURL;
22 | }
23 |
24 | public void setDownloadURL(String downloadURL) {
25 | this.downloadURL = downloadURL;
26 | }
27 |
28 | public String getVersionInfo() {
29 | return versionInfo;
30 | }
31 |
32 | public void setVersionInfo(String versionInfo) {
33 | this.versionInfo = versionInfo;
34 | }
35 |
36 | public String getVersionCodeName() {
37 | return versionCodeName;
38 | }
39 |
40 | public void setVersionCodeName(String versionCodeName) {
41 | this.versionCodeName = versionCodeName;
42 | }
43 |
44 | public int getVersionCode() {
45 | return versionCode;
46 | }
47 |
48 | public void setVersionCode(Integer versionCode) {
49 | this.versionCode = versionCode;
50 | }
51 |
52 | public String getFileSize() {
53 | return fileSize;
54 | }
55 |
56 | public void setFileSize(String fileSize) {
57 | this.fileSize = fileSize;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Card.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Card implements Serializable {
9 |
10 | //交易时间
11 | private String tradeTime;
12 |
13 | //商户名称
14 | private String merchantName;
15 |
16 | //交易名称
17 | private String tradeName;
18 |
19 | //交易金额
20 | private String tradePrice;
21 |
22 | //账户余额
23 | private String accountBalance;
24 |
25 | public String getAccountBalance() {
26 | return accountBalance;
27 | }
28 |
29 | public void setAccountBalance(String accountBalance) {
30 | this.accountBalance = accountBalance;
31 | }
32 |
33 | public String getTradePrice() {
34 | return tradePrice;
35 | }
36 |
37 | public void setTradePrice(String tradePrice) {
38 | this.tradePrice = tradePrice;
39 | }
40 |
41 | public String getTradeName() {
42 | return tradeName;
43 | }
44 |
45 | public void setTradeName(String tradeName) {
46 | this.tradeName = tradeName;
47 | }
48 |
49 | public String getMerchantName() {
50 | return merchantName;
51 | }
52 |
53 | public void setMerchantName(String merchantName) {
54 | this.merchantName = merchantName;
55 | }
56 |
57 | public String getTradeTime() {
58 | return tradeTime;
59 | }
60 |
61 | public void setTradeTime(String tradeTime) {
62 | this.tradeTime = tradeTime;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/LostNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.JsonResult.JsonResult;
11 | import cn.gdeiassistant.R;
12 | import cn.gdeiassistant.Tools.OkHttpUtils;
13 | import okhttp3.FormBody;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.RequestBody;
17 | import okhttp3.Response;
18 |
19 | public class LostNetWork {
20 |
21 | /**
22 | * 校园卡挂失
23 | *
24 | * @param cardPassword
25 | * @param context
26 | */
27 | public JsonResult CardLost(String cardPassword, Context context) throws Exception {
28 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
29 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CARD_LOST_NETWORK_TIMEOUT, context);
30 | RequestBody requestBody = new FormBody.Builder().add("token", application.getToken())
31 | .add("cardPassword", cardPassword).build();
32 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/cardlost").post(requestBody).build();
33 | Response response = okHttpClient.newCall(request).execute();
34 | if (response.isSuccessful()) {
35 | return new Gson().fromJson(response.body().string(), JsonResult.class);
36 | }
37 | throw new ResponseStatusCodeException("服务暂不可用");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/EvaluateNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 |
7 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.JsonResult.JsonResult;
11 | import cn.gdeiassistant.R;
12 | import cn.gdeiassistant.Tools.OkHttpUtils;
13 | import okhttp3.FormBody;
14 | import okhttp3.OkHttpClient;
15 | import okhttp3.Request;
16 | import okhttp3.RequestBody;
17 | import okhttp3.Response;
18 |
19 | public class EvaluateNetWork {
20 |
21 | /**
22 | * 提交教学评价请求
23 | *
24 | * @param directlySubmit
25 | * @param context
26 | * @return
27 | */
28 | public JsonResult SubmitEvaluateRequest(boolean directlySubmit, Context context) throws Exception {
29 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
30 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.EVALUATE_NETWORK_TIMEOUT, context);
31 | RequestBody requestBody = new FormBody.Builder().add("directlySubmit", String.valueOf(directlySubmit))
32 | .add("token", application.getToken()).build();
33 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/evaluate").post(requestBody).build();
34 | Response response = okHttpClient.newCall(request).execute();
35 | if (response.isSuccessful()) {
36 | return new Gson().fromJson(response.body().string(), JsonResult.class);
37 | }
38 | throw new ResponseStatusCodeException("服务暂不可用");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/grade_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
23 |
24 |
32 |
33 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
18 |
19 |
24 |
25 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/ProfileNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
9 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
10 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
11 | import cn.gdeiassistant.Pojo.Entity.Profile;
12 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
13 | import cn.gdeiassistant.R;
14 | import cn.gdeiassistant.Tools.OkHttpUtils;
15 | import okhttp3.FormBody;
16 | import okhttp3.OkHttpClient;
17 | import okhttp3.Request;
18 | import okhttp3.RequestBody;
19 | import okhttp3.Response;
20 |
21 | public class ProfileNetWork {
22 |
23 | /**
24 | * 获取用户资料
25 | *
26 | * @param context
27 | * @return
28 | * @throws Exception
29 | */
30 | public DataJsonResult GetUserProfile(Context context) throws Exception {
31 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
32 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.PROFILE_NETWORK_TIMEOUT, context);
33 | RequestBody requestBody = new FormBody.Builder().add("token", application.getToken()).build();
34 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/profile").post(requestBody).build();
35 | Response response = okHttpClient.newCall(request).execute();
36 | if (response.isSuccessful()) {
37 | return new Gson().fromJson(response.body().string(), new TypeToken>() {
38 | }.getType());
39 | }
40 | throw new ResponseStatusCodeException("服务暂不可用");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/AccessNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
9 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
10 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
11 | import cn.gdeiassistant.Pojo.Entity.Access;
12 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
13 | import cn.gdeiassistant.R;
14 | import cn.gdeiassistant.Tools.OkHttpUtils;
15 | import okhttp3.FormBody;
16 | import okhttp3.OkHttpClient;
17 | import okhttp3.Request;
18 | import okhttp3.RequestBody;
19 | import okhttp3.Response;
20 |
21 | public class AccessNetWork {
22 |
23 | /**
24 | * 获取安卓客户端权限列表
25 | *
26 | * @param context
27 | * @return
28 | */
29 | public DataJsonResult GetAndroidAccess(Context context) throws Exception {
30 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
31 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CARD_QUERY_NETWORK_TIMEOUT, context);
32 | RequestBody requestBody = new FormBody.Builder().add("token", application.getToken()).build();
33 | Request request = new Request.Builder().post(requestBody).url(context.getString(R.string.resource_domain) + "rest/access/android").build();
34 | Response response = okHttpClient.newCall(request).execute();
35 | if (response.isSuccessful()) {
36 | return new Gson().fromJson(response.body().string()
37 | , new TypeToken>() {
38 | }.getType());
39 | }
40 | throw new ResponseStatusCodeException("服务暂不可用");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # 广东二师助手安卓客户端
6 |
7 | **广东第二师范学院校园助手系统安卓原生客户端应用**,兼容Android 9.0,已正式投入校园生产环境供在校师生使用。应用使用了Sophix、JWT、HttpDNS、OKHttp等框架组件,应用主要涉及JSON序列化、数据存储和网络访问等技术。应用的后端API数据接口由广东第二师范学院校园助手系统提供。
8 |
9 | ## 功能
10 |
11 | - 成绩查询
12 | - 课表查询
13 | - 四六级查询
14 | - 教学评价
15 | - 消费查询
16 | - 校园卡充值
17 |
18 | ## 预览
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | ## 日志
27 |
28 | - V3.1.0:添加图书借阅查询功能
29 | - V3.0.0:新版广东二师助手安卓客户端发布
30 |
31 | ## 链接
32 | - [广东二师助手官网](https://gdeiassistant.cn)
33 |
34 | ## 数据接口
35 |
36 | 广东二师助手安卓客户端的后端API数据接口由[广东第二师范学院校园助手系统](https://github.com/GdeiAssistant/GdeiAssistant)提供
37 |
38 | 数据接口API文档说明请查阅[广东第二师范学院校园助手系统数据接口API文档](https://github.com/GdeiAssistant/GdeiAssistant/wiki)
39 |
40 | ## 初始化
41 |
42 | ### 克隆仓库
43 |
44 | ```bash
45 | $ git clone https://github.com/GdeiAssistant/GdeiAssistant-Android.git
46 | ```
47 |
48 | ## 协议
49 |
50 | [MIT License](http://opensource.org/licenses/MIT)
51 |
52 | [Anti 996 License](https://github.com/996icu/996.ICU/blob/master/LICENSE)
53 |
54 | Copyright (c) 2016 - 2023 GdeiAssistant
55 |
56 | ## 贡献
57 |
58 | - 若你喜欢本项目,欢迎Star本项目
59 |
60 | - 要贡献代码,欢迎Fork之后再提交[Pull Request](https://github.com/GdeiAssistant/GdeiAssistant-Android/pulls)
61 |
62 | - 如果你有好的意见或建议,欢迎给我们提交[Issue](https://github.com/GdeiAssistant/GdeiAssistant-Android/issues)
63 |
64 | ## 联系
65 |
66 | - 技术支持和意见建议反馈:[gdeiassistant@gmail.com](mailto:gdeiassistant@gmail.com)
67 |
68 | - 用户客服和系统故障工单提交:[support@gdeiassistant.cn](mailto:support@gdeiassistant.cn)
69 |
70 | - 社区违法和不良信息举报邮箱:[report@gdeiassistant.cn](mailto:report@gdeiassistant.cn)
71 |
72 | ## 声明
73 |
74 | 本项目只用作个人学习研究,如因使用本项目导致任何损失,本人概不负责。
75 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/OssFederationToken/OssFederationTokenResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.OssFederationToken;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class OssFederationTokenResult implements Serializable {
9 |
10 | //表示获取Token的状态,获取成功时,返回值是200
11 | private String status;
12 |
13 | //表示Android/iOS应用初始化OSSClient获取的AccessKeyId
14 | private String accessKeyId;
15 |
16 | //表示Android/iOS应用初始化OSSClient获取AccessKeySecret
17 | private String accessKeySecret;
18 |
19 | //表示Android/iOS应用初始化的Token
20 | private String securityToken;
21 |
22 | //表示该Token失效的时间。主要在Android SDK会自动判断是否失效,自动获取Token
23 | private String expiration;
24 |
25 | public String getStatus() {
26 | return status;
27 | }
28 |
29 | public void setStatus(String status) {
30 | this.status = status;
31 | }
32 |
33 | public String getAccessKeyId() {
34 | return accessKeyId;
35 | }
36 |
37 | public void setAccessKeyId(String accessKeyId) {
38 | this.accessKeyId = accessKeyId;
39 | }
40 |
41 | public String getAccessKeySecret() {
42 | return accessKeySecret;
43 | }
44 |
45 | public void setAccessKeySecret(String accessKeySecret) {
46 | this.accessKeySecret = accessKeySecret;
47 | }
48 |
49 | public String getSecurityToken() {
50 | return securityToken;
51 | }
52 |
53 | public void setSecurityToken(String securityToken) {
54 | this.securityToken = securityToken;
55 | }
56 |
57 | public String getExpiration() {
58 | return expiration;
59 | }
60 |
61 | public void setExpiration(String expiration) {
62 | this.expiration = expiration;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Activity/AboutSoftWareActivity.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Activity;
2 |
3 | import android.content.pm.PackageManager;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import android.widget.TextView;
9 |
10 | import cn.gdeiassistant.R;
11 |
12 | public class AboutSoftWareActivity extends AppCompatActivity {
13 |
14 | private Toolbar toolbar;
15 |
16 | private TextView aboutSoftWareVersionCode;
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_aboutsoftware);
22 | InitView();
23 | }
24 |
25 | private void InitView() {
26 | toolbar = findViewById(R.id.aboutSoftWareToolbar);
27 | aboutSoftWareVersionCode = findViewById(R.id.aboutSoftWareVersionCode);
28 | setSupportActionBar(toolbar);
29 | if (getSupportActionBar() != null) {
30 | getSupportActionBar().setDisplayShowTitleEnabled(false);
31 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
32 | }
33 | //更新版本号
34 | try {
35 | String versionName = "V " + getApplicationContext().getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
36 | aboutSoftWareVersionCode.setText(versionName);
37 | } catch (PackageManager.NameNotFoundException ignored) {
38 |
39 | }
40 | }
41 |
42 | @Override
43 | public boolean onOptionsItemSelected(MenuItem item) {
44 | switch (item.getItemId()) {
45 | case android.R.id.home:
46 | //返回上一层
47 | finish();
48 |
49 | default:
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/TokenNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
9 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
10 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
11 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
12 | import cn.gdeiassistant.Pojo.Token.TokenRefreshResult;
13 | import cn.gdeiassistant.R;
14 | import cn.gdeiassistant.Tools.OkHttpUtils;
15 | import okhttp3.FormBody;
16 | import okhttp3.OkHttpClient;
17 | import okhttp3.Request;
18 | import okhttp3.RequestBody;
19 | import okhttp3.Response;
20 |
21 | public class TokenNetWork {
22 |
23 | /**
24 | * 刷新令牌
25 | *
26 | * @param refreshToken
27 | * @param context
28 | * @return
29 | */
30 | public DataJsonResult RefreshToken(String refreshToken, Context context) throws Exception {
31 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
32 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.TOKEN_NETWORK_TIMEOUT, context);
33 | RequestBody requestBody = new FormBody.Builder().add("token", refreshToken).build();
34 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/token/refresh").post(requestBody).build();
35 | Response response = okHttpClient.newCall(request).execute();
36 | if (response.isSuccessful()) {
37 | return new Gson().fromJson(response.body().string()
38 | , new TypeToken>() {
39 | }.getType());
40 | }
41 | throw new ResponseStatusCodeException("服务暂不可用");
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Adapter/ListViewNumberAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.TextView;
9 |
10 | import java.util.ArrayList;
11 |
12 | public class ListViewNumberAdapter extends BaseAdapter {
13 |
14 | private Context context;
15 |
16 | private ArrayList list;
17 |
18 | public ListViewNumberAdapter(Context context) {
19 | this.context = context;
20 | this.list = new ArrayList<>();
21 | for (int i = 1; i <= 10; i++) {
22 | this.list.add(i + "");
23 | }
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return list != null ? list.size() : 0;
29 | }
30 |
31 | @Override
32 | public Object getItem(int position) {
33 | return null;
34 | }
35 |
36 | @Override
37 | public long getItemId(int position) {
38 | return 0;
39 | }
40 |
41 | @Override
42 | public View getView(int position, View convertView, ViewGroup parent) {
43 | ViewHolder viewHolder;
44 | if (convertView == null) {
45 | viewHolder = new ViewHolder();
46 | convertView = LayoutInflater.from(context).inflate(cn.gdeiassistant.R.layout.item_listview_number, null);
47 | viewHolder.textViewNumber = convertView.findViewById(cn.gdeiassistant.R.id.textviewNumber);
48 | convertView.setTag(viewHolder);
49 | } else {
50 | viewHolder = (ViewHolder) convertView.getTag();
51 | }
52 | viewHolder.textViewNumber.setText(list.get(position));
53 | return convertView;
54 | }
55 |
56 | public static class ViewHolder {
57 | TextView textViewNumber;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/CardInfo.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class CardInfo implements Serializable {
9 |
10 | private String name;
11 |
12 | private String number;
13 |
14 | private String cardBalance;
15 |
16 | private String cardInterimBalance;
17 |
18 | private String cardNumber;
19 |
20 | private String cardLostState;
21 |
22 | private String cardFreezeState;
23 |
24 | public String getCardBalance() {
25 | return cardBalance;
26 | }
27 |
28 | public void setCardBalance(String cardBalance) {
29 | this.cardBalance = cardBalance;
30 | }
31 |
32 | public String getCardInterimBalance() {
33 | return cardInterimBalance;
34 | }
35 |
36 | public void setCardInterimBalance(String cardInterimBalance) {
37 | this.cardInterimBalance = cardInterimBalance;
38 | }
39 |
40 | public String getCardNumber() {
41 | return cardNumber;
42 | }
43 |
44 | public void setCardNumber(String cardNumber) {
45 | this.cardNumber = cardNumber;
46 | }
47 |
48 | public String getCardLostState() {
49 | return cardLostState;
50 | }
51 |
52 | public void setCardLostState(String cardLostState) {
53 | this.cardLostState = cardLostState;
54 | }
55 |
56 | public String getCardFreezeState() {
57 | return cardFreezeState;
58 | }
59 |
60 | public void setCardFreezeState(String cardFreezeState) {
61 | this.cardFreezeState = cardFreezeState;
62 | }
63 |
64 | public String getNumber() {
65 | return number;
66 | }
67 |
68 | public void setNumber(String number) {
69 | this.number = number;
70 | }
71 |
72 | public String getName() {
73 | return name;
74 | }
75 |
76 | public void setName(String name) {
77 | this.name = name;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Adapter/GridViewDateAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.TextView;
9 |
10 | import java.util.ArrayList;
11 |
12 | public class GridViewDateAdapter extends BaseAdapter {
13 |
14 | private Context context;
15 |
16 | private ArrayList list;
17 |
18 | public GridViewDateAdapter(Context context) {
19 | this.context = context;
20 | this.list = new ArrayList<>();
21 | this.list.add("课程");
22 | this.list.add("周一");
23 | this.list.add("周二");
24 | this.list.add("周三");
25 | this.list.add("周四");
26 | this.list.add("周五");
27 | this.list.add("周六");
28 | this.list.add("周日");
29 | }
30 |
31 | @Override
32 | public int getCount() {
33 | return list != null ? list.size() : 0;
34 | }
35 |
36 | @Override
37 | public Object getItem(int position) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public long getItemId(int position) {
43 | return 0;
44 | }
45 |
46 | @Override
47 | public View getView(int position, View convertView, ViewGroup parent) {
48 | ViewHolder viewHolder;
49 | if (convertView == null) {
50 | viewHolder = new ViewHolder();
51 | convertView = LayoutInflater.from(context).inflate(cn.gdeiassistant.R.layout.item_gridview_date, null);
52 | viewHolder.textViewDate = convertView.findViewById(cn.gdeiassistant.R.id.textviewDate);
53 | convertView.setTag(viewHolder);
54 | } else {
55 | viewHolder = (ViewHolder) convertView.getTag();
56 | }
57 | viewHolder.textViewDate.setText(list.get(position));
58 | return convertView;
59 | }
60 |
61 | private static class ViewHolder {
62 | TextView textViewDate;
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Book.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Book implements Serializable {
9 |
10 | //条形码
11 | private String id;
12 |
13 | //续借的SN号
14 | private String sn;
15 |
16 | //续借的Code号
17 | private String code;
18 |
19 | //书名
20 | private String name;
21 |
22 | //作者
23 | private String author;
24 |
25 | //借阅时间
26 | private String borrowDate;
27 |
28 | //应还时间
29 | private String returnDate;
30 |
31 | //续借次数
32 | private Integer renewTime;
33 |
34 | public String getId() {
35 | return id;
36 | }
37 |
38 | public void setId(String id) {
39 | this.id = id;
40 | }
41 |
42 | public String getSn() {
43 | return sn;
44 | }
45 |
46 | public void setSn(String sn) {
47 | this.sn = sn;
48 | }
49 |
50 | public String getCode() {
51 | return code;
52 | }
53 |
54 | public void setCode(String code) {
55 | this.code = code;
56 | }
57 |
58 | public String getName() {
59 | return name;
60 | }
61 |
62 | public void setName(String name) {
63 | this.name = name;
64 | }
65 |
66 | public String getAuthor() {
67 | return author;
68 | }
69 |
70 | public void setAuthor(String author) {
71 | this.author = author;
72 | }
73 |
74 | public String getBorrowDate() {
75 | return borrowDate;
76 | }
77 |
78 | public void setBorrowDate(String borrowDate) {
79 | this.borrowDate = borrowDate;
80 | }
81 |
82 | public String getReturnDate() {
83 | return returnDate;
84 | }
85 |
86 | public void setReturnDate(String returnDate) {
87 | this.returnDate = returnDate;
88 | }
89 |
90 | public Integer getRenewTime() {
91 | return renewTime;
92 | }
93 |
94 | public void setRenewTime(Integer renewTime) {
95 | this.renewTime = renewTime;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Constant/ResultConstant.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Constant;
2 |
3 | public class ResultConstant {
4 |
5 | //请求参数不合法
6 | public static final int INCORRECT_REQUEST_PARAM = 40001;
7 |
8 | //请求数据摘要不匹配
9 | public static final int REQUEST_SIGN_INVALID = 40002;
10 |
11 | //请求时间戳校验失败
12 | public static final int REQUEST_TIMESTAMP_INVALID = 40003;
13 |
14 | //重复提交的请求
15 | public static final int REPLAY_REQUEST = 40004;
16 |
17 | //充值金额不合法
18 | public static final int CHARGE_AMOUNT_NOT_AVAILABLE = 40005;
19 |
20 | //实名认证身份证照片模糊
21 | public static final int ID_CARD_BLURRED = 40006;
22 |
23 | //实名认证身份证照片为复印件
24 | public static final int ID_CARD_COPY_TYPE = 40007;
25 |
26 | //实名认证身份证照片被编辑过
27 | public static final int ID_CARD_EDITED = 40008;
28 |
29 | //实名认证身份证照片反光或过曝
30 | public static final int ID_CARD_OVER_EXPOSURE = 40009;
31 |
32 | //实名认证身份证照片正反面颠倒
33 | public static final int ID_CARD_REVERSED_SIDE = 40010;
34 |
35 | //实名认证身份证照片为翻拍
36 | public static final int ID_CARD_SCREEN_TYPE = 40011;
37 |
38 | //实名认证身份证照片为临时身份证
39 | public static final int ID_CARD_TEMPORARY_TYPE = 40012;
40 |
41 | //实名认证上传的图片没有身份证信息
42 | public static final int NON_ID_CARD_INFO = 40013;
43 |
44 | //实名认证上传的非第二代居民身份证
45 | public static final int OTHER_TYPE_CARD = 40014;
46 |
47 | //权限令牌过期
48 | public static final int TOKEN_EXPIRED_EXCEPTION = 40101;
49 |
50 | //异常登录地
51 | public static final int UNUSUAL_LOCATION_EXCEPTION = 40102;
52 |
53 | //令牌校验失败
54 | public static final int TOKEN_NOT_MATCHING = 40103;
55 |
56 | //令牌校验服务异常
57 | public static final int TOKEN_SERVER_ERROR = 40104;
58 |
59 | //充值安全校验不通过
60 | public static final int CHARGE_SECURITY_INVALID = 40105;
61 |
62 | //自定义课程数量超过限制
63 | public static final int CUSTOM_SCHEDULE_OVER_LIMIT = 40301;
64 |
65 | //查询的数据不存在
66 | public static final int DATA_NOT_EXIST = 40401;
67 |
68 | //服务器内部异常
69 | public static final int INTERNAL_SERVER_ERROR = 50001;
70 |
71 | //网络连接超时
72 | public static final int NETWORK_TIMEOUT = 50301;
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/ScheduleQueryNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.google.gson.Gson;
7 | import com.google.gson.reflect.TypeToken;
8 |
9 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
10 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
11 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
12 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
13 | import cn.gdeiassistant.Pojo.ScheduleQuery.ScheduleQueryResult;
14 | import cn.gdeiassistant.R;
15 | import cn.gdeiassistant.Tools.OkHttpUtils;
16 | import okhttp3.FormBody;
17 | import okhttp3.OkHttpClient;
18 | import okhttp3.Request;
19 | import okhttp3.RequestBody;
20 | import okhttp3.Response;
21 |
22 | public class ScheduleQueryNetWork {
23 |
24 | /**
25 | * 查询课表信息
26 | *
27 | * @param week
28 | * @param context
29 | * @return
30 | * @throws Exception
31 | */
32 | public DataJsonResult ScheduleQuery(@Nullable Integer week, Context context) throws Exception {
33 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
34 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.SCHEDULE_QUERY_NETWORK_TIMEOUT, context);
35 | RequestBody requestBody = null;
36 | if (week == null) {
37 | requestBody = new FormBody.Builder().add("token", application.getToken()).build();
38 | } else {
39 | requestBody = new FormBody.Builder().add("token", application.getToken()).add("week", String.valueOf(week)).build();
40 | }
41 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/schedulequery").post(requestBody).build();
42 | Response response = okHttpClient.newCall(request).execute();
43 | if (response.isSuccessful()) {
44 | return new Gson().fromJson(response.body().string(), new TypeToken>() {
45 | }.getType());
46 | }
47 | throw new ResponseStatusCodeException("服务暂不可用");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/GradeQueryNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.google.gson.Gson;
7 | import com.google.gson.reflect.TypeToken;
8 |
9 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
10 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
11 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
12 | import cn.gdeiassistant.Pojo.GradeQuery.GradeQueryResult;
13 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
14 | import cn.gdeiassistant.R;
15 | import cn.gdeiassistant.Tools.OkHttpUtils;
16 | import okhttp3.FormBody;
17 | import okhttp3.OkHttpClient;
18 | import okhttp3.Request;
19 | import okhttp3.RequestBody;
20 | import okhttp3.Response;
21 |
22 | public class GradeQueryNetWork {
23 |
24 | /**
25 | * 查询学年成绩
26 | *
27 | * @param year
28 | * @param context
29 | * @return
30 | */
31 | public DataJsonResult GradeQuery(@Nullable Integer year, Context context) throws Exception {
32 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
33 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.GRADE_QUERY_NETWORK_TIMEOUT, context);
34 | RequestBody requestBody = null;
35 | if (year == null) {
36 | //若没有指定查询学年,则查询默认学年
37 | requestBody = new FormBody.Builder().add("token", application.getToken()).build();
38 | } else {
39 | requestBody = new FormBody.Builder().add("year", String.valueOf(year))
40 | .add("token", application.getToken()).build();
41 | }
42 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/gradequery").post(requestBody).build();
43 | Response response = okHttpClient.newCall(request).execute();
44 | if (response.isSuccessful()) {
45 | return new Gson().fromJson(response.body().string()
46 | , new TypeToken>() {
47 | }.getType());
48 | }
49 | throw new ResponseStatusCodeException("服务暂不可用");
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/GradeQuery/GradeQueryResult.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.GradeQuery;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 | import java.util.List;
7 |
8 | import cn.gdeiassistant.Pojo.Entity.Grade;
9 |
10 | @JsonIgnoreProperties(ignoreUnknown = true)
11 | public class GradeQueryResult implements Serializable {
12 |
13 | private Integer year;
14 |
15 | private String firstTermGPA;
16 |
17 | private String secondTermGPA;
18 |
19 | private String firstTermIGP;
20 |
21 | private String secondTermIGP;
22 |
23 | private List firstTermGradeList;
24 |
25 | private List secondTermGradeList;
26 |
27 | public String getFirstTermGPA() {
28 | return firstTermGPA;
29 | }
30 |
31 | public void setFirstTermGPA(String firstTermGPA) {
32 | this.firstTermGPA = firstTermGPA;
33 | }
34 |
35 | public String getSecondTermGPA() {
36 | return secondTermGPA;
37 | }
38 |
39 | public void setSecondTermGPA(String secondTermGPA) {
40 | this.secondTermGPA = secondTermGPA;
41 | }
42 |
43 | public String getFirstTermIGP() {
44 | return firstTermIGP;
45 | }
46 |
47 | public void setFirstTermIGP(String firstTermIGP) {
48 | this.firstTermIGP = firstTermIGP;
49 | }
50 |
51 | public String getSecondTermIGP() {
52 | return secondTermIGP;
53 | }
54 |
55 | public void setSecondTermIGP(String secondTermIGP) {
56 | this.secondTermIGP = secondTermIGP;
57 | }
58 |
59 | public List getFirstTermGradeList() {
60 | return firstTermGradeList;
61 | }
62 |
63 | public void setFirstTermGradeList(List firstTermGradeList) {
64 | this.firstTermGradeList = firstTermGradeList;
65 | }
66 |
67 | public List getSecondTermGradeList() {
68 | return secondTermGradeList;
69 | }
70 |
71 | public void setSecondTermGradeList(List secondTermGradeList) {
72 | this.secondTermGradeList = secondTermGradeList;
73 | }
74 |
75 | public Integer getYear() {
76 | return year;
77 | }
78 |
79 | public void setYear(Integer year) {
80 | this.year = year;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/LostModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 |
10 | import cn.gdeiassistant.Constant.RequestConstant;
11 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
12 | import cn.gdeiassistant.NetWork.LostNetWork;
13 | import cn.gdeiassistant.Pojo.JsonResult.JsonResult;
14 |
15 | public class LostModel {
16 |
17 | private LostNetWork lostNetWork = new LostNetWork();
18 |
19 | /**
20 | * 校园卡挂失
21 | *
22 | * @param cardPassword
23 | * @param context
24 | */
25 | public void CardLost(final String cardPassword, final Handler handler, final Context context) {
26 | new Thread() {
27 | @Override
28 | public void run() {
29 | super.run();
30 | Message message = handler.obtainMessage();
31 | Bundle bundle = new Bundle();
32 | try {
33 | message.what = RequestConstant.SHOW_PROGRESS;
34 | handler.sendMessage(message);
35 | message = handler.obtainMessage();
36 | JsonResult result = lostNetWork.CardLost(cardPassword, context);
37 | if (Boolean.TRUE.equals(result.isSuccess())) {
38 | message.what = RequestConstant.REQUEST_SUCCESS;
39 | } else {
40 | bundle.putString("Message", result.getMessage());
41 | message.what = RequestConstant.REQUEST_FAILURE;
42 | }
43 | } catch (NullPointerException ignored) {
44 |
45 | } catch (IOException e) {
46 | message.what = RequestConstant.REQUEST_TIMEOUT;
47 | } catch (ResponseStatusCodeException e) {
48 | message.what = RequestConstant.SERVER_ERROR;
49 | } catch (Exception e) {
50 | message.what = RequestConstant.UNKNOWN_ERROR;
51 | }
52 | message.setData(bundle);
53 | handler.sendMessage(message);
54 | }
55 | }.start();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Cet.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Cet implements Serializable {
9 |
10 | private String name;
11 |
12 | private String school;
13 |
14 | private String type;
15 |
16 | private String admissionCard;
17 |
18 | private String totalScore;
19 |
20 | private String listeningScore;
21 |
22 | private String readingScore;
23 |
24 | private String writingAndTranslatingScore;
25 |
26 | public String getName() {
27 | return name;
28 | }
29 |
30 | public void setName(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String getSchool() {
35 | return school;
36 | }
37 |
38 | public void setSchool(String school) {
39 | this.school = school;
40 | }
41 |
42 | public String getType() {
43 | return type;
44 | }
45 |
46 | public void setType(String type) {
47 | this.type = type;
48 | }
49 |
50 | public String getAdmissionCard() {
51 | return admissionCard;
52 | }
53 |
54 | public void setAdmissionCard(String admissionCard) {
55 | this.admissionCard = admissionCard;
56 | }
57 |
58 | public String getTotalScore() {
59 | return totalScore;
60 | }
61 |
62 | public void setTotalScore(String totalScore) {
63 | this.totalScore = totalScore;
64 | }
65 |
66 | public String getListeningScore() {
67 | return listeningScore;
68 | }
69 |
70 | public void setListeningScore(String listeningScore) {
71 | this.listeningScore = listeningScore;
72 | }
73 |
74 | public String getReadingScore() {
75 | return readingScore;
76 | }
77 |
78 | public void setReadingScore(String readingScore) {
79 | this.readingScore = readingScore;
80 | }
81 |
82 | public String getWritingAndTranslatingScore() {
83 | return writingAndTranslatingScore;
84 | }
85 |
86 | public void setWritingAndTranslatingScore(String writingAndTranslatingScore) {
87 | this.writingAndTranslatingScore = writingAndTranslatingScore;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Access.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Access implements Serializable {
9 |
10 | private Boolean grade;
11 |
12 | private Boolean schedule;
13 |
14 | private Boolean cet;
15 |
16 | private Boolean evaluate;
17 |
18 | private Boolean book;
19 |
20 | private Boolean card;
21 |
22 | private Boolean bill;
23 |
24 | private Boolean lost;
25 |
26 | private Boolean charge;
27 |
28 | public Boolean getGrade() {
29 | return grade;
30 | }
31 |
32 | public void setGrade(Boolean grade) {
33 | this.grade = grade;
34 | }
35 |
36 | public Boolean getSchedule() {
37 | return schedule;
38 | }
39 |
40 | public void setSchedule(Boolean schedule) {
41 | this.schedule = schedule;
42 | }
43 |
44 | public Boolean getCet() {
45 | return cet;
46 | }
47 |
48 | public void setCet(Boolean cet) {
49 | this.cet = cet;
50 | }
51 |
52 | public Boolean getEvaluate() {
53 | return evaluate;
54 | }
55 |
56 | public void setEvaluate(Boolean evaluate) {
57 | this.evaluate = evaluate;
58 | }
59 |
60 | public Boolean getCard() {
61 | return card;
62 | }
63 |
64 | public void setCard(Boolean card) {
65 | this.card = card;
66 | }
67 |
68 | public Boolean getBill() {
69 | return bill;
70 | }
71 |
72 | public void setBill(Boolean bill) {
73 | this.bill = bill;
74 | }
75 |
76 | public Boolean getLost() {
77 | return lost;
78 | }
79 |
80 | public void setLost(Boolean lost) {
81 | this.lost = lost;
82 | }
83 |
84 | public Boolean getCharge() {
85 | return charge;
86 | }
87 |
88 | public void setCharge(Boolean charge) {
89 | this.charge = charge;
90 | }
91 |
92 | public Boolean getBook() {
93 | return book;
94 | }
95 |
96 | public void setBook(Boolean book) {
97 | this.book = book;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Pojo/Entity/Grade.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Pojo.Entity;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import java.io.Serializable;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Grade implements Serializable {
9 |
10 | //课程学年
11 | private String gradeYear;
12 |
13 | //课程学期
14 | private String gradeTerm;
15 |
16 | //课程编号
17 | private String gradeId;
18 |
19 | //课程名称
20 | private String gradeName;
21 |
22 | //课程学分
23 | private String gradeCredit;
24 |
25 | //课程类型
26 | private String gradeType;
27 |
28 | //课程绩点
29 | private String gradeGpa;
30 |
31 | //课程成绩
32 | private String gradeScore;
33 |
34 | public String getGradeYear() {
35 | return gradeYear;
36 | }
37 |
38 | public void setGradeYear(String gradeYear) {
39 | this.gradeYear = gradeYear;
40 | }
41 |
42 | public String getGradeTerm() {
43 | return gradeTerm;
44 | }
45 |
46 | public void setGradeTerm(String gradeTerm) {
47 | this.gradeTerm = gradeTerm;
48 | }
49 |
50 | public String getGradeId() {
51 | return gradeId;
52 | }
53 |
54 | public void setGradeId(String gradeId) {
55 | this.gradeId = gradeId;
56 | }
57 |
58 | public String getGradeName() {
59 | return gradeName;
60 | }
61 |
62 | public void setGradeName(String gradeName) {
63 | this.gradeName = gradeName;
64 | }
65 |
66 | public String getGradeCredit() {
67 | return gradeCredit;
68 | }
69 |
70 | public void setGradeCredit(String gradeCredit) {
71 | this.gradeCredit = gradeCredit;
72 | }
73 |
74 | public String getGradeType() {
75 | return gradeType;
76 | }
77 |
78 | public void setGradeType(String gradeType) {
79 | this.gradeType = gradeType;
80 | }
81 |
82 | public String getGradeGpa() {
83 | return gradeGpa;
84 | }
85 |
86 | public void setGradeGpa(String gradeGpa) {
87 | this.gradeGpa = gradeGpa;
88 | }
89 |
90 | public String getGradeScore() {
91 | return gradeScore;
92 | }
93 |
94 | public void setGradeScore(String gradeScore) {
95 | this.gradeScore = gradeScore;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | namespace "cn.gdeiassistant"
5 | compileSdkVersion 28
6 | defaultConfig {
7 | applicationId "cn.gdeiassistant"
8 | minSdkVersion 16
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | buildTypes {
16 | release {
17 | minifyEnabled = true
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 | packagingOptions {
23 | exclude 'META-INF/NOTICE'
24 | exclude 'META-INF/LICENSE'
25 | }
26 | }
27 |
28 | repositories {
29 | maven {
30 | allowInsecureProtocol = true
31 | url "http://maven.aliyun.com/nexus/content/repositories/releases"
32 | }
33 | flatDir {
34 | dirs 'libs'
35 | }
36 | google()
37 | jcenter()
38 | }
39 |
40 | dependencies {
41 | androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
42 | exclude group: 'com.android.support', module: 'support-annotations'
43 | })
44 | testImplementation 'junit:junit:4.12'
45 | implementation 'commons-codec:commons-codec:1.11'
46 | implementation 'com.alibaba:fastjson:1.2.54'
47 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.7'
48 | implementation 'com.fasterxml.jackson.core:jackson-core:2.9.7'
49 | implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.7'
50 | implementation 'de.hdodenhof:circleimageview:2.1.0'
51 | implementation 'com.auth0.android:jwtdecode:1.2.0'
52 | implementation 'com.google.code.gson:gson:2.8.5'
53 | implementation 'com.squareup.okhttp3:okhttp:3.10.0'
54 | implementation 'com.squareup.okio:okio:1.14.0'
55 | implementation 'com.android.support:appcompat-v7:28.0.0'
56 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
57 | implementation 'com.android.support:design:28.0.0'
58 | implementation files('libs/aliyun-oss-sdk-android-2.4.3.jar')
59 | }
60 |
61 | configurations {
62 | configureEach {
63 | exclude module: 'httpclient'
64 | }
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/BitmapFileModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 |
6 | import java.io.ByteArrayOutputStream;
7 | import java.io.File;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 |
11 | public class BitmapFileModel {
12 |
13 | /**
14 | * 将Bitmap图片保存到本地路径,并返回路径
15 | *
16 | * @param context
17 | * @param fileName 文件名称
18 | * @param bitmap 图片
19 | * @return
20 | */
21 |
22 | public static String saveFile(Context context, String fileName, Bitmap bitmap) {
23 | return saveFile(context, "", fileName, bitmap);
24 | }
25 |
26 | public static String saveFile(Context context, String filePath, String fileName, Bitmap bitmap) {
27 | byte[] bytes = bitmapToBytes(bitmap);
28 | return saveFile(context, filePath, fileName, bytes);
29 | }
30 |
31 | public static byte[] bitmapToBytes(Bitmap bitmap) {
32 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
33 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
34 | return baos.toByteArray();
35 | }
36 |
37 | public static String saveFile(Context context, String filePath, String fileName, byte[] bytes) {
38 | String fileFullName = "";
39 | FileOutputStream fileOutputStream = null;
40 | try {
41 | String suffix = "";
42 | if (filePath == null || filePath.trim().length() == 0) {
43 | filePath = context.getCacheDir() + "/gdeiassistant/";
44 | }
45 | File file = new File(filePath);
46 | if (!file.exists()) {
47 | file.mkdirs();
48 | }
49 | File fullFile = new File(filePath, fileName + suffix);
50 | fileFullName = fullFile.getPath();
51 | fileOutputStream = new FileOutputStream(new File(filePath, fileName + suffix));
52 | fileOutputStream.write(bytes);
53 | } catch (Exception e) {
54 | fileFullName = "";
55 | } finally {
56 | if (fileOutputStream != null) {
57 | try {
58 | fileOutputStream.close();
59 | } catch (IOException e) {
60 | fileFullName = "";
61 | }
62 | }
63 | }
64 | return fileFullName;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/todayschedule_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
19 |
20 |
31 |
32 |
47 |
48 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/LoginNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import org.apache.commons.codec.binary.Hex;
9 | import org.apache.commons.codec.digest.DigestUtils;
10 |
11 | import java.util.Date;
12 |
13 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
14 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
15 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
16 | import cn.gdeiassistant.Pojo.Login.UserLoginResult;
17 | import cn.gdeiassistant.R;
18 | import cn.gdeiassistant.Tools.OkHttpUtils;
19 | import cn.gdeiassistant.Tools.StringUtils;
20 | import okhttp3.FormBody;
21 | import okhttp3.OkHttpClient;
22 | import okhttp3.Request;
23 | import okhttp3.RequestBody;
24 | import okhttp3.Response;
25 |
26 | public class LoginNetWork {
27 |
28 | /**
29 | * 用户登录
30 | *
31 | * @param username
32 | * @param password
33 | * @param context
34 | * @return
35 | */
36 | public DataJsonResult UserLogin(String username, String password, Context context) throws Exception {
37 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.LOGIN_NETWORK_TIMEOUT, context);
38 | String unionid = StringUtils.getUniquePsuedoID();
39 | String nonce = StringUtils.getUUID();
40 | String timestamp = String.valueOf(new Date().getTime());
41 | String signature = new String(Hex.encodeHex(DigestUtils.sha1(timestamp + nonce + context.getString(R.string.request_validate_token))));
42 | RequestBody requestBody = new FormBody.Builder().add("username", username)
43 | .add("password", password)
44 | .add("unionid", unionid).add("nonce", nonce)
45 | .add("timestamp", timestamp).add("signature", signature).build();
46 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/userlogin")
47 | .post(requestBody).build();
48 | Response response = okHttpClient.newCall(request).execute();
49 | if (response.isSuccessful()) {
50 | return new Gson().fromJson(response.body().string()
51 | , new TypeToken>() {
52 | }.getType());
53 | }
54 | throw new ResponseStatusCodeException("服务暂不可用");
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/EvaluateModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 |
10 | import cn.gdeiassistant.Constant.EvaluateTagConstant;
11 | import cn.gdeiassistant.Constant.RequestConstant;
12 | import cn.gdeiassistant.NetWork.EvaluateNetWork;
13 | import cn.gdeiassistant.Pojo.JsonResult.JsonResult;
14 |
15 | public class EvaluateModel {
16 |
17 | private EvaluateNetWork evaluateNetWork = new EvaluateNetWork();
18 |
19 | /**
20 | * 提交教学评价请求
21 | *
22 | * @param directlySubmit
23 | * @param context
24 | */
25 | public void SubmitEvaluate(final boolean directlySubmit, final Handler handler, final Context context) {
26 | new Thread() {
27 | @Override
28 | public void run() {
29 | super.run();
30 | Message message = handler.obtainMessage();
31 | Bundle bundle = new Bundle();
32 | try {
33 | message.what = RequestConstant.SHOW_PROGRESS;
34 | handler.sendMessage(message);
35 | message = handler.obtainMessage();
36 | if (directlySubmit) {
37 | bundle.putInt("Tag", EvaluateTagConstant.DIRECTLY_SUBMIT);
38 | } else {
39 | bundle.putInt("Tag", EvaluateTagConstant.NORMAL_SUBMIT);
40 | }
41 | JsonResult result = evaluateNetWork.SubmitEvaluateRequest(directlySubmit, context);
42 | if (Boolean.TRUE.equals(result.isSuccess())) {
43 | message.what = RequestConstant.REQUEST_SUCCESS;
44 | } else {
45 | bundle.putString("Message", result.getMessage());
46 | message.what = RequestConstant.REQUEST_FAILURE;
47 | }
48 | } catch (NullPointerException ignored) {
49 |
50 | } catch (IOException e) {
51 | message.what = RequestConstant.REQUEST_TIMEOUT;
52 | } catch (Exception e) {
53 | message.what = RequestConstant.UNKNOWN_ERROR;
54 | }
55 | message.setData(bundle);
56 | handler.sendMessage(message);
57 | }
58 | }.start();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/book_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
27 |
28 |
39 |
40 |
49 |
50 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/ChargeNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
9 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
10 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
11 | import cn.gdeiassistant.Pojo.Entity.EncryptedData;
12 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
13 | import cn.gdeiassistant.R;
14 | import cn.gdeiassistant.Tools.OkHttpUtils;
15 | import okhttp3.FormBody;
16 | import okhttp3.OkHttpClient;
17 | import okhttp3.Request;
18 | import okhttp3.RequestBody;
19 | import okhttp3.Response;
20 |
21 | public class ChargeNetWork {
22 |
23 | /**
24 | * 提交充值请求
25 | *
26 | * @param amount
27 | * @param context
28 | * @return
29 | */
30 | public DataJsonResult ChargeRequest(String amount, String userAgent, String nonce, Long timestamp, String signature
31 | , String clientRSAPublicKey, String clientAESKey, String clientRSASignature, Context context) throws Exception {
32 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
33 | RequestBody requestBody = new FormBody.Builder()
34 | .add("amount", amount).add("token", application.getToken())
35 | .add("nonce", nonce).add("timestamp", String.valueOf(timestamp)).add("signature", signature)
36 | .add("clientRSAPublicKey", clientRSAPublicKey).add("clientAESKey", clientAESKey)
37 | .add("clientRSASignature", clientRSASignature)
38 | .build();
39 | Request request = new Request.Builder()
40 | .header("Version-Code", "V" + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName)
41 | .header("Client-Type", "Android")
42 | .header("User-Agent", userAgent)
43 | .post(requestBody).url(context.getString(R.string.resource_domain) + "rest/charge").build();
44 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CHARGE_NETWORK_TIMEOUT, context);
45 | Response response = okHttpClient.newCall(request).execute();
46 | if (response.isSuccessful()) {
47 | return new Gson().fromJson(response.body().string(), new TypeToken>() {
48 | }.getType());
49 | }
50 | throw new ResponseStatusCodeException("服务暂不可用");
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
69 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/StringUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import android.os.Build;
4 |
5 | import java.util.UUID;
6 |
7 | public class StringUtils {
8 |
9 | public static boolean isBlank(String string) {
10 | return string == null || string.isEmpty();
11 | }
12 |
13 | public static boolean isNotBlank(String string) {
14 | return !isBlank(string);
15 | }
16 |
17 | public static String getUUID() {
18 | return UUID.randomUUID().toString().replace("-", "");
19 | }
20 |
21 | /**
22 | * Return pseudo unique ID
23 | *
24 | * @return ID
25 | */
26 | public static String getUniquePsuedoID() {
27 | // If all else fails, if the user does have lower than API 9 (lower
28 | // than Gingerbread), has reset their device or 'Secure.ANDROID_ID'
29 | // returns 'null', then simply the ID returned will be solely based
30 | // off their Android device information. This is where the collisions
31 | // can happen.
32 | // Thanks http://www.pocketmagic.net/?p=1662!
33 | // Try not to use DISPLAY, HOST or ID - these items could change.
34 | // If there are collisions, there will be overlapping data
35 | String m_szDevIDShort = "35" + (Build.BOARD.length() % 10) + (Build.BRAND.length() % 10) + (Build.CPU_ABI.length() % 10) + (Build.DEVICE.length() % 10) + (Build.MANUFACTURER.length() % 10) + (Build.MODEL.length() % 10) + (Build.PRODUCT.length() % 10);
36 |
37 | // Thanks to @Roman SL!
38 | // http://stackoverflow.com/a/4789483/950427
39 | // Only devices with API >= 9 have android.os.Build.SERIAL
40 | // http://developer.android.com/reference/android/os/Build.html#SERIAL
41 | // If a user upgrades software or roots their device, there will be a duplicate entry
42 | String serial = null;
43 | try {
44 | serial = android.os.Build.class.getField("SERIAL").get(null).toString();
45 |
46 | // Go ahead and return the serial for api => 9
47 | return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
48 | } catch (Exception exception) {
49 | // String needs to be initialized
50 | serial = "gdeiassistant"; // some value
51 | }
52 |
53 | // Thanks @Joe!
54 | // http://stackoverflow.com/a/2853253/950427
55 | // Finally, combine the values we have found by using the UUID class to create a unique identifier
56 | return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/GuideModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 |
10 | import cn.gdeiassistant.Constant.RequestConstant;
11 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
12 | import cn.gdeiassistant.NetWork.TokenNetWork;
13 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
14 | import cn.gdeiassistant.Pojo.Token.TokenRefreshResult;
15 |
16 | public class GuideModel {
17 |
18 | private TokenNetWork tokenNetWork = new TokenNetWork();
19 |
20 | /**
21 | * 刷新权限令牌
22 | *
23 | * @param refreshToken
24 | */
25 | public void RefreshToken(final Handler handler, final String refreshToken, final Context context) {
26 | new Thread() {
27 | @Override
28 | public void run() {
29 | super.run();
30 | Message message = handler.obtainMessage();
31 | Bundle bundle = new Bundle();
32 | try {
33 | DataJsonResult result = tokenNetWork.RefreshToken(refreshToken, context);
34 | if (Boolean.TRUE.equals(result.isSuccess())) {
35 | if (result.getData() != null) {
36 | //缓存刷新后的令牌信息
37 | bundle.putString("AccessToken", result.getData().getAccessToken().getSignature());
38 | bundle.putString("RefreshToken", result.getData().getRefreshToken().getSignature());
39 | message.what = RequestConstant.REQUEST_SUCCESS;
40 | } else {
41 | message.what = RequestConstant.SERVER_ERROR;
42 | }
43 | } else {
44 | bundle.putString("Message", result.getMessage());
45 | message.what = RequestConstant.REQUEST_FAILURE;
46 | }
47 | } catch (NullPointerException ignored) {
48 |
49 | } catch (IOException e) {
50 | message.what = RequestConstant.REQUEST_TIMEOUT;
51 | } catch (ResponseStatusCodeException e) {
52 | message.what = RequestConstant.SERVER_ERROR;
53 | } catch (Exception e) {
54 | message.what = RequestConstant.UNKNOWN_ERROR;
55 | }
56 | message.setData(bundle);
57 | handler.sendMessage(message);
58 | }
59 | }.start();
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/CetQueryNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
9 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
10 | import cn.gdeiassistant.Pojo.Entity.Cet;
11 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
12 | import cn.gdeiassistant.R;
13 | import cn.gdeiassistant.Tools.OkHttpUtils;
14 | import okhttp3.FormBody;
15 | import okhttp3.OkHttpClient;
16 | import okhttp3.Request;
17 | import okhttp3.RequestBody;
18 | import okhttp3.Response;
19 |
20 | public class CetQueryNetWork {
21 |
22 | /**
23 | * 加载四六级成绩查询页面验证码
24 | *
25 | * @param context
26 | * @return
27 | * @throws Exception
28 | */
29 | public DataJsonResult CetCheckCode(Context context) throws Exception {
30 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CET_QUERY_NETWORK_TIMEOUT, context);
31 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/cet/checkcode").build();
32 | Response response = okHttpClient.newCall(request).execute();
33 | if (response.isSuccessful()) {
34 | return new Gson().fromJson(response.body().string()
35 | , new TypeToken>() {
36 | }.getType());
37 | }
38 | throw new ResponseStatusCodeException("服务暂不可用");
39 | }
40 |
41 | /**
42 | * 查询四六级成绩
43 | *
44 | * @param number
45 | * @param name
46 | * @param checkcode
47 | * @param context
48 | * @return
49 | */
50 | public DataJsonResult CetQuery(String number, String name, String checkcode, Context context) throws Exception {
51 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CET_QUERY_NETWORK_TIMEOUT, context);
52 | RequestBody requestBody = new FormBody.Builder().add("number", number).add("name", name)
53 | .add("checkcode", checkcode).build();
54 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/cetquery").post(requestBody).build();
55 | Response response = okHttpClient.newCall(request).execute();
56 | if (response.isSuccessful()) {
57 | return new Gson().fromJson(response.body().string()
58 | , new TypeToken>() {
59 | }.getType());
60 | }
61 | throw new ResponseStatusCodeException("服务暂不可用");
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
29 |
30 |
31 |
32 |
43 |
44 |
54 |
55 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/GradeQueryModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 |
10 | import cn.gdeiassistant.Constant.RequestConstant;
11 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
12 | import cn.gdeiassistant.NetWork.GradeQueryNetWork;
13 | import cn.gdeiassistant.Pojo.GradeQuery.GradeQueryResult;
14 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
15 |
16 | public class GradeQueryModel {
17 |
18 | private GradeQueryNetWork gradeQueryNetWork = new GradeQueryNetWork();
19 |
20 | /**
21 | * 查询成绩
22 | *
23 | * @param handler
24 | * @param year
25 | */
26 | public void GradeQuery(final Handler handler, final Integer year, final Context context) {
27 | new Thread() {
28 | @Override
29 | public void run() {
30 | super.run();
31 | Message message = handler.obtainMessage();
32 | Bundle bundle = new Bundle();
33 | try {
34 | message.what = RequestConstant.SHOW_PROGRESS;
35 | handler.sendMessage(message);
36 | message = handler.obtainMessage();
37 | DataJsonResult result = gradeQueryNetWork.GradeQuery(year, context);
38 | if (Boolean.TRUE.equals(result.isSuccess())) {
39 | if (result.getData() != null) {
40 | bundle.putSerializable("GradeData", result.getData());
41 | message.what = RequestConstant.REQUEST_SUCCESS;
42 | } else {
43 | message.what = RequestConstant.SERVER_ERROR;
44 | }
45 | } else {
46 | bundle.putString("Message", result.getMessage());
47 | message.setData(bundle);
48 | message.what = RequestConstant.REQUEST_FAILURE;
49 | }
50 | } catch (NullPointerException ignored) {
51 |
52 | } catch (IOException e) {
53 | message.what = RequestConstant.REQUEST_TIMEOUT;
54 | } catch (ResponseStatusCodeException e) {
55 | message.what = RequestConstant.SERVER_ERROR;
56 | } catch (Exception e) {
57 | message.what = RequestConstant.UNKNOWN_ERROR;
58 | }
59 | message.setData(bundle);
60 | handler.sendMessage(message);
61 | }
62 | }.start();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Adapter/GradeListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.RelativeLayout;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | import cn.gdeiassistant.Pojo.Entity.Grade;
14 |
15 | public class GradeListViewAdapter extends BaseAdapter {
16 |
17 | //父列表视图容器
18 | private LayoutInflater listContainer;
19 |
20 | //成绩数据集合
21 | private List gradeDataList;
22 |
23 | //列表项布局
24 | private int itemViewResource;
25 |
26 | //列表项组件集合
27 | private static class ListItemView {
28 | TextView subject_name;
29 | TextView subject_score;
30 | RelativeLayout item_layout;
31 | }
32 |
33 | //根据父列表构造列表项适配器,加载列表项界面、读取并设置列表项数据
34 | public GradeListViewAdapter(Context context, List gradeDataList, int itemViewResource) {
35 | this.listContainer = LayoutInflater.from(context);
36 | this.itemViewResource = itemViewResource;
37 | this.gradeDataList = gradeDataList;
38 | }
39 |
40 | @Override
41 | public int getCount() {
42 | //根据成绩数据条目返回列表项数目
43 | return gradeDataList.size();
44 | }
45 |
46 | @Override
47 | public Object getItem(int position) {
48 | return gradeDataList.get(position);
49 | }
50 |
51 | @Override
52 | public long getItemId(int position) {
53 | return position;
54 | }
55 |
56 | @Override
57 | public View getView(int position, View convertView, ViewGroup parent) {
58 | // 创建自定义列表项组件
59 | ListItemView listItemView;
60 | if (convertView == null) {
61 | //获取列表项布局
62 | convertView = listContainer.inflate(this.itemViewResource, null);
63 | //初始化列表项各组件
64 | listItemView = new ListItemView();
65 | listItemView.item_layout = convertView.findViewById(cn.gdeiassistant.R.id.grade_item_layout);
66 | listItemView.subject_name = convertView.findViewById(cn.gdeiassistant.R.id.grade_item_subjectname);
67 | listItemView.subject_score = convertView.findViewById(cn.gdeiassistant.R.id.grade_item_subjectscore);
68 | //设置控件集到convertView
69 | convertView.setTag(listItemView);
70 | } else {
71 | listItemView = (ListItemView) convertView.getTag();
72 | }
73 | //依次读取列表项数据中的第position项数据赋于news对象
74 | Grade grade = gradeDataList.get(position);
75 | listItemView.subject_name.setText(grade.getGradeName());
76 | listItemView.subject_score.setText(grade.getGradeScore());
77 | return convertView;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Activity/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.Toolbar;
6 | import android.view.MenuItem;
7 | import android.webkit.WebView;
8 | import android.webkit.WebViewClient;
9 | import android.widget.TextView;
10 |
11 | import cn.gdeiassistant.Presenter.WebViewPresenter;
12 | import cn.gdeiassistant.R;
13 |
14 | public class WebViewActivity extends AppCompatActivity {
15 |
16 | private TextView webviewTitle;
17 |
18 | private WebView webviewWebView;
19 |
20 | private Toolbar webviewToolbar;
21 |
22 | private WebViewPresenter webViewPresenter;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_webview);
28 | //初始化控件
29 | InitView();
30 | //配置加载Presenter
31 | webViewPresenter = new WebViewPresenter(this);
32 | }
33 |
34 | @Override
35 | protected void onDestroy() {
36 | super.onDestroy();
37 | if (webviewWebView != null) {
38 | webviewWebView.removeAllViews();
39 | webviewWebView.destroy();
40 | }
41 | }
42 |
43 | /**
44 | * 初始化控件
45 | */
46 | private void InitView() {
47 | webviewTitle = findViewById(R.id.chargeTitle);
48 | webviewWebView = findViewById(R.id.chargeWebView);
49 | webviewToolbar = findViewById(R.id.chargeToolbar);
50 | setSupportActionBar(webviewToolbar);
51 | if (getSupportActionBar() != null) {
52 | getSupportActionBar().setDisplayShowTitleEnabled(false);
53 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
54 | }
55 | }
56 |
57 | /**
58 | * 加载网页
59 | *
60 | * @param url
61 | */
62 | public void LoadWeb(String url) {
63 | if (webviewWebView != null) {
64 | //设置支持JavaScript脚本
65 | webviewWebView.getSettings().setJavaScriptEnabled(true);
66 | //设置WEB视图
67 | webviewWebView.setWebViewClient(new WebViewClient());
68 | //加载需要显示的用户协议内容
69 | webviewWebView.loadUrl(url);
70 | }
71 | }
72 |
73 | /**
74 | * 设置标题名
75 | *
76 | * @param title
77 | */
78 | public void SetTitleName(String title) {
79 | webviewTitle.setText(title);
80 | }
81 |
82 | @Override
83 | public boolean onOptionsItemSelected(MenuItem item) {
84 | switch (item.getItemId()) {
85 | case android.R.id.home:
86 | //返回上一层
87 | finish();
88 |
89 | default:
90 | return super.onOptionsItemSelected(item);
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/ScheduleQueryModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 | import android.support.annotation.Nullable;
8 |
9 | import java.io.IOException;
10 | import java.io.Serializable;
11 |
12 | import cn.gdeiassistant.Constant.RequestConstant;
13 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
14 | import cn.gdeiassistant.NetWork.ScheduleQueryNetWork;
15 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
16 | import cn.gdeiassistant.Pojo.ScheduleQuery.ScheduleQueryResult;
17 |
18 | public class ScheduleQueryModel {
19 |
20 | private ScheduleQueryNetWork scheduleQueryNetWork = new ScheduleQueryNetWork();
21 |
22 | /**
23 | * 课表查询
24 | *
25 | * @param week
26 | * @param handler
27 | * @param context
28 | */
29 | public void ScheduleQuery(@Nullable final Integer week, final Handler handler, final Context context) {
30 | new Thread() {
31 | @Override
32 | public void run() {
33 | super.run();
34 | Message message = handler.obtainMessage();
35 | Bundle bundle = new Bundle();
36 | try {
37 | message.what = RequestConstant.SHOW_PROGRESS;
38 | handler.sendMessage(message);
39 | message = handler.obtainMessage();
40 | DataJsonResult result = scheduleQueryNetWork.ScheduleQuery(week, context);
41 | if (Boolean.TRUE.equals(result.isSuccess())) {
42 | if (result.getData() != null) {
43 | bundle.putSerializable("ScheduleList", (Serializable) result.getData().getScheduleList());
44 | message.what = RequestConstant.REQUEST_SUCCESS;
45 | } else {
46 | message.what = RequestConstant.SERVER_ERROR;
47 | }
48 | } else {
49 | bundle.putString("Message", result.getMessage());
50 | message.what = RequestConstant.REQUEST_FAILURE;
51 | }
52 | } catch (NullPointerException ignored) {
53 |
54 | } catch (IOException e) {
55 | message.what = RequestConstant.REQUEST_TIMEOUT;
56 | } catch (ResponseStatusCodeException e) {
57 | message.what = RequestConstant.SERVER_ERROR;
58 | } catch (Exception e) {
59 | message.what = RequestConstant.UNKNOWN_ERROR;
60 | }
61 | message.setData(bundle);
62 | handler.sendMessage(message);
63 | }
64 | }.start();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/TokenUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import com.auth0.android.jwt.DecodeException;
7 | import com.auth0.android.jwt.JWT;
8 |
9 | import java.util.Date;
10 |
11 | public class TokenUtils {
12 |
13 | /**
14 | * 获取用户权限令牌
15 | *
16 | * @param context
17 | * @return
18 | */
19 | public static String GetUserAccessToken(Context context) {
20 | SharedPreferences sharedPreferences = context.getSharedPreferences("GdeiAssistant", Context.MODE_PRIVATE);
21 | return sharedPreferences.getString("AccessToken", null);
22 | }
23 |
24 | /**
25 | * 获取用户刷新令牌
26 | *
27 | * @param context
28 | * @return
29 | */
30 | public static String GetUserRefreshToken(Context context) {
31 | SharedPreferences sharedPreferences = context.getSharedPreferences("GdeiAssistant", Context.MODE_PRIVATE);
32 | return sharedPreferences.getString("RefreshToken", null);
33 | }
34 |
35 | /**
36 | * 删除用户保存的权限和刷新令牌信息
37 | *
38 | * @param context
39 | */
40 | public static void ClearUserToken(Context context) {
41 | SharedPreferences sharedPreferences = context.getSharedPreferences("GdeiAssistant", Context.MODE_PRIVATE);
42 | sharedPreferences.edit().clear().apply();
43 | }
44 |
45 | /**
46 | * 保存用户令牌信息
47 | *
48 | * @param accessToken
49 | * @param refreshToken
50 | * @param context
51 | */
52 | public static void SaveUserToken(String accessToken, String refreshToken, Context context) {
53 | SharedPreferences sharedPreferences = context.getSharedPreferences("GdeiAssistant", Context.MODE_PRIVATE);
54 | SharedPreferences.Editor editor = sharedPreferences.edit();
55 | editor.putString("AccessToken", accessToken);
56 | editor.putString("RefreshToken", refreshToken);
57 | editor.apply();
58 | }
59 |
60 | /**
61 | * 校验令牌时间戳有效性
62 | *
63 | * @param token
64 | * @return
65 | */
66 | public static boolean ValidateTokenTimestamp(String token) {
67 | try {
68 | String expireTime = new JWT(token).getClaim("expireTime").asString();
69 | if (StringUtils.isNotBlank(expireTime)) {
70 | return TimeUtils.GetTimestampDifference(new Date(), new Date(Long.valueOf(expireTime)), TimeUtils.TimeUnit.HOUR) > 1;
71 | }
72 | return false;
73 | } catch (DecodeException | NumberFormatException e) {
74 | return false;
75 | }
76 | }
77 |
78 | public static String GetAccessTokenUsername(String accessToken) {
79 | try {
80 | return new JWT(accessToken).getClaim("username").asString();
81 | } catch (DecodeException e) {
82 | return null;
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/LoginModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 |
10 | import cn.gdeiassistant.Constant.RequestConstant;
11 | import cn.gdeiassistant.Constant.ResultConstant;
12 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
13 | import cn.gdeiassistant.NetWork.LoginNetWork;
14 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
15 | import cn.gdeiassistant.Pojo.Login.UserLoginResult;
16 |
17 | public class LoginModel {
18 |
19 | private LoginNetWork loginNetWork = new LoginNetWork();
20 |
21 | /**
22 | * 用户登录
23 | *
24 | * @param handler
25 | * @param username
26 | * @param password
27 | */
28 | public void UserLogin(final Handler handler, final String username, final String password, final Context context) {
29 | new Thread() {
30 | @Override
31 | public void run() {
32 | super.run();
33 | Message message = handler.obtainMessage();
34 | Bundle bundle = new Bundle();
35 | try {
36 | message.what = RequestConstant.SHOW_PROGRESS;
37 | handler.sendMessage(message);
38 | message = handler.obtainMessage();
39 | DataJsonResult result = loginNetWork.UserLogin(username, password, context);
40 | if (Boolean.TRUE.equals(result.isSuccess())) {
41 | if (result.getData() != null) {
42 | //发送服务器返回的用户和令牌信息
43 | bundle.putString("AccessToken", result.getData().getAccessToken().getSignature());
44 | bundle.putString("RefreshToken", result.getData().getRefreshToken().getSignature());
45 | message.what = RequestConstant.REQUEST_SUCCESS;
46 | } else {
47 | message.what = RequestConstant.SERVER_ERROR;
48 | }
49 | } else {
50 | bundle.putString("Message", result.getMessage());
51 | message.what = RequestConstant.REQUEST_FAILURE;
52 | }
53 | } catch (NullPointerException ignored) {
54 |
55 | } catch (IOException e) {
56 | message.what = ResultConstant.NETWORK_TIMEOUT;
57 | } catch (ResponseStatusCodeException e) {
58 | message.what = RequestConstant.SERVER_ERROR;
59 | } catch (Exception e) {
60 | message.what = RequestConstant.UNKNOWN_ERROR;
61 | }
62 | message.setData(bundle);
63 | handler.sendMessage(message);
64 | }
65 | }.start();
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Adapter/BookListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 | import java.util.List;
12 |
13 | import cn.gdeiassistant.Pojo.Entity.Book;
14 | import cn.gdeiassistant.R;
15 |
16 | public class BookListViewAdapter extends BaseAdapter {
17 |
18 | //父列表视图容器
19 | private LayoutInflater listContainer;
20 |
21 | //借阅图书数据集合
22 | private List bookDataList;
23 |
24 | //列表项布局
25 | private int itemViewResource;
26 |
27 | //列表项组件集合
28 | private static class ListItemView {
29 | TextView bookName;
30 | TextView borrowDate;
31 | TextView returnDate;
32 | LinearLayout itemLayout;
33 | }
34 |
35 | //根据父列表构造列表项适配器,加载列表项界面、读取并设置列表项数据
36 | public BookListViewAdapter(Context context, List bookDataList, int itemViewResource) {
37 | this.listContainer = LayoutInflater.from(context);
38 | this.itemViewResource = itemViewResource;
39 | this.bookDataList = bookDataList;
40 | }
41 |
42 | @Override
43 | public int getCount() {
44 | //根据成绩数据条目返回列表项数目
45 | return bookDataList.size();
46 | }
47 |
48 | @Override
49 | public Object getItem(int position) {
50 | return bookDataList.get(position);
51 | }
52 |
53 | @Override
54 | public long getItemId(int position) {
55 | return position;
56 | }
57 |
58 | @Override
59 | public View getView(int position, View convertView, ViewGroup parent) {
60 | // 创建自定义列表项组件
61 | BookListViewAdapter.ListItemView listItemView;
62 | if (convertView == null) {
63 | //获取列表项布局
64 | convertView = listContainer.inflate(this.itemViewResource, null);
65 | //初始化列表项各组件
66 | listItemView = new BookListViewAdapter.ListItemView();
67 | listItemView.itemLayout = convertView.findViewById(R.id.bookItemLayout);
68 | listItemView.bookName = convertView.findViewById(R.id.bookItemBookName);
69 | listItemView.borrowDate = convertView.findViewById(R.id.bookItemBorrowDate);
70 | listItemView.returnDate = convertView.findViewById(R.id.bookItemReturnDate);
71 | //设置控件集到convertView
72 | convertView.setTag(listItemView);
73 | } else {
74 | listItemView = (BookListViewAdapter.ListItemView) convertView.getTag();
75 | }
76 | //依次读取列表项数据中的第position项数据赋于news对象
77 | Book book = bookDataList.get(position);
78 | listItemView.bookName.setText(book.getName());
79 | listItemView.borrowDate.setText("借阅时间:" + book.getBorrowDate());
80 | listItemView.returnDate.setText("应还时间:" + book.getReturnDate());
81 | return convertView;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/BookNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import java.util.List;
9 |
10 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
11 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
12 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
13 | import cn.gdeiassistant.Pojo.Entity.Book;
14 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
15 | import cn.gdeiassistant.Pojo.JsonResult.JsonResult;
16 | import cn.gdeiassistant.R;
17 | import cn.gdeiassistant.Tools.OkHttpUtils;
18 | import okhttp3.FormBody;
19 | import okhttp3.OkHttpClient;
20 | import okhttp3.Request;
21 | import okhttp3.RequestBody;
22 | import okhttp3.Response;
23 |
24 | public class BookNetWork {
25 |
26 | /**
27 | * 提交图书借阅查询请求
28 | *
29 | * @param password
30 | * @param context
31 | * @return
32 | */
33 | public DataJsonResult> BookQuery(String password, Context context) throws Exception {
34 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
35 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.BOOK_QUERY_NETWORK_TIMEOUT, context);
36 | RequestBody requestBody = new FormBody.Builder().add("password", password)
37 | .add("token", application.getToken()).build();
38 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/bookquery").post(requestBody).build();
39 | Response response = okHttpClient.newCall(request).execute();
40 | if (response.isSuccessful()) {
41 | return new Gson().fromJson(response.body().string(), new TypeToken>>() {
42 | }.getType());
43 | }
44 | throw new ResponseStatusCodeException("服务暂不可用");
45 | }
46 |
47 | /**
48 | * 提交图书续借请求
49 | *
50 | * @param password
51 | * @param context
52 | * @return
53 | */
54 | public JsonResult BookRenew(String password, String sn, String code, Context context) throws Exception {
55 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
56 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.BOOK_QUERY_NETWORK_TIMEOUT, context);
57 | RequestBody requestBody = new FormBody.Builder().add("password", password).add("sn", sn)
58 | .add("code", code).add("token", application.getToken()).build();
59 | Request request = new Request.Builder().url(context.getString(R.string.resource_domain) + "rest/bookrenew").post(requestBody).build();
60 | Response response = okHttpClient.newCall(request).execute();
61 | if (response.isSuccessful()) {
62 | return new Gson().fromJson(response.body().string(), JsonResult.class);
63 | }
64 | throw new ResponseStatusCodeException("服务暂不可用");
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_lost.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
22 |
23 |
33 |
34 |
35 |
36 |
37 |
38 |
44 |
45 |
55 |
56 |
67 |
68 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_evaluate.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
22 |
23 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
49 |
50 |
55 |
56 |
61 |
62 |
63 |
64 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Tools/AESUtils.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Tools;
2 |
3 | import android.util.Base64;
4 |
5 | import java.security.InvalidAlgorithmParameterException;
6 | import java.security.InvalidKeyException;
7 | import java.security.NoSuchAlgorithmException;
8 |
9 | import javax.crypto.BadPaddingException;
10 | import javax.crypto.Cipher;
11 | import javax.crypto.IllegalBlockSizeException;
12 | import javax.crypto.KeyGenerator;
13 | import javax.crypto.NoSuchPaddingException;
14 | import javax.crypto.spec.IvParameterSpec;
15 | import javax.crypto.spec.SecretKeySpec;
16 |
17 | public class AESUtils {
18 |
19 | /**
20 | * 生成AES密钥
21 | *
22 | * @return
23 | * @throws NoSuchAlgorithmException
24 | */
25 | public static byte[] GenerateSecretKey() throws NoSuchAlgorithmException {
26 | KeyGenerator kgen = KeyGenerator.getInstance("AES");
27 | kgen.init(256);
28 | return kgen.generateKey().getEncoded();
29 | }
30 |
31 | /**
32 | * 加密字节数组
33 | *
34 | * @param secretKeyByte
35 | * @param content
36 | * @return
37 | * @throws NoSuchPaddingException
38 | * @throws NoSuchAlgorithmException
39 | * @throws InvalidKeyException
40 | * @throws BadPaddingException
41 | * @throws IllegalBlockSizeException
42 | */
43 | public static byte[] EncryptByte(byte[] secretKeyByte, byte[] content) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException {
44 | //通过secretKeyByte生成SecretKeySpec
45 | SecretKeySpec key = new SecretKeySpec(secretKeyByte, "AES");
46 | //Cipher对象实际完成加密操作
47 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
48 | //用密匙初始化Cipher对象
49 | cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(Base64.encodeToString(secretKeyByte, Base64.NO_WRAP)
50 | .substring(0, 16).getBytes()));
51 | //执行加密操作
52 | return cipher.doFinal(content);
53 | }
54 |
55 | /**
56 | * 解密字节数组
57 | *
58 | * @param secretKeyByte
59 | * @param content
60 | * @return
61 | * @throws NoSuchPaddingException
62 | * @throws NoSuchAlgorithmException
63 | * @throws InvalidKeyException
64 | * @throws BadPaddingException
65 | * @throws IllegalBlockSizeException
66 | */
67 | public static byte[] DecryptByte(byte[] secretKeyByte, byte[] content) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException {
68 |
69 | //通过secretKeyByte生成SecretKeySpec
70 | SecretKeySpec key = new SecretKeySpec(secretKeyByte, "AES");
71 | //Cipher对象实际完成加密操作
72 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
73 | //用密匙初始化Cipher对象
74 | cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(Base64.encodeToString(secretKeyByte, Base64.NO_WRAP)
75 | .substring(0, 16).getBytes()));
76 | //执行加密操作
77 | return cipher.doFinal(content);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_schedule.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
18 |
19 |
29 |
30 |
31 |
32 |
38 |
39 |
44 |
45 |
49 |
50 |
55 |
56 |
62 |
63 |
67 |
68 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/BookDetailPresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import java.lang.ref.WeakReference;
7 |
8 | import cn.gdeiassistant.Activity.BookDetailActivity;
9 | import cn.gdeiassistant.Constant.RequestConstant;
10 | import cn.gdeiassistant.Model.BookModel;
11 |
12 | public class BookDetailPresenter {
13 |
14 | private BookDetailActivity bookDetailActivity;
15 |
16 | private BookDetailActivityHandler bookDetailActivityHandler;
17 |
18 | private BookModel bookModel;
19 |
20 | public BookDetailPresenter(BookDetailActivity bookDetailActivity) {
21 | this.bookDetailActivity = bookDetailActivity;
22 | this.bookModel = new BookModel();
23 | this.bookDetailActivityHandler = new BookDetailActivityHandler(bookDetailActivity);
24 | }
25 |
26 | public static class BookDetailActivityHandler extends Handler {
27 |
28 | private BookDetailActivity bookDetailActivity;
29 |
30 | BookDetailActivityHandler(BookDetailActivity bookDetailActivity) {
31 | this.bookDetailActivity = new WeakReference<>(bookDetailActivity).get();
32 | }
33 |
34 | @Override
35 | public void handleMessage(Message msg) {
36 | super.handleMessage(msg);
37 | switch (msg.what) {
38 | case RequestConstant.REQUEST_SUCCESS:
39 | //续借图书成功
40 | bookDetailActivity.HideProgressDialog();
41 | bookDetailActivity.ShowToast("续借图书成功");
42 | bookDetailActivity.AddRenewTime();
43 | break;
44 |
45 | case RequestConstant.REQUEST_FAILURE:
46 | //续借图书失败
47 | bookDetailActivity.HideProgressDialog();
48 | bookDetailActivity.ShowToast(msg.getData().getString("Message"));
49 | break;
50 |
51 | case RequestConstant.REQUEST_TIMEOUT:
52 | //网络连接超时
53 | bookDetailActivity.HideProgressDialog();
54 | bookDetailActivity.ShowToast("网络连接超时,请重试");
55 | break;
56 |
57 | case RequestConstant.UNKNOWN_ERROR:
58 | //出现未知异常
59 | bookDetailActivity.HideProgressDialog();
60 | bookDetailActivity.ShowToast("出现未知异常,请联系管理员");
61 | break;
62 |
63 | case RequestConstant.SHOW_PROGRESS:
64 | //显示进度条
65 | bookDetailActivity.ShowProgressDialog();
66 | break;
67 | }
68 | }
69 | }
70 |
71 | /**
72 | * 移除所有的回调和消息,防止内存泄露
73 | */
74 | public void RemoveCallBacksAndMessages() {
75 | bookDetailActivityHandler.removeCallbacksAndMessages(null);
76 | }
77 |
78 | /**
79 | * 提交图书借阅查询请求
80 | */
81 | public void SubmitBookRenew(String password, String sn, String code) {
82 | bookModel.SubmitBookRenew(password, sn, code, bookDetailActivityHandler, bookDetailActivity.getApplicationContext());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/NetWork/CardQueryNetWork.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.NetWork;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.Gson;
6 | import com.google.gson.reflect.TypeToken;
7 |
8 | import cn.gdeiassistant.Application.GdeiAssistantApplication;
9 | import cn.gdeiassistant.Constant.NetWorkTimeoutConstant;
10 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
11 | import cn.gdeiassistant.Pojo.CardQuery.CardQueryResult;
12 | import cn.gdeiassistant.Pojo.Entity.CardInfo;
13 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
14 | import cn.gdeiassistant.R;
15 | import cn.gdeiassistant.Tools.OkHttpUtils;
16 | import okhttp3.FormBody;
17 | import okhttp3.OkHttpClient;
18 | import okhttp3.Request;
19 | import okhttp3.RequestBody;
20 | import okhttp3.Response;
21 |
22 | public class CardQueryNetWork {
23 |
24 | /**
25 | * 查询校园卡基本信息
26 | *
27 | * @param context
28 | * @return
29 | */
30 | public DataJsonResult CardInfoQuery(Context context) throws Exception {
31 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
32 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CARD_QUERY_NETWORK_TIMEOUT, context);
33 | RequestBody requestBody = new FormBody.Builder().add("token", application.getToken()).build();
34 | Request request = new Request.Builder().post(requestBody).url(context.getString(R.string.resource_domain) + "rest/cardinfo").build();
35 | Response response = okHttpClient.newCall(request).execute();
36 | if (response.isSuccessful()) {
37 | return new Gson().fromJson(response.body().string()
38 | , new TypeToken>() {
39 | }.getType());
40 | }
41 | throw new ResponseStatusCodeException("服务暂不可用");
42 | }
43 |
44 | /**
45 | * 查询消费流水记录
46 | *
47 | * @param year
48 | * @param month
49 | * @param date
50 | * @param context
51 | * @return
52 | * @throws Exception
53 | */
54 | public DataJsonResult CardQuery(int year, int month, int date, Context context) throws Exception {
55 | GdeiAssistantApplication application = (GdeiAssistantApplication) context;
56 | OkHttpClient okHttpClient = OkHttpUtils.GetOkHttpClient(NetWorkTimeoutConstant.CARD_QUERY_NETWORK_TIMEOUT, context);
57 | RequestBody requestBody = new FormBody.Builder().add("token", application.getToken())
58 | .add("year", year + "").add("month", month + "")
59 | .add("date", date + "").build();
60 | Request request = new Request.Builder().post(requestBody).url(context.getString(R.string.resource_domain) + "rest/cardquery").build();
61 | Response response = okHttpClient.newCall(request).execute();
62 | if (response.isSuccessful()) {
63 | return new Gson().fromJson(response.body().string()
64 | , new TypeToken>() {
65 | }.getType());
66 | }
67 | throw new ResponseStatusCodeException("服务暂不可用");
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Model/CardQueryModel.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Model;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.os.Message;
7 |
8 | import java.io.IOException;
9 | import java.io.Serializable;
10 |
11 | import cn.gdeiassistant.Constant.RequestConstant;
12 | import cn.gdeiassistant.Exception.ResponseStatusCodeException;
13 | import cn.gdeiassistant.NetWork.CardQueryNetWork;
14 | import cn.gdeiassistant.Pojo.CardQuery.CardQueryResult;
15 | import cn.gdeiassistant.Pojo.JsonResult.DataJsonResult;
16 |
17 | public class CardQueryModel {
18 |
19 | private CardQueryNetWork cardQueryNetWork = new CardQueryNetWork();
20 |
21 | /**
22 | * 校园卡消费记录查询
23 | *
24 | * @param handler
25 | * @param year
26 | * @param month
27 | * @param date
28 | * @param context
29 | */
30 | public void CardQuery(final Handler handler, final int year, final int month, final int date, final Context context) {
31 | new Thread() {
32 | @Override
33 | public void run() {
34 | super.run();
35 | Message message = handler.obtainMessage();
36 | Bundle bundle = new Bundle();
37 | try {
38 | message.what = RequestConstant.SHOW_PROGRESS;
39 | handler.sendMessage(message);
40 | message = handler.obtainMessage();
41 | DataJsonResult result = cardQueryNetWork.CardQuery(year, month, date, context);
42 | if (Boolean.TRUE.equals(result.isSuccess())) {
43 | if (result.getData() != null) {
44 | bundle.putString("Year", String.valueOf(year));
45 | bundle.putString("Month", String.valueOf(month));
46 | bundle.putString("Date", String.valueOf(date));
47 | bundle.putSerializable("CardInfo", result.getData().getCardInfo());
48 | bundle.putSerializable("CardList", (Serializable) result.getData().getCardList());
49 | message.what = RequestConstant.REQUEST_SUCCESS;
50 | } else {
51 | message.what = RequestConstant.SERVER_ERROR;
52 | }
53 | } else {
54 | bundle.putString("Message", result.getMessage());
55 | message.what = RequestConstant.REQUEST_FAILURE;
56 | }
57 | } catch (NullPointerException ignored) {
58 |
59 | } catch (IOException e) {
60 | message.what = RequestConstant.REQUEST_TIMEOUT;
61 | } catch (ResponseStatusCodeException e) {
62 | message.what = RequestConstant.SERVER_ERROR;
63 | } catch (Exception e) {
64 | message.what = RequestConstant.UNKNOWN_ERROR;
65 | }
66 | message.setData(bundle);
67 | handler.sendMessage(message);
68 | }
69 | }.start();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Activity/GradeDetailActivity.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Activity;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.Toolbar;
6 | import android.view.MenuItem;
7 | import android.widget.TextView;
8 |
9 | import cn.gdeiassistant.R;
10 |
11 | public class GradeDetailActivity extends AppCompatActivity {
12 |
13 | private Toolbar gradeDetailToolbar;
14 |
15 | private TextView gradeDetailSubjectName;
16 | private TextView gradeDetailSubjectScore;
17 | private TextView gradeDetailSubjectCredit;
18 | private TextView gradeDetailSubjectGPA;
19 | private TextView gradeDetailSubjectId;
20 | private TextView gradeDetailSubjectYear;
21 | private TextView gradeDetailSubjectType;
22 | private TextView gradeDetailSubjectTerm;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_grade_detail);
28 | InitView();
29 | }
30 |
31 | private void InitView() {
32 | gradeDetailToolbar = (Toolbar) findViewById(R.id.gradeDetailToolbar);
33 | setSupportActionBar(gradeDetailToolbar);
34 | if (getSupportActionBar() != null) {
35 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
36 | getSupportActionBar().setDisplayShowTitleEnabled(false);
37 | }
38 | gradeDetailSubjectName = (TextView) findViewById(R.id.gradeDetailSubjectName);
39 | gradeDetailSubjectScore = (TextView) findViewById(R.id.gradeDetailSubjectScore);
40 | gradeDetailSubjectCredit = (TextView) findViewById(R.id.gradeDetailSubjectCredit);
41 | gradeDetailSubjectGPA = (TextView) findViewById(R.id.gradeDetailSubjectGPA);
42 | gradeDetailSubjectId = (TextView) findViewById(R.id.gradeDetailSubjectId);
43 | gradeDetailSubjectYear = (TextView) findViewById(R.id.gradeDetailSubjectYear);
44 | gradeDetailSubjectType = (TextView) findViewById(R.id.gradeDetailSubjectType);
45 | gradeDetailSubjectTerm = (TextView) findViewById(R.id.gradeDetailSubjectTerm);
46 | gradeDetailSubjectName.setText(getIntent().getStringExtra("SubjectName"));
47 | gradeDetailSubjectScore.setText(getIntent().getStringExtra("SubjectScore"));
48 | gradeDetailSubjectCredit.setText(getIntent().getStringExtra("SubjectCredit"));
49 | gradeDetailSubjectGPA.setText(getIntent().getStringExtra("SubjectGPA"));
50 | gradeDetailSubjectId.setText(getIntent().getStringExtra("SubjectId"));
51 | gradeDetailSubjectYear.setText(getIntent().getStringExtra("SubjectYear"));
52 | gradeDetailSubjectType.setText(getIntent().getStringExtra("SubjectType"));
53 | gradeDetailSubjectTerm.setText(getIntent().getStringExtra("SubjectTerm"));
54 | }
55 |
56 | @Override
57 | public boolean onOptionsItemSelected(MenuItem item) {
58 | switch (item.getItemId()) {
59 | case android.R.id.home:
60 | //返回上一层
61 | finish();
62 |
63 | default:
64 | return super.onOptionsItemSelected(item);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
28 |
29 |
33 |
34 |
39 |
42 |
43 |
44 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Activity/LostActivity.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Activity;
2 |
3 | import android.app.Dialog;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import cn.gdeiassistant.Presenter.LostPresenter;
14 | import cn.gdeiassistant.R;
15 | import cn.gdeiassistant.View.Dialog.ProgressDialogCreator;
16 |
17 | public class LostActivity extends AppCompatActivity implements View.OnClickListener {
18 |
19 | private Toolbar lostToolbar;
20 |
21 | private EditText lostPassword;
22 |
23 | private Button lostButton;
24 |
25 | private Dialog dialog;
26 |
27 | private LostPresenter lostPresenter;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_lost);
33 | //初始化控件
34 | InitView();
35 | //配置加载Presenter
36 | lostPresenter = new LostPresenter(this);
37 | }
38 |
39 | @Override
40 | protected void onDestroy() {
41 | super.onDestroy();
42 | if (dialog != null) {
43 | dialog.dismiss();
44 | }
45 | lostPresenter.RemoveCallBacksAndMessages();
46 | }
47 |
48 | private void InitView() {
49 | lostToolbar = findViewById(R.id.lostToolbar);
50 | setSupportActionBar(lostToolbar);
51 | if (getSupportActionBar() != null) {
52 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
53 | getSupportActionBar().setDisplayShowTitleEnabled(false);
54 | }
55 | lostPassword = findViewById(R.id.lostPassword);
56 | lostButton = findViewById(R.id.lostButton);
57 | lostButton.setOnClickListener(this);
58 | }
59 |
60 | /**
61 | * 显示Toast消息
62 | *
63 | * @param text
64 | */
65 | public void ShowToast(String text) {
66 | Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
67 | }
68 |
69 | /**
70 | * 显示进度条
71 | */
72 | public void ShowProgressDialog() {
73 | if (dialog == null) {
74 | dialog = new ProgressDialogCreator().GetProgressDialogCreator(this);
75 | dialog.show();
76 | } else {
77 | dialog.show();
78 | }
79 | }
80 |
81 | /**
82 | * 隐藏进度条
83 | */
84 | public void HideProgressDialog() {
85 | if (dialog != null) {
86 | dialog.dismiss();
87 | }
88 | }
89 |
90 |
91 | @Override
92 | public void onClick(View v) {
93 | switch (v.getId()) {
94 | case R.id.lostButton:
95 | lostPresenter.CardLost(lostPassword.getText().toString());
96 | break;
97 | }
98 | }
99 |
100 | @Override
101 | public boolean onOptionsItemSelected(MenuItem item) {
102 | switch (item.getItemId()) {
103 | case android.R.id.home:
104 | //返回上一层
105 | finish();
106 |
107 | default:
108 | return super.onOptionsItemSelected(item);
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/EvaluatePresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import java.lang.ref.WeakReference;
7 |
8 | import cn.gdeiassistant.Activity.EvaluateActivity;
9 | import cn.gdeiassistant.Constant.EvaluateTagConstant;
10 | import cn.gdeiassistant.Constant.RequestConstant;
11 | import cn.gdeiassistant.Model.EvaluateModel;
12 |
13 | public class EvaluatePresenter {
14 |
15 | private EvaluateActivity evaluateActivity;
16 |
17 | private EvaluateModel evaluateModel;
18 |
19 | private EvaluateActivityHandler evaluateActivityHandler;
20 |
21 | public EvaluatePresenter(EvaluateActivity evaluateActivity) {
22 | this.evaluateActivity = evaluateActivity;
23 | this.evaluateModel = new EvaluateModel();
24 | this.evaluateActivityHandler = new EvaluateActivityHandler(evaluateActivity);
25 | }
26 |
27 | public static class EvaluateActivityHandler extends Handler {
28 |
29 | private EvaluateActivity evaluateActivity;
30 |
31 | EvaluateActivityHandler(EvaluateActivity evaluateActivity) {
32 | this.evaluateActivity = new WeakReference<>(evaluateActivity).get();
33 | }
34 |
35 | @Override
36 | public void handleMessage(Message msg) {
37 | super.handleMessage(msg);
38 | switch (msg.what) {
39 | case RequestConstant.REQUEST_SUCCESS:
40 | //教学评价成功
41 | evaluateActivity.HideProgressDialog();
42 | switch (msg.getData().getInt("Tag")) {
43 | case EvaluateTagConstant.NORMAL_SUBMIT:
44 | evaluateActivity.ShowToast("教学评价成功,请登录教务系统进行最终确认");
45 | break;
46 |
47 | case EvaluateTagConstant.DIRECTLY_SUBMIT:
48 | evaluateActivity.ShowToast("教学评价成功");
49 | break;
50 | }
51 | break;
52 |
53 | case RequestConstant.REQUEST_FAILURE:
54 | //教学评价失败
55 | evaluateActivity.HideProgressDialog();
56 | evaluateActivity.ShowToast(msg.getData().getString("Message"));
57 | break;
58 |
59 | case RequestConstant.REQUEST_TIMEOUT:
60 | //网络连接超时
61 | evaluateActivity.HideProgressDialog();
62 | evaluateActivity.ShowToast("网络连接超时,请重试");
63 | break;
64 |
65 | case RequestConstant.UNKNOWN_ERROR:
66 | //出现未知异常
67 | evaluateActivity.HideProgressDialog();
68 | evaluateActivity.ShowToast("出现未知异常,请联系管理员");
69 | break;
70 |
71 | case RequestConstant.SHOW_PROGRESS:
72 | //显示进度条
73 | evaluateActivity.ShowProgressDialog();
74 | break;
75 | }
76 | }
77 | }
78 |
79 | /**
80 | * 移除所有的回调和消息,防止内存泄露
81 | */
82 | public void RemoveCallBacksAndMessages() {
83 | evaluateActivityHandler.removeCallbacksAndMessages(null);
84 | }
85 |
86 | /**
87 | * 提交教学评价请求
88 | */
89 | public void SubmitEvaluate(boolean directlySubmit) {
90 | evaluateModel.SubmitEvaluate(directlySubmit, evaluateActivityHandler, evaluateActivity.getApplicationContext());
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Activity/EvaluateActivity.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Activity;
2 |
3 | import android.app.Dialog;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.SwitchCompat;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.Toast;
12 |
13 | import cn.gdeiassistant.Presenter.EvaluatePresenter;
14 | import cn.gdeiassistant.R;
15 | import cn.gdeiassistant.View.Dialog.ProgressDialogCreator;
16 |
17 | public class EvaluateActivity extends AppCompatActivity implements View.OnClickListener {
18 |
19 | private Toolbar evaluateToolbar;
20 |
21 | private SwitchCompat switchCompat;
22 |
23 | private Button evaluateSubmit;
24 |
25 | private Dialog dialog;
26 |
27 | private EvaluatePresenter evaluatePresenter;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_evaluate);
33 | //初始化控件
34 | InitView();
35 | //配置加载Presenter
36 | evaluatePresenter = new EvaluatePresenter(this);
37 | }
38 |
39 | @Override
40 | protected void onDestroy() {
41 | super.onDestroy();
42 | if (dialog != null) {
43 | dialog.dismiss();
44 | }
45 | evaluatePresenter.RemoveCallBacksAndMessages();
46 | }
47 |
48 | private void InitView() {
49 | evaluateToolbar = findViewById(R.id.evaluateToolbar);
50 | setSupportActionBar(evaluateToolbar);
51 | if (getSupportActionBar() != null) {
52 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
53 | getSupportActionBar().setDisplayShowTitleEnabled(false);
54 | }
55 | switchCompat = findViewById(R.id.evaluateSwitchCompat);
56 | evaluateSubmit = findViewById(R.id.evaluateSubmit);
57 | evaluateSubmit.setOnClickListener(this);
58 | }
59 |
60 | /**
61 | * 显示Toast消息
62 | *
63 | * @param text
64 | */
65 | public void ShowToast(String text) {
66 | Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
67 | }
68 |
69 | /**
70 | * 显示进度条
71 | */
72 | public void ShowProgressDialog() {
73 | if (dialog == null) {
74 | dialog = new ProgressDialogCreator().GetProgressDialogCreator(this);
75 | dialog.show();
76 | } else {
77 | dialog.show();
78 | }
79 | }
80 |
81 | /**
82 | * 隐藏进度条
83 | */
84 | public void HideProgressDialog() {
85 | if (dialog != null) {
86 | dialog.dismiss();
87 | }
88 | }
89 |
90 | @Override
91 | public boolean onOptionsItemSelected(MenuItem item) {
92 | switch (item.getItemId()) {
93 | case android.R.id.home:
94 | //返回上一层
95 | finish();
96 |
97 | default:
98 | return super.onOptionsItemSelected(item);
99 | }
100 | }
101 |
102 | @Override
103 | public void onClick(View view) {
104 | switch (view.getId()) {
105 | case R.id.evaluateSubmit:
106 | //提交教学评价请求
107 | evaluatePresenter.SubmitEvaluate(switchCompat.isChecked());
108 | break;
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/View/Adapter/TodayScheduleListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.View.Adapter;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 |
12 | import java.util.List;
13 |
14 | import cn.gdeiassistant.Pojo.Entity.Schedule;
15 |
16 | public class TodayScheduleListViewAdapter extends BaseAdapter {
17 |
18 | //父列表视图容器
19 | private LayoutInflater listContainer;
20 |
21 | //成绩数据集合
22 | private List todayScheduleList;
23 |
24 | //列表项布局
25 | private int itemViewResource;
26 |
27 | //列表项组件集合
28 | private static class ListItemView {
29 | TextView scheduleName;
30 | TextView scheduleLocation;
31 | TextView scheduleTime;
32 | LinearLayout itemLayout;
33 | ImageView dividerLine;
34 | }
35 |
36 | //根据父列表构造列表项适配器,加载列表项界面、读取并设置列表项数据
37 | public TodayScheduleListViewAdapter(Context context, List todayScheduleList, int itemViewResource) {
38 | this.listContainer = LayoutInflater.from(context);
39 | this.itemViewResource = itemViewResource;
40 | this.todayScheduleList = todayScheduleList;
41 | }
42 |
43 | @Override
44 | public int getCount() {
45 | //根据今日课表数据条目返回列表项数目
46 | return todayScheduleList.size();
47 | }
48 |
49 | @Override
50 | public Object getItem(int position) {
51 | return todayScheduleList.get(position);
52 | }
53 |
54 | @Override
55 | public long getItemId(int position) {
56 | return position;
57 | }
58 |
59 | @Override
60 | public View getView(final int position, View convertView, ViewGroup parent) {
61 | // 创建自定义列表项组件
62 | ListItemView listItemView;
63 | if (convertView == null) {
64 | //获取列表项布局
65 | convertView = listContainer.inflate(this.itemViewResource, null);
66 | //初始化列表项各组件
67 | listItemView = new ListItemView();
68 | listItemView.itemLayout = convertView.findViewById(cn.gdeiassistant.R.id.todayScheduleItemLayout);
69 | listItemView.dividerLine = convertView.findViewById(cn.gdeiassistant.R.id.todayScheduleItemDividerline);
70 | listItemView.scheduleTime = convertView.findViewById(cn.gdeiassistant.R.id.todayScheduleItemScheduleTime);
71 | listItemView.scheduleName = convertView.findViewById(cn.gdeiassistant.R.id.todayScheduleItemScheduleName);
72 | listItemView.scheduleLocation = convertView.findViewById(cn.gdeiassistant.R.id.todayScheduleItemScheduleLocation);
73 | //设置控件集到convertView
74 | convertView.setTag(listItemView);
75 | } else {
76 | listItemView = (ListItemView) convertView.getTag();
77 | }
78 | //依次读取列表项数据中的第position项数据赋于news对象
79 | Schedule schedule = todayScheduleList.get(position);
80 | listItemView.scheduleName.setText(schedule.getScheduleName());
81 | listItemView.scheduleLocation.setText(schedule.getScheduleLocation());
82 | listItemView.scheduleTime.setText((schedule.getPosition() / 7 + 1) + "-" + (schedule.getPosition() / 7 + schedule.getScheduleLength()));
83 | if (position == 0) {
84 | //隐藏第一行的分割线
85 | listItemView.dividerLine.setVisibility(View.INVISIBLE);
86 | }
87 | return convertView;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_book.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
25 |
26 |
27 |
28 |
31 |
32 |
38 |
39 |
49 |
50 |
61 |
62 |
63 |
64 |
70 |
71 |
77 |
78 |
79 |
80 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/linguancheng/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
27 | #-----------------不需要混淆第三方类库------------------------------------------------------------------
28 | -keep class android.support.v4.** { *; }
29 | -keep interface android.support.v4.app.** { *; }
30 | -keep public class * extends android.support.v4.**
31 | -keep public class * extends android.app.Fragment
32 | -keep class com.goole.** { *; }
33 | -keep class org.jdesktop.** { *; }
34 | -keep class com.sun.** { *; }
35 | -keep class org.jsoup.** { *; }
36 | -dontwarn android.support.v4.**
37 |
38 | # keep okhttp3、okio
39 | -keep class okhttp3.** { *;}
40 | -keep interface okhttp3.** { *; }
41 | -keep class okio.** { *; }
42 | -keep interface okio.** { *; }
43 | -dontwarn okio.**
44 | -dontwarn okhttp3.**
45 |
46 | # keep rx
47 | -dontwarn sun.misc.**
48 | -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
49 | long producerIndex;
50 | long consumerIndex;
51 | }
52 |
53 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
54 | rx.internal.util.atomic.LinkedQueueNode producerNode;
55 | }
56 |
57 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
58 | rx.internal.util.atomic.LinkedQueueNode consumerNode;
59 | }
60 |
61 | #-----------------不需要混淆系统组件等-------------------------------------------------------------------
62 | -keep public class * extends android.app.Activity
63 | -keep public class * extends android.app.Application
64 | -keep public class * extends android.app.Fragment
65 | -keep public class * extends android.app.Service
66 | -keep public class * extends android.content.BroadcastReceiver
67 | -keep public class * extends android.content.ContentProvider
68 | -keep public class * extends android.app.backup.BackupAgentHelper
69 | -keep public class * extends android.preference.Preference
70 | -keep public class com.android.vending.licensing.ILicensingService
71 |
72 | #-----------------不需要混淆JavaBean实体类-------------------------------------------------------------------
73 | # 确保JavaBean不被混淆-否则gson将无法将数据解析成具体对象
74 | -keep class cn.gdeiassistant.Pojo.** { *; }
75 |
76 | #基线包使用,生成mapping.txt
77 | -printmapping mapping.txt
78 | #生成的mapping.txt在app/build/outputs/mapping/release路径下,移动到/app路径下
79 |
80 | #修复后的项目使用,保证混淆结果一致
81 | #-applymapping mapping.txt
82 |
83 | # 不混淆阿里云移动研发平台组件
84 | -keep class com.taobao.** { *; }
85 | -keep class com.alibaba.** { *; }
86 | -keep class com.ta.** { *; }
87 | -keep class com.ut.** { *; }
88 | -dontwarn com.taobao.**
89 | -dontwarn com.alibaba.**
90 | -dontwarn com.ta.**
91 | -dontwarn com.ut.**
92 |
93 | #防止inline
94 | -dontoptimize
95 |
96 | -keepclassmembers class cn.gdeiassistant.Application.GdeiAssistantApplication {
97 | public ();
98 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2016-2023] [GdeiAssistant]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | Anti 996 License Version 1.0 (Draft)
12 |
13 | Copyright (c) [2016-2023] [GdeiAssistant]
14 |
15 | Permission is hereby granted to any individual or legal entity
16 | obtaining a copy of this licensed work (including the source code,
17 | documentation and/or related items, hereinafter collectively referred
18 | to as the "licensed work"), free of charge, to deal with the licensed
19 | work for any purpose, including without limitation, the rights to use,
20 | reproduce, modify, prepare derivative works of, distribute, publish
21 | and sublicense the licensed work, subject to the following conditions:
22 |
23 | 1. The individual or the legal entity must conspicuously display,
24 | without modification, this License and the notice on each redistributed
25 | or derivative copy of the Licensed Work.
26 |
27 | 2. The individual or the legal entity must strictly comply with all
28 | applicable laws, regulations, rules and standards of the jurisdiction
29 | relating to labor and employment where the individual is physically
30 | located or where the individual was born or naturalized; or where the
31 | legal entity is registered or is operating (whichever is stricter). In
32 | case that the jurisdiction has no such laws, regulations, rules and
33 | standards or its laws, regulations, rules and standards are
34 | unenforceable, the individual or the legal entity are required to
35 | comply with Core International Labor Standards.
36 |
37 | 3. The individual or the legal entity shall not induce or force its
38 | employee(s), whether full-time or part-time, or its independent
39 | contractor(s), in any methods, to agree in oral or written form, to
40 | directly or indirectly restrict, weaken or relinquish his or her
41 | rights or remedies under such laws, regulations, rules and standards
42 | relating to labor and employment as mentioned above, no matter whether
43 | such written or oral agreement are enforceable under the laws of the
44 | said jurisdiction, nor shall such individual or the legal entity
45 | limit, in any methods, the rights of its employee(s) or independent
46 | contractor(s) from reporting or complaining to the copyright holder or
47 | relevant authorities monitoring the compliance of the license about
48 | its violation(s) of the said license.
49 |
50 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
51 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53 | IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
54 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
55 | OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
56 | LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
57 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/LostPresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.view.inputmethod.InputMethodManager;
7 |
8 | import java.lang.ref.WeakReference;
9 |
10 | import cn.gdeiassistant.Activity.LostActivity;
11 | import cn.gdeiassistant.Constant.RequestConstant;
12 | import cn.gdeiassistant.Model.LostModel;
13 | import cn.gdeiassistant.Tools.StringUtils;
14 |
15 | public class LostPresenter {
16 |
17 | private LostActivity lostActivity;
18 |
19 | private LostModel lostModel;
20 |
21 | private LostActivityHandler lostActivityHandler;
22 |
23 | public LostPresenter(LostActivity lostActivity) {
24 | this.lostActivity = lostActivity;
25 | this.lostModel = new LostModel();
26 | this.lostActivityHandler = new LostActivityHandler(lostActivity);
27 | }
28 |
29 | public static class LostActivityHandler extends Handler {
30 |
31 | private LostActivity lostActivity;
32 |
33 | LostActivityHandler(LostActivity lostActivity) {
34 | this.lostActivity = new WeakReference<>(lostActivity).get();
35 | }
36 |
37 | @Override
38 | public void handleMessage(Message msg) {
39 | super.handleMessage(msg);
40 | switch (msg.what) {
41 | case RequestConstant.SHOW_PROGRESS:
42 | //显示进度条
43 | lostActivity.ShowProgressDialog();
44 | break;
45 |
46 | case RequestConstant.REQUEST_SUCCESS:
47 | //挂失成功
48 | lostActivity.HideProgressDialog();
49 | lostActivity.ShowToast("挂失校园卡成功");
50 | break;
51 |
52 | case RequestConstant.REQUEST_FAILURE:
53 | //挂失失败
54 | lostActivity.HideProgressDialog();
55 | lostActivity.ShowToast(msg.getData().getString("Message"));
56 | break;
57 |
58 | case RequestConstant.SERVER_ERROR:
59 | //服务暂不可用
60 | lostActivity.HideProgressDialog();
61 | lostActivity.ShowToast("服务暂不可用,请稍后再试");
62 | break;
63 |
64 | case RequestConstant.REQUEST_TIMEOUT:
65 | //网络连接超时
66 | lostActivity.HideProgressDialog();
67 | lostActivity.ShowToast("网络连接超时,请重试");
68 | break;
69 |
70 | case RequestConstant.UNKNOWN_ERROR:
71 | //出现未知异常
72 | lostActivity.HideProgressDialog();
73 | lostActivity.ShowToast("出现未知异常,请联系管理员");
74 | break;
75 |
76 | }
77 | }
78 | }
79 |
80 | public void RemoveCallBacksAndMessages() {
81 | lostActivityHandler.removeCallbacksAndMessages(null);
82 | }
83 |
84 | /**
85 | * 校园卡挂失
86 | *
87 | * @param cardPassword
88 | */
89 | public void CardLost(String cardPassword) {
90 | if (StringUtils.isBlank(cardPassword)) {
91 | lostActivity.ShowToast("校园卡密码不能为空");
92 | } else if (cardPassword.length() != 6) {
93 | lostActivity.ShowToast("校园卡密码为6位数字");
94 | } else {
95 | InputMethodManager inputMethodManager = (InputMethodManager) lostActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
96 | if (inputMethodManager != null) {
97 | //收起虚拟键盘
98 | inputMethodManager.hideSoftInputFromWindow(lostActivity.getWindow().getDecorView().getWindowToken(), 0);
99 | }
100 | lostModel.CardLost(cardPassword, lostActivityHandler, lostActivity.getApplicationContext());
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/BookPresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.view.inputmethod.InputMethodManager;
7 |
8 | import java.lang.ref.WeakReference;
9 | import java.util.List;
10 |
11 | import cn.gdeiassistant.Activity.BookActivity;
12 | import cn.gdeiassistant.Constant.RequestConstant;
13 | import cn.gdeiassistant.Model.BookModel;
14 | import cn.gdeiassistant.Pojo.Entity.Book;
15 | import cn.gdeiassistant.Tools.StringUtils;
16 |
17 | public class BookPresenter {
18 |
19 | private BookActivity bookActivity;
20 |
21 | private BookActivityHandler bookActivityHandler;
22 |
23 | private BookModel bookModel;
24 |
25 | public BookPresenter(BookActivity bookActivity) {
26 | this.bookActivity = bookActivity;
27 | this.bookModel = new BookModel();
28 | this.bookActivityHandler = new BookActivityHandler(bookActivity);
29 | }
30 |
31 | public static class BookActivityHandler extends Handler {
32 |
33 | private BookActivity bookActivity;
34 |
35 | BookActivityHandler(BookActivity bookActivity) {
36 | this.bookActivity = new WeakReference<>(bookActivity).get();
37 | }
38 |
39 | @Override
40 | public void handleMessage(Message msg) {
41 | super.handleMessage(msg);
42 | switch (msg.what) {
43 | case RequestConstant.REQUEST_SUCCESS:
44 | //查询图书借阅信息成功
45 | bookActivity.HideProgressDialog();
46 | List bookList = (List) msg.getData().getSerializable("BookList");
47 | bookActivity.HideProgressDialog();
48 | bookActivity.ShowDataLayout();
49 | bookActivity.SaveBookList(bookList);
50 | bookActivity.LoadBookData();
51 | break;
52 |
53 | case RequestConstant.REQUEST_FAILURE:
54 | //查询图书借阅信息或续借图书失败
55 | bookActivity.HideProgressDialog();
56 | bookActivity.ShowToast(msg.getData().getString("Message"));
57 | break;
58 |
59 | case RequestConstant.REQUEST_TIMEOUT:
60 | //网络连接超时
61 | bookActivity.HideProgressDialog();
62 | bookActivity.ShowToast("网络连接超时,请重试");
63 | break;
64 |
65 | case RequestConstant.UNKNOWN_ERROR:
66 | //出现未知异常
67 | bookActivity.HideProgressDialog();
68 | bookActivity.ShowToast("出现未知异常,请联系管理员");
69 | break;
70 |
71 | case RequestConstant.SHOW_PROGRESS:
72 | //显示进度条
73 | bookActivity.ShowProgressDialog();
74 | break;
75 | }
76 | }
77 | }
78 |
79 | /**
80 | * 移除所有的回调和消息,防止内存泄露
81 | */
82 | public void RemoveCallBacksAndMessages() {
83 | bookActivityHandler.removeCallbacksAndMessages(null);
84 | }
85 |
86 | /**
87 | * 提交图书借阅查询请求
88 | */
89 | public void SubmitBookQuery(String password) {
90 | if (StringUtils.isBlank(password)) {
91 | bookActivity.ShowToast("图书证借阅密码不能为空");
92 | } else {
93 | InputMethodManager inputMethodManager = (InputMethodManager) bookActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
94 | if (inputMethodManager != null) {
95 | //收起虚拟键盘
96 | inputMethodManager.hideSoftInputFromWindow(bookActivity.getWindow().getDecorView().getWindowToken(), 0);
97 | }
98 | bookModel.SubmitBookQuery(password, bookActivityHandler, bookActivity.getApplicationContext());
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/gdeiassistant/Presenter/SchedulePresenter.java:
--------------------------------------------------------------------------------
1 | package cn.gdeiassistant.Presenter;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import java.lang.ref.WeakReference;
7 | import java.util.List;
8 |
9 | import cn.gdeiassistant.Constant.RequestConstant;
10 | import cn.gdeiassistant.Fragment.FragmentSchedule;
11 | import cn.gdeiassistant.Model.ScheduleQueryModel;
12 | import cn.gdeiassistant.Pojo.Entity.Schedule;
13 |
14 | public class SchedulePresenter {
15 |
16 | private Integer week;
17 |
18 | private FragmentSchedule fragmentSchedule;
19 |
20 | private FragmentScheduleHandler fragmentScheduleHandler;
21 |
22 | private ScheduleQueryModel scheduleQueryModel;
23 |
24 | public SchedulePresenter(FragmentSchedule fragmentSchedule) {
25 | this.fragmentSchedule = fragmentSchedule;
26 | this.fragmentScheduleHandler = new FragmentScheduleHandler(fragmentSchedule);
27 | this.scheduleQueryModel = new ScheduleQueryModel();
28 | Init();
29 | }
30 |
31 | public static class FragmentScheduleHandler extends Handler {
32 |
33 | private FragmentSchedule fragmentSchedule;
34 |
35 | FragmentScheduleHandler(FragmentSchedule fragmentSchedule) {
36 | this.fragmentSchedule = new WeakReference<>(fragmentSchedule).get();
37 | }
38 |
39 | @Override
40 | public void handleMessage(Message msg) {
41 | super.handleMessage(msg);
42 | switch (msg.what) {
43 | case RequestConstant.SHOW_PROGRESS:
44 | //显示进度条
45 | fragmentSchedule.ShowProgressbar();
46 | fragmentSchedule.HideFailTip();
47 | break;
48 |
49 | case RequestConstant.REQUEST_SUCCESS:
50 | //查询课表成功
51 | fragmentSchedule.HideProgressbar();
52 | fragmentSchedule.HideFailTip();
53 | List scheduleList = (List) msg.getData().getSerializable("ScheduleList");
54 | fragmentSchedule.LoadScheduleData(scheduleList);
55 | break;
56 |
57 | case RequestConstant.REQUEST_FAILURE:
58 | //查询课表失败
59 | fragmentSchedule.HideProgressbar();
60 | fragmentSchedule.ShowFailTip(msg.getData().getString("Message"));
61 | break;
62 |
63 | case RequestConstant.REQUEST_TIMEOUT:
64 | //网络连接超时
65 | fragmentSchedule.HideProgressbar();
66 | fragmentSchedule.ShowFailTip("网络连接超时,点击重试");
67 | break;
68 |
69 | case RequestConstant.SERVER_ERROR:
70 | //服务暂不可用
71 | fragmentSchedule.HideProgressbar();
72 | fragmentSchedule.ShowFailTip("服务暂不可用,点击重试");
73 | break;
74 |
75 | case RequestConstant.UNKNOWN_ERROR:
76 | //出现未知异常
77 | fragmentSchedule.HideProgressbar();
78 | fragmentSchedule.ShowFailTip("出现未知异常,点击重试");
79 | break;
80 | }
81 | }
82 | }
83 |
84 | /**
85 | * 移除所有的回调和消息,防止内存泄露
86 | */
87 | public void RemoveCallBacksAndMessages() {
88 | fragmentScheduleHandler.removeCallbacksAndMessages(null);
89 | }
90 |
91 | private void Init() {
92 | ScheduleQuery();
93 | }
94 |
95 | public void ChangeSelectWeek(int week) {
96 | this.week = week;
97 | ScheduleQuery();
98 | }
99 |
100 | /**
101 | * 查询课表信息
102 | */
103 | public void ScheduleQuery() {
104 | scheduleQueryModel.ScheduleQuery(week, fragmentScheduleHandler, fragmentSchedule.getActivity().getApplicationContext());
105 | }
106 | }
107 |
--------------------------------------------------------------------------------