上传期末项目

main
heliuqing 1 year ago
parent cd18ffcffa
commit 12d4147dd8

@ -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
local.properties

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,5 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
</component>

@ -0,0 +1,12 @@
<project version="4">
<component name="CodeInsightWorkspaceSettings">
<option name="optimizeImportsOnTheFly" value="true" />
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,48 @@
plugins {
id("com.android.application")
}
android {
namespace = "com.example.final_project_app"
compileSdk = 33
defaultConfig {
applicationId = "com.example.final_project_app"
minSdk = 24
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
//noinspection GradleCompatible,GradleCompatible
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.8.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation(files("libs\\mysql-connector-java-5.1.49.jar"))
//轮播图依赖使用三方开源库youth5201314
implementation("io.github.youth5201314:banner:2.2.2")
//视频播放器依赖
implementation("com.android.support:recyclerview-v7:33.0.0")
//implementation("com.github.bumptech.glide:glide:4.8.0")
}

@ -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

@ -0,0 +1,26 @@
package com.example.final_project_app;
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.final_project_app", appContext.getPackageName());
}
}

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- 添加网络权限 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 读取权限 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
tools:ignore="ProtectedPermissions" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Final_Project_app"
tools:targetApi="31">
<activity
android:name=".QuestionActivity"
android:exported="false" />
<activity
android:name=".PlayActivity"
android:exported="false" />
<activity
android:name=".sql.UpdateNoteActivity"
android:exported="false" />
<activity
android:name=".sql.AddNoteActivity"
android:exported="false" />
<activity
android:name=".Helpctivity"
android:exported="false" />
<activity
android:name=".AboutUsActivity"
android:exported="true" />
<activity
android:name=".login"
android:exported="true"></activity>
<activity
android:name=".register"
android:exported="false" />
<activity
android:name=".Hello_GudieActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="false" />
<activity android:name=".Goods.GoodsActivity"
android:exported="true"/>
</application>
</manifest>

@ -0,0 +1,37 @@
package com.example.final_project_app;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class AboutUsActivity extends AppCompatActivity {
private Button btn_back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about_us);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/* btn_back = findViewById(R.id.btn_back);
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.fg_main,new FourFragment());
ft.addToBackStack(null);
ft.commit();
Intent intent = new Intent(AboutUsActivity.this, FourFragment.class);
startActivity(intent);
}
});*/
}
}

@ -0,0 +1,155 @@
package com.example.final_project_app;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
/**
* A simple {@link Fragment} subclass.
* Use the {@link ChexBoxFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class ChexBoxFragment extends Fragment {
//成员变量
private TextView question_stem;//题干文本框控件,就是选中的控件显示
private CheckBox[] cb =new CheckBox[5];
private Question question;//题目对象就是标题,单选多选,正确下标
private int result;//正确为1 错误为0 未答题为-1
private View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.e("复选onCreateView","复选onCreateView执行了");
view=inflater.inflate(R.layout.fragment_chex_box, container, false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Log.e("复选onViewCreated","复选onViewCreated执行了");
//初始化控件
initView(view);
//更新题目
nextQuestion(question);
}
//获取题目
public void setQuestion(Question question){
this.question=question;
}
public void clearChoice(){
//清除选择
for (int i = 0; i < cb.length; i++) {
cb[i].setChecked(false);
}
}
//初始化控件
public void initView(final View view){
Log.e("复选initView","复选initView执行了");
//获取题干
question_stem=view.findViewById(R.id.question_item2);
//单选控件
cb[0]=view.findViewById(R.id.boxs1);
cb[1]=view.findViewById(R.id.boxs2);
cb[2]=view.findViewById(R.id.boxs3);
cb[3]=view.findViewById(R.id.boxs4);
cb[4]=view.findViewById(R.id.boxs5);
}
//更新题目
public void nextQuestion(Question question){
Log.e("复选nextQuestion","nextQuestion执行了");
//设置题干
Log.e("a",question.getQuestionStem());
question_stem.setText(question.getQuestionStem());
//设置选项
for (int i=0;i<cb.length;i++){
//所有选项初始都未选中
cb[i].setChecked(false);
//设置选项内容
cb[i].setText(question.getOptions()[i]);
//设置背景颜色
cb[i].setBackgroundResource(R.drawable.select_button_text);
//设置字体颜色
cb[i].setTextColor(getResources().getColor(R.color.black));
}
}
//判断选择结果
public int getResult(Question question){
//得到正确的选项的下标数组
String[] correctOptions = question.getCorrectOptions().split(",");
boolean answer = true; //记录正确答案是否选择
int checkednum = 0; //选择的选项个数
for(int i = 0; i < cb.length; i++){
if(cb[i].isChecked()){
checkednum++; //选项个数增加
}
}
if(checkednum == 0){
Toast.makeText(getContext(),"请选择答案!",Toast.LENGTH_SHORT).show();
result = -1;
}else{
for(int i=0;i< cb.length;i++){
cb[i].setBackgroundResource(R.drawable.shape_radiobutton2);
}
if(checkednum==correctOptions.length){
for (String correctOption : correctOptions) {
//判断对应的选项是否被选择
boolean now = cb[Integer.parseInt(correctOption)].isChecked();
answer = answer && now;
}
}else {
answer=false;
}
if(answer){
for (String correctOption : correctOptions) {
//判断对应的选项是否被选择
CheckBox c = cb[Integer.parseInt(correctOption)];
c.setBackgroundResource(R.drawable.shape_success_answer);
c.setTextColor(getResources().getColor(R.color.black));
}
result = 1;
}else{
for (CheckBox checkBox : cb) {
if (checkBox.isChecked()) {
checkBox.setBackgroundResource(R.drawable.shape_error_answer);
checkBox.setTextColor(getResources().getColor(R.color.black));
}
}
showCorrectAnswer(correctOptions);
result = 0;
}
}
return result;
}
//显示正确答案的dialog
private void showCorrectAnswer(String[] correctOptions) {
//得到正确答案
String answer = "";
for (String correctOption : correctOptions) {
answer += cb[Integer.parseInt(correctOption)].getText().toString() + "\n";
}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("正确答案")
.setMessage(answer)
.setNegativeButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.create().show();
}
}

@ -0,0 +1,198 @@
package com.example.final_project_app.Fragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.Goods.Goods;
import com.example.final_project_app.Goods.GoodsAdapter;
import com.example.final_project_app.Goods.GoodsData;
import com.example.final_project_app.R;
import com.example.final_project_app.adpter.BannerViewAdapter;
import com.example.final_project_app.db.CultrualData;
import com.example.final_project_app.db.bannerBean;
import com.youth.banner.Banner;
import com.youth.banner.indicator.CircleIndicator;
import java.util.ArrayList;
import java.util.List;
public class FirstFragment extends Fragment {
//定义列表,放内容
private GoodsData goodsData;
private List<Goods> goodsList = new ArrayList<>();
//定义轮播图片
private final ArrayList<bannerBean> banners;
//定义文物列表
private List<CultrualData> CuList = new ArrayList<CultrualData>();
//定义布局
private RecyclerView recyclerView;
//定义文物适配器
CultrualAdapter adapter;
//轮播
public FirstFragment() {
//本地图片
banners = new ArrayList<>();
banners.add(new bannerBean(R.drawable.banner1));
banners.add(new bannerBean(R.drawable.banner2));
banners.add(new bannerBean(R.drawable.banner3));
banners.add(new bannerBean(R.drawable.banner4));
banners.add(new bannerBean(R.drawable.banner5));
banners.add(new bannerBean(R.drawable.banner6));
}
//
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fg_first, container, false); // 通过inflater获取页面
// initCrlists();
//获取recyclerview水平可滑动列表
recyclerView = inflate.findViewById(R.id.recycler_view);
adapter = new CultrualAdapter();
recyclerView.setAdapter(adapter);
goodsData = new GoodsData(inflate.getContext());
goodsList = goodsData.getGoodsList();
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
//设置间隔线
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
recyclerView.addItemDecoration(dividerItemDecoration);
layoutManager.setOrientation(recyclerView.VERTICAL);//水平/垂直显示
recyclerView.setLayoutManager(layoutManager);
GoodsAdapter adapter = new GoodsAdapter(goodsList);
recyclerView.setAdapter(adapter);
//获取banner
Banner banner = inflate.findViewById(R.id.banner);
//设置banner
//添加生命周期,回调这个方法
banner.addBannerLifecycleObserver(this)
//为banner设置适配器并将数据传递进去
.setAdapter(new BannerViewAdapter(banners, this))
//添加指示器
.setIndicator(new CircleIndicator(getContext()));
return inflate;
//返回inflate对象
}
//菜单按钮点击事件
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// //菜单栏点击跳转事件
/* menu_bnt1 = getActivity().findViewById(R.id.btn1);
menu_bnt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), waitActivity.class);
startActivity(intent);
}
});
menu_btn2= getActivity().findViewById(R.id.btn2);
menu_btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), waitActivity2.class);
startActivity(intent);
}
});
menu_btn3=getActivity().findViewById(R.id.btn3);
menu_btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), waitActivity3.class);
startActivity(intent);
}
});
menu_btn4 = getActivity().findViewById(R.id.btn4);
menu_btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), waitActivity5.class);
startActivity(intent);
}
});*/
}
//文物列表通过add将数据加入列表中
// private void initCrlists() {
// CultrualData list1 = new CultrualData("商.铜神树枝头花蕾及立鸟", R.drawable.cr_list1);
// CuList.add(list1);
// CultrualData list2 = new CultrualData("商晚.青铜器妇好鹄尊", R.drawable.cr_list2);
// CuList.add(list2);
// CultrualData list3 = new CultrualData("商晚.青铜器牛方鼎", R.drawable.cr_list3);
// CuList.add(list3);
// CultrualData list4 = new CultrualData("西周.青铜器凤纹尊", R.drawable.cr_list4);
// CuList.add(list4);
// CultrualData list5 = new CultrualData("五代.青瓷提梁倒灌壶", R.drawable.cr_list5);
// CuList.add(list5);
// CultrualData list6 = new CultrualData("西周.鸟纹觥", R.drawable.cr_list6);
// CuList.add(list6);
// CultrualData list7 = new CultrualData("三星堆", R.drawable.cr_list7);
// CuList.add(list7);
// CultrualData list8 = new CultrualData("商代.鹄卣", R.drawable.cr_list8);
// CuList.add(list8);
// CultrualData list9 = new CultrualData("兽面纹铜钺", R.drawable.cr_list9);
// CuList.add(list9);
// }
class CultrualAdapter extends RecyclerView.Adapter<MyViewHoder> {
@NonNull
@Override
public MyViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = View.inflate(getContext(), R.layout.cltrua_list, null);
MyViewHoder myViewHoder = new MyViewHoder(view);
// 将View对象传入ViewHolder构造函数创建ViewHolder对象并返回
return myViewHoder;
}
// onBindViewHolder方法用于绑定数据到ViewHolder对象
// 参数holder表示要绑定的ViewHolder对象position表示当前项的位置
@Override
public void onBindViewHolder(@NonNull MyViewHoder holder, @SuppressLint("RecyclerView") int position) {
// 从数据列表中获取当前位置的数据
CultrualData Cul = CuList.get(position);
//第二步
// 将数据设置到ViewHolder对象的textView中
// holder.textView.setText(fruit.getName());//fruit.getImageId()
holder.imageview.setBackgroundResource(Cul.getImageId());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getContext(),
""+CuList.get(position),
Toast.LENGTH_LONG).show();
}
});
}
@Override
public int getItemCount() {
return CuList.size();
}
}
class MyViewHoder extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageview;
public MyViewHoder(@NonNull View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.fruit_name);
imageview = itemView.findViewById(R.id.fruit_image);
}
}
}

@ -0,0 +1,92 @@
package com.example.final_project_app.Fragment;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.example.final_project_app.AboutUsActivity;
import com.example.final_project_app.Helpctivity;
import com.example.final_project_app.R;
import com.example.final_project_app.login;
public class FourFragment extends FirstFragment {
private RelativeLayout quite,aboutus,help;
private TextView username,userpwd;
SharedPreferences sp1;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fg_four,container,false);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//获取用户名和密码控件
username = getActivity().findViewById(R.id.username);
userpwd = getActivity().findViewById(R.id.userpwd);
//获取退出控件
quite = getActivity().findViewById(R.id.re_quite);
//退出点击事件
quite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("提示");
builder.setMessage("是否确定退出");
builder.setIcon(R.drawable.back_home0);
//确定
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(getActivity(), login.class);
startActivity(intent);
}
});
//取消
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss(); //关闭提示框
}
});
//生成提示框并显示
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
});
//关于我们点击事件
aboutus = getActivity().findViewById(R.id.re_aboutus);
aboutus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), AboutUsActivity.class);
startActivity(intent);
}
});
//帮助与反馈
help = getActivity().findViewById(R.id.re_help);
help.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), Helpctivity.class);
startActivity(intent);
}
});
}
}

@ -0,0 +1,99 @@
package com.example.final_project_app.Fragment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.R;
import com.example.final_project_app.adpter.NoteRecyAdapter;
import com.example.final_project_app.QuestionActivity;
import com.example.final_project_app.db.NoteBook;
import com.example.final_project_app.db.NoteData;
import com.example.final_project_app.sql.AddNoteActivity;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ThreeFragment extends FirstFragment {
private Button btn_add,btn_awser;
private NoteBook nb;
private RecyclerView recy;
private List<NoteData> datas;
private NoteRecyAdapter mAdapter;
@SuppressLint("MissingInflatedId")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fg_three, container, false);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//初始化数据
initdata();
//获取控件
recy = getActivity().findViewById(R.id.recy);
mAdapter = new com.example.final_project_app.adpter.NoteRecyAdapter(datas,getContext());
LinearLayoutManager lm = new LinearLayoutManager(getContext());
recy.setAdapter(mAdapter);
recy.setLayoutManager(lm);
//添加按钮
btn_add = getActivity().findViewById(R.id.btn_add);
btn_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), AddNoteActivity.class);
startActivity(intent);
}
});
btn_awser = getActivity().findViewById(R.id.btn_awser);
btn_awser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), QuestionActivity.class);
startActivity(intent);
}
});
}
@Override
public void onResume() {
super.onResume();
refreshData();
mAdapter.refresh(datas);
}
private void refreshData() {
datas = getDataFromSQL();
}
private void initdata() {
datas = new ArrayList<NoteData>();
nb = new NoteBook(getContext());
datas = getDataFromSQL();
}
private List<NoteData> getDataFromSQL() {
return nb.query();
}
private String getSystemCurrentTime() {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
Date datetime = new Date();
return sdf.format(datetime);
}
}

@ -0,0 +1,62 @@
package com.example.final_project_app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.example.final_project_app.R;
import com.example.final_project_app.adpter.MovieAdapter;
import com.example.final_project_app.db.Movie;
import java.util.ArrayList;
import java.util.List;
public class TwoFragment extends FirstFragment{
RecyclerView recyclerView;
List<Movie> movieList;
MovieAdapter movieAdapter;
private static final String TAG="MovieActivity";
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fg_two,container,false);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
recyclerView = getActivity().findViewById(R.id.fg_tworecyclerview);
initData();
}
private void initData() {
//建立动态数组存放数据
movieList = new ArrayList<>();
//获取网络视频
/* Movie firstmovie = new Movie("kkkkk1", "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4");
movieList.add(firstmovie);
/* //获取本工程中的视频*/
Movie one=new Movie("形式如何?适合自己才是王道","android.resource://"+getActivity().getPackageName()+"/"+R.raw.one);
movieList.add(one);
Movie two=new Movie("考研or考公如何抉择","android.resource://"+ getActivity().getPackageName()+"/"+R.raw.two);
movieList.add(two);
Movie three=new Movie("考研流程一览","android.resource://"+ getActivity().getPackageName()+"/"+R.raw.three);
movieList.add(three);
Movie four=new Movie("NEW1","android.resource://"+ getActivity().getPackageName()+"/"+R.raw.kaogongone);
movieList.add(four);
Movie five=new Movie("NEW2","android.resource://"+ getActivity().getPackageName()+"/"+R.raw.one);
movieList.add(five);
Movie six=new Movie("NEW3","android.resource://"+ getActivity().getPackageName()+"/"+R.raw.two);
movieList.add(six);
//将视频显示在控件上
movieAdapter = new MovieAdapter(movieList);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(movieAdapter);
}
}

@ -0,0 +1,60 @@
package com.example.final_project_app.Goods;
public class Goods {
private int goodsId;
private String goodsName;
private String goodsNotice;
// private int goodsPrice;
private int goodsImg;
public Goods() {
}
public Goods(String goodsName, String goodsNotice, int goodPrice, int goodsImg) {
this.goodsName = goodsName;
this.goodsNotice = goodsNotice;
// this.goodsPrice = goodPrice;
this.goodsImg = goodsImg;
}
public int getGoodsId() {
return goodsId;
}
public void setGoodsId(int goodsId) {
this.goodsId = goodsId;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getGoodsNotice() {
return goodsNotice;
}
public void setGoodsNotice(String goodsNotice) {
this.goodsNotice = goodsNotice;
}
// public int getGoodPrice() {
// return goodsPrice;
// }
// public void setGoodPrice(int goodPrice) {
// this.goodsPrice = goodPrice;
// }
public int getGoodsImg() {
return goodsImg;
}
public void setGoodsImg(int goodsImg) {
this.goodsImg = goodsImg;
}
}

@ -0,0 +1,55 @@
package com.example.final_project_app.Goods;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.final_project_app.R;
import java.util.ArrayList;
import java.util.List;
public class GoodsActivity extends AppCompatActivity {
private ImageView imageView;
private TextView goodsPrice,goodsName,goodsNotice;
private List<Goods> goodsList = new ArrayList<>();
private Goods goods;
private Button gom;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_goods);
imageView = findViewById(R.id.img);
goodsName = findViewById(R.id.name);
// goodsPrice = findViewById(R.id.price);
goodsNotice = findViewById(R.id.notice);
Intent intent = getIntent();
int goodsId = intent.getIntExtra("goodsId",0);
GoodsData goodsData = new GoodsData(GoodsActivity.this);
goodsList = goodsData.getGoodsList();
goods = goodsList.get(goodsId);
imageView.setImageResource(goods.getGoodsImg());
goodsName.setText(goods.getGoodsName());
// goodsPrice.setText("¥"+String.valueOf(goods.getGoodPrice())+"元");
goodsNotice.setText(goods.getGoodsNotice());
// gom = (Button) findViewById(R.id.gm);
// gom.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Intent intent = new Intent(GoodsActivity.this, plActivity.class);
// startActivity(intent);
// }
// });
}
}

@ -0,0 +1,72 @@
package com.example.final_project_app.Goods;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.R;
import java.util.List;
public class GoodsAdapter extends RecyclerView.Adapter<GoodsAdapter.ViewHolderR>{
private List<Goods> mGoodsList;
public GoodsAdapter(List<Goods> mGoodsList) {
this.mGoodsList = mGoodsList;
}
@NonNull
@Override
public ViewHolderR onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.goods_item,parent,false);
final ViewHolderR holderR = new ViewHolderR(view);
/*RecyclerView子项点击事件携带商品id跳转至商品详情页*/
holderR.goodsView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(),GoodsActivity.class);
intent.putExtra("goodsId",holderR.getAdapterPosition());
view.getContext().startActivity(intent);
}
});
return holderR;
}
@Override
public void onBindViewHolder(@NonNull ViewHolderR holder, int position) {
Goods goods = mGoodsList.get(position);
holder.goodsImage.setImageResource(goods.getGoodsImg());
holder.goodsNotice.setText("热门");
holder.goodsName.setText(goods.getGoodsName());
holder.goodsNotice.setText(goods.getGoodsNotice());
}
@Override
public int getItemCount() {
return mGoodsList.size();
}
static class ViewHolderR extends RecyclerView.ViewHolder{
View goodsView;
ImageView goodsImage;
TextView goodsPrice,goodsName,goodsNotice;
public ViewHolderR(@NonNull View itemView) {
super(itemView);
goodsView = itemView;
goodsImage = itemView.findViewById(R.id.goods_img);
// goodsPrice = itemView.findViewById(R.id.goods_price);
goodsName = itemView.findViewById(R.id.goods_name);
goodsNotice = itemView.findViewById(R.id.goods_notice);
}
}
}

@ -0,0 +1,101 @@
package com.example.final_project_app.Goods;
import android.content.Context;
import com.example.final_project_app.R;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class GoodsData {
private List<Goods> goodsList= new ArrayList<>();
// private String[] data_name= {"惊悚:我只卖凶宅","霸道总裁爱上我",
// "心理罪:十宗罪","阴间神探","六年后,大小姐带着系统杀回来了"
// ,"13路末班车","恐怖酒馆:我只养大凶之物","向盛夏"
// ,"许你年年岁岁好","揉碎温柔"};
private Context context;
public GoodsData(Context context) {
this.context = context;
}
public List<Goods> getGoodsList(){
initGoodsList();
return goodsList;
}
/*初始化商品数据列表*/
private void initGoodsList() {
Goods top1 = new Goods("2023年全国教育事业发展基本情况",getNotice
("2023年是全面贯彻党的二十大精神开局之年是实施“十四五”规划承上启下习贯彻习近平总书记关于教育的重要论述" +
"贯彻落实党的二十大精神,牢牢把握教育的政治属性、战略属性和民生属性,锚定教育强国建设目标,扎实推动教育事业高质量发展取得新突破。")
,getPrice(), R.drawable.sy1);
goodsList.add(top1);
Goods top2 = new Goods("2024年国家助学贷款免息及本金延期偿还如何操作",getNotice
("官方解读:为贯彻落实国务院常务会议决策部署,财政部、教育部、中国人民银行、金融监管总局认真研究," +
"报经国务院同意决定2024年延续实施国家助学贷款免息及本金延期偿还政策。本次措施的出台预计减免利息24.4亿元," +
"惠及约550万名高校毕业生有助于缓解贷款学生经济压力和就业压力帮助学生维护个人信用记录促进其顺利就业。")
,getPrice(),R.drawable.sy2);
goodsList.add(top2);
Goods top3 = new Goods("快讯2024年研考国家线发布",getNotice
("近日教育部部署2024年全国硕士研究生招生复试录取工作要求各地各招生单位以习近平新时代中国特色社会主义思想为指导" +
"深入贯彻党的二十大精神,全面贯彻党的教育方针,落实立德树人根本任务,坚持综合评价、择优录取,严格执行政策,严守工作纪律," +
"规范录取行为优化考生服务确保2024年硕士研究生复试录取工作公平、公正、科学。教育部要求招生单位加强招生信息公开" +
"提前在本单位招生网站和“中国研究生招生信息网”上发布本单位复试、调剂、录取工作办法,及时、准确做好政策宣传解读、咨询答复。")
,getPrice(),R.drawable.sy3);
goodsList.add(top3);
Goods top4 = new Goods("2024年第三届研究生招生与培养高峰论坛在成都举办",getNotice
("5月16日2024年第三届研究生招生与培养高峰论坛在成都举行。本次论坛以“乘势而上攀高向强”为主题旨在为各地区高校、科研院所提供优质交流平台" +
"共话新时代背景下研究生招生与培养新课题,探讨研究生教育高质量发展之路以及高层次人才选拔培养之道。")
,getPrice(),R.drawable.sy4);
goodsList.add(top4);
Goods top5 = new Goods("2024国考公告已出中央机关及其直属机构2024年度考试录用公务员公告",getNotice
("提交报考申请。报考者可于2023年10月15日8:00至10月24日18:00期间登录专题网站进行报名并提交报考申请" +
"每次只能选报1个职位。报名时应当仔细阅读诚信承诺书提交的报考申请材料应当真实、准确、完整。招录机关于2023年10月15日8:00至10月26日18:00期间" +
"对报考申请进行审查,确认报考者是否具有报考资格。报考者可登录专题网站查询资格审查结果。" +
"通过资格审查的不能再报考其他职位。2023年10月15日8:00至10月24日18:00期间报考申请未审查或者未通过资格审查的可以改报其他职位。")
,getPrice(),R.drawable.sy5);
goodsList.add(top5);
Goods top6 = new Goods("国家公务员考试政审流程是怎样的?需要哪些材料?",getNotice
("1、审核资料阶段2、查阅人事档案阶段3、座谈阶段4、组织部终审 等到以上三个阶段的考察完毕后,考察组根据考生的回答及表现书写考察报告," +
"然后会把这份考察报告会跟考生提交的资料,共同上交给组织部来做最后的审核,审核结果公布时间以考察组的公示为准。")
,getPrice(),R.drawable.sy6);
goodsList.add(top6);
Goods top7 = new Goods("2024国家公务员笔试时间定于11月25日至26日",getNotice
("公共科目包括行政职业能力测验和申论两科。其中行政职业能力测验为客观性试题申论为主观性试题满分均为100分" +
"详见《中央机关及其直属机构2024年度考试录用公务员公共科目笔试考试大纲》。公共科目笔试试卷分为3类分别适用于中央机" +
"关及其省级直属机构综合管理类职位、市(地)级及以下直属机构综合管理类职位和行政执法类职位。所有报考者均需参加公共科目笔试。")
,getPrice(),R.drawable.sy7);
goodsList.add(top7);
Goods top8 = new Goods("公务员考试是什么时候,公务员考试国考和省考的区别",getNotice
("时间在每年11月的第四个中央、国家机关公务员招考每年一次省、直辖市、自治区由各地自行决定并组织实施" +
"部分地区每年在上、下半年各组织一次考试,全国大部分地区每年只考一次,省级以下公务员主管部门不组织开展公务员考试。" +
"国考题目难度要相对大于省考,编制和福利待遇不同:通过省考和国考录用的公务员均属于“国家公务员”,均按照《公务员法》和同一套制" +
"度管理录用后也有统一的薪酬体系但因地域范围、部门(行业)类别及单位层级不同薪酬及晋升空间会有所差异。")
,getPrice(),R.drawable.sy8);
goodsList.add(top8);
}
/*商品描述模拟数据*/
private String getNotice(String name) {
Random random = new Random();//创建Random对象生成随机数
int length = random.nextInt(5)+1;
//使用nextInt方法生成一个0到4的随机整数加1最终结果是一个1到5的随机整数。存储在变量length中。
StringBuilder builder = new StringBuilder();
//创建StringBuilder对象构建和修改字符串
for (int i = 0;i<length;i++) {
builder.append(name);
}
return builder.toString();
}
/*商品价格模拟数据*/
private int getPrice() {
Random random = new Random();
int price = random.nextInt(50)+1;
return price;
}
}

@ -0,0 +1,50 @@
package com.example.final_project_app;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.os.CountDownTimer;
import androidx.appcompat.app.AppCompatActivity;
public class Hello_GudieActivity extends AppCompatActivity {
public TextView djs;
private android.os.CountDownTimer countDownTimer;
private long timeLeftInMillis =6000;
private boolean CountDownTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_gudie);
djs = findViewById(R.id.djs);
//启动倒计时
startCountdown();
}
private void startCountdown() {
countDownTimer =new CountDownTimer(timeLeftInMillis,1000) {
@Override
public void onTick(long millisUntilFinished) {
timeLeftInMillis = millisUntilFinished;
int secondsRemaining = (int) (millisUntilFinished / 1000);
djs.setText(secondsRemaining +" s");
}
@Override
public void onFinish() {
//跳转界面
startActivity(new Intent(Hello_GudieActivity.this,login.class));
// 倒计时结束后跳转到哪个界面
finish();
}
}.start();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (countDownTimer != null){
countDownTimer.cancel();
}
}
}

@ -0,0 +1,25 @@
package com.example.final_project_app;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class Helpctivity extends AppCompatActivity {
private Button btn_sure;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_helpctivity);
btn_sure = findViewById(R.id.btn_sure);
btn_sure.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(Helpctivity.this, "反馈成功", Toast.LENGTH_SHORT).show();
}
});
}
}

@ -0,0 +1,123 @@
package com.example.final_project_app;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;
import com.example.final_project_app.Fragment.FirstFragment;
import com.example.final_project_app.Fragment.FourFragment;
import com.example.final_project_app.Fragment.ThreeFragment;
import com.example.final_project_app.Fragment.TwoFragment;
import com.example.final_project_app.adpter.MyFragmentPaperAdapter;
public class MainActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener{
private FrameLayout fg_main;
private FragmentManager fm;
private ViewPager vp;
public static final int PAGE_ONE = 0;
public static final int PAGE_TWO = 1;
public static final int PAGE_THREE = 2;
public static final int PAGE_FOUR = 3;
public static final int PAGE_Five = 4;
private MyFragmentPaperAdapter mPaperAdapter;
private TextView tv1;
private TextView tv2;
private TextView tv3;
private TextView tv4;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fg_main = (FrameLayout) findViewById(R.id.fg_main);
vp = (ViewPager) findViewById(R.id.vp);
tv1 = (TextView) findViewById(R.id.tv_one);
tv2 = (TextView) findViewById(R.id.tv_two);
tv3 = (TextView) findViewById(R.id.tv_three);
tv4 = (TextView) findViewById(R.id.tv_four);
mPaperAdapter = new MyFragmentPaperAdapter(getSupportFragmentManager());
vp.setAdapter(mPaperAdapter);
vp.setCurrentItem(0);
vp.addOnPageChangeListener((ViewPager.OnPageChangeListener) this);
}
//MYClick点击事件
public void MyClick(View view){
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
//创建页面类对象
FirstFragment page1 = new FirstFragment();
TwoFragment page2 = new TwoFragment();
ThreeFragment page3 = new ThreeFragment();
FourFragment page4 = new FourFragment();
//点击页面替换
if (view.getId()== R.id.tv_one){
// ft.replace(R.id.fg_main,page1);
vp.setCurrentItem(PAGE_ONE);
}else if (view.getId()==R.id.tv_two){
//ft.replace(R.id.fg_main,page2);
vp.setCurrentItem(PAGE_TWO);
}else if (view.getId()==R.id.tv_three) {
// ft.replace(R.id.fg_main, page3);
vp.setCurrentItem(PAGE_THREE);
}else if (view.getId()==R.id.tv_four) {
//ft.replace(R.id.fg_main, page4);
vp.setCurrentItem(PAGE_FOUR);
}
ft.commit();
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
//滑动切换判断事件
@Override
public void onPageScrollStateChanged(int state) {
if (state==2){
switch (vp.getCurrentItem()){
case PAGE_ONE:
tv1.setSelected(true);
//tv1.setBackgroundColor(R.color.black);
break;
case PAGE_TWO:
tv2.setSelected(true);
break;
case PAGE_THREE:
tv3.setSelected(true);
break;
case PAGE_FOUR:
tv4.setSelected(true);
break;
}
}
}
}

@ -0,0 +1,50 @@
package com.example.final_project_app;
import static com.example.final_project_app.db.PermissionUtiils.verifyStoragePermissions;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.appcompat.app.AppCompatActivity;
public class PlayActivity extends AppCompatActivity {
private TextView tvvedioname;
private VideoView videoView;
//媒体控制器
private MediaController mediaController;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play);
tvvedioname= findViewById(R.id.tvmovename);
videoView=findViewById(R.id.vvmovie);
mediaController=new MediaController(this);
initData();
verifyStoragePermissions(this);
}
private void initData() {
//获取从列表传过来的视频名称和地址
String videoname=getIntent().getStringExtra("my");
String videouri=getIntent().getStringExtra("movieurl");
//String videourl= Environment.getExternalStorageDirectory().getAbsolutePath()+"/jay.mp4";
//Log.i("PlayActivity","videourl="+videourl);
//将视频名称显示在文本框中,将视频地址关联到播放器中
tvvedioname.setText(videoname);
videoView.setVideoPath(videouri);
//videoView.setVideoPath(videourl);
//将视频播放器和媒体控制柄关联起来
videoView.setMediaController(mediaController);
//媒体控制柄和视频播放器关联起来
mediaController.setMediaPlayer(videoView);
//启动视频播放器播放视频
videoView.start();
}
}

@ -0,0 +1,49 @@
package com.example.final_project_app;
public class Question {
private String questionStem;//题干
private String[] options;//选项
private String correctOptions;//正确选项的下标从0开始
private int questionTypes;//1 为单选题, 2为多选题
public Question(String questionStem, String[] options, String correctOptions, int questionTypes) {
this.questionStem = questionStem;
this.options = options;
this.correctOptions = correctOptions;
this.questionTypes = questionTypes;
}
public Question() {
}
public String getQuestionStem() {
return questionStem;
}
public void setQuestionStem(String questionStem) {
this.questionStem = questionStem;
}
public String[] getOptions() {
return options;
}
public void setOptions(String[] options) {
this.options = options;
}
public String getCorrectOptions() {
return correctOptions;
}
public void setCorrectOptions(String correctOptions) {
this.correctOptions = correctOptions;
}
public int getQuestionTypes() {
return questionTypes;
}
public void setQuestionTypes(int questionTypes) {
this.questionTypes = questionTypes;
}
}

@ -0,0 +1,210 @@
package com.example.final_project_app;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import java.util.ArrayList;
import java.util.List;
public class QuestionActivity extends AppCompatActivity {
private int score=0;//答题分数
private final List<Question> questions=new ArrayList<>();//题目集合
private int i=0;//当前题号
private int previousType;//上一题题目类型单选为1多选为2
private int result;//答题结果正确为1错误为0未答题为2
private Button button;//提交按钮
private RadioButtonFragment radioButtonFragment;//单选按钮对象
private ChexBoxFragment chexBoxFragment;
private TextView time;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question);
//初始化题目
initQuestions();
//初始化控件
initView();
//根据题形加载第一题
Question question=questions.get(0);
Log.e("question", "可以获取题目");
if (question.getQuestionTypes()==1){
//给出题目的类型
radioButtonFragment.setQuestion(question);
replaceFragment(radioButtonFragment);
previousType=1;//当前题型为1为单选题
}else {
chexBoxFragment.setQuestion(question);
replaceFragment(chexBoxFragment);
previousType=2;//当前题型为2为多选题
}
}
CountDownTimer countDownTimer=new CountDownTimer(120000, 1000) {
public void onTick(long millisUntilFinished) {
time.setText("剩余时间 " + millisUntilFinished / 1000+"s");
}
public void onFinish() {
time.setText("时间到!");
}
}.start();
//替换fragment方法
private void replaceFragment(Fragment Fragment) {
FragmentManager manager=getSupportFragmentManager();
FragmentTransaction transaction=manager.beginTransaction();
transaction.replace(R.id.fragment1,Fragment);
transaction.commit();
}
public void initQuestions(){
Log.e("信息更新", "执行了");
Question question=new Question();
//题干
question.setQuestionStem("1、下列描写思念的成语与其所适用的思念对象对应不正确的是");
//选项
question.setOptions(new String[]{"A莼鲈之思——故乡","B蒹葭之思——恋人","C霜露之思——兄弟","D云树之思——朋友"});
//正确的答案
question.setCorrectOptions("2");
//题目类型
question.setQuestionTypes(1);
//把题目添加到集合中
questions.add(question);
Question question2=new Question();
//题干
question2.setQuestionStem("2、“二十四节气”鲜明地体现了中国人尊重自然、顺应自然规律和可持续发展的理念。下列关于“二十四节气”的说法正确的是");
//选项
question2.setOptions(new String[]{"A起源于长江流域是我国农历的重要组成部分","B立夏时北半球的白昼时间最长且越往北越长","C是通过观察地球周年运动形成的时间知识体系","D春分日太阳直射地球赤道南北半球昼夜平分"});
//正确的答案
question2.setCorrectOptions("3");
//题目类型
question2.setQuestionTypes(1);
//把题目添加到集合中
questions.add(question2);
Question question3=new Question();
//题干
question3.setQuestionStem("3、根据我国法律敏感个人信息是一旦泄露或者非法使用容易导致自然人的人格尊严受到侵害或者人身、财产安全受到危害的个人信息。以下不属于敏感个人信息的是:");
//选项css
question3.setOptions(new String[]{"A人脸特征","B从业经历","C医疗健康","D行踪轨迹"});
//正确的答案
question3.setCorrectOptions("1");
//题目类型
question3.setQuestionTypes(1);
//把题目添加到集合中
questions.add(question3);
Question question4=new Question();
//题干
question4.setQuestionStem("4、在马克思主义哲学中关于社会存在和社会意识的关系以下哪些描述是正确的");
//选项
question4.setOptions(new String[]{"A. 社会存在决定社会意识。","B. 社会意识具有相对独立性,可以反作用于社会存在。","C. 社会意识总是与社会存在完全同步。","D. 社会意识的发展具有历史继承性。","E. 社会意识的发展不具有历史继承性。\n"});
//正确的答案
question4.setCorrectOptions("0,1,3");
//题目类型
question4.setQuestionTypes(2);
//把题目添加到集合中
questions.add(question4);
Question question5=new Question();
//题干
question5.setQuestionStem("5、马克思在《资本论》中指出资本主义经济的直接目的是追求什么");
//选项
question5.setOptions(new String[]{"A. 提高生产效率","B. 增加就业机会","C. 实现社会公平","D. 获得剩余价值"});
//正确的答案
question5.setCorrectOptions("3");
//题目类型
question5.setQuestionTypes(1);
//把题目添加到集合中
questions.add(question5);
}
public void initView(){
//找到对应控件
button=findViewById(R.id.submit);
radioButtonFragment=new RadioButtonFragment();
chexBoxFragment=new ChexBoxFragment();
time=findViewById(R.id.time);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//如果是提交按钮根据当前题目类型调用getResult
if(button.getText().equals("提交")){
if(questions.get(i).getQuestionTypes()==1){
result=radioButtonFragment.getResult(questions.get(i));
}else {
result=chexBoxFragment.getResult(questions.get(i));
}
//如果答对了就+1分
if(result==1){
score++;
}
//如果不是第五题,就改文本为下一题,如果是第五题,就修改文本为结束
if(i==4){
button.setText("结束");
}else if(result!=-1){
button.setText("下一题");
}
}else {
//如果是下一题按钮,题号增加,判断你是否已经答题完成
i++;
if(i<questions.size()){
//根据上一题类型选择是否替换fragment
if(questions.get(i).getQuestionTypes()==1){
if (previousType!=1){
chexBoxFragment.clearChoice();
radioButtonFragment.setQuestion(questions.get(i));
replaceFragment(radioButtonFragment);
previousType=1;
}else {
radioButtonFragment.nextQuestion(questions.get(i));
}
}else {
if(previousType!=2){
radioButtonFragment.clear();
chexBoxFragment.setQuestion(questions.get(i));
replaceFragment(chexBoxFragment);
previousType=2;
}else {
chexBoxFragment.nextQuestion(questions.get(i));
}
}
button.setText("提交");
}else {
showDialog();
button.setVisibility(View.INVISIBLE);
}
}
}
});
}
//显示答题结束的页面
private void showDialog(){
AlertDialog.Builder builder=new AlertDialog.Builder(QuestionActivity.this);
builder.setTitle("提示");
builder.setMessage("答题结束得分"+score);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent=new Intent(QuestionActivity.this,QuestionActivity.class);
startActivity(intent);
}
});
builder.create().show();
}
}

@ -0,0 +1,112 @@
package com.example.final_project_app;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
public class RadioButtonFragment extends Fragment {
//成员变量
private TextView question_stem;//题干文本框控件,就是选中的控件显示
private RadioGroup radioGroup;
private RadioButton [] rb =new RadioButton[4];
private Question question;//题目对象就是标题,单选多选,正确下标
private int result;//正确为1 错误为0 未答题为-1
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.e("单选onCreateView","单选onCreateView执行了");
View view=inflater.inflate(R.layout.fragment_radio_button, container, false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Log.e("单选onViewCreated","单选onViewCreated执行了");
//初始化控件
initView(view);
//更新题目
nextQuestion(question);
}
//获取题目
public void setQuestion(Question question){
this.question=question;
}
//初始化控件
public void initView(final View view){
Log.e("单选initView","单选initView执行了");
//获取题干
question_stem=view.findViewById(R.id.question_item);
radioGroup=view.findViewById(R.id.radiogroup);
//单选控件
rb[0]=view.findViewById(R.id.radio1);
rb[1]=view.findViewById(R.id.radio2);
rb[2]=view.findViewById(R.id.radio3);
rb[3]=view.findViewById(R.id.radio4);
}
//清空原来选项
public void clear(){
radioGroup.clearCheck();
}
//更新题目
public void nextQuestion(Question question){
Log.e("单选nextQuestion","单选nextQuestion执行了");
clear();
//设置题干
question_stem.setText(question.getQuestionStem());
//设置选项
for (int i=0;i<rb.length;i++){
//所有选项初始都未选中
rb[i].setChecked(false);
//设置选项内容
rb[i].setText(question.getOptions()[i]);
//设置背景颜色
rb[i].setBackgroundResource(R.drawable.select_button_text);
//设置字体颜色
rb[i].setTextColor(getResources().getColor(R.color.black));
}
}
//判断选择结果
public int getResult(Question question){
//正确的id下标
int correctIndex=Integer.parseInt(question.getCorrectOptions());
int correctId=rb[correctIndex].getId();
//当前选中的id
int radioId=radioGroup.getCheckedRadioButtonId();
if(radioId==-1){
Toast.makeText(getContext(), "请选择你的选项", Toast.LENGTH_SHORT).show();
result=-1;
}else {
for(int i=0;i< rb.length;i++){
rb[i].setBackgroundResource(R.drawable.shape_radiobutton2);
}
if (radioId==correctId){
Toast.makeText(getContext(), "回答正确", Toast.LENGTH_SHORT).show();
result=1;
}else {
//答案错误背景和字体变对应的颜色
RadioButton radioButton=getView().findViewById(radioId);
radioButton.setBackgroundResource(R.drawable.shape_error_answer);
radioButton.setTextColor(getResources().getColor(R.color.black));
result=0;
}
//无论正确还是错误,正确的答案都显示出来
rb[correctIndex].setBackgroundResource(R.drawable.shape_success_answer);
rb[correctIndex].setTextColor(getResources().getColor(R.color.black));
}
return result;
}
}

@ -0,0 +1,48 @@
package com.example.final_project_app.adpter;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.db.bannerBean;
import com.youth.banner.adapter.BannerAdapter;
import java.util.List;
public class BannerViewAdapter extends BannerAdapter<bannerBean, BannerViewAdapter.BannerViewHodler>{
private Fragment fragment;
public BannerViewAdapter(List<bannerBean> datas,Fragment fragment) {
super(datas);
this.fragment = fragment;
}
@Override
public BannerViewAdapter.BannerViewHodler onCreateHolder(ViewGroup parent, int viewType) {
ImageView imageView = new ImageView(parent.getContext());
imageView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
));
//setScaleType对图片进行大小处理 CENTER_CROP对原图居中显示后进行等比放缩处理使最小边等于ImageView的相应边
imageView.setScaleType(ImageView.ScaleType.CENTER);
return new BannerViewHodler(imageView);
}
//绑定图片资源文件
@Override
public void onBindView(BannerViewAdapter.BannerViewHodler holder, bannerBean data, int position, int size) {
holder.imageView.setImageResource(data.picture);
}
//ViewHolder主要用于容纳view视图
public class BannerViewHodler extends RecyclerView.ViewHolder {
ImageView imageView;
public BannerViewHodler(@NonNull ImageView itemView) {
super(itemView);
this.imageView = itemView;
}
}
}

@ -0,0 +1,69 @@
package com.example.final_project_app.adpter;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.PlayActivity;
import com.example.final_project_app.R;
import com.example.final_project_app.db.Movie;
import java.util.List;
public class MovieAdapter extends RecyclerView.Adapter<MovieAdapter.ViewHolder> {
List<Movie> mymovieList;
public class ViewHolder extends RecyclerView.ViewHolder {
View movieview;
TextView moviename;
public ViewHolder(@NonNull View view) {
super(view);
moviename = itemView.findViewById(R.id.moviename);
movieview = view;
}
}
//利用适配器的构造函数传入要展示的数据
public MovieAdapter(List<Movie> mymovieList){
this.mymovieList=mymovieList;
}
//创建实例把每一行的布局加载进来创建一个ViewHolder实例将布局传入到构造函数中最后将实例返回
public MovieAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.movie_item,parent,false);
final ViewHolder holder=new ViewHolder(view);
//单击任意视频跳转到播放界面
holder.movieview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//获取位置
int position=holder.getAdapterPosition();
Movie movie=mymovieList.get(position);
//获取movie中的名字
String mymoviename=movie.getMoviename();
//获取视频播放地址
String mymovievideo=movie.getMovieuri();
//获取播放视频的位置后跳转到播放页
Intent intent=new Intent(view.getContext(),PlayActivity.class);
//然后根据位置传递信息
intent.putExtra("my",mymoviename);
intent.putExtra("movieurl",mymovievideo);
view.getContext().startActivity(intent);
}
});
return holder;
}
//对recyclerview中子项目进行赋值通过位置得到当前的实例然后电影名和视频显示在控件上
public void onBindViewHolder(@NonNull MovieAdapter.ViewHolder holder,int position){
Movie movie=mymovieList.get(position);
holder.moviename.setText(movie.getMoviename());
}
public int getItemCount(){
return mymovieList.size();
}
}

@ -0,0 +1,59 @@
package com.example.final_project_app.adpter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import com.example.final_project_app.Fragment.FirstFragment;
import com.example.final_project_app.Fragment.FourFragment;
import com.example.final_project_app.Fragment.ThreeFragment;
import com.example.final_project_app.Fragment.TwoFragment;
import com.example.final_project_app.MainActivity;
public class MyFragmentPaperAdapter extends FragmentPagerAdapter {
private final FirstFragment b1;
private final TwoFragment b2;
private final ThreeFragment b3;
private final FourFragment b4;
private int PAGE = 4;
public MyFragmentPaperAdapter(@NonNull FragmentManager fm) {
super(fm);
b1 = new FirstFragment();
b2 = new TwoFragment();
b3 = new ThreeFragment();
b4 = new FourFragment();
}
@NonNull
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
switch (position){
case MainActivity.PAGE_ONE:
fragment = b1;
break;
case MainActivity.PAGE_TWO:
fragment = b2;
break;
case MainActivity.PAGE_THREE:
fragment = b3;
break;
case MainActivity.PAGE_FOUR:
fragment = b4;
break;
}
return fragment;
}
@Override
public int getCount() {
return PAGE;
}
}

@ -0,0 +1,121 @@
package com.example.final_project_app.adpter;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.final_project_app.R;
import com.example.final_project_app.db.NoteBook;
import com.example.final_project_app.db.NoteData;
import com.example.final_project_app.sql.UpdateNoteActivity;
import java.util.List;
public class NoteRecyAdapter extends RecyclerView.Adapter<NoteRecyAdapter.MyViewHolder> {
private List<NoteData> dataList;
private Context context;
private TextView tv_edit,tv_deledt;
public NoteRecyAdapter(List<NoteData> dataList, Context context) {
this.dataList = dataList;
this.context = context;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//加载布局
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.note_item_recy,parent,false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
NoteData data = dataList.get(position);
holder.tv_title.setText(data.getTitle());
holder.tv_time.setText(data.getTimee());
holder.tv_content.setText(data.getContent());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dg = new Dialog(context, android.R.style.ThemeOverlay_Material_Dialog_Alert);
View view = LayoutInflater.from(context).inflate(R.layout.note_dialog,null);
TextView tv_edit= view.findViewById(R.id.tv_edit);
TextView tv_delete = view.findViewById(R.id.tv_delete);
tv_edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, UpdateNoteActivity.class);//跳转到更新编辑页面
intent.putExtra("data_sql",data);
context.startActivity(intent);
}
});
tv_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//删除
NoteBook noteBook = new NoteBook(context);
int row = noteBook.deleteById(data);
if (row>0){
removeData(position);
Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(context, "删除失败", Toast.LENGTH_SHORT).show();
}
}
});
dg.setContentView(view);
dg.show();
}
});
}
//删除
private void removeData(int position) {
//从列表删除数据
dataList.remove(position);
notifyItemRemoved(position);
}
@Override
public int getItemCount() {
return dataList.size();
}
public void refresh(List<NoteData> datas) {
this.dataList = datas;
notifyDataSetChanged();
}
class MyViewHolder extends RecyclerView.ViewHolder{
private TextView tv_title;
private TextView tv_time;
private TextView tv_content;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
tv_title = (TextView) itemView.findViewById(R.id.tv_title);
tv_time = (TextView) itemView.findViewById(R.id.tv_time);
tv_content = (TextView) itemView.findViewById(R.id.tv_content);
}
}
}

@ -0,0 +1,163 @@
package com.example.final_project_app.dao;
import android.util.Log;
import com.example.final_project_app.entity.User;
import com.example.final_project_app.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
/**
* **/
public class UserDao {
private static final String TAG = "mysql-myapplication-UserDao";
/**
* function:
* */
public int login(String userAccount, String userPassword){
HashMap<String, Object> map = new HashMap<>();
// 根据数据库名称,建立连接
Connection connection = JDBCUtils.getConn();
int msg = 0;
try {
// mysql简单的查询语句。这里是根据user表的userAccount字段来查询某条记录
String sql = "select * from user where userAccount = ?";
if (connection != null){// connection不为null表示与数据库建立了连接
PreparedStatement ps = connection.prepareStatement(sql);
if (ps != null){
Log.e(TAG,"账号:" + userAccount);
//根据账号进行查询
ps.setString(1, userAccount);
// 执行sql查询语句并返回结果集
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
//将查到的内容储存在map里
while (rs.next()){
// 注意下标是从1开始的
for (int i = 1;i <= count;i++){
String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field));
}
}
connection.close();
ps.close();
if (map.size()!=0){
StringBuilder s = new StringBuilder();
//寻找密码是否匹配
for (String key : map.keySet()){
if(key.equals("userPassword")){
if(userPassword.equals(map.get(key))){
msg = 1; //密码正确
}
else
msg = 2; //密码错误
break;
}
}
}else {
Log.e(TAG, "查询结果为空");
msg = 3;
}
}else {
msg = 0;
}
}else {
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "异常login" + e.getMessage());
msg = 0;
}
return msg;
}
/**
* function:
* */
public boolean register(User user){
HashMap<String, Object> map = new HashMap<>();
// 根据数据库名称,建立连接
Connection connection = JDBCUtils.getConn();
try {
String sql = "insert into user(userAccount,userPassword,userName,userType,userState,userDel) values (?,?,?,?,?,?)";
if (connection != null){// connection不为null表示与数据库建立了连接
PreparedStatement ps = connection.prepareStatement(sql);
if (ps != null){
//将数据插入数据库
ps.setString(1,user.getUserAccount());
ps.setString(2,user.getUserPassword());
ps.setString(3,user.getUserName());
ps.setInt(4,user.getUserType());
ps.setInt(5, user.getUserState());
ps.setInt(6,user.getUserDel());
// 执行sql查询语句并返回结果集
int rs = ps.executeUpdate();
if(rs>0)
return true;
else
return false;
}else {
return false;
}
}else {
return false;
}
}catch (Exception e){
e.printStackTrace();
Log.e(TAG, "异常register" + e.getMessage());
return false;
}
}
/**
* function:
* */
public User findUser(String userAccount) {
// 根据数据库名称,建立连接
Connection connection = JDBCUtils.getConn();
User user = null;
try {
String sql = "select * from user where userAccount = ?";
if (connection != null){// connection不为null表示与数据库建立了连接
PreparedStatement ps = connection.prepareStatement(sql);
if (ps != null) {
ps.setString(1, userAccount);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
//注意下标是从1开始
int id = rs.getInt(1);
String userAccount1 = rs.getString(2);
String userPassword = rs.getString(3);
String userName = rs.getString(4);
int userType = rs.getInt(5);
int userState = rs.getInt(6);
int userDel = rs.getInt(7);
user = new User(id, userAccount1, userPassword, userName, userType, userState, userDel);
}
}
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "异常findUser" + e.getMessage());
return null;
}
return user;
}
}

@ -0,0 +1,30 @@
package com.example.final_project_app.db;
public class CultrualData {
private String name;
private int image;
public CultrualData() {
}
public CultrualData(String name, int imageId) {
this.name = name;
this.image = imageId;
}
@Override
public String toString() {
return "简介:" + name ;
}
public String getName() {
return name;
}
public int getImageId() {
return image;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,16 @@
package com.example.final_project_app.db;
public class Movie {
private String moviename;
private String movieuri;
public Movie(String moviename,String movieuri){
this.moviename=moviename;
this.movieuri=movieuri;
}
public String getMoviename(){
return moviename;
}
public String getMovieuri(){
return movieuri;
}
}

@ -0,0 +1,77 @@
package com.example.final_project_app.db;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;
public class NoteBook extends SQLiteOpenHelper {
private List<NoteData> dataList;
private static final String DB_NAME = "note.db";
private static final String TABLE_NAME = "notebook";
private static final String CREATE_TABLE = "create table "+
TABLE_NAME +" (id integer primary key autoincrement," +
"title text,timee text,content text)";
public NoteBook(Context context) {
super(context, DB_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
}
public long insert(NoteData dt){
SQLiteDatabase sd = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("title",dt.getTitle());
values.put("content",dt.getContent());
values.put("timee",dt.getTimee());
return sd.insert(TABLE_NAME,null,values);
}
public List<NoteData> query() {
List<NoteData> dtlist = new ArrayList<>();
SQLiteDatabase sd = getWritableDatabase();
Cursor cursor = sd.query(TABLE_NAME,null,null,null,null,null,null);
if (cursor!=null) {
while (cursor.moveToNext()){
@SuppressLint("Range") String title = cursor.getString(cursor.getColumnIndex("title"));
@SuppressLint("Range") String content = cursor.getString(cursor.getColumnIndex("content"));
@SuppressLint("Range") String timee = cursor.getString(cursor.getColumnIndex("timee"));
NoteData dt_sql = new NoteData();
dt_sql.setTitle(title);
dt_sql.setContent(content);
dt_sql.setTimee(timee);
dtlist.add(dt_sql);
}
cursor.close();
}
return dtlist;
}
//更新
public int updateByTitle(NoteData dt) {
SQLiteDatabase sd = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("content", dt.getContent());
return sd.update(TABLE_NAME, values, "title like ?", new String[]{dt.getTitle()});
}
//删除 //调用delete语句
public int deleteById(NoteData dt){
SQLiteDatabase sd = getWritableDatabase();
return sd.delete(TABLE_NAME,"title like ?",new String[]{dt.getTitle()});
}
}

@ -0,0 +1,57 @@
package com.example.final_project_app.db;
import java.io.Serializable;
public class NoteData implements Serializable {
private String title;
private String content;
private String timee;
private String id;
public NoteData(String title, String content) {
this.title = title;
this.content = content;
}
public NoteData() {
}
public NoteData(String title, String content, String time, String id) {
this.title = title;
this.content = content;
this.timee = time;
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTimee() {
return timee;
}
public void setTimee(String timee) {
this.timee = timee;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

@ -0,0 +1,27 @@
package com.example.final_project_app.db;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
public class PermissionUtiils {
//请求权限类
// Storage Permissions
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
public static void verifyStoragePermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
// We don't have permission so prompt the user
ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE);
}
}
}

@ -0,0 +1,17 @@
package com.example.final_project_app.db;
public class bannerBean {
public int picture;
public bannerBean(int picture) {
this.picture = picture;
}
public int getPicture() {
return picture;
}
public void setPicture(int picture) {
this.picture = picture;
}
}

@ -0,0 +1,84 @@
package com.example.final_project_app.entity;
public class User {
private int id;
private String userAccount;
private String userPassword;
private String userName;
private int userType;
private int userState;
private int userDel;
public User() {
}
public User(int id, String userAccount, String userPassword, String userName, int userType, int userState, int userDel) {
this.id = id;
this.userAccount = userAccount;
this.userPassword = userPassword;
this.userName = userName;
this.userType = userType;
this.userState = userState;
this.userDel = userDel;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserAccount() {
return userAccount;
}
public void setUserAccount(String userAccount) {
this.userAccount = userAccount;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getUserType() {
return userType;
}
public void setUserType(int userType) {
this.userType = userType;
}
public int getUserState() {
return userState;
}
public void setUserState(int userState) {
this.userState = userState;
}
public int getUserDel() {
return userDel;
}
public void setUserDel(int userDel) {
this.userDel = userDel;
}
}

@ -0,0 +1,69 @@
package com.example.final_project_app;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.final_project_app.dao.UserDao;
/**
* function
*/
public class login extends AppCompatActivity {
private static final String TAG = "mysql-myapplication-MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
public void reg(View view){
startActivity(new Intent(getApplicationContext(), register.class));
}
/**
* function:
* */
public void login(View view){
EditText EditTextAccount = findViewById(R.id.uesrAccount);
EditText EditTextPassword = findViewById(R.id.userPassword);
new Thread(){
@Override
public void run() {
UserDao userDao = new UserDao();
int msg = userDao.login(EditTextAccount.getText().toString(),EditTextPassword.getText().toString());
hand1.sendEmptyMessage(msg);
}
}.start();
}
@SuppressLint("HandlerLeak")
final Handler hand1 = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0){
Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_LONG).show();
} else if (msg.what == 1) {
Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_LONG).show();
startActivity(new Intent(login.this, MainActivity.class));
login.this.finish();
} else if (msg.what == 2){
Toast.makeText(getApplicationContext(), "密码错误", Toast.LENGTH_LONG).show();
} else if (msg.what == 3){
Toast.makeText(getApplicationContext(), "账号不存在", Toast.LENGTH_LONG).show();
}
}
};
}

@ -0,0 +1,93 @@
package com.example.final_project_app;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.final_project_app.dao.UserDao;
import com.example.final_project_app.entity.User;
/**
* function
*/
public class register extends AppCompatActivity {
private static final String TAG = "mysql-myapplication-register";
EditText userAccount = null;
EditText userPassword = null;
EditText userName = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_regist);
userAccount = findViewById(R.id.userAccount);
userPassword = findViewById(R.id.userPassword);
}
public void register(View view){
String userAccount1 = userAccount.getText().toString();
String userPassword1 = userPassword.getText().toString();
String userName1 = userName.getText().toString();
User user = new User();
user.setUserAccount(userAccount1);
user.setUserPassword(userPassword1);
user.setUserName(userName1);
user.setUserType(1);
user.setUserState(0);
user.setUserDel(0);
new Thread(){
@Override
public void run() {
int msg = 0;
UserDao userDao = new UserDao();
User uu = userDao.findUser(user.getUserAccount());
if(uu != null){
msg = 1;
}
else{
boolean flag = userDao.register(user);
if(flag){
msg = 2;
}
}
hand.sendEmptyMessage(msg);
}
}.start();
}
@SuppressLint("HandlerLeak")
final Handler hand = new Handler()
{
public void handleMessage(Message msg) {
if(msg.what == 0) {
Toast.makeText(getApplicationContext(),"注册失败",Toast.LENGTH_SHORT).show();
} else if(msg.what == 1) {
Toast.makeText(getApplicationContext(),"该账号已经存在,请换一个账号",Toast.LENGTH_SHORT).show();
} else if(msg.what == 2) {
Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_SHORT).show();
startActivity(new Intent(register.this, login.class));
register.this.finish();
Intent intent = new Intent();
//将想要传递的数据用putExtra封装在intent中
intent.putExtra("a","注册");
setResult(RESULT_CANCELED,intent);
finish();
}
}
};
}

@ -0,0 +1,53 @@
package com.example.final_project_app.sql;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.final_project_app.R;
import com.example.final_project_app.db.NoteBook;
import com.example.final_project_app.db.NoteData;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AddNoteActivity extends AppCompatActivity {
private NoteBook nb;
private EditText et_content,et_title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_note);
et_title= (EditText) findViewById(R.id.et_title);
et_content = (EditText) findViewById(R.id.et_content);
}
public void BtnAdd(View view) {
String title = et_title.getText().toString().trim();
String content = et_content.getText().toString().trim();
NoteData dt = new NoteData(title,content);
dt.setTimee(getSystemCurrentTime());
nb = new NoteBook(this);
long rowId = nb.insert(dt);
if (rowId!=-1) {
Toast.makeText(this, "添加成功", Toast.LENGTH_SHORT).show();
this.finish();
}else {
Toast.makeText(this, "添加失败", Toast.LENGTH_SHORT).show();
}
}
private String getSystemCurrentTime() {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
Date datetime = new Date();
return sdf.format(datetime);
}
}

@ -0,0 +1,63 @@
package com.example.final_project_app.sql;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.final_project_app.R;
import com.example.final_project_app.db.NoteBook;
import com.example.final_project_app.db.NoteData;
import java.text.SimpleDateFormat;
import java.util.Date;
public class UpdateNoteActivity extends AppCompatActivity {
private EditText et_content,et_title;
private NoteData dt_up;
private NoteBook nb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update_note);
//获取控件
et_title= (EditText) findViewById(R.id.et_title);
et_content = (EditText) findViewById(R.id.et_content);
//数据接收
Intent intent = getIntent();
dt_up = (NoteData) intent.getSerializableExtra("data_sql");
if (dt_up!=null){
et_title.setText(dt_up.getTitle());
et_content.setText(dt_up.getContent());
}
}
public void BtnUpdate(View view) {
String title = et_title.getText().toString().trim();
String content = et_content.getText().toString().trim();
NoteData dt = new NoteData(title,content);
dt.setTimee(getSystemCurrentTime());
nb = new NoteBook(this);
nb.updateByTitle(dt);
int row = nb.updateByTitle(dt);
if (row>0){
Toast.makeText(this, "更新成功", Toast.LENGTH_SHORT).show();
this.finish();
}else {
Toast.makeText(this, "更新失败", Toast.LENGTH_SHORT).show();
}
}
private String getSystemCurrentTime() {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
Date datetime = new Date();
return sdf.format(datetime);
}
}

@ -0,0 +1,35 @@
package com.example.final_project_app.utils;
import java.sql.Connection;
import java.sql.DriverManager;
/**
* function
*/
public class JDBCUtils {
private static final String TAG = "mysql-myapplication-JDBCUtils";
private static String driver = "com.mysql.jdbc.Driver";// MySql驱动
private static String dbName = "android_ruanjian";// 数据库名称
private static String user = "root";// 用户名
private static String password = "root";// 密码
public static Connection getConn(){
Connection connection = null;
try{
Class.forName(driver);// 动态加载类
String ip = "192.168.16.81";// 写成本机地址不能写成localhost同时手机和电脑连接的网络必须是同一个
// 尝试建立到给定数据库URL的连接
connection = DriverManager.getConnection("jdbc:mysql://" + ip + ":3306/" + dbName,
user, password);
}catch (Exception e){
e.printStackTrace();
}
return connection;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 按钮选中状态-->
<item android:state_checked="true" android:drawable="@drawable/shape_radiobutton"></item>
<!-- 按钮未选中状态-->
<item android:state_checked="false" android:drawable="@drawable/shape_radiobutton2"></item>
</selector>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save