diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a8f8666
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+/.idea/shelf/
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..681f41a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..fb7f4a8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml
new file mode 100644
index 0000000..70f212e
--- /dev/null
+++ b/.idea/dbnavigator.xml
@@ -0,0 +1,414 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..346f741
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..6e5389e
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..4e875f3
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..113ceb4
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..cbc0067
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,48 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 31
+ buildToolsVersion "31.0.0"
+ defaultConfig {
+ applicationId "com.example.androidtermwork"
+ minSdkVersion 21
+ targetSdkVersion 31
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ vectorDrawables.useSupportLibrary = true
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'com.google.android.material:material:1.0.0'
+ implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
+ implementation 'androidx.navigation:navigation-fragment:2.3.5'
+ implementation 'androidx.navigation:navigation-ui:2.3.5'
+ implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test:runner:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+ implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
+
+ implementation 'com.android.volley:volley:1.1.1'
+ implementation 'com.scwang.smart:refresh-layout-kernel:2.0.1' //核心必须依赖
+ implementation 'com.scwang.smart:refresh-header-classics:2.0.1' //经典刷新头
+ implementation 'com.scwang.smart:refresh-footer-classics:2.0.1' //经典加载
+
+ implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
+ implementation 'de.hdodenhof:circleimageview:3.1.0'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/com/example/androidtermwork/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/androidtermwork/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..dd8fa44
--- /dev/null
+++ b/app/src/androidTest/java/com/example/androidtermwork/ExampleInstrumentedTest.java
@@ -0,0 +1,27 @@
+package com.example.androidtermwork;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ assertEquals("com.example.androidtermwork", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..b0dd3f0
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/images/back.png b/app/src/main/assets/images/back.png
new file mode 100644
index 0000000..ec69d51
Binary files /dev/null and b/app/src/main/assets/images/back.png differ
diff --git a/app/src/main/assets/images/broad.png b/app/src/main/assets/images/broad.png
new file mode 100644
index 0000000..6c11f61
Binary files /dev/null and b/app/src/main/assets/images/broad.png differ
diff --git a/app/src/main/assets/images/duanxin.png b/app/src/main/assets/images/duanxin.png
new file mode 100644
index 0000000..3fd7ce5
Binary files /dev/null and b/app/src/main/assets/images/duanxin.png differ
diff --git a/app/src/main/assets/images/iconwhite.png b/app/src/main/assets/images/iconwhite.png
new file mode 100644
index 0000000..56302e6
Binary files /dev/null and b/app/src/main/assets/images/iconwhite.png differ
diff --git a/app/src/main/assets/images/onplay.png b/app/src/main/assets/images/onplay.png
new file mode 100644
index 0000000..87d3512
Binary files /dev/null and b/app/src/main/assets/images/onplay.png differ
diff --git a/app/src/main/assets/images/share.png b/app/src/main/assets/images/share.png
new file mode 100644
index 0000000..e1b0f53
Binary files /dev/null and b/app/src/main/assets/images/share.png differ
diff --git a/app/src/main/assets/images/shoucang.png b/app/src/main/assets/images/shoucang.png
new file mode 100644
index 0000000..cfd0754
Binary files /dev/null and b/app/src/main/assets/images/shoucang.png differ
diff --git a/app/src/main/assets/index.css b/app/src/main/assets/index.css
new file mode 100644
index 0000000..669aeb0
--- /dev/null
+++ b/app/src/main/assets/index.css
@@ -0,0 +1,129 @@
+body {
+ background-color: rgb(250, 251, 253);
+ padding: 0 10px;
+}
+
+.top {
+ width: 90%;
+ height: 90px;
+ display: flex;
+ justify-content: space-between;
+ border-bottom: 2px solid rgb(213, 215, 216);
+ position: fixed;
+ top: -2px;
+ background-color: rgb(250, 251, 253);
+}
+
+.top img {
+ height: 30px;
+ width: 30px;
+ margin-top: 10px;
+}
+
+.top>div {
+ display: flex;
+ flex-direction: column;
+}
+
+.top .topIcon {
+ background-color: rgb(228, 36, 23);
+ height: fit-content;
+ width: fit-content;
+ padding: 10px 20px;
+}
+
+#time {
+ font-size: 9px;
+ color: rgb(116, 116, 117);
+ margin-top: 5px;
+}
+
+.container {
+ margin-top: 100px;
+ margin-bottom: 100px;
+}
+
+#resource {
+ font-size: 8px;
+ color: rgb(116, 116, 117);
+ margin-top: 5px;
+}
+
+#title {
+ margin-top: 15px;
+}
+
+#title2 {
+ margin-top: 10px;
+}
+
+#article {
+ margin-top: 10px;
+ font-size: 16px;
+ line-height: 1.5em;
+ text-indent: 2em;
+}
+
+#editor {
+ margin-top: 10px;
+ font-size: 13px;
+ float: right;
+}
+
+.bottom {
+ width: 90%;
+ height: 40px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border-top: 1px solid rgb(213, 215, 216);
+ position: fixed;
+ bottom: -2px;
+ background-color: rgb(250, 251, 253);
+}
+
+#input {
+ padding: 2px 8px;
+ font-size: 10px;
+ background-color: rgb(212, 211, 211);
+ width: 200px;
+ height: 20px;
+ border: rgb(212, 211, 211);
+ border-radius: 2px;
+}
+
+.bottom img {
+ height: 20px;
+ width: 20px;
+}
+
+.player {
+ position: fixed;
+ bottom: 120px;
+ display: flex;
+ align-items: center;
+ justify-content: space-around;
+ border: 1px solid rgb(212, 211, 211);
+ background-color: rgb(241, 243, 244);
+ border-radius: 5px;
+}
+
+.player img {
+ margin-left: 5px;
+ height: 20px;
+ width: 20px;
+}
+
+#zhankai {
+ position: fixed;
+ bottom: 131px;
+ left: 0px;
+ margin-left: 5px;
+ height: 20px;
+ width: 20px;
+}
+
+#audio {
+ width: 230px;
+ height: 40px;
+}
\ No newline at end of file
diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html
new file mode 100644
index 0000000..c0d5533
--- /dev/null
+++ b/app/src/main/assets/index.html
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/index.js b/app/src/main/assets/index.js
new file mode 100644
index 0000000..625741f
--- /dev/null
+++ b/app/src/main/assets/index.js
@@ -0,0 +1,94 @@
+// var result = JavaScriptInterface.jsontohtml();
+// var obj = eval("(" + result + ")"); //解析json字符串
+// function showAndroidToast(toast) {
+// JavaScriptInterface.showToast(toast);
+// }
+var title = document.getElementById('title');
+var title2 = document.getElementById('title2');
+var time = document.getElementById('time');
+var resource = document.getElementById('resource');
+var article = document.getElementById('article');
+var editor = document.getElementById('editor');
+var player = document.getElementById('player');
+getjsonData();
+
+function getjsonData() {
+// var result = JavaScriptInterface.jsontohtml();
+// var obj = eval("("+result+")");//解析json字符串
+ var news = {
+ title: '中国共产党第十九届中央委员会第六次全体会议公报',
+ title2: '中国共产党第十九届中央委员会第六次全体会议公报(2021年11月11日中国共产党第十九届中央委员会第六次全体会议通过)',
+ time: '2021 年 11 月 12 日',
+ resource: '“学习强国”学习平台',
+ article: '中国共产党第十九届中央委员会第六次全体会议,于2021年11月8日至11日在北京举行。\n' +
+ '出席这次全会的有,中央委员197人,候补中央委员151人。中央纪律检查委员会常务委员会委员和有关方面负责同志列席会议。\n' +
+ '全会由中央政治局主持。中央委员会总书记习近平作了重要讲话。\n' +
+ '全会听取和讨论了习近平受中央政治局委托作的工作报告,审议通过了《中共中央关于党的百年奋斗重大成就和历史经验的决议》,审议通过了《关于召开党的第二十次全国代表大会的决议》。习近平就《中共中央关于党的百年奋斗重大成就和历史经验的决议(讨论稿)》向全会作了说明。\n' +
+ '全会认为,总结党的百年奋斗重大成就和历史经验,是在建党百年历史条件下开启全面建设社会主义现代化国家新征程、在新时代坚持和发展中国特色社会主义的需要;是增强政治意识、大局意识、核心意识、看齐意识,坚定道路自信、理论自信、制度自信、文化自信,做到坚决维护习近平同志党中央的核心、全党的核心地位,坚决维护党中央权威和集中统一领导,确保全党步调一致向前进的需要;是推进党的自我革命、提高全党斗争本领和应对风险挑战能力、永葆党的生机活力、团结带领全国各族人民为实现中华民族伟大复兴的中国梦而继续奋斗的需要。全党要坚持唯物史观和正确党史观,从党的百年奋斗中看清楚过去我们为什么能够成功、弄明白未来我们怎样才能继续成功,从而更加坚定、更加自觉地践行初心使命,在新时代更好坚持和发展中国特色社会主义。',
+ editor: '秦辰宇',
+ }
+ showData(news);
+}
+
+function showData(news) {
+ console.log(news)
+ title.innerHTML = news.title;
+ title2.innerHTML = news.title2;
+ time.innerHTML = news.time;
+ resource.innerHTML = `来源:${news.resource}`;
+ //按照换行符分隔成数组
+ const tempArr = news.article.split(/[(\r\n)\r\n]+/);
+ //删除空项
+ tempArr.forEach((item, index) => {
+ if (!item) {
+ snsArr.splice(index, 1);
+ }
+ });
+ //循环添加单个段落
+ tempArr.forEach((item, index) => {
+ var p = document.createElement('div');
+ console.log(item)
+ p.id = `p${index}`;
+ p.innerText = item;
+ article.appendChild(p);
+ });
+ editor.innerHTML = `责任编辑:${news.editor}`;
+}
+
+function changeBroadIcon(flag) {
+ if (flag) {
+ var play = document.getElementById('play');
+ play.src = './images/onplay.png';
+ play.onclick = () => {
+ stop();
+ }
+ } else {
+ var play = document.getElementById('play');
+ play.src = './images/broad.png';
+ play.onclick = () => {
+ fun();
+ }
+ }
+}
+
+function fun() {
+ const values = title.innerText + title2.innerText + time.innerText + article.innerText + editor.innerText;
+ console.log(values);
+ var url = "http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=" + encodeURI(values);
+ var div = document.createElement('div');
+ div.innerHTML = ``
+ player.appendChild(div);
+ var audio = document.getElementById('audio');
+ audio.play();
+ changeBroadIcon(true);
+}
+
+function stop() {
+ var audio = document.getElementById('audio');
+ //停止音频
+ audio.currentTime = 0;
+ audio.pause();
+ //删除dom
+ player.removeChild(player.children[0]);
+ changeBroadIcon(false);
+}
\ No newline at end of file
diff --git a/app/src/main/assets/mock_data_tv_01.json b/app/src/main/assets/mock_data_tv_01.json
new file mode 100644
index 0000000..32c00d0
--- /dev/null
+++ b/app/src/main/assets/mock_data_tv_01.json
@@ -0,0 +1,62 @@
+[
+ {
+ "id": 1,
+ "videoSource": "http://asdasdqqw.6655.la/video/0.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/0.jpg",
+ "title": "我们的背后,就是祖国",
+ "timeLength": 171,
+ "itemType": 0,
+ "author": "人民日报",
+ "date": "2021-10-25"
+ },
+ {
+ "id": 2,
+ "videoSource": "http://asdasdqqw.6655.la/video/1.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/1.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad\u3011\u78cb\u5546\u4e25\u91cd\u53d7\u632b \u8d23\u4efb\u5b8c\u5168\u5728\u7f8e\u65b9",
+ "timeLength": 33,
+ "itemType": 1,
+ "author": "\u4e2d\u592e\u7535\u89c6\u53f0",
+ "date": "2021-10-27"
+ },
+ {
+ "id": 3,
+ "videoSource": "http://asdasdqqw.6655.la/video/2.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/2.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad\u3011\u4e60\u8fd1\u5e73\u5bf9\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u611f\u67d3\u7684\u80ba\u708e\u75ab\u60c5\u4f5c\u51fa\u91cd\u8981\u6307\u793a",
+ "timeLength": 33,
+ "itemType": 0,
+ "author": "\u4e2d\u592e\u7535\u89c6\u53f0",
+ "date": "2021-10-27"
+ },
+ {
+ "id": 4,
+ "videoSource": "http://asdasdqqw.6655.la/video/3.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/3.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad5\u8054\u5f39\u3011\u4e2d\u56fd\u7ecf\u6d4e\u7684\u5e95\u6c14\u4ece\u4f55\u800c\u6765\uff1f\u5173\u7a0e\u5927\u68d2\u635f\u4eba\u5bb3\u5df1\uff01\u7f8e\u65b9\u5728\u8c08\u5224\u4e2d\u4e0d\u8bb2\u89c4\u5219\u86ee\u6a2a\u65e0\u7406",
+ "timeLength": 33,
+ "itemType": 0,
+ "author": "\u4e2d\u592e\u7535\u89c6\u53f0",
+ "date": "2021-10-27"
+ },
+ {
+ "id": 5,
+ "videoSource": "http://asdasdqqw.6655.la/video/4.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/4.jpg",
+ "title": "\u65b0\u95fb\u8054\u64ad\uff1a\u541b\u5b50\u4e4b\u56fd \u5148\u793c\u540e\u5175",
+ "timeLength": 33,
+ "itemType": 0,
+ "author": "\u4e2d\u592e\u7535\u89c6\u53f0",
+ "date": "2021-10-27"
+ },
+ {
+ "id": 6,
+ "videoSource": "http://asdasdqqw.6655.la/video/5.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/5.jpg",
+ "title": "\u65b0\u95fb\u8054\u64ad\uff1a\u4e2d\u529e \u56fd\u529e\u5370\u53d1\u300a\u5173\u4e8e\u8fdb\u4e00\u6b65\u51cf\u8f7b\u4e49\u52a1\u6559\u80b2\u9636\u6bb5\u5b66\u751f\u4f5c\u4e1a\u8d1f\u62c5\u548c\u6821\u5916\u57f9\u8bad\u8d1f\u62c5\u7684\u610f\u89c1\u300b",
+ "timeLength": 33,
+ "itemType": 1,
+ "author": "\u4e2d\u592e\u7535\u89c6\u53f0",
+ "date": "2021-10-27"
+ }
+]
\ No newline at end of file
diff --git a/app/src/main/assets/mock_data_tv_02.json b/app/src/main/assets/mock_data_tv_02.json
new file mode 100644
index 0000000..e70ce12
--- /dev/null
+++ b/app/src/main/assets/mock_data_tv_02.json
@@ -0,0 +1,52 @@
+[
+ {
+ "id": "7",
+ "videoSource": "http://asdasdqqw.6655.la/video/10.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/10.jpg",
+ "title": "\u4e2d\u5171\u4e2d\u592e\u5173\u4e8e\u5236\u5b9a\u56fd\u6c11\u7ecf\u6d4e\u548c\u793e\u4f1a\u53d1\u5c55\u7b2c\u5341\u56db\u4e2a\u4e94\u5e74\u89c4\u5212\u548c\u4e8c\u3007\u4e09\u4e94\u5e74\u8fdc\u666f\u76ee\u6807\u7684\u5efa\u8bae",
+ "timeLength": 33,
+ "itemType": 1,
+ "author": "\u592e\u89c6\u65b0\u95fb",
+ "date": "2021-10-30"
+ },
+ {
+ "id": "8",
+ "videoSource": "http://asdasdqqw.6655.la/video/6.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/6.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad\u3011\u5341\u4e8c\u8fde\u53d1\uff01\u6279\u7f8e\u56fd\u63d2\u624b\u9999\u6e2f\u4e8b\u52a1",
+ "timeLength": 33,
+ "itemType": 1,
+ "author": "\u592e\u89c6\u65b0\u95fb",
+ "date": "2021-10-30"
+ },
+ {
+ "id": "9",
+ "videoSource": "http://asdasdqqw.6655.la/video/7.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/7.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad\u3011\u4ed6\u56fd\u9a9a\u4e71\u662f\u201c\u7f8e\u4e3d\u7684\u98ce\u666f\u7ebf\u201d\uff1f\u865a\u4f2a\u53cc\u6807 \u4ee4\u4eba\u4f5c\u5455\uff01",
+ "timeLength": 33,
+ "itemType": 0,
+ "author": "\u592e\u89c6\u65b0\u95fb",
+ "date": "2021-10-30"
+ },
+ {
+ "id": "10",
+ "videoSource": "http://asdasdqqw.6655.la/video/8.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/8.jpg",
+ "title": "\u65b0\u95fb\u8054\u64ad\uff1a\u7f8e\u56fd\u6ee1\u5634\u8dd1\u706b\u8f66\uff0c\u6028\u5987\u5fc3\u6001\uff01",
+ "timeLength": 33,
+ "itemType": 1,
+ "author": "\u592e\u89c6\u65b0\u95fb",
+ "date": "2021-10-30"
+ },
+ {
+ "id": "11",
+ "videoSource": "http://asdasdqqw.6655.la/video/9.mp4",
+ "cover": "http://asdasdqqw.6655.la/img/9.jpg",
+ "title": "\u3010\u65b0\u95fb\u8054\u64ad\u3011\u534e\u4e3a\u7edd\u5730\u53cd\u51fb \u4e2d\u56fd\u5c45\u5b89\u601d\u5371",
+ "timeLength": 33,
+ "itemType": 0,
+ "author": "\u592e\u89c6\u65b0\u95fb",
+ "date": "2021-10-30"
+ }
+]
\ No newline at end of file
diff --git a/app/src/main/assets/mock_data_tv_comments.json b/app/src/main/assets/mock_data_tv_comments.json
new file mode 100644
index 0000000..521406b
--- /dev/null
+++ b/app/src/main/assets/mock_data_tv_comments.json
@@ -0,0 +1,42 @@
+[
+ {
+ "userId": 342284102,
+ "userName": "头像我女神438",
+ "feelGoodCounts": 16592,
+ "isFeelGood": false,
+ "commentDate": "2021-10-25",
+ "commentContent": "197653,不是冰冷的数字,是鲜活的生命和滚烫的热血。"
+ },
+ {
+ "userId": 268085226,
+ "userName": "努力_上岸",
+ "feelGoodCounts": 10599,
+ "isFeelGood": false,
+ "commentDate": "2021-10-25",
+ "commentContent": "我工作就要去基层了 我会用自己的方式去为群众服务"
+ },
+ {
+ "userId": 138408320,
+ "userName": "懿维我祖",
+ "feelGoodCounts": 9599,
+ "isFeelGood": false,
+ "commentDate": "2021-10-25",
+ "commentContent": "我希望大家把197653喊成197654 多那个1,代表所有未被统计的英烈!不知牺牲在战俘营里的英烈在不在统计范围"
+ },
+ {
+ "userId": 987423234,
+ "userName": "杜甫几句堆积思思",
+ "feelGoodCounts": 7642,
+ "isFeelGood": false,
+ "commentDate": "2021-10-25",
+ "commentContent": "我外公打过抗美援朝,参加过上甘岭和三八线"
+ },
+ {
+ "userId": 887635213,
+ "userName": "安丘一中学生会",
+ "feelGoodCounts": 5557,
+ "isFeelGood": false,
+ "commentDate": "2021-10-25",
+ "commentContent": "\"什么叫祖国,当我们跨过鸭绿江,看到战火的时候,我后边就是祖国\""
+ }
+]
\ No newline at end of file
diff --git a/app/src/main/assets/mock_data_tv_details.json b/app/src/main/assets/mock_data_tv_details.json
new file mode 100644
index 0000000..afb2134
--- /dev/null
+++ b/app/src/main/assets/mock_data_tv_details.json
@@ -0,0 +1,8 @@
+{
+ "playCounts": 1089906,
+ "feelGoodCounts": 82615,
+ "introduction": "“黄继光”“杨根思”“到!到!到!”……这一声声“到”,跨越71年。纪念中国人民志愿军抗美援朝出国作战71周年,致敬每一位最可爱的人。山河无恙,如您所愿!",
+ "isFeelGood": false,
+ "moreInfo": "责任编辑:...\n校对:...",
+ "isCollect": false
+}
\ No newline at end of file
diff --git a/app/src/main/assets/mock_list_task.json b/app/src/main/assets/mock_list_task.json
new file mode 100644
index 0000000..6a9284f
--- /dev/null
+++ b/app/src/main/assets/mock_list_task.json
@@ -0,0 +1,37 @@
+[
+ {
+ "name": "登录",
+ "description": "1分/每日首次登录",
+ "todayPoints": 1,
+ "pointsLimit": 1,
+ "goAction": "def"
+ },
+ {
+ "name": "我要选读文章",
+ "description": "1分/每有效阅读/播报一篇,上限6分\n1分/有效阅读或播报文章累计1分钟,上限6分",
+ "todayPoints": 11,
+ "pointsLimit": 12,
+ "goAction": "res_article"
+ },
+ {
+ "name": "视听学习",
+ "description": "1分/每有效收听/观看一个",
+ "todayPoints": 4,
+ "pointsLimit": 6,
+ "goAction": "res_tv"
+ },
+ {
+ "name": "每日答题",
+ "description": "每组答题每答对1道积1分",
+ "todayPoints": 1,
+ "pointsLimit": 6,
+ "goAction": "new_dailyQ"
+ },
+ {
+ "name": "每周答题",
+ "description": "每组答题每答对1道积1分,同组答题不重复积分",
+ "todayPoints": 6,
+ "pointsLimit": 6,
+ "goAction": "new_weeklyQ"
+ }
+]
\ No newline at end of file
diff --git a/app/src/main/assets/mock_user_points.json b/app/src/main/assets/mock_user_points.json
new file mode 100644
index 0000000..7698f69
--- /dev/null
+++ b/app/src/main/assets/mock_user_points.json
@@ -0,0 +1,5 @@
+{
+ "points": 9000,
+ "dan": 9,
+ "pointsToday": 20
+}
diff --git a/app/src/main/java/com/example/androidtermwork/Activity1.java b/app/src/main/java/com/example/androidtermwork/Activity1.java
new file mode 100644
index 0000000..a4cf709
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/Activity1.java
@@ -0,0 +1,39 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Html;
+import android.view.View;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class Activity1 extends AppCompatActivity {
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_1);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ TextView tv=(TextView)findViewById(R.id.text3);
+ String str="来源:《中国共产党简史》(人民出版社、中国共产党史出版社2021年版)";
+ tv.setTextSize(16);
+ tv.setText(Html.fromHtml(str));
+ }
+ public void ts(View view){
+ Intent intent = new Intent();
+ intent.setClass(Activity1.this,Activity2.class);
+ startActivity(intent);
+ }
+ public void next(View view){
+ Intent intent = new Intent();
+ intent.setClass(Activity1.this,Activity3.class);
+ startActivity(intent);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/Activity2.java b/app/src/main/java/com/example/androidtermwork/Activity2.java
new file mode 100644
index 0000000..6a91e7b
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/Activity2.java
@@ -0,0 +1,25 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Html;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class Activity2 extends AppCompatActivity {
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_2);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ TextView da =(TextView) findViewById(R.id.daan);
+ String str2="中华苏维埃第一次全国代表大会于1931年11月在江西瑞金召开,中华苏维埃共和国临时中央政府宣布成立。";
+ da.setText(Html.fromHtml(str2));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/Activity3.java b/app/src/main/java/com/example/androidtermwork/Activity3.java
new file mode 100644
index 0000000..9b2794a
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/Activity3.java
@@ -0,0 +1,34 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Html;
+import android.view.View;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class Activity3 extends AppCompatActivity {
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_3);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ TextView tv=(TextView)findViewById(R.id.from3);
+ String str3="来源:《中国共产党简史》(人民出版社、中国共产党史出版社2021年版)";
+ tv.setTextSize(16);
+ tv.setText(Html.fromHtml(str3));
+ }
+ public void next2(View view){
+ Intent intent = new Intent();
+ intent.setClass(Activity3.this,Activity4.class);
+ startActivity(intent);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/Activity4.java b/app/src/main/java/com/example/androidtermwork/Activity4.java
new file mode 100644
index 0000000..841a47b
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/Activity4.java
@@ -0,0 +1,33 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Html;
+import android.view.View;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class Activity4 extends AppCompatActivity {
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_4);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ TextView tv=(TextView)findViewById(R.id.from4);
+ String str4="来源:《中国共产党简史》(人民出版社、中国共产党史出版社2021年版)";
+ tv.setTextSize(16);
+ tv.setText(Html.fromHtml(str4));
+ }
+ public void next1(View view){
+ Intent intent =new Intent(Activity4.this,Activity5.class);
+ startActivity(intent);
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/Activity5.java b/app/src/main/java/com/example/androidtermwork/Activity5.java
new file mode 100644
index 0000000..d12e56d
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/Activity5.java
@@ -0,0 +1,32 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class Activity5 extends AppCompatActivity {
+ private Button btn;
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_5);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ btn = (Button) findViewById(R.id.btn2);
+ btn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(Activity5.this,PointsPage.class);
+ startActivity(intent);
+ finish();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/AndroidToastForJs.java b/app/src/main/java/com/example/androidtermwork/AndroidToastForJs.java
new file mode 100644
index 0000000..8e6082d
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/AndroidToastForJs.java
@@ -0,0 +1,45 @@
+package com.example.androidtermwork;
+
+import android.content.Context;
+import android.widget.Toast;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class AndroidToastForJs {
+
+ public static String title;
+ public static String resource;
+ public static String title2;
+ public static String time;
+ public static String article;
+ public static String editor;
+
+ private Context mContext;
+
+ public AndroidToastForJs(Context context) {
+ this.mContext = context;
+ }
+
+ //webview中调用toast原生组件
+ public void showToast(String toast) {
+ Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
+ }
+
+ //以json实现webview与js之间的数据交互
+ public String jsontohtml() {
+ JSONObject map = null;
+ try {
+ map = new JSONObject();
+ map.put("title", title);
+ map.put("resource", resource);
+ map.put("title2", title2);
+ map.put("time", time);
+ map.put("article", article);
+ map.put("editor", editor);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ return map.toString();
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/ChatActivity.java b/app/src/main/java/com/example/androidtermwork/ChatActivity.java
new file mode 100644
index 0000000..c41bb96
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/ChatActivity.java
@@ -0,0 +1,155 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChatActivity extends AppCompatActivity {
+
+ private ListView msgListView;
+ private EditText inputText;
+ private Button send;
+ private MsgAdapter adapter;
+ private List msgList = new ArrayList();
+ private Toolbar toolbar;
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);//设置窗口没有标题栏
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ setContentView(R.layout.activity_chat);
+ toolbar = findViewById(R.id.chat_toolbar);
+ eventListener();
+ initMsg();
+ adapter = new MsgAdapter(ChatActivity.this, R.layout.msg_item, msgList);
+ inputText = (EditText) findViewById(R.id.input_text);
+ send = (Button) findViewById(R.id.send);
+ msgListView = (ListView) findViewById(R.id.msg_list_view);
+ msgListView.setAdapter(adapter);
+ send.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View v) {
+ String content = inputText.getText().toString();
+ if(!"".equals(content)){
+ Msg msg = new Msg(content, Msg.SENT);
+ msgList.add(msg);
+ adapter.notifyDataSetChanged();//有新消息时,刷新ListView中的显示
+ msgListView.setSelection(msgList.size());//将ListView定位到最后一行
+ inputText.setText("");//清空输入框的内容
+ }
+ }
+ });
+ }
+ private void eventListener() {
+ //右上角返回
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish(); // 返回
+ }
+ });
+ }
+ private void initMsg() {
+ Msg msg1 = new Msg("全国党史知识竞赛总决赛",Msg.RECEIVED);
+ msgList.add(msg1);
+ Msg msg2 = new Msg("收到",Msg.SENT);
+ msgList.add(msg2);
+ Msg msg3 = new Msg("关注进博会,游世界展馆,看全球展品",Msg.RECEIVED);
+ msgList.add(msg3);
+ }
+
+ public class Msg{
+ public static final int RECEIVED = 0;//收到一条消息
+ public static final int SENT = 1;//发出一条消息
+ private String content;//消息的内容
+ private int type;//消息的类型
+ public Msg(String content,int type){
+ this.content = content;
+ this.type = type;
+ }
+ public String getContent(){
+ return content;
+ }
+ public int getType(){
+ return type;
+ }
+ }
+
+ public class MsgAdapter extends ArrayAdapter {
+ private int resourceId;
+
+ public MsgAdapter(Context context, int textViewresourceId, List objects) {
+ super(context, textViewresourceId, objects);
+ resourceId = textViewresourceId;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ Msg msg = getItem(position);
+ View view;
+ ViewHolder viewHolder;
+
+ if(convertView == null){
+ view = LayoutInflater.from(getContext()).inflate(resourceId, null);
+ viewHolder = new ViewHolder();
+ viewHolder.leftLayout = (LinearLayout)view.findViewById(R.id.left_layout);
+ viewHolder.rightLayout = (LinearLayout)view.findViewById(R.id.right_Layout);
+ viewHolder.leftMsg = (TextView)view.findViewById(R.id.left_msg);
+ viewHolder.rightMsg = (TextView)view.findViewById(R.id.right_msg);
+ viewHolder.lefthead = (ImageView)view.findViewById(R.id.head_left);
+ viewHolder.righthead = (ImageView)view.findViewById(R.id.head_right);
+ view.setTag(viewHolder);
+ }else{
+ view = convertView;
+ viewHolder = (ViewHolder) view.getTag();
+ }
+
+ if(msg.getType()==Msg.RECEIVED){
+ //如果是收到的消息,则显示左边消息布局,将右边消息布局隐藏
+ viewHolder.leftLayout.setVisibility(View.VISIBLE);
+ viewHolder.lefthead.setVisibility(View.VISIBLE);
+ viewHolder.rightLayout.setVisibility(View.GONE);
+ viewHolder.righthead.setVisibility(View.GONE);
+ viewHolder.leftMsg.setText(msg.getContent());
+ }else if(msg.getType()==Msg.SENT){
+ //如果是发出去的消息,显示右边布局的消息布局,将左边的消息布局隐藏
+ viewHolder.rightLayout.setVisibility(View.VISIBLE);
+ viewHolder.righthead.setVisibility(View.VISIBLE);
+ viewHolder.leftLayout.setVisibility(View.GONE);
+ viewHolder.lefthead.setVisibility(View.GONE);
+ viewHolder.rightMsg.setText(msg.getContent());
+ }
+ return view;
+ }
+
+ class ViewHolder{
+ LinearLayout leftLayout;
+ LinearLayout rightLayout;
+ TextView leftMsg;
+ TextView rightMsg;
+ ImageView lefthead;
+ ImageView righthead;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/LoginPage.java b/app/src/main/java/com/example/androidtermwork/LoginPage.java
new file mode 100644
index 0000000..77d3d12
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/LoginPage.java
@@ -0,0 +1,277 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.text.Editable;
+import android.text.InputType;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.TextWatcher;
+import android.text.method.HideReturnsTransformationMethod;
+import android.text.method.LinkMovementMethod;
+import android.text.method.PasswordTransformationMethod;
+import android.text.method.TransformationMethod;
+import android.text.style.ClickableSpan;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+@RequiresApi(api = Build.VERSION_CODES.M)
+public class LoginPage extends AppCompatActivity {
+ private AlertDialog.Builder builder;
+ private boolean isHideFirst = true;// 输入框密码是否是隐藏的,默认为true
+ private ImageView imageView_password;
+ private ImageView inputDel; //一键清除输入内容
+ public static ProgressDialog mDefaultDialog; //加载中对话框
+
+ //加载中对话框:正在进行网络请求
+
+ /**
+ * setCancelable默认为true,表示可以触摸屏幕或者按后退键关闭对话框。如果改为false,那么必须要使用代码来控制关闭对话框,触摸屏幕或者按后退键都是无法关闭对话框。
+ * setCanceledOnTouchOutside 默认true表示触摸屏幕可以关闭对话框。如果改为false,表示按后退键可以退出对话框,触摸屏幕不会退回对话框。
+ */
+ public static void showCommonDialog(Context context) {
+ mDefaultDialog = new ProgressDialog(context);
+ //默认就是小圆圈的那种形式
+ mDefaultDialog.setProgressStyle(android.app.ProgressDialog.STYLE_SPINNER);
+ mDefaultDialog.setMessage("正在进行网络请求...");
+ // mDefaultDialog.setCancelable(true);
+ mDefaultDialog.setCanceledOnTouchOutside(false);
+ mDefaultDialog.show();
+ }
+
+ //延时关闭加载中对话框
+ @SuppressLint("HandlerLeak")
+ public static Handler dialogHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ mDefaultDialog.dismiss();
+ super.handleMessage(msg);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_login_page);
+ //登录
+ OnButtonToLogin();
+ //注册
+ OnButtonToRegister();
+ //初始化页面底部可点击文本
+ initView();
+ //密码显示或隐藏
+ showOrHide();
+ //清空输入框
+ inputClear();
+ }
+
+ /**
+ * 密码显示或隐藏 (切换)
+ */
+ private void showOrHide() {
+ final EditText password = findViewById(R.id.userPassword);
+ imageView_password = findViewById(R.id.imageView);
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ imageView_password.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (isHideFirst == true) {
+ imageView_password.setImageResource(R.mipmap.visibleon);
+ //密文
+ HideReturnsTransformationMethod method1 = HideReturnsTransformationMethod.getInstance();
+ password.setTransformationMethod(method1);
+ isHideFirst = false;
+ } else {
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ //密文
+ TransformationMethod method = PasswordTransformationMethod.getInstance();
+ password.setTransformationMethod(method);
+ isHideFirst = true;
+
+ }
+ // 光标的位置
+ int index = password.getText().toString().length();
+ password.setSelection(index);
+ }
+ });
+ }
+
+ /**
+ * 清空输入框
+ */
+ private void inputClear() {
+ //设置监听器
+ final EditText input = findViewById(R.id.userPhone);
+ inputDel = findViewById(R.id.del);
+ input.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ if (input.getEditableText().length() >= 1) {
+ inputDel.setVisibility(View.VISIBLE);
+ } else {
+ inputDel.setVisibility(View.GONE);
+ }
+ }
+ });
+ inputDel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ //点击事件(清空)
+ public void onClick(View view) {
+ input.setText("");
+ }
+ });
+ }
+
+ public void OnButtonToLogin() {
+ final EditText phoneEdit = findViewById(R.id.userPhone);
+ final EditText passwordEdit = findViewById(R.id.userPassword);
+
+ final Button btn_login = findViewById(R.id.submit);
+ btn_login.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View arg0) {
+ final String input_phone = phoneEdit.getText().toString().trim();
+ String input_password = passwordEdit.getText().toString().trim();
+ // 不为空
+ if (input_phone.length() != 0 && input_password.length() != 0) {
+ // 密码长度大于等于6且小于等于20
+ if (input_password.length() >= 6 && input_password.length() <= 20) {
+ // 通过接口判断密码是否正确
+ if (input_password.length() != 0) {
+ //加载中对话框
+ showCommonDialog(LoginPage.this);
+ try {
+ Intent intent = new Intent(LoginPage.this, MainActivity.class);
+ startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ dialogHandler.sendEmptyMessageDelayed(0, 1000);
+ } else {
+ builder = new AlertDialog.Builder(LoginPage.this)
+ .setMessage("号码或者密码不正确")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ } else {
+ builder = new AlertDialog.Builder(LoginPage.this)
+ .setMessage("普通成员的密码需要6~20位字符;为保证安全性,请在大写英文字母,小写英文字母,数字和特殊符号中选中至少两项组合为密码。")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ } else {
+ Toast.makeText(LoginPage.this, "用户名或密码不能为空!", Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ }
+
+ public void OnButtonToRegister() {
+ Button regis = findViewById(R.id.register);
+ regis.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(LoginPage.this, RegisterFirstPage.class);
+ startActivity(intent);
+ }
+ });
+ }
+
+ //初始化页面底部可点击文本
+
+ public void initView() {
+ TextView textView1 = findViewById(R.id.retrieve);
+ TextView textView2 = findViewById(R.id.loss);
+ SpannableStringBuilder stringBuilder1 = new SpannableStringBuilder("找回密码");
+ SpannableStringBuilder stringBuilder2 = new SpannableStringBuilder("账号挂失");
+ TextViewSpan1 span1 = new TextViewSpan1();
+ TextViewSpan2 span2 = new TextViewSpan2();
+ //找回密码
+ stringBuilder1.setSpan(span1, 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ textView1.setText(stringBuilder1);
+ //账号挂失
+ stringBuilder2.setSpan(span2, 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ textView2.setText(stringBuilder2);
+ //一定要记得设置这个方法 不然不起作用
+ textView1.setMovementMethod(LinkMovementMethod.getInstance());
+ textView2.setMovementMethod(LinkMovementMethod.getInstance());
+ //取消文本的点击背景
+ textView1.setHighlightColor(getResources().getColor(android.R.color.transparent));
+ textView2.setHighlightColor(getResources().getColor(android.R.color.transparent));
+ //修改状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ //找回密码
+ private class TextViewSpan1 extends ClickableSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ //设置是否有下划线
+ ds.setUnderlineText(false);
+ }
+
+ @Override
+ public void onClick(View widget) {
+ //点击事件
+ Intent intent = new Intent(LoginPage.this, RetrievePasswordPage.class);
+ startActivity(intent);
+ //点击后设置可点击文本的字体颜色
+// TextView textView = findViewById(R.id.retrieve);
+// textView.setTextColor(Color.parseColor("#6495ED"));
+ }
+ }
+
+ //账号挂失
+ private class TextViewSpan2 extends ClickableSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ //设置是否有下划线
+ ds.setUnderlineText(false);
+ }
+
+ @Override
+ public void onClick(View widget) {
+ //点击事件
+ Intent intent = new Intent(LoginPage.this, LossPage.class);
+ startActivity(intent);
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/LossPage.java b/app/src/main/java/com/example/androidtermwork/LossPage.java
new file mode 100644
index 0000000..e3d72b7
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/LossPage.java
@@ -0,0 +1,21 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.view.WindowManager;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class LossPage extends AppCompatActivity {
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_loss_page);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/MainActivity.java b/app/src/main/java/com/example/androidtermwork/MainActivity.java
new file mode 100644
index 0000000..c60c49e
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/MainActivity.java
@@ -0,0 +1,129 @@
+package com.example.androidtermwork;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.method.LinkMovementMethod;
+import android.text.style.ClickableSpan;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.navigation.NavController;
+import androidx.navigation.Navigation;
+import androidx.navigation.ui.AppBarConfiguration;
+import androidx.navigation.ui.NavigationUI;
+
+public class MainActivity extends AppCompatActivity {
+
+ static final int POINTS_PAGE = 0x36f2;
+ private NavController navController;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ BottomNavigationView navView = findViewById(R.id.nav_view);
+ // Passing each menu ID as a set of Ids because each
+ // menu should be considered as top level destinations.
+ AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
+ R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
+ .build();
+ navController = Navigation.findNavController(this, R.id.nav_host_fragment);
+ //顶部菜单栏
+// NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
+ NavigationUI.setupWithNavController(navView, navController);
+ initView();
+ }
+
+ //初始化可点击文本
+ public void initView() {
+ int score = 9000;
+ TextView scoreText = findViewById(R.id.score);
+ TextView ownText = findViewById(R.id.own);
+ scoreText.setText(String.valueOf(score));
+
+ SpannableStringBuilder stringBuilder1 = new SpannableStringBuilder(scoreText.getText());
+ SpannableStringBuilder stringBuilder2 = new SpannableStringBuilder(ownText.getText());
+ MainActivity.TextViewSpan1 span1 = new MainActivity.TextViewSpan1();
+ MainActivity.TextViewSpan2 span2 = new MainActivity.TextViewSpan2();
+ //积分
+ stringBuilder1.setSpan(span1, 0, scoreText.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ scoreText.setText(stringBuilder1);
+ scoreText.setMovementMethod(LinkMovementMethod.getInstance());
+ //我的
+ stringBuilder2.setSpan(span2, 0, ownText.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ ownText.setText(stringBuilder2);
+ ownText.setMovementMethod(LinkMovementMethod.getInstance());
+ //取消文本的点击背景
+ scoreText.setHighlightColor(getResources().getColor(android.R.color.transparent));
+ ownText.setHighlightColor(getResources().getColor(android.R.color.transparent));
+ }
+
+ //积分
+ private class TextViewSpan1 extends ClickableSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ //设置是否有下划线
+ ds.setUnderlineText(false);
+ }
+
+ @Override
+ public void onClick(View widget) {
+ //点击事件
+ //Toast.makeText(MainActivity.this, "点击积分", Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(MainActivity.this, PointsPage.class);
+ startActivityForResult(intent, POINTS_PAGE);
+ }
+ }
+
+ //我的
+ private class TextViewSpan2 extends ClickableSpan {
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ //设置是否有下划线
+ ds.setUnderlineText(false);
+ }
+
+ @Override
+ public void onClick(View widget) {
+ //点击事件
+ Intent intent = new Intent(MainActivity.this,MinePage.class);
+ startActivity(intent);
+ }
+ }
+
+ /**
+ * 获取子Activity返回值
+ * @param requestCode
+ * @param resultCode
+ * @param data
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == RESULT_CANCELED || data == null)
+ return;
+ if (requestCode == POINTS_PAGE){
+ handlePointsPageResult(data.getStringExtra("goAction"));
+ }
+ }
+
+ /**
+ * 根据“学习积分”Activity的返回值,导航至不同的Tab
+ * @param goAction
+ */
+ private void handlePointsPageResult(String goAction)
+ {
+ switch (goAction){
+ //如果点击的是“我要选读文章”的去做任务,则导航到第二个Tab
+ case "res_article":navController.navigate(R.id.navigation_dashboard);break;
+ case "res_tv":navController.navigate(R.id.navigation_notifications);break;
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/MinePage.java b/app/src/main/java/com/example/androidtermwork/MinePage.java
new file mode 100644
index 0000000..c898d98
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/MinePage.java
@@ -0,0 +1,34 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class MinePage extends AppCompatActivity {
+
+ private Toolbar toolbar;
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_mine_page);
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ toolbar = findViewById(R.id.mine_toolbar);
+ eventListener();
+ }
+ private void eventListener() {
+ //右上角返回
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish(); // 返回
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/PointsPage.java b/app/src/main/java/com/example/androidtermwork/PointsPage.java
new file mode 100644
index 0000000..4a6c06a
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/PointsPage.java
@@ -0,0 +1,92 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ListView;
+
+import com.example.androidtermwork.adpter.PointsItemAdapter;
+import com.example.androidtermwork.pojo.PointSummary;
+import com.example.androidtermwork.pojo.PointTask;
+import com.example.androidtermwork.util.ResourceUtil;
+import com.example.androidtermwork.util.StatusBarUtil;
+import com.example.androidtermwork.util.TestUtil;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import java.util.List;
+
+@RequiresApi(api = Build.VERSION_CODES.M)
+public class PointsPage extends AppCompatActivity {
+
+ private Gson gson;
+ private Toolbar toolbar;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_points_page);
+ initInstance();
+ //setToolbar();
+ bindListViewData();
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ eventListener();
+ }
+
+ /**
+ * 初始化对象(引用)
+ */
+ private void initInstance() {
+ gson = new Gson();
+ toolbar = findViewById(R.id.points_toolbar);
+ }
+
+ /**
+ * 添加事件监听器
+ */
+ private void eventListener() {
+ //右上角返回
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish(); // 返回
+ }
+ });
+ }
+
+ /**
+ * 给ListView绑定数据
+ */
+ private void bindListViewData() {
+ PointSummary pointSummary =
+ gson.fromJson(
+ TestUtil.getJson("mock_user_points.json", this),
+ PointSummary.class);
+ int dan = pointSummary.getDan();
+ pointSummary.setDanName(getResources().getStringArray(R.array.dan_name_array)[dan]);
+ pointSummary.setDanStar(
+ ResourceUtil.getIdentifier(this, getString(R.string.dan_star_prefix) + dan, "mipmap")
+ );
+ List pointTasks = gson.fromJson(
+ TestUtil.getJson("mock_list_task.json", this),
+ new TypeToken>() {
+ }.getType()
+ );
+ ListView listView = findViewById(R.id.contentListView);
+ listView.setAdapter(new PointsItemAdapter(this, pointSummary, pointTasks));
+ }
+
+ /**
+ * 设置ToolBar
+ */
+ private void setToolbar() {
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setHomeButtonEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/RegisterFirstPage.java b/app/src/main/java/com/example/androidtermwork/RegisterFirstPage.java
new file mode 100644
index 0000000..28d8c85
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/RegisterFirstPage.java
@@ -0,0 +1,104 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class RegisterFirstPage extends AppCompatActivity {
+ private AlertDialog.Builder builder;
+ private ImageView inputDel; //一键清除输入内容
+ private Button next; //下一步
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_retrieve_password_page);
+ //复用找回密码页面,将“请输入手机号”替换为“新用户注册”
+ TextView textView = findViewById(R.id.fontText);
+ textView.setText("新用户注册");
+
+ OnButtonToNext();
+ //清空输入框
+ inputClear();
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ public void OnButtonToNext() {
+ final EditText phoneNumber = findViewById(R.id.userPhone);
+ next = findViewById(R.id.submit_next);
+ next.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String input_phoneNumber = phoneNumber.getText().toString().trim();
+ // 密码长度大于等于6且小于等于20
+ if (input_phoneNumber.length() == 11) {
+ // 通过接口设置密码
+ Intent intent = new Intent(RegisterFirstPage.this, RegisterSecondPage.class);
+ startActivity(intent);
+ } else {
+ builder = new AlertDialog.Builder(RegisterFirstPage.this)
+ .setMessage("请输入11位手机号。")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ }
+ });
+ }
+
+ /**
+ * 清空输入框
+ */
+ private void inputClear() {
+ //设置监听器
+ final EditText input = findViewById(R.id.userPhone);
+ inputDel = findViewById(R.id.del);
+ input.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ if (input.getEditableText().length() >= 1) {
+ inputDel.setVisibility(View.VISIBLE);
+ } else {
+ inputDel.setVisibility(View.GONE);
+ }
+ }
+ });
+ inputDel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ //点击事件(清空)
+ public void onClick(View view) {
+ input.setText("");
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/RegisterSecondPage.java b/app/src/main/java/com/example/androidtermwork/RegisterSecondPage.java
new file mode 100644
index 0000000..b9f73b2
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/RegisterSecondPage.java
@@ -0,0 +1,98 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.method.HideReturnsTransformationMethod;
+import android.text.method.PasswordTransformationMethod;
+import android.text.method.TransformationMethod;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class RegisterSecondPage extends AppCompatActivity {
+ private AlertDialog.Builder builder;
+ private Button next; //下一步
+ private boolean isHideFirst = true;// 输入框密码是否是隐藏的,默认为true
+ private ImageView imageView_password;
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_reset_password_page);
+ OnButtonToNext();
+ //密码显示或隐藏
+ showOrHide();
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ public void OnButtonToNext() {
+ final EditText passwordEdit = findViewById(R.id.userPassword);
+ next = findViewById(R.id.submit_next);
+ next.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String input_password = passwordEdit.getText().toString().trim();
+ // 密码长度大于等于6且小于等于20
+ if (input_password.length() >= 6 && input_password.length() <= 20) {
+ // 通过接口设置密码
+ Intent intent = new Intent(RegisterSecondPage.this, RegisterThirdPage.class);
+ startActivity(intent);
+ } else {
+ builder = new AlertDialog.Builder(RegisterSecondPage.this)
+ .setMessage("普通成员的密码需要6~20位字符;为保证安全性,请在大写英文字母,小写英文字母,数字和特殊符号中选中至少两项组合为密码。")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ }
+ });
+ }
+
+ /**
+ * 密码显示或隐藏 (切换)
+ */
+ private void showOrHide() {
+ final EditText password = findViewById(R.id.userPassword);
+ imageView_password = findViewById(R.id.imageView);
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ imageView_password.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (isHideFirst == true) {
+ imageView_password.setImageResource(R.mipmap.visibleon);
+ //密文
+ HideReturnsTransformationMethod method1 = HideReturnsTransformationMethod.getInstance();
+ password.setTransformationMethod(method1);
+ isHideFirst = false;
+ } else {
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ //密文
+ TransformationMethod method = PasswordTransformationMethod.getInstance();
+ password.setTransformationMethod(method);
+ isHideFirst = true;
+
+ }
+ // 光标的位置
+ int index = password.getText().toString().length();
+ password.setSelection(index);
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/RegisterThirdPage.java b/app/src/main/java/com/example/androidtermwork/RegisterThirdPage.java
new file mode 100644
index 0000000..1c463a9
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/RegisterThirdPage.java
@@ -0,0 +1,89 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class RegisterThirdPage extends AppCompatActivity {
+ private ImageView inputDel; //一键清除输入内容
+ private Button intoApp; //进入学习强国
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_register_third_page);
+
+ OnButtonIntoApp();
+ //清空输入框
+ inputClear();
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ //点击进入学习强国
+ public void OnButtonIntoApp() {
+ intoApp = findViewById(R.id.submit_intoApp);
+ intoApp.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ LoginPage.showCommonDialog(RegisterThirdPage.this);
+ try {
+ Intent intent = new Intent(RegisterThirdPage.this, LoginPage.class);
+ startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ LoginPage.dialogHandler.sendEmptyMessageDelayed(0,1000);
+ }
+ });
+ }
+
+ /**
+ * 清空输入框
+ */
+ private void inputClear() {
+ //设置监听器
+ final EditText input = findViewById(R.id.userName);
+ inputDel = findViewById(R.id.del);
+ input.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ if (input.getEditableText().length() >= 1) {
+ inputDel.setVisibility(View.VISIBLE);
+ } else {
+ inputDel.setVisibility(View.GONE);
+ }
+ }
+ });
+ inputDel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ //点击事件(清空)
+ public void onClick(View view) {
+ input.setText("");
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/ResetPasswordPage.java b/app/src/main/java/com/example/androidtermwork/ResetPasswordPage.java
new file mode 100644
index 0000000..7b8a752
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/ResetPasswordPage.java
@@ -0,0 +1,99 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.method.HideReturnsTransformationMethod;
+import android.text.method.PasswordTransformationMethod;
+import android.text.method.TransformationMethod;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class ResetPasswordPage extends AppCompatActivity {
+ private AlertDialog.Builder builder;
+ private Button next; //下一步
+ private boolean isHideFirst = true;// 输入框密码是否是隐藏的,默认为true
+ private ImageView imageView_password;
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_reset_password_page);
+ OnButtonToNext();
+ //密码显示或隐藏
+ showOrHide();
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ public void OnButtonToNext() {
+ final EditText passwordEdit = findViewById(R.id.userPassword);
+ next = findViewById(R.id.submit_next);
+ next.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String input_password = passwordEdit.getText().toString().trim();
+ // 密码长度大于等于6且小于等于20
+ if (input_password.length() >= 6 && input_password.length() <= 20) {
+ // 通过接口设置密码
+ Intent intent = new Intent(ResetPasswordPage.this, LoginPage.class);
+ startActivity(intent);
+ } else {
+ builder = new AlertDialog.Builder(ResetPasswordPage.this)
+ .setMessage("普通成员的密码需要6~20位字符;为保证安全性,请在大写英文字母,小写英文字母,数字和特殊符号中选中至少两项组合为密码。")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ }
+ });
+ }
+
+ /**
+ * 密码显示或隐藏 (切换)
+ */
+ private void showOrHide() {
+ final EditText password = findViewById(R.id.userPassword);
+ imageView_password = findViewById(R.id.imageView);
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ imageView_password.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (isHideFirst == true) {
+ imageView_password.setImageResource(R.mipmap.visibleon);
+ //密文
+ HideReturnsTransformationMethod method1 = HideReturnsTransformationMethod.getInstance();
+ password.setTransformationMethod(method1);
+ isHideFirst = false;
+ } else {
+ imageView_password.setImageResource(R.mipmap.visibleoff);
+ //密文
+ TransformationMethod method = PasswordTransformationMethod.getInstance();
+ password.setTransformationMethod(method);
+ isHideFirst = true;
+
+ }
+ // 光标的位置
+ int index = password.getText().toString().length();
+ password.setSelection(index);
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/RetrievePasswordPage.java b/app/src/main/java/com/example/androidtermwork/RetrievePasswordPage.java
new file mode 100644
index 0000000..6a71075
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/RetrievePasswordPage.java
@@ -0,0 +1,98 @@
+package com.example.androidtermwork;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+import com.example.androidtermwork.util.StatusBarUtil;
+
+public class RetrievePasswordPage extends AppCompatActivity {
+ private AlertDialog.Builder builder;
+ private ImageView inputDel; //一键清除输入内容
+ private Button next; //下一步
+
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_retrieve_password_page);
+ OnButtonToNext();
+ inputClear();
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ }
+
+ public void OnButtonToNext() {
+ final EditText phoneNumber = findViewById(R.id.userPhone);
+ next = findViewById(R.id.submit_next);
+ next.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ String input_phoneNumber = phoneNumber.getText().toString().trim();
+ // 密码长度大于等于6且小于等于20
+ if (input_phoneNumber.length() == 11) {
+ // 通过接口设置密码
+ Intent intent = new Intent(RetrievePasswordPage.this, ResetPasswordPage.class);
+ startActivity(intent);
+ } else {
+ builder = new AlertDialog.Builder(RetrievePasswordPage.this)
+ .setMessage("请输入11位手机号。")
+ .setPositiveButton("确定", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //ToDo: 关闭弹窗
+ dialogInterface.dismiss();
+ }
+ });
+ builder.create().show();
+ }
+ }
+ });
+ }
+
+ /**
+ * 清空输入框
+ */
+ private void inputClear() {
+ //设置监听器
+ final EditText input = findViewById(R.id.userPhone);
+ inputDel = findViewById(R.id.del);
+ input.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ if (input.getEditableText().length() >= 1) {
+ inputDel.setVisibility(View.VISIBLE);
+ } else {
+ inputDel.setVisibility(View.GONE);
+ }
+ }
+ });
+ inputDel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ //点击事件(清空)
+ public void onClick(View view) {
+ input.setText("");
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/TvStationPlayPage.java b/app/src/main/java/com/example/androidtermwork/TvStationPlayPage.java
new file mode 100644
index 0000000..ed951d6
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/TvStationPlayPage.java
@@ -0,0 +1,177 @@
+package com.example.androidtermwork;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.LinearSmoothScroller;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.androidtermwork.adpter.TVDetailsCommentsAdapter;
+import com.example.androidtermwork.pojo.TvComment;
+import com.example.androidtermwork.pojo.TvDetails;
+import com.example.androidtermwork.util.StatusBarUtil;
+import com.example.androidtermwork.util.TestUtil;
+import com.example.androidtermwork.view.JzvdPlayer;
+import com.google.gson.reflect.TypeToken;
+import com.scwang.smart.refresh.layout.SmartRefreshLayout;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.jzvd.Jzvd;
+
+
+public class TvStationPlayPage extends AppCompatActivity {
+
+ private TvDetails tvDetails;
+ private List tvComments;
+ private RecyclerView detailsCommentsView;
+ private JzvdPlayer playerStandard;
+ private Intent startIntent;
+ private SmartRefreshLayout refreshLayout;
+ @RequiresApi(api = Build.VERSION_CODES.M)
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_tv_station_play);
+ //设置状态栏字体为黑色
+ StatusBarUtil.setAndroidNativeLightStatusBar(this, true);
+ startIntent = getIntent();
+ prepareTestData();
+ buildDetailsData();
+ initPlayer();
+ loadDetailsAndComments();
+ buildCommentIcon();
+
+ }
+
+ /**
+ * 测试方法
+ */
+ private void prepareTestData() {
+ //第一个视频有测试数据
+ if (startIntent.getLongExtra("id", 0) == 1){
+ tvDetails =
+ TestUtil.getMockData("mock_data_tv_details.json",
+ new TypeToken(){}, this);
+ tvComments = TestUtil.getMockData("mock_data_tv_comments.json",
+ new TypeToken>(){}, this);
+ } else {
+ tvDetails = new TvDetails();
+ tvComments = new ArrayList<>();
+ tvDetails.setPlayCounts((long)(Math.random() * 1005));
+ tvDetails.setFeelGoodCounts((long)(Math.random() * 105));
+ tvDetails.setCollect((Math.random() + 0.5) > 1.0d);
+ tvDetails.setFeelGood((Math.random() + 0.5) > 1.0d);
+ tvDetails.setIntroduction("暂无简介");
+ closeLoadMore();
+ }
+ }
+
+ /**
+ * 关闭下拉加载更多评论
+ */
+ private void closeLoadMore(){
+ if (refreshLayout == null)
+ refreshLayout = findViewById(R.id.videoInfoRefreshLayout);
+ refreshLayout.setEnableLoadMore(false);
+ }
+ /**
+ * 加载视频详情和评论
+ */
+ private void loadDetailsAndComments() {
+ detailsCommentsView = findViewById(R.id.play_recyclerView);
+ TVDetailsCommentsAdapter dataAdapter = new TVDetailsCommentsAdapter(this);
+ dataAdapter.setTvDetails(tvDetails);
+ dataAdapter.setTvComments(tvComments);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(this);
+ detailsCommentsView.setLayoutManager(layoutManager);
+ detailsCommentsView.setAdapter(dataAdapter);
+ }
+
+ /**
+ * 准备视频详情
+ *
+ */
+ private void buildDetailsData(){
+ tvDetails.setId(startIntent.getLongExtra("id", 0));
+ tvDetails.setTitle(startIntent.getStringExtra("title"));
+ tvDetails.setAuthor(startIntent.getStringExtra("author"));
+ tvDetails.setDate(startIntent.getStringExtra("date"));
+ tvDetails.setSourceUrl(startIntent.getStringExtra("sourceUrl"));
+ }
+
+ /**
+ * 加载播放器
+ */
+ private void initPlayer(){
+ playerStandard = findViewById(R.id.play_playerStandard);
+ playerStandard.setUp(tvDetails.getSourceUrl(),"");
+ playerStandard.startVideo();
+ }
+
+ /**
+ * 设置评论按钮显示评论数,以及点击事件
+ */
+ private void buildCommentIcon() {
+ ImageView icon = findViewById(R.id.icComment);
+ TextView commentCount = findViewById(R.id.tvCommentCount);
+ if (tvComments.size() > 0){
+ commentCount.setText(String.valueOf(tvComments.size()));
+ icon.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ scrollItemToTop(1);
+ }
+ });
+ } else {
+ commentCount.setVisibility(View.GONE);
+ }
+
+ }
+ @Override
+ public void onBackPressed() {
+ if (Jzvd.backPress()) {
+ return;
+ }
+ super.onBackPressed();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ Jzvd.releaseAllVideos();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+ private void scrollItemToTop(int position){
+ LinearSmoothScroller smoothScroller = new LinearTopSmoothScroller(this);
+ smoothScroller.setTargetPosition(position);
+ detailsCommentsView.getLayoutManager().startSmoothScroll(smoothScroller);
+ }
+
+}
+
+class LinearTopSmoothScroller extends LinearSmoothScroller {
+
+ public LinearTopSmoothScroller(Context context) {
+ super(context);
+ }
+
+ @Override
+ protected int getVerticalSnapPreference() {
+ return SNAP_TO_START;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/WelcomePage.java b/app/src/main/java/com/example/androidtermwork/WelcomePage.java
new file mode 100644
index 0000000..6953c9b
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/WelcomePage.java
@@ -0,0 +1,37 @@
+package com.example.androidtermwork;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.WindowManager;
+
+public class WelcomePage extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_welcome_page);
+// //设置全屏
+// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+// //隐藏顶部标题栏
+// getSupportActionBar().hide();
+ //设置延时时间
+ handler.sendEmptyMessageDelayed(0,1000);
+ }
+
+ @SuppressLint("HandlerLeak")
+ private Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ //实现页面的跳转
+ Intent intent = new Intent(WelcomePage.this, LoginPage.class);
+ startActivity(intent);
+ finish();
+ super.handleMessage(msg);
+ }
+ };
+}
diff --git a/app/src/main/java/com/example/androidtermwork/adpter/PointsItemAdapter.java b/app/src/main/java/com/example/androidtermwork/adpter/PointsItemAdapter.java
new file mode 100644
index 0000000..c5de764
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/adpter/PointsItemAdapter.java
@@ -0,0 +1,263 @@
+package com.example.androidtermwork.adpter;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.style.ForegroundColorSpan;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.androidtermwork.Activity1;
+import com.example.androidtermwork.R;
+import com.example.androidtermwork.pojo.PointSummary;
+import com.example.androidtermwork.pojo.PointTask;
+import com.example.androidtermwork.util.TestUtil;
+
+import org.w3c.dom.Text;
+
+import java.util.List;
+
+/**
+ * “学习积分”界面采用ListView,这是ListView的数据适配器。
+ * 列表项中第一项是“积分概述”,之后的项都是“积分任务”
+ */
+public class PointsItemAdapter extends BaseAdapter {
+
+ private static final int TYPE_SUMMARY = 0; //表示积分概述
+ private static final int TYPE_TASK = 1; //表示积分任务
+ private Context context;
+ private PointSummary summary; //积分概述
+ private List pointTasks; //积分任务列表
+
+ public PointsItemAdapter(Context context, PointSummary summary, List pointTasks) {
+ super();
+ this.context = context;
+ this.summary = summary;
+ this.pointTasks = pointTasks;
+ }
+
+ @Override
+ public int getCount() {
+ return pointTasks.size() + 1;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ return position == 0 ? TYPE_SUMMARY : TYPE_TASK; //只有第一个列表项是概述,之后的都是任务
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 2; //概述、任务2种类型的item放在ListView中
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return false;
+ }
+
+ @SuppressLint("InflateParams")
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TaskSummaryViewHolder summaryHolder;
+ TaskViewHolder taskHolder;
+ switch (getItemViewType(position)) {
+ case TYPE_SUMMARY: {
+ if (convertView == null) {
+ convertView = LayoutInflater.from(context).inflate(R.layout.points_page_item_sum, null);
+ summaryHolder = buildSummaryViewHolder(convertView);
+ convertView.setTag(summaryHolder);
+
+ } else {
+ summaryHolder = (TaskSummaryViewHolder) convertView.getTag();
+ }
+ buildPointSummaryLayout(summaryHolder);
+ break;
+ }
+
+ case TYPE_TASK: {
+ if (convertView == null) {
+ convertView = LayoutInflater.from(context).inflate(R.layout.points_page_item_task, null);
+
+ RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ convertView.setLayoutParams(layoutParams);
+ taskHolder = buildTaskViewHolder(convertView);
+
+ convertView.setTag(taskHolder);
+ } else {
+ taskHolder = (TaskViewHolder) convertView.getTag();
+ }
+ buildPointTaskLayout(taskHolder, position - 1);
+ break;
+ }
+ }
+ return convertView;
+ }
+
+ /**
+ * 获取积分概述布局中的组件,存放到其ViewHolder中
+ *
+ * @param summaryView
+ * @return viewHolder
+ */
+ private TaskSummaryViewHolder buildSummaryViewHolder(View summaryView) {
+ TaskSummaryViewHolder viewHolder = new TaskSummaryViewHolder();
+ viewHolder.points = summaryView.findViewById(R.id.tvPoints);
+ viewHolder.danName = summaryView.findViewById(R.id.tvDanName);
+ viewHolder.pointsToday = summaryView.findViewById(R.id.tvPointsToday);
+ viewHolder.danStars = summaryView.findViewById(R.id.imgDanStar);
+ return viewHolder;
+ }
+
+ /**
+ * 将“积分概览”的数据展示到布局中
+ *
+ * @param viewHolder
+ */
+ private void buildPointSummaryLayout(TaskSummaryViewHolder viewHolder) {
+ viewHolder.points.setText(String.valueOf(this.summary.getPoints()));
+ viewHolder.danName.setText(String.format(context.getString(R.string.dan_name),
+ this.summary.getDanName()));
+ viewHolder.danStars.setImageDrawable(context.getDrawable(summary.getDanStar()));
+ SpannableString pointsTodayString =
+ SpannableString.valueOf(String.format(context.getString(R.string.today_points),
+ summary.getPointsToday()));
+
+ pointsTodayString.setSpan(new ForegroundColorSpan(Color.RED), 6, pointsTodayString.length(),
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //标红 ”%d积分“
+ viewHolder.pointsToday.setText(pointsTodayString);
+ }
+
+ /**
+ * 获取积分任务布局中的组件,存放到其ViewHolder中
+ *
+ * @param taskView
+ * @return
+ */
+ private TaskViewHolder buildTaskViewHolder(View taskView) {
+ TaskViewHolder taskViewHolder = new TaskViewHolder();
+ taskViewHolder.name = taskView.findViewById(R.id.taskName);
+ taskViewHolder.description = taskView.findViewById(R.id.taskDescription);
+ taskViewHolder.pointDetails = taskView.findViewById(R.id.taskPointsDetail);
+ taskViewHolder.go = taskView.findViewById(R.id.taskGo);
+ taskViewHolder.pointsProgress = taskView.findViewById(R.id.progress_bar_points);
+
+ return taskViewHolder;
+ }
+
+ /**
+ * 将“积分任务”的数据展示到其布局中
+ *
+ * @param position
+ * @param viewHolder
+ */
+ private void buildPointTaskLayout(TaskViewHolder viewHolder, int position) {
+ PointTask pointTaskData = this.pointTasks.get(position);
+ viewHolder.name.setText(pointTaskData.getName());
+ viewHolder.description.setText(pointTaskData.getDescription());
+
+ int pointsToday = pointTaskData.getTodayPoints();
+ int pointsLimit = pointTaskData.getPointsLimit();
+ String pointDetails = String.format(context.getString(R.string.today_points_details),
+ pointsToday, pointsLimit);
+ viewHolder.pointDetails.setText(pointDetails);
+ viewHolder.pointsProgress.setProgress((int) ((double) pointsToday / pointsLimit * 100));
+ //根据今日积分和积分上限判断今日该任务是否完成,未完成添加跳转界面的事件监听器
+ String backColor = context.getString(R.string.background_todo);
+ String textColor = context.getString(R.string.text_todo);
+ String text = "去看看";
+
+ if (pointsToday == pointsLimit) {
+ backColor = context.getString(R.string.background_done);
+ textColor = context.getString(R.string.text_done);
+ text = "已完成";
+ }
+ if (pointsToday < pointsLimit || pointTaskData.getGoAction().startsWith("new_")){
+ viewHolder.go.setTag(pointTaskData.getGoAction()); //将动作描述设置为去做任务TextView的tag
+ viewHolder.go.setOnClickListener(new DoTaskClickListener(context));
+ }
+
+ viewHolder.go.setText(text);
+ viewHolder.go.setTextColor(Color.parseColor(textColor));
+ viewHolder.go.setBackgroundColor(Color.parseColor(backColor));
+
+ }
+
+ /**
+ * ViewHolder类,用于存放布局中组件,把它放在组件的Tag中。
+ * 需要时可以直接获取它,通过它改掉布局中组件的显示内容等属性。
+ */
+ private static final class TaskSummaryViewHolder {
+ TextView points; //总积分
+ TextView pointsToday; //今日已累积积分
+ TextView danName; //段位名称
+ ImageView danStars; //段位星星数图片
+ }
+
+ private static final class TaskViewHolder {
+ TextView name; //任务名称
+ TextView description; //任务描述
+ TextView pointDetails; //积分详情
+ TextView go; //去做任务
+ ProgressBar pointsProgress; //积分进度条
+ }
+}
+
+//点击去做任务的事件监听器
+class DoTaskClickListener implements View.OnClickListener {
+
+ private Context context;
+
+ public DoTaskClickListener(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public void onClick(View v) {
+ String task = (String) v.getTag();
+ AppCompatActivity activity = (AppCompatActivity) context;
+ if (task.startsWith("res_")) {
+
+ activity.setResult(Activity.RESULT_OK, new Intent().putExtra("goAction", task));
+ activity.finish();
+ return;
+ }
+
+ //TestUtil.showSnakeBarMessage(task, -1, v);
+ switch (task){
+ case "new_dailyQ":
+ Intent intent = new Intent(context, Activity1.class);
+ context.startActivity(intent);
+ break;
+ case "new_weeklyQ":
+ Intent intent1 = new Intent(context, Activity1.class);
+ context.startActivity(intent1);
+ break;
+ //case...
+ }
+ activity.finish();
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/adpter/TVDetailsCommentsAdapter.java b/app/src/main/java/com/example/androidtermwork/adpter/TVDetailsCommentsAdapter.java
new file mode 100644
index 0000000..910e577
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/adpter/TVDetailsCommentsAdapter.java
@@ -0,0 +1,281 @@
+package com.example.androidtermwork.adpter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.volley.RequestQueue;
+import com.android.volley.toolbox.ImageLoader;
+import com.android.volley.toolbox.Volley;
+import com.example.androidtermwork.R;
+import com.example.androidtermwork.pojo.TvComment;
+import com.example.androidtermwork.pojo.TvDetails;
+import com.example.androidtermwork.util.FormatUtil;
+import com.example.androidtermwork.util.TestUtil;
+import com.example.androidtermwork.volley.BitmapCache;
+
+import java.util.List;
+
+import de.hdodenhof.circleimageview.CircleImageView;
+
+
+public class TVDetailsCommentsAdapter extends RecyclerView.Adapter {
+
+ private TvDetails tvDetails;
+ private List tvComments;
+ private static final int DETAILS = 0;
+ private static final int COMMENT = 1;
+ private static final int HINT_NO_COMMENT = 2;
+ private static boolean isMoreInfoOpened = false;
+ private RequestQueue requestQueue;
+ private ImageLoader imageLoader;
+ private Context context;
+ public TVDetailsCommentsAdapter(Context context){
+ this.context = context;
+ requestQueue = Volley.newRequestQueue(context);
+ imageLoader = new ImageLoader(requestQueue, new BitmapCache());
+ }
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ RecyclerView.ViewHolder viewHolder;
+ View view;
+ switch (viewType){
+ case DETAILS:
+ view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tv_play_details_item, parent, false);
+ viewHolder = new TvDetailsViewHolder(view);
+ break;
+ case COMMENT:
+ view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tv_play_comment_item, parent, false);
+ viewHolder = new TvCommentsViewHolder(view);
+ break;
+ default: // case HINT_NO_COMMENT:
+ view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tv_play_hint_item_nocomment, parent, false);
+ viewHolder = new RecyclerView.ViewHolder(view){};
+ break;
+ }
+
+ return viewHolder;
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof TvDetailsViewHolder){
+ bindDetailsData(holder);
+ } else if (holder instanceof TvCommentsViewHolder){
+ bindCommentData(holder, position);
+ }
+ }
+
+ private void bindCommentData(RecyclerView.ViewHolder viewHolder, int position) {
+ TvCommentsViewHolder holder = (TvCommentsViewHolder) viewHolder;
+ TvComment comment = tvComments.get(position - 1);
+ //请求并设置头像
+ if (comment.getUserHead() != null) {
+ imageLoader.get(comment.getUserHead(),
+ ImageLoader.getImageListener(holder.userHeadImage, R.mipmap.loading_head_portrait, R.mipmap.default_head_portrait));
+ } else {
+ holder.userHeadImage.setImageResource(R.mipmap.default_head_portrait);
+ }
+
+ //设置用户名
+ holder.userName.setText(comment.getUserName());
+ //设置评论内容
+ holder.commentContent.setText(comment.getCommentContent());
+ //设置评论发表时间
+ holder.commentDate.setText(comment.getCommentDate());
+ //设置点赞
+ holder.setFeelGood(comment.getFeelGoodCounts(), comment.isFeelGood());
+ //设置点赞事件监听(测试,跳过接口调用)
+ holder.feelGoodHub.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (comment.isFeelGood()){
+ comment.setFeelGood(false);
+ comment.setFeelGoodCounts(comment.getFeelGoodCounts() - 1);
+ } else {
+ comment.setFeelGood(true);
+ comment.setFeelGoodCounts(comment.getFeelGoodCounts() + 1);
+ }
+ holder.setFeelGood(comment.getFeelGoodCounts(), comment.isFeelGood());
+ }
+ });
+ //todo 设置点击回复事件监听
+
+ }
+
+ private void bindDetailsData(RecyclerView.ViewHolder viewHolder) {
+ TvDetailsViewHolder holder = (TvDetailsViewHolder) viewHolder;
+ //设置视频标题
+ holder.title.setText(tvDetails.getTitle());
+ //设置作者和发布时间
+ String authorAndDate = tvDetails.getAuthor() + " " + tvDetails.getDate();
+ holder.authorAndDate.setText(authorAndDate);
+ //设置播放量
+ String playCounts = "播放 " + FormatUtil.simpleFormat(tvDetails.getPlayCounts());
+ holder.playCounts.setText(playCounts);
+ //设置点赞数
+ holder.setFeelGood(tvDetails.getFeelGoodCounts(), tvDetails.isFeelGood());
+ //点赞数事件监听
+ holder.feelGood.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (!tvDetails.isFeelGood()){
+ // 调用相关接口,成功后增加点赞数
+ //测试,跳过接口调用
+ tvDetails.setFeelGoodCounts(tvDetails.getFeelGoodCounts() + 1);
+ tvDetails.setFeelGood(true);
+ } else {
+ //调用相关接口,成功后减少点赞数
+ //测试,跳过接口调用
+ tvDetails.setFeelGoodCounts(tvDetails.getFeelGoodCounts() - 1);
+ tvDetails.setFeelGood(false);
+ }
+ holder.setFeelGood(tvDetails.getFeelGoodCounts(), tvDetails.isFeelGood());
+ }
+ });
+ //设置简介
+ holder.introduction.setText(tvDetails.getIntroduction());
+
+ //设置更多信息和展开更多信息
+ holder.moreInfo.setVisibility(View.GONE);
+ if (tvDetails.getMoreInfo() == null || tvDetails.getMoreInfo().length() == 0) {
+ holder.openOrCloseHub.setVisibility(View.GONE);
+
+ } else {
+ holder.moreInfo.setText(tvDetails.getMoreInfo());
+ holder.openOrCloseHub.setOnClickListener(view -> {
+ ImageView openOrClose = view.findViewById(R.id.tvPlay_openOrCloseImage);
+ if (isMoreInfoOpened){
+ isMoreInfoOpened = false;
+ openOrClose.setRotation(0f);
+ holder.moreInfo.setVisibility(View.GONE);
+ } else {
+ isMoreInfoOpened = true;
+ openOrClose.setRotation(180f);
+ holder.moreInfo.setVisibility(View.VISIBLE);
+ }
+ });
+ }
+
+ }
+
+ @Override
+ public int getItemCount() {
+ int t = tvComments.size() + 1;
+ return t == 1 ? 2 : t;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ int type = COMMENT;
+ if (tvComments.size() == 0){
+ type = HINT_NO_COMMENT;
+ }
+ return position == 0 ? DETAILS : type;
+ }
+
+ public TvDetails getTvDetails() {
+ return tvDetails;
+ }
+
+ public void setTvDetails(TvDetails tvDetails) {
+ this.tvDetails = tvDetails;
+ }
+
+ public List getTvComments() {
+ return tvComments;
+ }
+
+ public void setTvComments(List tvComments) {
+ this.tvComments = tvComments;
+ }
+
+ class TvDetailsViewHolder extends RecyclerView.ViewHolder {
+
+ TextView title;
+ TextView authorAndDate;
+ TextView moreInfo;
+ TextView playCounts;
+ CheckBox feelGood;
+ TextView introduction;
+ RelativeLayout openOrCloseHub;
+ public TvDetailsViewHolder(@NonNull View itemView) {
+ super(itemView);
+ title = itemView.findViewById(R.id.title);
+ authorAndDate = itemView.findViewById(R.id.authorAndDate);
+ moreInfo = itemView.findViewById(R.id.moreInfo);
+ playCounts = itemView.findViewById(R.id.playCounts);
+ feelGood = itemView.findViewById(R.id.feelGood);
+ introduction = itemView.findViewById(R.id.introduction);
+ openOrCloseHub = itemView.findViewById(R.id.tvPlay_openOrCloseHub);
+ }
+
+ /**
+ * 设置视频点赞
+ * @param counts
+ * @param status
+ */
+ private void setFeelGood(long counts, boolean status){
+ String feelGoodCounts = "点赞 " + FormatUtil.simpleFormat(counts);
+ feelGood.setText(feelGoodCounts);
+ feelGood.setChecked(status);
+ }
+ }
+
+ class TvCommentsViewHolder extends RecyclerView.ViewHolder{
+
+ CircleImageView userHeadImage;
+ TextView userName;
+ TextView feelGoodCounts;
+ ImageView feelGood;
+ TextView commentContent;
+ TextView commentDate;
+ TextView reply;
+ LinearLayout feelGoodHub;
+ public TvCommentsViewHolder(@NonNull View itemView) {
+ super(itemView);
+ userHeadImage = itemView.findViewById(R.id.userHeadImage);
+ userName = itemView.findViewById(R.id.userName);
+ feelGoodCounts = itemView.findViewById(R.id.commentFeelGoodCounts);
+ feelGood = itemView.findViewById(R.id.commentFeelGood);
+ commentContent = itemView.findViewById(R.id.commentContent);
+ commentDate = itemView.findViewById(R.id.commentDate);
+ reply = itemView.findViewById(R.id.replyComment);
+ feelGoodHub = itemView.findViewById(R.id.commentFeelGoodHub);
+ }
+
+
+ /**
+ * 设置评论点赞
+ * @param counts
+ * @param status
+ */
+ private void setFeelGood(long counts, boolean status){
+ String feelGoodCounts = String.valueOf(counts);
+ if (counts > 10000){
+ feelGoodCounts = String.format("%.2f万", FormatUtil.getFloorCount(counts) /10000.0);
+ //feelGoodCounts = counts / 10000.0 + "万";
+ }
+ this.feelGoodCounts.setText(feelGoodCounts);
+ if (status){
+ feelGood.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.feel_good));
+ } else {
+ feelGood.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_feel_good));
+ }
+ }
+
+
+ }
+
+}
diff --git a/app/src/main/java/com/example/androidtermwork/adpter/TVStationAdapter.java b/app/src/main/java/com/example/androidtermwork/adpter/TVStationAdapter.java
new file mode 100644
index 0000000..1a38703
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/adpter/TVStationAdapter.java
@@ -0,0 +1,131 @@
+package com.example.androidtermwork.adpter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.volley.RequestQueue;
+import com.android.volley.toolbox.ImageLoader;
+import com.android.volley.toolbox.Volley;
+import com.example.androidtermwork.R;
+import com.example.androidtermwork.pojo.TVStation;
+import com.example.androidtermwork.volley.BitmapCache;
+
+import java.util.List;
+
+
+public class TVStationAdapter extends BaseAdapter {
+ private static final int BIG_COVER_TV = 0;
+ //private static final int STD_COVER_TV = 1;
+ private Context context;
+ private List tvStations;
+ private RequestQueue mQueue;
+ private ImageLoader imageLoader;
+
+ public TVStationAdapter(Context context, List tvStations) {
+ this.context = context;
+ this.tvStations = tvStations;
+ mQueue = Volley.newRequestQueue(context);
+ imageLoader = new ImageLoader(mQueue, new BitmapCache());
+ }
+
+ public Context getContext() {
+ return context;
+ }
+ public void setContext(Context context) {
+ this.context = context;
+ }
+ public List getTvStations() {
+ return tvStations;
+ }
+ public void setTvStations(List tvStations) {
+ this.tvStations = tvStations;
+ }
+
+ @Override
+ public int getCount() {
+ return tvStations.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return tvStations.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return tvStations.get(position).getId();
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TVStationViewHolder viewHolder;
+ TVStation tvStation = tvStations.get(position);
+ if (convertView != null){
+ viewHolder = (TVStationViewHolder) convertView.getTag();
+ bindItemData(tvStation, viewHolder);
+ return convertView;
+ }
+ switch (tvStation.getItemType()){
+ case BIG_COVER_TV:
+ convertView = LayoutInflater.from(context).inflate(R.layout.tv_station_big_item, null);
+ break;
+ default: convertView = LayoutInflater.from(context).inflate(R.layout.tv_station_standard_item, null);
+ }
+ ViewGroup.MarginLayoutParams layoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ convertView.setLayoutParams(layoutParams);
+ viewHolder = buildTVStationViewHolder(convertView);
+ bindItemData(tvStation, viewHolder);
+ convertView.setTag(viewHolder);
+ return convertView;
+ }
+
+ private void bindItemData(TVStation tvStation, TVStationViewHolder viewHolder) {
+ //设置标题
+ viewHolder.title.setText(tvStation.getTitle());
+ //设置作者和发布时间
+ String authorAndDate = tvStation.getAuthor() + " " + tvStation.getDate();
+ viewHolder.authorAndDate.setText(authorAndDate);
+ //设置视频时长
+ int minutes = tvStation.getTimeLength()/60;
+ int seconds = tvStation.getTimeLength()%60;
+ String timeLength = minutes + ":" + seconds;
+ viewHolder.timeLength.setText(timeLength);
+
+ //请求封面图片
+ imageLoader.get(tvStation.getCover(),
+ ImageLoader.getImageListener(viewHolder.cover, R.mipmap.img_loading, R.mipmap.img_fail_to_load));
+
+ //viewHolder.cover.setImageURI(Uri.parse(tvStation.getCover()));
+
+ }
+
+ private TVStationViewHolder buildTVStationViewHolder(View convertView) {
+ TVStationViewHolder viewHolder = new TVStationViewHolder();
+ viewHolder.cover = convertView.findViewById(R.id.tvImgCover);
+ viewHolder.title = convertView.findViewById(R.id.tvTitle);
+ viewHolder.timeLength = convertView.findViewById(R.id.tvTimeLength);
+ viewHolder.authorAndDate = convertView.findViewById(R.id.tvAuthorDate);
+ return viewHolder;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 2; //大图片封面和小封面图片两种电视台
+ }
+
+ /**
+ * “电视台”ViewHolder
+ */
+ private static final class TVStationViewHolder {
+ ImageView cover; //封面图片
+ TextView title; //标题
+ TextView authorAndDate; //作者和发布时间
+ TextView timeLength; //视频时长
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/androidtermwork/pojo/PointSummary.java b/app/src/main/java/com/example/androidtermwork/pojo/PointSummary.java
new file mode 100644
index 0000000..7b72eaf
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/pojo/PointSummary.java
@@ -0,0 +1,51 @@
+package com.example.androidtermwork.pojo;
+
+//积分概览
+public class PointSummary
+{
+ private int points; //总积分
+ private int pointsToday; //今日已累积积分
+ private int dan; //段位
+ private String danName; //段位名称
+ private int danStar; //段位星星图片id
+
+ public int getPoints() {
+ return points;
+ }
+
+ public void setPoints(int points) {
+ this.points = points;
+ }
+
+ public int getPointsToday() {
+ return pointsToday;
+ }
+
+ public void setPointsToday(int pointsToday) {
+ this.pointsToday = pointsToday;
+ }
+
+ public String getDanName() {
+ return danName;
+ }
+
+ public void setDanName(String danName) {
+ this.danName = danName;
+ }
+
+ public int getDanStar() {
+ return danStar;
+ }
+
+ public void setDanStar(int danStar) {
+ this.danStar = danStar;
+ }
+
+ public int getDan() {
+ return dan;
+ }
+
+ public void setDan(int dan) {
+ this.dan = dan;
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/pojo/PointTask.java b/app/src/main/java/com/example/androidtermwork/pojo/PointTask.java
new file mode 100644
index 0000000..696172e
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/pojo/PointTask.java
@@ -0,0 +1,51 @@
+package com.example.androidtermwork.pojo;
+
+//积分任务
+public class PointTask
+{
+ private String name; // 任务名
+ private String description; // 任务描述
+ private int todayPoints; // 今日已获积分
+ private int pointsLimit; // 任务积分上限
+ private String goAction; // 表示点击去做任务后的动作
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getGoAction() {
+ return goAction;
+ }
+
+ public void setGoAction(String goAction) {
+ this.goAction = goAction;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getTodayPoints() {
+ return todayPoints;
+ }
+
+ public void setTodayPoints(int todayPoints) {
+ this.todayPoints = todayPoints;
+ }
+
+ public int getPointsLimit() {
+ return pointsLimit;
+ }
+
+ public void setPointsLimit(int pointsLimit) {
+ this.pointsLimit = pointsLimit;
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/pojo/TVStation.java b/app/src/main/java/com/example/androidtermwork/pojo/TVStation.java
new file mode 100644
index 0000000..a8d87c7
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/pojo/TVStation.java
@@ -0,0 +1,78 @@
+package com.example.androidtermwork.pojo;
+
+public class TVStation
+{
+ private long id;
+ private String cover;
+ private String videoSource;
+ private String author;
+ private String date;
+ private int timeLength;
+ private int itemType;
+ private String title;
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getCover() {
+ return cover;
+ }
+
+ public void setCover(String cover) {
+ this.cover = cover;
+ }
+
+ public String getVideoSource() {
+ return videoSource;
+ }
+
+ public void setVideoSource(String videoSource) {
+ this.videoSource = videoSource;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public int getTimeLength() {
+ return timeLength;
+ }
+
+ public void setTimeLength(int timeLength) {
+ this.timeLength = timeLength;
+ }
+
+ public int getItemType() {
+ return itemType;
+ }
+
+ public void setItemType(int itemType) {
+ this.itemType = itemType;
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/pojo/TvComment.java b/app/src/main/java/com/example/androidtermwork/pojo/TvComment.java
new file mode 100644
index 0000000..553112c
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/pojo/TvComment.java
@@ -0,0 +1,67 @@
+package com.example.androidtermwork.pojo;
+
+public class TvComment {
+ private String userHead;
+ private String userId;
+ private String userName;
+ private long feelGoodCounts;
+ private boolean isFeelGood;
+ private String commentContent;
+ private String commentDate;
+
+ public String getUserHead() {
+ return userHead;
+ }
+
+ public void setUserHead(String userHead) {
+ this.userHead = userHead;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public long getFeelGoodCounts() {
+ return feelGoodCounts;
+ }
+
+ public void setFeelGoodCounts(long feelGoodCounts) {
+ this.feelGoodCounts = feelGoodCounts;
+ }
+
+ public boolean isFeelGood() {
+ return isFeelGood;
+ }
+
+ public void setFeelGood(boolean feelGood) {
+ isFeelGood = feelGood;
+ }
+
+ public String getCommentContent() {
+ return commentContent;
+ }
+
+ public void setCommentContent(String commentContent) {
+ this.commentContent = commentContent;
+ }
+
+ public String getCommentDate() {
+ return commentDate;
+ }
+
+ public void setCommentDate(String commentDate) {
+ this.commentDate = commentDate;
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/pojo/TvDetails.java b/app/src/main/java/com/example/androidtermwork/pojo/TvDetails.java
new file mode 100644
index 0000000..1a803aa
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/pojo/TvDetails.java
@@ -0,0 +1,103 @@
+package com.example.androidtermwork.pojo;
+
+public class TvDetails {
+ private long id;
+ private String title;
+ private String author;
+ private String date;
+ private String moreInfo;
+ private long playCounts;
+ private long feelGoodCounts;
+ private String introduction;
+ private boolean isFeelGood;
+ private boolean isCollect;
+ private String sourceUrl;
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public String getMoreInfo() {
+ return moreInfo;
+ }
+
+ public void setMoreInfo(String moreInfo) {
+ this.moreInfo = moreInfo;
+ }
+
+ public long getPlayCounts() {
+ return playCounts;
+ }
+
+ public void setPlayCounts(long playCounts) {
+ this.playCounts = playCounts;
+ }
+
+ public long getFeelGoodCounts() {
+ return feelGoodCounts;
+ }
+
+ public void setFeelGoodCounts(long feelGoodCounts) {
+ this.feelGoodCounts = feelGoodCounts;
+ }
+
+ public String getIntroduction() {
+ return introduction;
+ }
+
+ public void setIntroduction(String introduction) {
+ this.introduction = introduction;
+ }
+
+ public boolean isFeelGood() {
+ return isFeelGood;
+ }
+
+ public void setFeelGood(boolean feelGood) {
+ isFeelGood = feelGood;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public boolean isCollect() {
+ return isCollect;
+ }
+
+ public void setCollect(boolean collect) {
+ isCollect = collect;
+ }
+
+ public String getSourceUrl() {
+ return sourceUrl;
+ }
+
+ public void setSourceUrl(String sourceUrl) {
+ this.sourceUrl = sourceUrl;
+ }
+}
diff --git a/app/src/main/java/com/example/androidtermwork/ui/dashboard/DashboardFragment.java b/app/src/main/java/com/example/androidtermwork/ui/dashboard/DashboardFragment.java
new file mode 100644
index 0000000..822005c
--- /dev/null
+++ b/app/src/main/java/com/example/androidtermwork/ui/dashboard/DashboardFragment.java
@@ -0,0 +1,140 @@
+package com.example.androidtermwork.ui.dashboard;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.example.androidtermwork.R;
+import com.example.androidtermwork.webView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+class News {
+ public String title;
+ public String resource;
+ public String title2;
+ public String time;
+ public String article;
+ public String editor;
+
+ public News(String title, String resource, String title2, String time, String article, String editor) {
+ this.title = title;
+ this.resource = resource;
+ this.title2 = title2;
+ this.time = time;
+ this.article = article;
+ this.editor = editor;
+ }
+}
+
+public class DashboardFragment extends Fragment {
+ public static List newLists = Arrays.asList(
+ new News("中国共产党第十九届中央委员会第六次全体会议公报",
+ "“学习强国”学习平台",
+ "中国共产党第十九届中央委员会第六次全体会议公报(2021年11月11日中国共产党第十九届中央委员会第六次全体会议通过)",
+ "2021-11-12",
+ "中国共产党第十九届中央委员会第六次全体会议,于2021年11月8日至11日在北京举行。\\n' +\n" +
+ " '出席这次全会的有,中央委员197人,候补中央委员151人。中央纪律检查委员会常务委员会委员和有关方面负责同志列席会议。\\n' +\n" +
+ " '全会由中央政治局主持。中央委员会总书记习近平作了重要讲话。\\n' +\n" +
+ " '全会听取和讨论了习近平受中央政治局委托作的工作报告,审议通过了《中共中央关于党的百年奋斗重大成就和历史经验的决议》,审议通过了《关于召开党的第二十次全国代表大会的决议》。习近平就《中共中央关于党的百年奋斗重大成就和历史经验的决议(讨论稿)》向全会作了说明。\\n' +\n" +
+ " '全会认为,总结党的百年奋斗重大成就和历史经验,是在建党百年历史条件下开启全面建设社会主义现代化国家新征程、在新时代坚持和发展中国特色社会主义的需要;是增强政治意识、大局意识、核心意识、看齐意识,坚定道路自信、理论自信、制度自信、文化自信,做到坚决维护习近平同志党中央的核心、全党的核心地位,坚决维护党中央权威和集中统一领导,确保全党步调一致向前进的需要;是推进党的自我革命、提高全党斗争本领和应对风险挑战能力、永葆党的生机活力、团结带领全国各族人民为实现中华民族伟大复兴的中国梦而继续奋斗的需要。全党要坚持唯物史观和正确党史观,从党的百年奋斗中看清楚过去我们为什么能够成功、弄明白未来我们怎样才能继续成功,从而更加坚定、更加自觉地践行初心使命,在新时代更好坚持和发展中国特色社会主义。",
+ "秦辰宇"),
+ new News("习近平主持召开中央政治局会议 分析研究2022年经济工作", "“学习强国”学习平台",
+ "征求对经济工作的意见和建议\n" +
+ "\n" +
+ "中共中央召开党外人士座谈会\n" +
+ "\n" +
+ "习近平主持并发表重要讲话\n" +
+ "\n" +
+ "李克强通报有关情况 汪洋王沪宁韩正出席",
+ "2021-12-06",
+ "新华社北京12月6日电 12月2日,中共中央在中南海召开党外人士座谈会,就今年经济形势和明年经济工作听取各民主党派中央、全国工商联负责人和无党派人士代表的意见和建议。中共中央总书记习近平主持座谈会并发表重要讲话强调,要全面贯彻落实中共十九届六中全会精神,重温多党合作的历程和作用,发扬光荣传统,坚守合作初心,围绕宏观政策要稳健有效、微观政策要激发市场主体活力、改革开放政策要增强发展动力、社会政策要兜住民生底线,积极履行职能,加强自身建设,引导广大成员和所联系群众把会议精神转化为共同奋斗的政治共识,在全面建设社会主义现代化国家新征程中继续团结奋斗。\n" +
+ "\n" +
+ "座谈会上,民革中央主席万鄂湘、民盟中央主席丁仲礼、民建中央主席郝明金、民进中央主席蔡达峰、农工党中央主席陈竺、致公党中央常务副主席蒋作君、九三学社中央主席武维华、台盟中央主席苏辉、全国工商联主席高云龙、无党派人士代表宇如聪先后发言。他们完全赞同中共中央对当前我国经济形势的分析判断和明年经济工作的谋划考虑,并就加强宏观调控、提升政策效能,改善进出口结构、促进内外贸一体化,提高生产制造装备水平、加快我国高端制造业发展,健全人口服务体系、激发内需增长潜力,完善我国疫情防控策略、为稳增长打牢扎实基础,强化法治保障和政策引领、科学有序推进“双碳”目标,转变涉企财税支持方式、提高财政收入质量,加强农村生态环境治理、夯实乡村振兴基础,加大改革力度、助力推进共同富裕,强化中小企业发展政策导向和可持续发展能力,发挥民企在促进共同富裕中积极作用,完善科技领域“揭榜挂帅”工作机制,加快推动省际交界地区协同发展等提出意见建议。",
+ "张秋兰"),
+ new News("习近平主持党外人士座谈会并发表重要讲话", "“学习强国”学习平台",
+ "",
+ "2021-12-06",
+ "", "张玙蕗"),
+ new News("国家主席习近平任免驻外大使", "“学习强国”学习平台",
+ "",
+ "2021-12-03",
+ "", "齐翼"),
+ new News("习近平向“2021从都国际论坛”开幕式发表视频致辞",
+ "“学习强国”学习平台",
+ "",
+ "2021-12-05",
+ "", "秦辰宇"),
+ new News("习近平同老挝人民革命党中央总书记、国家主席通伦共同出席中老铁路通车仪式",
+ "“学习强国”学习平台",
+ "",
+ "2021-12-03",
+ "", "胡佳"),
+ new News("习近平向中国-拉共体论坛第三届部长会议发表视频致辞",
+ "“学习强国”学习平台",
+ "",
+ "2021-12-03",
+ "", "齐翼"),
+ new News("习近平出席全国宗教工作会议并发表重要讲话",
+ "“学习强国”学习平台",
+ "",
+ "2021-12-04",
+ "", "秦辰宇"));
+
+ private DashboardViewModel dashboardViewModel;
+
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+// dashboardViewModel =
+// ViewModelProviders.of(this).get(DashboardViewModel.class);
+ View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
+ final ListView listView = root.findViewById(R.id.newsList);
+// dashboardViewModel.getText().observe(this, new Observer() {
+// @Override
+// public void onChanged(@Nullable String s) {
+// }
+// });
+ updateListView(listView);
+ return root;
+ }
+
+ public void updateListView(ListView listView) {
+ final List