Compare commits

..

1 Commits

Author SHA1 Message Date
pc4y93prn aa9e7109a9 ADD file via upload
2 years ago

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Binary file not shown.

@ -1,26 +0,0 @@
package com.example.hamburger;
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.hamburger", appContext.getPackageName());
}
}

@ -1,84 +0,0 @@
package com.example.hamburger;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
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.*;
import com.example.hamburger.dao.UserDao;
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.view.View;
import android.widget.Toast;
import android.widget.Button;
import android.os.Handler;
import android.os.Message;
import android.annotation.SuppressLint;
import com.example.hamburger.dao.UserDao;
import com.example.hamburger.entity.User;
@RunWith(AndroidJUnit4.class)
public class Mtest {
@Test
public void text_1() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.hamburger", appContext.getPackageName());
new Thread(){
@Override
public void run() {
UserDao userDao = new UserDao();
int msg = userDao.login("1","1");
}
}.start();
}
@Test
public void text_2() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.hamburger", appContext.getPackageName());
User user = new User();
user.setUserAccount("11");
user.setUserPassword("11");
user.setUserName("11");
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;
}
}
}
}.start();
}
}

@ -1,70 +0,0 @@
package com.example.hamburger;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.view.View;
import android.widget.Toast;
import android.widget.Button;
import android.os.Handler;
import android.os.Message;
import android.annotation.SuppressLint;
import com.example.hamburger.dao.UserDao;
public class MainActivity extends AppCompatActivity {
//这个类主要用来进行,账号密码的验证,以及监听事件的编写。
// 所以首先需要将一开始设计的输入文本框id name 和passwd获取。
EditText name;//创建账号
EditText passwd;//创建密码
private static final String TAG="mysql-party-MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void login(View view){
EditText EditTextAccount = findViewById(R.id.name);
EditText EditTextPassword = findViewById(R.id.passwd);
Button button = (Button) findViewById(R.id.button);
new Thread(){
@Override
public void run() {
UserDao userDao = new UserDao();
int msg = userDao.login(EditTextAccount.getText().toString(),EditTextPassword.getText().toString());
hand1.sendEmptyMessage(msg);
}
}.start();
}
public void reg(View view){
startActivity(new Intent(getApplicationContext(),register.class));
}
@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(getApplicationContext(),MainActivity2.class));
} else if (msg.what == 2){
Toast.makeText(getApplicationContext(), "密码错误", Toast.LENGTH_LONG).show();
} else if (msg.what == 3){
Toast.makeText(getApplicationContext(), "账号不存在", Toast.LENGTH_LONG).show();
}
}
};
}

@ -1,37 +0,0 @@
package com.example.hamburger;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.example.hamburger.databinding.ActivityMain2Binding;
public class MainActivity2 extends AppCompatActivity {
private ActivityMain2Binding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMain2Binding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
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 navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main2);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(binding.navView, navController);
}
}

@ -1,247 +0,0 @@
package com.example.hamburger.dao;
import com.example.hamburger.entity.IsolationUser;
import com.example.hamburger.entity.User;
import com.example.hamburger.utils.JDBCUtils;
import android.annotation.SuppressLint;
import android.util.Log;
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-party-UserDao";
/**
* function:
* */
@SuppressLint("LongLogTag")
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:
* */
@SuppressLint("LongLogTag")
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:
* */
@SuppressLint("LongLogTag")
public boolean LogInfor(IsolationUser user){
HashMap<String, Object> map = new HashMap<>();
// 根据数据库名称,建立连接
Connection connection = JDBCUtils.getConn();
try {
String sql = "insert into infor_(name,gender,id_number,room_number,checkin_time) values (?,?,?,?,?)";
if (connection != null){// connection不为null表示与数据库建立了连接
PreparedStatement ps = connection.prepareStatement(sql);
if (ps != null){
//将数据插入数据库
ps.setString(1,user.getname());
ps.setString(2,user.getGender());
ps.setString(3,user.getIdnumber());
ps.setInt(4,user.getRoomnumber());
ps.setString(5, user.getCheckin_time());
// 执行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, "异常loginfor" + e.getMessage());
return false;
}
}
/**
* function:
* */
@SuppressLint("LongLogTag")
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(userAccount1, userPassword);
}
}
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "异常findUser" + e.getMessage());
return null;
}
return user;
}
/**
* function:
* */
@SuppressLint("LongLogTag")
public IsolationUser findUser_(String name) {
// 根据数据库名称,建立连接
Connection connection = JDBCUtils.getConn();
IsolationUser user = null;
try {
String sql = "select * from infor_ where name = ?";
if (connection != null){// connection不为null表示与数据库建立了连接
PreparedStatement ps = connection.prepareStatement(sql);
if (ps != null) {
ps.setString(1, name);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
//注意下标是从1开始
int id = rs.getInt(1);
String name1 = rs.getString(2);
String gender = rs.getString(3);
String idnumber = rs.getString(4);
int roomnumber = rs.getInt(5);
String checkin_time = rs.getString(6);
user = new IsolationUser(name1,gender,idnumber,roomnumber,checkin_time);
}
}
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "异常findUser" + e.getMessage());
return null;
}
return user;
}
}

@ -1,72 +0,0 @@
package com.example.hamburger.entity;
public class IsolationUser {
private int id;
private String name;
private String gender;
private String idnumber;
private int roomnumber;
private String checkin_time;
public IsolationUser() {
}
public IsolationUser(String name, String gender, String idnumber, int roomnumber, String checkin_time) {
this.id = id;
this.name = name;
this.gender = gender;
this.idnumber = idnumber;
this.roomnumber = roomnumber;
this.checkin_time = checkin_time;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getname() {
return name;
}
public void setname(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getIdnumber() {
return idnumber;
}
public void setIdnumber(String idnumber) {
this.idnumber = idnumber;
}
public int getRoomnumber() {
return roomnumber;
}
public void setRoomnumber(int roomnumber) {
this.roomnumber = roomnumber;
}
public String getCheckin_time() {
return checkin_time;
}
public void setCheckin_time(String checkin_time) {
this.checkin_time = checkin_time;
}
}

@ -1,83 +0,0 @@
package com.example.hamburger.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(String userAccount, String userPassword) {
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;
}
}

@ -1,104 +0,0 @@
package com.example.hamburger;
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.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.hamburger.dao.UserDao;
import com.example.hamburger.entity.User;
import androidx.appcompat.app.AppCompatActivity;
public class register extends AppCompatActivity {
private static final String TAG = "mysql-party-register";
EditText userAccount = null;
EditText userPassword = null;
EditText userName = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
userAccount = findViewById(R.id.userAccount);
userPassword = findViewById(R.id.userPassword);
userName = findViewById(R.id.userName);
}
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_LONG).show();
} else if(msg.what == 1) {
Toast.makeText(getApplicationContext(),"该账号已经存在,请换一个账号",Toast.LENGTH_LONG).show();
} else if(msg.what == 2) {
Toast.makeText(getApplicationContext(), "注册成功", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
//将想要传递的数据用putExtra封装在intent中
intent.putExtra("a","注册");
setResult(RESULT_CANCELED,intent);
finish();
}
}
};
public void Ret(View view){
//获取按钮
Button button = (Button) findViewById(R.id.ret);
//按钮进行监听
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//监听按钮,如果点击,就跳转
Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(register.this, MainActivity.class);
startActivity(intent);
}
});
}
}

@ -1,101 +0,0 @@
package com.example.hamburger.ui.home;
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.View;
import android.widget.EditText;
import android.widget.Toast;
import com.example.hamburger.R;
import com.example.hamburger.dao.UserDao;
import com.example.hamburger.entity.IsolationUser;
public class Inform_input extends AppCompatActivity{
private static final String TAG = "mysql-party-register";
EditText name = null;
EditText gender = null;
EditText idnumber = null;
EditText roomnumber = null;
EditText checkin_time = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.infor_input);
name = findViewById(R.id.name);
gender = findViewById(R.id.gender);
idnumber = findViewById(R.id.ID_number);
roomnumber = findViewById(R.id.roomnumber);
checkin_time = findViewById(R.id.checkin_time);
}
public void addInfor(View view){
String name1 = name.getText().toString();
String gender1 = gender.getText().toString();
String idnumber1 = idnumber.getText().toString();
int roomnumber1 = Integer.parseInt(roomnumber.getText().toString());
String checkin_time1 = checkin_time.getText().toString();
IsolationUser user=new IsolationUser();
user.setname(name1);
user.setGender(gender1);
user.setIdnumber(idnumber1);
user.setRoomnumber(roomnumber1);
user.setCheckin_time(checkin_time1);
new Thread(){
@Override
public void run() {
int msg = 0;
UserDao userDao = new UserDao();
IsolationUser uu = userDao.findUser_(user.getname());
if(uu != null){
msg = 1;
}
else{
boolean flag = userDao.LogInfor(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_LONG).show();
} else if(msg.what == 1) {
Toast.makeText(getApplicationContext(),"该信息已经存在,请重新录入",Toast.LENGTH_LONG).show();
} else if(msg.what == 2) {
Toast.makeText(getApplicationContext(), "录入成功", Toast.LENGTH_LONG).show();
Intent intent = new Intent();
//将想要传递的数据用putExtra封装在intent中
intent.putExtra("a","录入");
setResult(RESULT_CANCELED,intent);
finish();
}
}
};
public void findInfor(View view){
}
}

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

@ -1,140 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#c8c7c5"
tools:context=".MainActivity">
<!--
思路
1.登录界面需要输入账号、密码,那么我们我要两个输入文本框。
2.需要点击一个登录,那么需要一个登录按钮,以及监听按钮的登陆事件。
3.作为一个简易的登录界面,我们并不加入数据库,添加一个账号密码识别认证即可。-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="-25dp"
tools:layout_editor_absoluteY="291dp">
<!--android:layout_marginLeft 这个作用是设置和左边的间距
android:layout_marginTop 这个作用是设置和顶部的间距
android:ems 这个作用是限制输入长度
android:hint 这个作用是设置输入文本框内的提示内容
android:inputType 这个作用是选择输入的内容类型
android:textColorHint 这个作用是设置文本框内提示内容的颜色-->
<!--android:onClick 这个作用是与java文件中的监听事件对应
android:text 这个作用是给按钮一个文本显示-->
<TextView
android:id="@+id/title"
android:layout_width="400dp"
android:layout_height="100dp"
android:text="隔离酒店智慧管理系统"
android:textColor="#083684"
android:gravity="center"
android:textSize="30dp"
>
</TextView>
<ImageView
android:id="@+id/icon"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/hotel_logo"
app:layout_constraintTop_toBottomOf="@id/title"
>
</ImageView>
<EditText
android:id="@+id/name"
android:layout_width="264dp"
android:layout_height="50dp"
android:background="@color/white"
android:ems="12"
android:layout_marginTop="10dp"
android:hint="输入用户名"
android:inputType="text"
android:textColorHint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="256dp"></EditText>
<EditText
android:id="@+id/passwd"
android:layout_width="264dp"
android:layout_height="50dp"
android:background="@color/white"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="输入密码"
android:inputType="textPassword"
android:textColorHint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="360dp"></EditText>
<!-- <RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton"
android:orientation="horizontal"
android:layout_constraintTop_toBottomOf="@id/passwd">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton_1"
android:text="隔离人员"
android:textColor="#083684">
</RadioButton>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton_2"
android:text="管理员"
android:textColor="#083684">
</RadioButton>
</RadioGroup>-->
<Button
android:id="@+id/button"
android:layout_width="200dp"
android:layout_height="48dp"
android:onClick="login"
android:text="登录"
android:layout_marginTop="10dp"
android:backgroundTint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="105dp"
tools:layout_editor_absoluteY="469dp" />
<!---->
<Button
android:id="@+id/register"
android:layout_width="200dp"
android:layout_height="48dp"
android:onClick="reg"
android:text="注册"
android:layout_marginTop="10dp"
android:backgroundTint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="105dp"
tools:layout_editor_absoluteY="469dp" />
</LinearLayout>
<!---->
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#c8c7c5"
tools:context=".register">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="-25dp"
tools:layout_editor_absoluteY="291dp">
<TextView
android:layout_width="400dp"
android:layout_height="100dp"
android:text="酒店智慧管理系统"
android:textColor="#083684"
android:gravity="center"
android:textSize="30dp">
</TextView>
<EditText
android:id="@+id/userAccount"
android:layout_width="264dp"
android:layout_height="50dp"
android:background="@color/white"
android:ems="12"
android:layout_marginTop="10dp"
android:hint="创建用户名"
android:inputType="text"
android:textColorHint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="256dp"></EditText>
<EditText
android:id="@+id/userName"
android:layout_width="264dp"
android:layout_height="50dp"
android:background="@color/white"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="创建昵称"
android:inputType="text"
android:textColorHint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="360dp"></EditText>
<EditText
android:id="@+id/userPassword"
android:layout_width="264dp"
android:layout_height="50dp"
android:background="@color/white"
android:layout_marginTop="10dp"
android:ems="12"
android:hint="创建密码"
android:inputType="textPassword"
android:textColorHint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="75dp"
tools:layout_editor_absoluteY="360dp"></EditText>
<Button
android:id="@+id/register"
android:layout_width="200dp"
android:layout_height="48dp"
android:onClick="register"
android:text="注册"
android:layout_marginTop="10dp"
android:backgroundTint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="105dp"
tools:layout_editor_absoluteY="469dp" />
<Button
android:id="@+id/ret"
android:layout_width="200dp"
android:layout_height="48dp"
android:onClick="Ret"
android:text="返回"
android:layout_marginTop="10dp"
android:backgroundTint="#083684"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="105dp"
tools:layout_editor_absoluteY="469dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#c8c7c5"
tools:context=".ui.home.Inform_input">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="219dp"
tools:layout_editor_absoluteY="207dp"
android:padding="50dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:text="姓名:" />
<EditText
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:text="性别:" />
<EditText
android:id="@+id/gender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:text="身份证号:"
/>
<EditText
android:id="@+id/ID_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text"
tools:ignore="DuplicateIds" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:text="房间号:"
/>
<EditText
android:id="@+id/roomnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="15sp"
android:text="入住时间:"
/>
<EditText
android:id="@+id/checkin_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
<Button
android:layout_marginTop="50dp"
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="录入"
android:backgroundTint="#083684"
android:onClick="addInfor"
/>
<Button
android:layout_marginTop="10dp"
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="查询"
android:backgroundTint="#083684"
android:onClick="findInfor"
/>
<TextView
android:id="@+id/tv_response"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,15 +0,0 @@
*.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

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

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

@ -1,20 +0,0 @@
<?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="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://maven.aliyun.com/repository/google" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://maven.aliyun.com/repository/jcenter" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="http://maven.aliyun.com/nexus/content/repositories/jcenter" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -1,61 +0,0 @@
package com.example.noteapp281;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AddActivity extends AppCompatActivity {
private EditText etTitle,etContent;
private NoteDbOpenHelper mNoteDbOpenHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
etTitle = findViewById(R.id.et_title);
etContent = findViewById(R.id.et_content);
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
}
public void add(View view) {
String title = etTitle.getText().toString();
String content = etContent.getText().toString();
if (TextUtils.isEmpty(title)) {
ToastUtil.toastShort(this, "标题不能为空!");
return;
}
Note note = new Note();
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(getCurrentTimeFormat());
long row = mNoteDbOpenHelper.insertData(note);
if (row != -1) {
ToastUtil.toastShort(this,"添加成功!");
this.finish();
}else {
ToastUtil.toastShort(this,"添加失败!");
}
}
private String getCurrentTimeFormat() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
Date date = new Date();
return simpleDateFormat.format(date);
}
}

@ -1,71 +0,0 @@
package com.example.noteapp281;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
public class EditActivity extends AppCompatActivity {
private Note note;
private EditText etTitle,etContent;
private NoteDbOpenHelper mNoteDbOpenHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit);
etTitle = findViewById(R.id.et_title);
etContent = findViewById(R.id.et_content);
initData();
}
private void initData() {
Intent intent = getIntent();
note = (Note) intent.getSerializableExtra("note");
if (note != null) {
etTitle.setText(note.getTitle());
etContent.setText(note.getContent());
}
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
}
public void save(View view) {
String title = etTitle.getText().toString();
String content = etContent.getText().toString();
if (TextUtils.isEmpty(title)) {
ToastUtil.toastShort(this, "标题不能为空!");
return;
}
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(getCurrentTimeFormat());
long rowId = mNoteDbOpenHelper.updateData(note);
if (rowId != -1) {
ToastUtil.toastShort(this, "修改成功!");
this.finish();
}else{
ToastUtil.toastShort(this, "修改失败!");
}
}
private String getCurrentTimeFormat() {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd日 HH:mm:ss");
Date date = new Date();
return sdf.format(date);
}
}

@ -1,191 +0,0 @@
package com.example.noteapp281;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.noteapp281.adapter.MyAdapter;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.SpfUtil;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private FloatingActionButton mBtnAdd;
private List<Note> mNotes;
private MyAdapter mMyAdapter;
private NoteDbOpenHelper mNoteDbOpenHelper;
public static final int MODE_LINEAR = 0;
public static final int MODE_GRID = 1;
public static final String KEY_LAYOUT_MODE = "key_layout_mode";
private int currentListLayoutMode = MODE_LINEAR;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initData();
initEvent();
}
@Override
protected void onResume() {
super.onResume();
refreshDataFromDb();
setListLayout();
}
private void setListLayout() {
currentListLayoutMode = SpfUtil.getIntWithDefault(this, KEY_LAYOUT_MODE, MODE_LINEAR);
if (currentListLayoutMode == MODE_LINEAR) {
setToLinearList();
}else{
setToGridList();
}
}
private void refreshDataFromDb() {
mNotes = getDataFromDB();
mMyAdapter.refreshData(mNotes);
}
private void initEvent() {
mMyAdapter = new MyAdapter(this, mNotes);
mRecyclerView.setAdapter(mMyAdapter);
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
// mRecyclerView.setLayoutManager(linearLayoutManager);
// mMyAdapter.setViewType(MyAdapter.TYPE_LINEAR_LAYOUT);
setListLayout();
}
private void initData() {
mNotes = new ArrayList<>();
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
//
// for (int i = 0; i < 30; i++) {
// Note note = new Note();
// note.setTitle("这是标题"+i);
// note.setContent("这是内容"+i);
// note.setCreatedTime(getCurrentTimeFormat());
// mNotes.add(note);
// }
// mNotes = getDataFromDB();
}
private List<Note> getDataFromDB() {
return mNoteDbOpenHelper.queryAllFromDb();
}
private String getCurrentTimeFormat() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd HH:mm:ss");
Date date = new Date();
return simpleDateFormat.format(date);
}
private void initView() {
mRecyclerView = findViewById(R.id.rlv);
}
public void add(View view) {
Intent intent = new Intent(this, AddActivity.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mNotes = mNoteDbOpenHelper.queryFromDbByTitle(newText);
mMyAdapter.refreshData(mNotes);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
item.setChecked(true);
switch (item.getItemId()) {
case R.id.menu_linear:
setToLinearList();
currentListLayoutMode = MODE_LINEAR;
SpfUtil.saveInt(this,KEY_LAYOUT_MODE,MODE_LINEAR);
return true;
case R.id.menu_grid:
setToGridList();
currentListLayoutMode = MODE_GRID;
SpfUtil.saveInt(this,KEY_LAYOUT_MODE,MODE_GRID);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void setToLinearList() {
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
mRecyclerView.setLayoutManager(linearLayoutManager);
mMyAdapter.setViewType(MyAdapter.TYPE_LINEAR_LAYOUT);
mMyAdapter.notifyDataSetChanged();
}
private void setToGridList() {
RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
mRecyclerView.setLayoutManager(gridLayoutManager);
mMyAdapter.setViewType(MyAdapter.TYPE_GRID_LAYOUT);
mMyAdapter.notifyDataSetChanged();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (currentListLayoutMode == MODE_LINEAR) {
MenuItem item = menu.findItem(R.id.menu_linear);
item.setChecked(true);
} else {
menu.findItem(R.id.menu_grid).setChecked(true);
}
return super.onPrepareOptionsMenu(menu);
}
}

@ -1,130 +0,0 @@
package com.example.noteapp281;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import com.example.noteapp281.bean.Note;
import java.util.ArrayList;
import java.util.List;
public class NoteDbOpenHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "noteSQLite.db";
private static final String TABLE_NAME_NOTE = "note";
private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_NOTE + " (id integer primary key autoincrement, title text, content text, create_time text)";
public NoteDbOpenHelper(Context context) {
super(context, DB_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_SQL);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public long insertData(Note note) {
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("title", note.getTitle());
values.put("content", note.getContent());
values.put("create_time", note.getCreatedTime());
return db.insert(TABLE_NAME_NOTE, null, values);
}
public int deleteFromDbById(String id) {
SQLiteDatabase db = getWritableDatabase();
// return db.delete(TABLE_NAME_NOTE, "id = ?", new String[]{id});
// return db.delete(TABLE_NAME_NOTE, "id is ?", new String[]{id});
return db.delete(TABLE_NAME_NOTE, "id like ?", new String[]{id});
}
public int updateData(Note note) {
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("title", note.getTitle());
values.put("content", note.getContent());
values.put("create_time", note.getCreatedTime());
return db.update(TABLE_NAME_NOTE, values, "id like ?", new String[]{note.getId()});
}
public List<Note> queryAllFromDb() {
SQLiteDatabase db = getWritableDatabase();
List<Note> noteList = new ArrayList<>();
Cursor cursor = db.query(TABLE_NAME_NOTE, null, null, null, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex("id"));
String title = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
Note note = new Note();
note.setId(id);
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(createTime);
noteList.add(note);
}
cursor.close();
}
return noteList;
}
public List<Note> queryFromDbByTitle(String title) {
if (TextUtils.isEmpty(title)) {
return queryAllFromDb();
}
SQLiteDatabase db = getWritableDatabase();
List<Note> noteList = new ArrayList<>();
Cursor cursor = db.query(TABLE_NAME_NOTE, null, "title like ?", new String[]{"%"+title+"%"}, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex("id"));
String title2 = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
Note note = new Note();
note.setId(id);
note.setTitle(title2);
note.setContent(content);
note.setCreatedTime(createTime);
noteList.add(note);
}
cursor.close();
}
return noteList;
}
}

@ -1,230 +0,0 @@
package com.example.noteapp281.adapter;
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 androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.noteapp281.EditActivity;
import com.example.noteapp281.NoteDbOpenHelper;
import com.example.noteapp281.R;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<Note> mBeanList;
private LayoutInflater mLayoutInflater;
private Context mContext;
private NoteDbOpenHelper mNoteDbOpenHelper;
private int viewType;
public static int TYPE_LINEAR_LAYOUT = 0;
public static int TYPE_GRID_LAYOUT = 1;
public MyAdapter(Context context, List<Note> mBeanList){
this.mBeanList = mBeanList;
this.mContext = context;
mLayoutInflater = LayoutInflater.from(mContext);
mNoteDbOpenHelper = new NoteDbOpenHelper(mContext);
}
public void setViewType(int viewType) {
this.viewType = viewType;
}
@Override
public int getItemViewType(int position) {
return viewType;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if(viewType == TYPE_LINEAR_LAYOUT){
View view = mLayoutInflater.inflate(R.layout.list_item_layout, parent, false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}else if(viewType == TYPE_GRID_LAYOUT){
View view = mLayoutInflater.inflate(R.layout.list_item_grid_layout, parent, false);
MyGridViewHolder myGridViewHolder = new MyGridViewHolder(view);
return myGridViewHolder;
}
return null;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder == null) {
return;
}
if(holder instanceof MyViewHolder){
bindMyViewHolder((MyViewHolder) holder, position);
} else if (holder instanceof MyGridViewHolder) {
bindGridViewHolder((MyGridViewHolder) holder, position);
}
}
private void bindMyViewHolder(MyViewHolder holder, int position) {
Note note = mBeanList.get(position);
holder.mTvTitle.setText(note.getTitle());
holder.mTvContent.setText(note.getContent());
holder.mTvTime.setText(note.getCreatedTime());
holder.rlContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
}
});
holder.rlContainer.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// 弹出弹窗
Dialog dialog = new Dialog(mContext, android.R.style.ThemeOverlay_Material_Dialog_Alert);
View dialogView = mLayoutInflater.inflate(R.layout.list_item_dialog_layout, null);
TextView tvDelete = dialogView.findViewById(R.id.tv_delete);
TextView tvEdit = dialogView.findViewById(R.id.tv_edit);
tvDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int row = mNoteDbOpenHelper.deleteFromDbById(note.getId());
if (row > 0) {
removeData(position);
}
dialog.dismiss();
}
});
tvEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
dialog.dismiss();
}
});
dialog.setContentView(dialogView);
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
});
}
private void bindGridViewHolder(MyGridViewHolder holder, int position) {
Note note = mBeanList.get(position);
holder.mTvTitle.setText(note.getTitle());
holder.mTvContent.setText(note.getContent());
holder.mTvTime.setText(note.getCreatedTime());
holder.rlContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
}
});
holder.rlContainer.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// 弹出弹窗
Dialog dialog = new Dialog(mContext, android.R.style.ThemeOverlay_Material_Dialog_Alert);
View dialogView = mLayoutInflater.inflate(R.layout.list_item_dialog_layout, null);
TextView tvDelete = dialogView.findViewById(R.id.tv_delete);
TextView tvEdit = dialogView.findViewById(R.id.tv_edit);
tvDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int row = mNoteDbOpenHelper.deleteFromDbById(note.getId());
if (row > 0) {
removeData(position);
}
dialog.dismiss();
}
});
tvEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
dialog.dismiss();
}
});
dialog.setContentView(dialogView);
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
});
}
@Override
public int getItemCount() {
return mBeanList.size();
}
public void refreshData(List<Note> notes) {
this.mBeanList = notes;
notifyDataSetChanged();
}
public void removeData(int pos) {
mBeanList.remove(pos);
notifyItemRemoved(pos);
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView mTvTitle;
TextView mTvContent;
TextView mTvTime;
ViewGroup rlContainer;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
this.mTvTitle = itemView.findViewById(R.id.tv_title);
this.mTvContent = itemView.findViewById(R.id.tv_content);
this.mTvTime = itemView.findViewById(R.id.tv_time);
this.rlContainer = itemView.findViewById(R.id.rl_item_container);
}
}
class MyGridViewHolder extends RecyclerView.ViewHolder{
TextView mTvTitle;
TextView mTvContent;
TextView mTvTime;
ViewGroup rlContainer;
public MyGridViewHolder(@NonNull View itemView) {
super(itemView);
this.mTvTitle = itemView.findViewById(R.id.tv_title);
this.mTvContent = itemView.findViewById(R.id.tv_content);
this.mTvTime = itemView.findViewById(R.id.tv_time);
this.rlContainer = itemView.findViewById(R.id.rl_item_container);
}
}
}

@ -1,39 +0,0 @@
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.noteapp281"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

@ -1,21 +0,0 @@
# 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

@ -1,26 +0,0 @@
package com.example.noteapp281;
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.noteapp281", appContext.getPackageName());
}
}

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.noteapp281">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplicationBase">
<activity android:name=".EditActivity"
android:label="编辑公告"
android:parentActivityName=".MainActivity"
></activity>
<activity
android:name=".AddActivity"
android:label="添加公告"
android:parentActivityName=".MainActivity" />
<activity
android:name=".MainActivity"
android:label="公告栏">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -1,61 +0,0 @@
package com.example.noteapp281;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AddActivity extends AppCompatActivity {
private EditText etTitle,etContent;
private NoteDbOpenHelper mNoteDbOpenHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
etTitle = findViewById(R.id.et_title);
etContent = findViewById(R.id.et_content);
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
}
public void add(View view) {
String title = etTitle.getText().toString();
String content = etContent.getText().toString();
if (TextUtils.isEmpty(title)) {
ToastUtil.toastShort(this, "标题不能为空!");
return;
}
Note note = new Note();
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(getCurrentTimeFormat());
long row = mNoteDbOpenHelper.insertData(note);
if (row != -1) {
ToastUtil.toastShort(this,"添加成功!");
this.finish();
}else {
ToastUtil.toastShort(this,"添加失败!");
}
}
private String getCurrentTimeFormat() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY年MM月dd HH:mm:ss");
Date date = new Date();
return simpleDateFormat.format(date);
}
}

@ -1,71 +0,0 @@
package com.example.noteapp281;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.text.SimpleDateFormat;
import java.util.Date;
public class EditActivity extends AppCompatActivity {
private Note note;
private EditText etTitle,etContent;
private NoteDbOpenHelper mNoteDbOpenHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit);
etTitle = findViewById(R.id.et_title);
etContent = findViewById(R.id.et_content);
initData();
}
private void initData() {
Intent intent = getIntent();
note = (Note) intent.getSerializableExtra("note");
if (note != null) {
etTitle.setText(note.getTitle());
etContent.setText(note.getContent());
}
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
}
public void save(View view) {
String title = etTitle.getText().toString();
String content = etContent.getText().toString();
if (TextUtils.isEmpty(title)) {
ToastUtil.toastShort(this, "标题不能为空!");
return;
}
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(getCurrentTimeFormat());
long rowId = mNoteDbOpenHelper.updateData(note);
if (rowId != -1) {
ToastUtil.toastShort(this, "修改成功!");
this.finish();
}else{
ToastUtil.toastShort(this, "修改失败!");
}
}
private String getCurrentTimeFormat() {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY年MM月dd日 HH:mm:ss");
Date date = new Date();
return sdf.format(date);
}
}

@ -1,191 +0,0 @@
package com.example.noteapp281;
import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.noteapp281.adapter.MyAdapter;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.SpfUtil;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private FloatingActionButton mBtnAdd;
private List<Note> mNotes;
private MyAdapter mMyAdapter;
private NoteDbOpenHelper mNoteDbOpenHelper;
public static final int MODE_LINEAR = 0;
public static final int MODE_GRID = 1;
public static final String KEY_LAYOUT_MODE = "key_layout_mode";
private int currentListLayoutMode = MODE_LINEAR;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initData();
initEvent();
}
@Override
protected void onResume() {
super.onResume();
refreshDataFromDb();
setListLayout();
}
private void setListLayout() {
currentListLayoutMode = SpfUtil.getIntWithDefault(this, KEY_LAYOUT_MODE, MODE_LINEAR);
if (currentListLayoutMode == MODE_LINEAR) {
setToLinearList();
}else{
setToGridList();
}
}
private void refreshDataFromDb() {
mNotes = getDataFromDB();
mMyAdapter.refreshData(mNotes);
}
private void initEvent() {
mMyAdapter = new MyAdapter(this, mNotes);
mRecyclerView.setAdapter(mMyAdapter);
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
// mRecyclerView.setLayoutManager(linearLayoutManager);
// mMyAdapter.setViewType(MyAdapter.TYPE_LINEAR_LAYOUT);
setListLayout();
}
private void initData() {
mNotes = new ArrayList<>();
mNoteDbOpenHelper = new NoteDbOpenHelper(this);
//
// for (int i = 0; i < 30; i++) {
// Note note = new Note();
// note.setTitle("这是标题"+i);
// note.setContent("这是内容"+i);
// note.setCreatedTime(getCurrentTimeFormat());
// mNotes.add(note);
// }
// mNotes = getDataFromDB();
}
private List<Note> getDataFromDB() {
return mNoteDbOpenHelper.queryAllFromDb();
}
private String getCurrentTimeFormat() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd HH:mm:ss");
Date date = new Date();
return simpleDateFormat.format(date);
}
private void initView() {
mRecyclerView = findViewById(R.id.rlv);
}
public void add(View view) {
Intent intent = new Intent(this, AddActivity.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mNotes = mNoteDbOpenHelper.queryFromDbByTitle(newText);
mMyAdapter.refreshData(mNotes);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
item.setChecked(true);
switch (item.getItemId()) {
case R.id.menu_linear:
setToLinearList();
currentListLayoutMode = MODE_LINEAR;
SpfUtil.saveInt(this,KEY_LAYOUT_MODE,MODE_LINEAR);
return true;
case R.id.menu_grid:
setToGridList();
currentListLayoutMode = MODE_GRID;
SpfUtil.saveInt(this,KEY_LAYOUT_MODE,MODE_GRID);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void setToLinearList() {
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
mRecyclerView.setLayoutManager(linearLayoutManager);
mMyAdapter.setViewType(MyAdapter.TYPE_LINEAR_LAYOUT);
mMyAdapter.notifyDataSetChanged();
}
private void setToGridList() {
RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
mRecyclerView.setLayoutManager(gridLayoutManager);
mMyAdapter.setViewType(MyAdapter.TYPE_GRID_LAYOUT);
mMyAdapter.notifyDataSetChanged();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (currentListLayoutMode == MODE_LINEAR) {
MenuItem item = menu.findItem(R.id.menu_linear);
item.setChecked(true);
} else {
menu.findItem(R.id.menu_grid).setChecked(true);
}
return super.onPrepareOptionsMenu(menu);
}
}

@ -1,130 +0,0 @@
package com.example.noteapp281;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import com.example.noteapp281.bean.Note;
import java.util.ArrayList;
import java.util.List;
public class NoteDbOpenHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "noteSQLite.db";
private static final String TABLE_NAME_NOTE = "note";
private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_NOTE + " (id integer primary key autoincrement, title text, content text, create_time text)";
public NoteDbOpenHelper(Context context) {
super(context, DB_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_SQL);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public long insertData(Note note) {
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("title", note.getTitle());
values.put("content", note.getContent());
values.put("create_time", note.getCreatedTime());
return db.insert(TABLE_NAME_NOTE, null, values);
}
public int deleteFromDbById(String id) {
SQLiteDatabase db = getWritableDatabase();
// return db.delete(TABLE_NAME_NOTE, "id = ?", new String[]{id});
// return db.delete(TABLE_NAME_NOTE, "id is ?", new String[]{id});
return db.delete(TABLE_NAME_NOTE, "id like ?", new String[]{id});
}
public int updateData(Note note) {
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("title", note.getTitle());
values.put("content", note.getContent());
values.put("create_time", note.getCreatedTime());
return db.update(TABLE_NAME_NOTE, values, "id like ?", new String[]{note.getId()});
}
public List<Note> queryAllFromDb() {
SQLiteDatabase db = getWritableDatabase();
List<Note> noteList = new ArrayList<>();
Cursor cursor = db.query(TABLE_NAME_NOTE, null, null, null, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex("id"));
String title = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
Note note = new Note();
note.setId(id);
note.setTitle(title);
note.setContent(content);
note.setCreatedTime(createTime);
noteList.add(note);
}
cursor.close();
}
return noteList;
}
public List<Note> queryFromDbByTitle(String title) {
if (TextUtils.isEmpty(title)) {
return queryAllFromDb();
}
SQLiteDatabase db = getWritableDatabase();
List<Note> noteList = new ArrayList<>();
Cursor cursor = db.query(TABLE_NAME_NOTE, null, "title like ?", new String[]{"%"+title+"%"}, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex("id"));
String title2 = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
String createTime = cursor.getString(cursor.getColumnIndex("create_time"));
Note note = new Note();
note.setId(id);
note.setTitle(title2);
note.setContent(content);
note.setCreatedTime(createTime);
noteList.add(note);
}
cursor.close();
}
return noteList;
}
}

@ -1,230 +0,0 @@
package com.example.noteapp281.adapter;
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 androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.noteapp281.EditActivity;
import com.example.noteapp281.NoteDbOpenHelper;
import com.example.noteapp281.R;
import com.example.noteapp281.bean.Note;
import com.example.noteapp281.util.ToastUtil;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<Note> mBeanList;
private LayoutInflater mLayoutInflater;
private Context mContext;
private NoteDbOpenHelper mNoteDbOpenHelper;
private int viewType;
public static int TYPE_LINEAR_LAYOUT = 0;
public static int TYPE_GRID_LAYOUT = 1;
public MyAdapter(Context context, List<Note> mBeanList){
this.mBeanList = mBeanList;
this.mContext = context;
mLayoutInflater = LayoutInflater.from(mContext);
mNoteDbOpenHelper = new NoteDbOpenHelper(mContext);
}
public void setViewType(int viewType) {
this.viewType = viewType;
}
@Override
public int getItemViewType(int position) {
return viewType;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if(viewType == TYPE_LINEAR_LAYOUT){
View view = mLayoutInflater.inflate(R.layout.list_item_layout, parent, false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}else if(viewType == TYPE_GRID_LAYOUT){
View view = mLayoutInflater.inflate(R.layout.list_item_grid_layout, parent, false);
MyGridViewHolder myGridViewHolder = new MyGridViewHolder(view);
return myGridViewHolder;
}
return null;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder == null) {
return;
}
if(holder instanceof MyViewHolder){
bindMyViewHolder((MyViewHolder) holder, position);
} else if (holder instanceof MyGridViewHolder) {
bindGridViewHolder((MyGridViewHolder) holder, position);
}
}
private void bindMyViewHolder(MyViewHolder holder, int position) {
Note note = mBeanList.get(position);
holder.mTvTitle.setText(note.getTitle());
holder.mTvContent.setText(note.getContent());
holder.mTvTime.setText(note.getCreatedTime());
holder.rlContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
}
});
holder.rlContainer.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// 弹出弹窗
Dialog dialog = new Dialog(mContext, android.R.style.ThemeOverlay_Material_Dialog_Alert);
View dialogView = mLayoutInflater.inflate(R.layout.list_item_dialog_layout, null);
TextView tvDelete = dialogView.findViewById(R.id.tv_delete);
TextView tvEdit = dialogView.findViewById(R.id.tv_edit);
tvDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int row = mNoteDbOpenHelper.deleteFromDbById(note.getId());
if (row > 0) {
removeData(position);
}
dialog.dismiss();
}
});
tvEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
dialog.dismiss();
}
});
dialog.setContentView(dialogView);
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
});
}
private void bindGridViewHolder(MyGridViewHolder holder, int position) {
Note note = mBeanList.get(position);
holder.mTvTitle.setText(note.getTitle());
holder.mTvContent.setText(note.getContent());
holder.mTvTime.setText(note.getCreatedTime());
holder.rlContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
}
});
holder.rlContainer.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// 弹出弹窗
Dialog dialog = new Dialog(mContext, android.R.style.ThemeOverlay_Material_Dialog_Alert);
View dialogView = mLayoutInflater.inflate(R.layout.list_item_dialog_layout, null);
TextView tvDelete = dialogView.findViewById(R.id.tv_delete);
TextView tvEdit = dialogView.findViewById(R.id.tv_edit);
tvDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int row = mNoteDbOpenHelper.deleteFromDbById(note.getId());
if (row > 0) {
removeData(position);
}
dialog.dismiss();
}
});
tvEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, EditActivity.class);
intent.putExtra("note", note);
mContext.startActivity(intent);
dialog.dismiss();
}
});
dialog.setContentView(dialogView);
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
});
}
@Override
public int getItemCount() {
return mBeanList.size();
}
public void refreshData(List<Note> notes) {
this.mBeanList = notes;
notifyDataSetChanged();
}
public void removeData(int pos) {
mBeanList.remove(pos);
notifyItemRemoved(pos);
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView mTvTitle;
TextView mTvContent;
TextView mTvTime;
ViewGroup rlContainer;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
this.mTvTitle = itemView.findViewById(R.id.tv_title);
this.mTvContent = itemView.findViewById(R.id.tv_content);
this.mTvTime = itemView.findViewById(R.id.tv_time);
this.rlContainer = itemView.findViewById(R.id.rl_item_container);
}
}
class MyGridViewHolder extends RecyclerView.ViewHolder{
TextView mTvTitle;
TextView mTvContent;
TextView mTvTime;
ViewGroup rlContainer;
public MyGridViewHolder(@NonNull View itemView) {
super(itemView);
this.mTvTitle = itemView.findViewById(R.id.tv_title);
this.mTvContent = itemView.findViewById(R.id.tv_content);
this.mTvTime = itemView.findViewById(R.id.tv_time);
this.rlContainer = itemView.findViewById(R.id.rl_item_container);
}
}
}

@ -1,54 +0,0 @@
package com.example.noteapp281.bean;
import java.io.Serializable;
public class Note implements Serializable {
private String title;
private String content;
private String createdTime;
private String 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 getCreatedTime() {
return createdTime;
}
public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "Note{" +
"title='" + title + '\'' +
", content='" + content + '\'' +
", createdTime='" + createdTime + '\'' +
", id='" + id + '\'' +
'}';
}
}

@ -1,38 +0,0 @@
package com.example.noteapp281.util;
import android.content.Context;
import android.content.SharedPreferences;
public class SpfUtil {
private static String SPF_NAME = "noteSpf";
public static void saveString(Context context, String key, String value) {
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = spf.edit();
edit.putString(key, value);
edit.apply();
}
public static String getString(Context context, String key) {
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
return spf.getString(key, "");
}
public static void saveInt(Context context, String key, int value) {
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor edit = spf.edit();
edit.putInt(key, value);
edit.apply();
}
public static int getInt(Context context, String key) {
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
return spf.getInt(key, -1);
}
public static int getIntWithDefault(Context context, String key, int defValue) {
SharedPreferences spf = context.getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
return spf.getInt(key, defValue);
}
}

@ -1,15 +0,0 @@
package com.example.noteapp281.util;
import android.content.Context;
import android.widget.Toast;
public class ToastUtil {
public static void toastShort(Context context, String msg) {
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
public static void toastLong(Context context, String msg) {
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
}
}

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/colorPrimary"/>
<item android:state_pressed="false" android:drawable="@color/colorPrimaryDark"/>
</selector>

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<stroke android:width="3dp" android:color="#083684"/>
<corners android:radius="10dp" />
</shape>

@ -1,30 +0,0 @@
<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>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/mycolor"/>
<item android:state_pressed="false" android:drawable="@color/colorPrimaryDark"/>
</selector>

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<stroke android:width="3dp" android:color="#083684"/>
<corners android:radius="10dp" />
</shape>

@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>

@ -1,170 +0,0 @@
<?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="#083684"
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>

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".AddActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/MyTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标题" />
<EditText
android:id="@+id/et_title"
style="@style/MyEditStyle"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_marginLeft="5dp" />
</LinearLayout>
<TextView
style="@style/MyTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="内容" />
<EditText
android:id="@+id/et_content"
style="@style/MyEditStyle"
android:layout_width="match_parent"
android:gravity="left"
android:layout_height="300dp"
android:layout_marginTop="5dp" />
<Button
style="@style/MyBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="add"
android:text="添加" />
</LinearLayout>
</ScrollView>

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".EditActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/MyTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标题" />
<EditText
android:id="@+id/et_title"
style="@style/MyEditStyle"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_marginLeft="5dp" />
</LinearLayout>
<TextView
style="@style/MyTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="内容" />
<EditText
android:id="@+id/et_content"
style="@style/MyEditStyle"
android:layout_width="match_parent"
android:gravity="left"
android:layout_height="300dp"
android:layout_marginTop="5dp" />
<Button
style="@style/MyBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="save"
android:text="保存" />
</LinearLayout>
</ScrollView>

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_input_add"
android:layout_gravity="right|bottom"
android:layout_margin="20dp"
android:onClick="add"
android:backgroundTint="#083684"
/>
</FrameLayout>

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:id="@+id/tv_delete"
android:text="删除"
style="@style/MyTextStyle"
/>
<TextView
android:layout_width="match_parent"
android:id="@+id/tv_edit"
android:text="编辑"
style="@style/MyTextStyle"
/>
</LinearLayout>

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/rl_item_container"
android:padding="10dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:gravity="left"
android:text="你好"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:maxLines="2"
android:text="你好拉拉拉拉谁在用琵琶弹奏一曲东风破"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="2021-5-30 22:40:34"
android:textSize="14sp" />
</LinearLayout>

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rl_item_container"
android:padding="10dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:gravity="left"
android:layout_toLeftOf="@id/tv_time"
android:text="你好"
android:layout_alignParentLeft="true"
android:textSize="20sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:maxLines="2"
android:text="你好拉拉拉拉谁在用琵琶弹奏一曲东风破"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/tv_title"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="2021-5-30 22:40:34"
android:textSize="14sp" />
</RelativeLayout>

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_search"
android:title="搜索"
app:showAsAction="always"
android:icon="@drawable/ic_baseline_search_24"
app:actionViewClass="androidx.appcompat.widget.SearchView" />
<group android:checkableBehavior="single" >
<item android:id="@+id/menu_linear"
android:title="列表布局"
app:showAsAction="never"
/>
<item android:id="@+id/menu_grid"
android:title="网格布局"
app:showAsAction="never"
/>
</group>
</menu>

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

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

Loading…
Cancel
Save