Compare commits

...

No commits in common. 'master' and 'my' have entirely different histories.
master ... my

@ -1,7 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="盛洁">
<words>
<w>sttmt</w>
</words>
</dictionary>
</component>

@ -3,7 +3,4 @@
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" 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,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hunnu.sj.raise_money">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/img_2"
@ -9,7 +11,11 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".NewsContentActivity"></activity>
<activity android:name=".LongTermDonate"></activity>
<activity android:name=".BrowseDonatedRecordActivity" />
<activity android:name=".DonateActivity" />
<activity android:name=".BrowseDonateRecordActivity" />
<activity android:name=".NewsContentActivity" />
<activity android:name=".RegiteActivity" />
<activity android:name=".SignInActivity">
<intent-filter>
@ -22,6 +28,7 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar" />
</application>

@ -0,0 +1,55 @@
package hunnu.sj.raise_money;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ListView;
import java.util.ArrayList;
import hunnu.sj.raise_money.record.Record;
import hunnu.sj.raise_money.donate_record.DonateRecordAdapter;
public class BrowseDonateRecordActivity extends AppCompatActivity {
private ArrayList<Record> records = new ArrayList<>();
private ListView lv_record;
private DonateRecordAdapter recordAdapter;
private long user_id;
private long stu_id;
private Handler mhandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if(msg.what==1){
recordAdapter.notifyDataSetChanged();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse_record);
Intent intent = getIntent();
user_id = intent.getLongExtra("user_id",0);
recordAdapter = new DonateRecordAdapter(this,records);
lv_record = findViewById(R.id.lv_browse_denate_record);
lv_record.setAdapter(recordAdapter);
new BrowseDonateRecordThread().start();
}
class BrowseDonateRecordThread extends Thread{
@Override
public void run() {
Message msg =mhandler.obtainMessage();
int flags = InfoUtils.getDonateRecords(records,user_id);
msg.what = flags;
mhandler.sendMessage(msg);
}
}
}

@ -0,0 +1,54 @@
package hunnu.sj.raise_money;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ListView;
import java.util.ArrayList;
import hunnu.sj.raise_money.donated_record.DonatedRecordAdapter;
import hunnu.sj.raise_money.record.Record;
public class BrowseDonatedRecordActivity extends AppCompatActivity {
private ArrayList<Record> records = new ArrayList<>();
private ListView lv_record;
private DonatedRecordAdapter donatedRecordAdapter;
private long stu_id;
private Handler mhandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if(msg.what==1){
donatedRecordAdapter.notifyDataSetChanged();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse_record);
Intent intent = getIntent();
stu_id = intent.getLongExtra("stu_id",0);
donatedRecordAdapter = new DonatedRecordAdapter(this,records);
lv_record = findViewById(R.id.lv_browse_denate_record);
lv_record.setAdapter(donatedRecordAdapter);
new BrowseDonateRecordThread().start();
}
class BrowseDonateRecordThread extends Thread{
@Override
public void run() {
Message msg =mhandler.obtainMessage();
int flags = InfoUtils.getDonatedRecords(records,stu_id);
msg.what = flags;
mhandler.sendMessage(msg);
}
}
}

@ -13,13 +13,13 @@ public class DatabaseHelper {
}
public static Connection getConnection(){
public static Connection getConnection(){//数据库连接池
String username = "root";
String password ="SJ1126388959";
String password ="12345678";
if(conn==null){
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://139.180.223.93:3306/dogson?useSSL=true&characterEncoding=utf-8";
String url = "jdbc:mysql://39.105.116.16:3306/raise";
conn = DriverManager.getConnection(url,username,password);
return conn;
}catch(Exception e){

@ -1,9 +1,24 @@
package hunnu.sj.raise_money.DataBase;
import android.content.Context;
import androidx.core.content.ContextCompat;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import hunnu.sj.raise_money.record.Record;
import hunnu.sj.raise_money.news.News;
import hunnu.sj.raise_money.R;
import hunnu.sj.raise_money.User;
public class UserService {
@ -12,35 +27,39 @@ public class UserService {
public UserService(){
this.db = DatabaseHelper.getDb();
}
public int login(String username,String password){
conn = db.getConnection();
conn = DatabaseHelper.getConnection();
Statement sttmt;
try{
Statement sttmt = conn.createStatement();
ResultSet rs1 = sttmt.executeQuery("select * from user where username = '"+username+"'");
sttmt = conn.createStatement();
String sql = "select * from user_info where username = '"+username+"'";
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs1 = ps.executeQuery();
boolean flag1 = rs1.next();
if(!flag1){
sttmt.close();
return 0;
return 0; //当用户名不存在时返回0
}
ResultSet rs2 = sttmt.executeQuery("select * from user where username = '"+username+"'&&password = '"+password+"'");
ResultSet rs2 = sttmt.executeQuery("select * from user_info where username = '"+username+"'&&password = '"+password+"'");
boolean flag2 = rs2.next();
if(!flag2){
rs2.close();
sttmt.close();
return 1;
return 1; //当用户名存在密码错误时返回1
}
sttmt.close();
return 2;
return 2; //都正确时返回2
}catch (Exception e){
e.printStackTrace();
}
return 0;
return -1;
}
public boolean register(User user){
conn = db.getConnection();
conn = DatabaseHelper.getConnection();//将用户的信息上传到数据库上传成功返回true失败false
try{
String sql = "insert into user(username,password,role) values('"+user.getName()+"','"+user.getPasd()+"','"+user.getRole()+"')";
String sql = "insert into user_info(username,password,role,phone) values('"+user.getUsername()+"','"+user.getPassword()+"','"+user.getRole()+"','"+user.getPhone()+"')";
Statement sttmt = conn.createStatement();
sttmt.executeUpdate(sql);
sttmt.close();
@ -51,22 +70,155 @@ public class UserService {
return false;
}
public String getRole(String username){
public boolean donate(long stu_id,long user_id,float money){
conn = DatabaseHelper.getConnection();//将用户捐款信息上传到数据库成功返回true失败返回false
try{
String time=getNetTime();
// Date date = new Date();sdf.format(date)
//SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance();
String sql = "insert into record(stu_id,user_id,donatemon,time) values('"+stu_id+"','"+user_id+"','"+money+"','"+time+"')";
String sql1 ="update stu_info set hasdonated=hasdonated+'"+money+"' where stu_id='"+stu_id+"'";
//stu_id,stu_name,donatemon,time,username
Statement sttmt = conn.createStatement();
sttmt.executeUpdate(sql);
sttmt.executeUpdate(sql1);
sttmt.close();
return true;
}catch (Exception e){
e.printStackTrace();
}
return false;
}
public String getNetTime() throws IOException {
URL url;
url = new URL("http://www.baidu.com");
URLConnection baidu = url.openConnection();//生成连接对象
baidu.connect(); //发出连接
long time13 = baidu.getDate();
DateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time13);
String format = formatter.format(calendar.getTime());
return format;
}
public boolean longterm(String name, Long stu_id,Long user_id){
conn = DatabaseHelper.getConnection();//将长期资助信息上传到数据库成功返回true失败返回false
try{
String sql = "insert into usr_long_help(stu_id,user_id,flags) values('"+stu_id+"','"+user_id+"','"+0+"')";
// where null=(select name from user_info where user_id='"+user_id+"')
String sql1="update user_info set name='"+name+"' where (select name from (select name from user_info where user_id='"+user_id+"') t1 ) is not null";
//update user_info set name="你的好爸爸" where (select name from (select name from user_info where user_id=1) t1 ) is null
//stuid,useerid,flags
Statement sttmt = conn.createStatement();
sttmt.executeUpdate(sql);
sttmt.executeUpdate(sql1);
sttmt.close();
return true;
}
catch (Exception e){
e.printStackTrace();
}
return false;
}
public User getUserInfo(String username,String password){//从数据库获取用户的角色
//SQLiteDatabase sdb=dbHelper.getReadableDatabase();
String sql="select role from user where username = '" + username+"'";
conn = db.getConnection();
String sql="select * from user_info where username = '" + username+"'and password = '"+password+"'";
User user = new User();
conn = DatabaseHelper.getConnection();
try{
Statement sttmt = conn.createStatement();
ResultSet rs = sttmt.executeQuery(sql);
rs.next();
String role = rs.getString(1);
user.setUser_id(rs.getLong("user_id"));
user.setUsername(rs.getNString("username"));
user.setPassword(rs.getNString("password"));
user.setPhone(rs.getNString("phone"));
user.setRole(rs.getNString("role"));
rs.close();
sttmt.close();
return role;
return user;
}catch (SQLException e){
e.printStackTrace();
}
return null;
}
public boolean UploadInfo(News news){//用户上传信息到数据库,服务器
String sql = "insert into stu_info(name,descri) values('"+news.getName()+"','"+news.getDescri() + "')";
conn = DatabaseHelper.getConnection();
try{
Statement sttmt = conn.createStatement();
sttmt.executeUpdate(sql);
sttmt.close();
return true;
}catch (SQLException e){
e.printStackTrace();
}
return false;
}
public void getAllNews(Context context,ArrayList<News> list){
//ArrayList<News> mlist = list;
String sql = "select * from stu_info where flags = 1";
conn = DatabaseHelper.getConnection();
try{
Statement sttmt = conn.createStatement();
ResultSet rs = sttmt.executeQuery(sql);
while (rs.next()){
News news= new News();
news.setStu_id(rs.getLong("stu_id"));
news.setName(rs.getNString("name"));
news.setDescri(rs.getNString("descri"));
news.setHead_icon(ContextCompat.getDrawable(context, R.drawable.ic_launcher_background));
list.add(news);
}
rs.close();
sttmt.close();
}catch(SQLException e){
e.printStackTrace();
}
}
public void getDonateRecords(ArrayList<Record> recordlist,long user_id){
String sql = "select * from record,stu_info where record.stu_id = stu_info.stu_id and record.user_id='"+user_id+"'";
conn = DatabaseHelper.getConnection();
try{
Statement sttmt = conn.createStatement();
ResultSet rs = sttmt.executeQuery(sql);
while(rs.next()){
Record record = new Record();
record.setStu_name(rs.getNString("name"));
record.setTime(rs.getNString("time"));
record.setDonatemon(rs.getFloat("donatemon"));
recordlist.add(record);
}
rs.close();
sttmt.close();
}catch (SQLException e){
e.printStackTrace();
}
}
public void getDonatedRecords(ArrayList<Record> recordlist,long id){
String sql = "select * from record,user_info where record.user_id = user_info.user_id and record.stu_id = '"+id+"'";
conn = DatabaseHelper.getConnection();
try{
Statement sttmt = conn.createStatement();
ResultSet rs = sttmt.executeQuery(sql);
while(rs.next()){
Record record = new Record();
record.setUser_name(rs.getNString("username"));
record.setTime(rs.getNString("time"));
record.setDonatemon(rs.getFloat("donatemon"));
recordlist.add(record);
}
rs.close();
sttmt.close();
}catch (SQLException e){
e.printStackTrace();
}
}
}

@ -0,0 +1,168 @@
package hunnu.sj.raise_money;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import hunnu.sj.raise_money.DataBase.UserService;
public class DonateActivity extends AppCompatActivity {
UserService userService=new UserService();
String username;
private long stu_id;
private long user_id;
Long id;
Handler mHandler = new Handler(){//用于处理子线程传回的消息对主线的UI进行修改
int flag = -1;
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
String txt;
switch (msg.what){
// case 1:
// flag = 1;
// txt = (String) msg.obj;
// number.setError(txt);
// break;
case 2:
flag= 2;
txt = (String) msg.obj;
money.setError(txt);
// case 3:
// flag=3;
// txt = (String) msg.obj;
// name.setError(txt);
}
}
};
// EditText name;
// EditText number;
EditText money;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_donate);
stu_id = getIntent().getLongExtra("stu_id",0);
user_id = getIntent().getLongExtra("user_id",0);
// Button commit = (Button) findViewById(R.id.commit);
// commit.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Intent intent;
// intent = new Intent(MainActivity.this,aActivity.class);
// startActivity(intent);
// }
// });
}
// public void onToMain(View view){
// Intent intent = new Intent(DonateActivity.this, MainActivity.class);
// startActivity(intent);
// MessageCommit();
// }
public void onClick(View view){
money=findViewById(R.id.Money);
new CommitThread().start();
}
// private void MessageCommit(){
// if(judge()){
// startActivity(intent);
// }
//
// }
// private boolean judge(){
//
// }
// private int judgenum(String num){
// if(num.length()!=11) return 1;
// Pattern p = null;
// Matcher m = null;
// boolean b = false;
// p = Pattern.compile("^[1][3,5,8][0-9]{9}$"); // 验证手机号
// m = p.matcher(num);
// b = m.matches();
// if(!b) return 2;
// return 3;
// }
private int judgemon(String mon){
String reg_money = "\\d+(\\.\\d{1,2})?";// 金额正则,可以没有小数,小数最多不超过两位
Pattern pattern = Pattern.compile(reg_money);
Matcher matcher = pattern.matcher(mon);
boolean ismatch = matcher.matches();
if(ismatch) return 1;
return 0;
}
// private int judgenam(String nam){
//// String regEx = "[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*";
//// Pattern pattern = Pattern.compile(regEx);
//// Matcher matcher = pattern.matcher(nam);
////
////
//// boolean isMatch = matcher.matches();
//// if (isMatch) return 1;
//// return 0;
//// }
class CommitThread extends Thread{
@Override
public void run() {
// int flag = -1;//先设置flag为-1
int flag1=-1;
// int flag11=-1;
String mon = money.getText().toString();
// String num = number.getText().toString();
// String nam=name.getText().toString();
// flag = judgenum(num);//用login函数来判断用户输入的用户名与密码是否正确
flag1=judgemon(mon);
// flag11=judgenam(nam);
Message message = mHandler.obtainMessage();
// if(flag==1){
//// message.what = 1;
//// message.obj = "电话号码位数不对";
//// mHandler.sendMessage(message);
//// }
//// else if(flag==2){
//// message.what = 1;
//// message.obj = "请输入正确的电话号码";
//// mHandler.sendMessage(message);
//// }
if(flag1==0) {
message.what = 2;
message.obj = "金额输入不对";
mHandler.sendMessage(message);
// }else if(flag11==0){
// message.what = 3;
// message.obj = "姓名输入不对";
// mHandler.sendMessage(message);
// }
}
else{
Looper.prepare();
Toast toast=Toast.makeText(DonateActivity.this, "提交成功",Toast.LENGTH_LONG);
Intent intent = new Intent(DonateActivity.this, MainActivity.class);
startActivity(intent);
float money=Float.parseFloat(mon);
userService.donate(stu_id,user_id,money);
toast.setGravity(Gravity.CENTER, 100, 100);
toast.show();
Looper.loop();
finish();
}
}
}
}

@ -0,0 +1,29 @@
package hunnu.sj.raise_money;
import android.content.Context;
import java.util.ArrayList;
import hunnu.sj.raise_money.DataBase.UserService;
import hunnu.sj.raise_money.record.Record;
import hunnu.sj.raise_money.news.News;
public class InfoUtils {
public static int getAllNews(Context context,ArrayList<News> list){//从数据库获取信息到本地
UserService uService = new UserService();
uService.getAllNews(context,list);
return 1;
}
public static int getDonateRecords(ArrayList<Record> recordlist,long user_id){
UserService uService = new UserService();
uService.getDonateRecords(recordlist,user_id);
return 1;
}
public static int getDonatedRecords(ArrayList<Record> recordlist,long id){
UserService uService = new UserService();
uService.getDonatedRecords(recordlist,id);
return 1;
}
}

@ -0,0 +1,148 @@
package hunnu.sj.raise_money;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import hunnu.sj.raise_money.DataBase.UserService;
import hunnu.sj.raise_money.MainActivity;
import hunnu.sj.raise_money.R;
public class LongTermDonate extends AppCompatActivity {
UserService userService=new UserService();
//String username;
//String stu_name;
Long stu_id,user_id;
Handler mHandler = new Handler(){//用于处理子线程传回的消息对主线的UI进行修改
int flag = -1;
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
String txt;
switch (msg.what){
// case 1:
// flag = 1;
// txt = (String) msg.obj;
// number.setError(txt);
// break;
// case 2:
// flag=2;
// txt = (String) msg.obj;
// des.setError(txt);
case 3:
flag=3;
txt = (String) msg.obj;
name.setError(txt);
}
}
};
EditText name;
EditText number;
EditText des;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_long_term_donate);
stu_id= getIntent().getLongExtra("stu_id",0);
user_id=getIntent().getLongExtra("user_id",0);
}
public void onClick(View view){
name=findViewById(R.id.Name);
// number=findViewById(R.id.TeleNumber);
// des=findViewById(R.id.Desp);
new CommitThread().start();
}
// private int judgenum(String num){
// if(num.length()!=11) return 1;
// Pattern p = null;
// Matcher m = null;
// boolean b = false;
// p = Pattern.compile("^[1][3,5,8][0-9]{9}$"); // 验证手机号
// m = p.matcher(num);
// b = m.matches();
// if(!b) return 2;
// return 3;
// }
private int judgenam(String nam){//验证名字
String regEx = "[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*";
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(nam);
boolean isMatch = matcher.matches();
if (isMatch) return 1;
return 0;
}
// private int judgedes(String des){
// if ((des == null) || ("".equals(des)))
// return 0;
// return 1;//描述不为空
// }
class CommitThread extends Thread{
@Override
public void run() {
// int flag = -1;//先设置flag为-1
// int flag1=-1;
int flag11=-1;
String nam=name.getText().toString();
flag11=judgenam(nam);
// String num = number.getText().toString();
// String DESP=des.getText().toString();
// flag = judgenum(num);//判断手机号
// flag11 = judgedes(DESP);
Message message = mHandler.obtainMessage();
// if(flag==1){
// message.what = 1;
// message.obj = "电话号码位数不对";
// mHandler.sendMessage(message);
// }
// else if(flag==2){
// message.what = 1;
// message.obj = "请输入正确的电话号码";
// mHandler.sendMessage(message);
// }
if(flag11==0){
message.what = 3;
message.obj = "姓名输入不对";
mHandler.sendMessage(message);
}
// else if(flag1==0){
// message.what = 2;
// message.obj = "描述为空,请输入一些描述";
// mHandler.sendMessage(message);
// }
else{
Looper.prepare();
userService.longterm(nam,stu_id,user_id);
Toast toast=Toast.makeText(LongTermDonate.this, "提交成功",Toast.LENGTH_LONG);
Intent intent = new Intent(LongTermDonate.this, MainActivity.class);
startActivity(intent);
//userService.donate(username,stu_name,id,money);
toast.setGravity(Gravity.CENTER, 100, 100);
toast.show();
Looper.loop();
finish();
}
}
}
}

@ -1,18 +1,18 @@
package hunnu.sj.raise_money;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import android.os.Handler;
import android.os.Message;
import android.view.MenuItem;
import android.view.View;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.core.content.ContextCompat;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.navigation.NavigationView;
@ -22,71 +22,118 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
import java.util.ArrayList;
TextView menu_name;
TextView menu_role;
import hunnu.sj.raise_money.news.News;
import hunnu.sj.raise_money.news.NewsAdapter;
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener{
private AppBarConfiguration mAppBarConfiguration;
private Toolbar toolbar;
private ActionBarDrawerToggle mToggle;
private DrawerLayout mDrawerlayout;
private NavigationView navigationView;
private User user;
ArrayList<News> list = new ArrayList<>();
Context mContext;
private NewsAdapter newsAdapter;
private ListView lv_news;
private Handler mhandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if(msg.what==1){
newsAdapter.notifyDataSetChanged();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
User user;
user = (User) intent.getSerializableExtra("user");
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow,
R.id.nav_tools, R.id.nav_share, R.id.nav_send)
.setDrawerLayout(drawer)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
if(navigationView.getHeaderCount() > 0) {
mContext = this;
newsAdapter = new NewsAdapter(this,list);
init();
if(navigationView.getHeaderCount() > 0) {//设置侧滑栏的显示的值
View header = navigationView.getHeaderView(0);
TextView menu_name = header.findViewById(R.id.user_name);
TextView menu_role = header.findViewById(R.id.user_role);
menu_name.setText(user.getName());
menu_name.setText(user.getUsername());
menu_role.setText(user.getRole());
}
lv_news = findViewById(R.id.list);
lv_news.setAdapter(newsAdapter);
lv_news.setOnItemClickListener(this);
new UploadThread().start();
}
private void init(){
toolbar = (Toolbar) findViewById(R.id.toolbar);
mDrawerlayout = (DrawerLayout)findViewById(R.id.drawer_layout);
toolbar.setTitle("");
mToggle = new ActionBarDrawerToggle(this, mDrawerlayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawerlayout.addDrawerListener(mToggle);
mToggle.syncState();
mDrawerlayout.setDrawerListener(mToggle);
navigationView = findViewById(R.id.nav_view);
}
@Override//点击条目时调用该方法parent指listviewposition指条目位置
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
News news = (News)parent.getItemAtPosition(position);
String title=news.getName();
String des=news.getDescri();
long stu_id = news.getStu_id();
Intent intent = new Intent(this,NewsContentActivity.class);
intent.putExtra("news_title",title);
intent.putExtra("news_des",des);
intent.putExtra("stu_id",stu_id);
intent.putExtra("user_id",user.getUser_id());
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onSupportNavigateUp() {
private class UploadThread extends Thread{
@Override
public void run() {
Message message = mhandler.obtainMessage();
int isload = InfoUtils.getAllNews(mContext,list);
message.what = isload;
mhandler.sendMessage(message);//加载数据库成功返回1并且给handler发送信息刷新list的变量
}
}
/*public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|| super.onSupportNavigateUp();
}
}*/
public void onNeedHelp(MenuItem item){
public void onNeedHelp(MenuItem item){//侧滑栏的item用于提交信息
Intent intent = new Intent(this, UploadActivity.class);
startActivity(intent);
}//ssds
}
public void onBrowseDonateRecord(MenuItem item){
Intent intent = new Intent(this, BrowseDonateRecordActivity.class);
long user_id = user.getUser_id();
intent.putExtra("user_id",user_id);
startActivity(intent);
}
}

@ -0,0 +1,24 @@
package hunnu.sj.raise_money;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.navigation.fragment.NavHostFragment;
public class MyFragment extends NavHostFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
FrameLayout frameLayout = new FrameLayout(inflater.getContext());
// When added via XML, this has no effect (since this FrameLayout is given the ID
// automatically), but this ensures that the View exists as part of this Fragment's View
// hierarchy in cases where the NavHostFragment is added programmatically as is required
// for child fragment transactions
frameLayout.setId(getId());
return frameLayout;
}
}

@ -1,18 +0,0 @@
package hunnu.sj.raise_money;
public class News {
private String title;
private String content;
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;
}
}

@ -1,31 +0,0 @@
package hunnu.sj.raise_money;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
public class NewsAdapter extends ArrayAdapter<News> {
private int resourceId;
public NewsAdapter(Context context, int textViewResourceId, List<News> objects) {
super(context, textViewResourceId, objects);
resourceId = textViewResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
News news = getItem(position);
View view;
if (convertView == null) {
view = LayoutInflater.from(getContext()).inflate(resourceId, null);
} else {
view = convertView;
}
TextView newsTitleText =(TextView) view.findViewById(R.id.news_title);
newsTitleText.setText(news.getTitle());
return view;
}
}

@ -4,29 +4,79 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class NewsContentActivity extends AppCompatActivity{
public static void actionStart(Context context, String newsTitle, String newsContent) {
Intent intent = new Intent(context, NewsContentActivity.class);
intent.putExtra("news_title", newsTitle);
intent.putExtra("news_content", newsContent);
context.startActivity(intent);
}
private long stu_id;
private long user_id;
String username;
String newsTitle;
// public static void actionStart(Context context, String newsTitle, String newsContent) {
// Intent intent = new Intent(context, NewsContentActivity.class);
// intent.putExtra("news_title", newsTitle);
// intent.putExtra("news_content", newsContent);
// context.startActivity(intent);
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.v("news_title","here");
// Log.v("news_title","here");
setContentView(R.layout.news_content);
String newsTitle = getIntent().getStringExtra("news_title"); // 获取传入的新闻标题
newsTitle = getIntent().getStringExtra("news_title"); // 获取传入的新闻标题
String newsContent = getIntent().getStringExtra("news_content"); // 获取传入的新闻内容
stu_id = getIntent().getLongExtra("stu_id",0);
user_id = getIntent().getLongExtra("user_id",0);
NewsContentFragment newsContentFragment = (NewsContentFragment)
getFragmentManager().findFragmentById(R.id.news_content_fragment);
newsContentFragment.refresh(newsTitle, newsContent); // 刷新NewsContentFragment界面
onToDonate();
onBrowseRecord();
onToLongTerm();
}
public void onToDonate( ){
Button button1 = findViewById(R.id.button);//id后面为上方button的id
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(NewsContentActivity.this, DonateActivity.class);//this前面为当前activty名称class前面为要跳转到得activity名称
intent.putExtra("stu_id",stu_id);
intent.putExtra("user_id",user_id);
startActivity(intent);
}
});
}
public void onBrowseRecord(){
Button button = findViewById(R.id.browse_donated_btn);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(NewsContentActivity.this, BrowseDonatedRecordActivity.class);
intent.putExtra("stu_id",stu_id);
startActivity(intent);
}
});
}
public void onToLongTerm( ){
Button longterm= findViewById(R.id.longterm);
longterm.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(NewsContentActivity.this, LongTermDonate.class);//this前面为当前activty名称class前面为要跳转到得activity名称
intent.putExtra("stu_id",stu_id);
intent.putExtra("user_id",user_id);
startActivity(intent);
}
});
}
}

@ -1,69 +0,0 @@
package hunnu.sj.raise_money;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.app.Fragment;
import java.util.ArrayList;
import java.util.List;
public class NewsTitleFragment extends Fragment implements AdapterView.OnItemClickListener {
private ListView newsTitleListView;
private List<News> newsList;
private NewsAdapter adapter;
private boolean isTwoPane;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
newsList = getNews(); // 初始化新闻数据
adapter = new NewsAdapter(activity, R.layout.news_item, newsList);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_news_title, container, false);
newsTitleListView = (ListView) view.findViewById(R.id.news_title_list_view);
newsTitleListView.setAdapter(adapter);
newsTitleListView.setOnItemClickListener(this);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
isTwoPane = false; // 可以找到news_content_layout布局时为双页模式
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
News news = newsList.get(position);
if (isTwoPane) {
// 如果是双页模式则刷新NewsContentFragment中的内容
NewsContentFragment newsContentFragment = (NewsContentFragment) getFragmentManager().findFragmentById(R.id.news_content_fragment);
newsContentFragment.refresh(news.getTitle(), news.getContent());
} else {
// 如果是单页模式则直接启动NewsContentActivity
NewsContentActivity.actionStart(getActivity(), news.getTitle(), news.getContent());
}
}
private List<News> getNews() {
List<News> newsList = new ArrayList<News>();
News news1 = new News();
news1.setTitle("Succeed in College as a Learning Disabled Student");
news1.setContent("College freshmen will soon learn to live with a"
+"roommate, adjust to a new social scene and survive less-than-stellar"
+"dining hall food. Students with learning disabilities will face these"
+"transitions while also grappling with a few more hurdles.");
newsList.add(news1);
News news2 = new News();
news2.setTitle("Google Android exec poached by China's Xiaomi");
news2.setContent("China's Xiaomi has poached a key Google executive"+
"involved in the tech giant's Android phones, in a move seen as a coup"+
" for the rapidly growing Chinese smartphone maker.");
newsList.add(news2);
return newsList;
}
}

@ -13,18 +13,19 @@ import android.widget.RadioButton;
import hunnu.sj.raise_money.DataBase.UserService;
//用户注册
public class RegiteActivity extends AppCompatActivity {
EditText user_name;
EditText pass_word;
EditText repass_word;
EditText phone_edit;
RadioButton radio1;
RadioButton radio2;
String role;
Handler rHandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
super.handleMessage(msg);//用户在主线程中处理子线程发送回来的消息,更改控件内容
String txt = (String) msg.obj;
switch (msg.what){
case 0:
@ -53,6 +54,7 @@ public class RegiteActivity extends AppCompatActivity {
user_name = findViewById(R.id.user_name);
pass_word = findViewById(R.id.pass_word);
repass_word = findViewById(R.id.repass_word);
phone_edit = findViewById(R.id.phone_edit);
role = "默认角色";
radio1 = findViewById(R.id.ratio1);
radio2 = findViewById(R.id.radio2);
@ -61,6 +63,7 @@ public class RegiteActivity extends AppCompatActivity {
}else if(radio2.isChecked()){
role = "贫困学生";
}
//获取注册界面的控件
new RegiteThread().start();
}
@ -69,10 +72,11 @@ public class RegiteActivity extends AppCompatActivity {
public void run() {
String username = user_name.getText().toString();
String password = pass_word.getText().toString();
String repassword = repass_word.getText().toString();
String repassword = repass_word.getText().toString();//从控件获取字符
String phone = phone_edit.getText().toString();
UserService uService = new UserService();
Message message = rHandler.obtainMessage();
if(username.trim().equals("")){
Message message = rHandler.obtainMessage();//使用handler来处理信息
if(username.trim().equals("")){//一系列条件来判断是否可注册
message.what = 0;
message.obj = "请输入用户名";
rHandler.sendMessage(message);
@ -80,20 +84,23 @@ public class RegiteActivity extends AppCompatActivity {
message.what = 1;
message.obj = "请输入密码";
rHandler.sendMessage(message);
}
if(!password.equals(repassword)){
}else if(!password.equals(repassword)){
message.what = 2;
message.obj = "密码验证错误";
rHandler.sendMessage(message);
}else if(uService.login(username,password)==1){
}else if(uService.login(username,password)!=0){
message.what = 3;
message.obj = "用户已存在";
}else{
rHandler.sendMessage(message);//发送信息给handler
}/*else if(){//
}*/else{
User user = new User();
user.setName(username);
user.setPasd(password);
user.setUsername(username);
user.setPassword(password);
user.setRole(role);
uService.register(user);
user.setPhone(phone);
uService.register(user);//注册
Intent intent = new Intent(RegiteActivity.this,SignInActivity.class);
startActivity(intent);
finish();

@ -6,11 +6,16 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.util.ArrayList;
import hunnu.sj.raise_money.DataBase.UserService;
public class SignInActivity extends AppCompatActivity {
@ -18,8 +23,9 @@ public class SignInActivity extends AppCompatActivity {
public static final int SEND = 0;
EditText usnm;
EditText pswd;
UserService uService;
User user;
Handler mHandler = new Handler(){
Handler mHandler = new Handler(){//用于处理子线程传回的消息对主线的UI进行修改
int flag = -1;
@Override
public void handleMessage(@NonNull Message msg) {
@ -44,12 +50,14 @@ public class SignInActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
uService = new UserService();
}
public void user_commit(View view){
usnm = findViewById(R.id.user_name);
pswd = findViewById(R.id.pass_word);
new LoginThread().start();
}
public void onToRegister(View view){
@ -60,32 +68,33 @@ public class SignInActivity extends AppCompatActivity {
class LoginThread extends Thread{
@Override
public void run() {
int flag = -1;
int flag = -1;//先设置flag为-1
String name = usnm.getText().toString();
String pasd = pswd.getText().toString();
UserService uService = new UserService();
flag = uService.login(name,pasd);
//UserService uService = new UserService();
flag = uService.login(name,pasd);//用login函数来判断用户输入的用户名与密码是否正确
Message message = mHandler.obtainMessage();
if(flag==0){
message.what = 0;
message.obj = "用户名不存在";
mHandler.sendMessage(message);
mHandler.sendMessage(message);//使用handler给主线程发送消息
}else if(flag==1){
message.what = 1;
message.obj = "密码错误";
mHandler.sendMessage(message);
}else if(flag==-1){
Looper.prepare();
Toast toast = Toast.makeText(SignInActivity.this,"断网了!",Toast.LENGTH_SHORT);
toast.show();
Looper.loop();
}else{
User user = new User();
user.setName(name);
user.setPasd(pasd);
String role = uService.getRole(name);
user.setRole(role);
Bundle bundle = new Bundle();
bundle.putSerializable("user",user);
Intent intent =new Intent(SignInActivity.this,MainActivity.class);
intent.putExtras(bundle);
startActivity(intent);
finish();
User user = uService.getUserInfo(name,pasd);
Bundle bundle = new Bundle();//将类包装到bundle里再放到intent里
bundle.putSerializable("user",user);
Intent intent =new Intent(SignInActivity.this,MainActivity.class);
intent.putExtras(bundle);
startActivity(intent);
finish();
}
}
}

@ -1,38 +1,41 @@
package hunnu.sj.raise_money;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import hunnu.sj.raise_money.R;
import hunnu.sj.raise_money.DataBase.UserService;
import hunnu.sj.raise_money.news.News;
public class UploadActivity extends AppCompatActivity {
public static final int TAKE_PHOTO = 1;
private ImageView stu_pic;
private ImageView[] stu_src;
private Uri imageUri;
private EditText info_name;
private EditText info_desc;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_upload);
stu_pic = findViewById(R.id.stu_pic);
context = this;
//stu_pic = findViewById(R.id.stu_pic);
}
protected void onUploadPic(View view){
public void onUploadPic(View view){
/*File outputImage = new File(getExternalCacheDir(),"output_image.jpg");
try {
if(outputImage.exists()){
@ -48,9 +51,38 @@ public class UploadActivity extends AppCompatActivity {
imageUri = Uri.fromFile(outputImage);
}*/
Intent intent = new Intent(Intent.ACTION_PICK,null);
/*Intent intent = new Intent(Intent.ACTION_PICK,null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,"image/*");
startActivityForResult(intent,1);
startActivityForResult(intent,1);*/
info_name = findViewById(R.id.info_name);
info_desc = findViewById(R.id.info_desc);
new UploadThread().start();
}
private class UploadThread extends Thread{
@Override
public void run() {
String name = info_name.getText().toString();
String desc = info_desc.getText().toString();
News news = new News();
news.setName(name);
news.setDescri(desc);
UserService uService = new UserService();
if(uService.UploadInfo(news)){
Looper.prepare();
Toast toast =Toast.makeText(context,"信息上传成功",Toast.LENGTH_SHORT);
toast.show();
Intent intent = new Intent(UploadActivity.this,MainActivity.class);
startActivity(intent);
Looper.loop();
}else{
Looper.prepare();
Toast toast =Toast.makeText(context,"信息上传失败",Toast.LENGTH_SHORT);
toast.show();
Looper.loop();
}
}
}
private void onLoadPic(){

@ -1,42 +1,62 @@
package hunnu.sj.raise_money;
import java.io.Serializable;
public class User implements Serializable{
private String name;
private String pasd;
private String username;
private String password;
private String role;
private String phone;
private String name;
private long user_id;
public User(){
super();
name = null;
}
public User(String name,String pasd,String role){
super();
this.name = name;
this.pasd = pasd;
this.role = role;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
public String getUsername() {
return username;
}
public void setPasd(String pasd) {
this.pasd = pasd;
public void setUsername(String username) {
this.username = username;
}
public String getPasd() {
return pasd;
public String getPassword() {
return password;
}
public void setRole(String role) {
this.role = role;
public void setPassword(String password) {
this.password = password;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public long getUser_id() {
return user_id;
}
public void setUser_id(long user_id) {
this.user_id = user_id;
}
}

@ -0,0 +1,51 @@
package hunnu.sj.raise_money.donate_record;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import hunnu.sj.raise_money.R;
import hunnu.sj.raise_money.record.Record;
public class DonateRecordAdapter extends BaseAdapter {
private ArrayList<Record> recordlist;
private Context context;
public DonateRecordAdapter(Context context, ArrayList<Record> recordlist) {
this.context = context;
this.recordlist = recordlist;
}
@Override
public int getCount() {
return recordlist.size();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return recordlist.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
if(convertView != null){
view = convertView;
}else{
view = View.inflate(context, R.layout.donate_record_item,null);
}
Record record = recordlist.get(position);
TextView record_vw = view.findViewById(R.id.record_descri);
String descri = "您于"+record.getTime()+"给"+record.getStu_name()+"捐赠"+record.getDonatemon()+"元";
record_vw.setText(descri);
return view;
}
}

@ -0,0 +1,52 @@
package hunnu.sj.raise_money.donated_record;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import hunnu.sj.raise_money.R;
import hunnu.sj.raise_money.record.Record;
public class DonatedRecordAdapter extends BaseAdapter {
private ArrayList<Record> recordlist;
private Context context;
public DonatedRecordAdapter(Context context, ArrayList<Record> recordlist) {
this.context = context;
this.recordlist = recordlist;
}
@Override
public int getCount() {
return recordlist.size();
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Object getItem(int position) {
return recordlist.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
if(convertView != null){
view = convertView;
}else{
view = View.inflate(context, R.layout.donate_record_item,null);
}
Record record = recordlist.get(position);
TextView record_vw = view.findViewById(R.id.record_descri);
String descri = "用户"+record.getUser_name()+"于"+record.getTime()+"捐赠了"+record.getDonatemon()+"元";
record_vw.setText(descri);
return view;
}
}

@ -0,0 +1,41 @@
package hunnu.sj.raise_money.news;
import android.graphics.drawable.Drawable;
public class News {//主界面浏览的信息的类
private long stu_id;
private String name;
private String descri;
private Drawable head_icon;
public Drawable getHead_icon() {
return head_icon;
}
public void setHead_icon(Drawable head_icon) {
this.head_icon = head_icon;
}
public long getStu_id() {
return stu_id;
}
public void setStu_id(long stu_id) {
this.stu_id = stu_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescri() {
return descri;
}
public void setDescri(String descri) {
this.descri = descri;
}
}

@ -0,0 +1,56 @@
package hunnu.sj.raise_money.news;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import hunnu.sj.raise_money.R;
//信息的适配器
public class NewsAdapter extends BaseAdapter {
private ArrayList<News> list;
private Context context;
public NewsAdapter(Context context,ArrayList<News> list) {
this.context = context;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position){
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
if(convertView != null){
view = convertView;
}else{
view = View.inflate(context, R.layout.info_item_layout,null);
}
ImageView item_icon = (ImageView) view.findViewById(R.id.item_head_icon);
TextView item_title = (TextView) view.findViewById(R.id.item_info_title);
TextView item_des = (TextView) view.findViewById(R.id.item_info_des);
News news = list.get(position);
item_icon.setImageDrawable(news.getHead_icon());
item_title.setText(news.getName());
item_des.setText(news.getDescri());
return view;
}
}

@ -0,0 +1,58 @@
package hunnu.sj.raise_money.record;
public class Record {
private long user_id;
private long stu_id;
private float donatemon = 0;
private String user_name;
private String stu_name;
private String time = null;
public float getDonatemon() {
return donatemon;
}
public void setDonatemon(float donatemon) {
this.donatemon = donatemon;
}
public long getUser_id() {
return user_id;
}
public void setUser_id(long user_id) {
this.user_id = user_id;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public long getStu_id() {
return stu_id;
}
public void setStu_id(long stu_id) {
this.stu_id = stu_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getStu_name() {
return stu_name;
}
public void setStu_name(String stu_name) {
this.stu_name = stu_name;
}
}

@ -0,0 +1,17 @@
<?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"
tools:context=".BrowseDonateRecordActivity">
<ListView
android:id="@+id/lv_browse_denate_record"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,82 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp">
<TextView
android:id="@+id/name"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/colorAccent"
android:text="姓名" />
<EditText
android:id="@+id/Name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="请输入你的姓名"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/teleNumber"
android:layout_width="40dp"
android:layout_height="34dp"
android:layout_weight="1"
android:maxLength="11"
android:numeric="integer"
android:textColor="@color/colorAccent"
android:text="电话号码" />
<EditText
android:id="@+id/TeleNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="请输入你的电话号码"
android:inputType="textPersonName" />
</LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<TextView
android:id="@+id/money"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/colorAccent"
android:text="输入捐款金额" />
<EditText
android:id="@+id/Money"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="请输入捐赠金额"
android:inputType="numberDecimal"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="onClick"
android:text="提交">
</Button>
</LinearLayout>

@ -0,0 +1,92 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textColor="@color/colorAccent"
android:text="姓名" />
<EditText
android:id="@+id/Name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="请输入你的姓名"
android:inputType="textPersonName" />
</LinearLayout>
<!--
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/teleNumber"
android:layout_width="40dp"
android:layout_height="34dp"
android:layout_weight="1"
android:maxLength="11"
android:numeric="integer"
android:textColor="@color/colorAccent"
android:text="电话号码" />
<EditText
android:id="@+id/TeleNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="请输入你的电话号码"
android:inputType="textPersonName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<TextView
android:id="@+id/desp"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/colorAccent"
android:text="输入你的信息描述" />
<EditText
android:id="@+id/Desp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:hint="信息描述"
/>-->
<!-- <Button
android:id="@+id/commit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="75dp"
android:onClick="onToMain"
android:text="跳转首页"></Button>
-->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:onClick="onClick"
android:text="提交">
</Button>
</LinearLayout>

@ -7,7 +7,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<!--侧滑栏的布局-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"

@ -4,99 +4,133 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
tools:context=".RegiteActivity">
<!--注册界面的布局-->
<EditText
android:id="@+id/user_name"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/linearLayout8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请输入你的用户名"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.358"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.148" />
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="@+id/pass_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请输入密码"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.358"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.256" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/repass_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="请再次确认密码"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.358"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.362" />
<EditText
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="请输入你的用户名"
android:inputType="textPersonName" />
<Button
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRegister"
android:text="注册"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.427"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.765" />
<EditText
android:id="@+id/pass_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="请输入密码"
android:inputType="textPassword" />
<RadioGroup
android:id="@+id/ratio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.63"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.56">
<EditText
android:id="@+id/repass_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="请再次确认密码"
android:inputType="textPassword" />
<RadioButton
android:id="@+id/ratio1"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="爱心人士" />
<EditText
android:id="@+id/phone_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="请输入电话"
android:inputType="textPersonName" />
</LinearLayout>
<RadioButton
android:id="@+id/radio2"
<LinearLayout
android:id="@+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="贫困学生" />
</RadioGroup>
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="80dp"
android:orientation="vertical">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="您是"
android:textColor="@android:color/background_dark"
android:textSize="30sp" />
</LinearLayout>
<TextView
android:id="@+id/textView3"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<RadioGroup
android:id="@+id/ratio"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/ratio1"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:checked="true"
android:text="爱心人士" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="贫困学生" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="您是"
android:textColor="@android:color/background_dark"
android:textSize="30sp"
android:layout_marginTop="20dp"
android:onClick="onRegister"
android:text="注册"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.202"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.557" />
app:layout_constraintTop_toBottomOf="@+id/linearLayout8"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:background="@drawable/beijin"
tools:context=".Initial">
<!--登录界面的布局-->
<EditText
android:id="@+id/user_name"
android:layout_width="wrap_content"

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UploadActivity">
<!--上传信息的布局(暂时)-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -34,7 +34,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@android:dimen/app_icon_size"
android:onClick="onUploadPic"
android:text="上传图片" />
</LinearLayout>
@ -44,7 +43,15 @@
android:orientation="vertical">
<EditText
android:id="@+id/editText"
android:id="@+id/info_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="姓名"
android:inputType="textPersonName" />
<EditText
android:id="@+id/info_desc"
android:layout_width="fill_parent"
android:layout_height="125dp"
android:layout_marginTop="@dimen/activity_horizontal_margin"
@ -104,6 +111,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:gravity="center"
android:onClick="onUploadPic"
android:text="提交" />
</LinearLayout>

@ -22,12 +22,4 @@
<include layout="@layout/content_main" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -6,21 +6,17 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main">
<!--主界面的布局(新闻)-->
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
<ListView
android:id="@+id/list"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
</ListView>
<fragment
android:id="@+id/fragment"
android:name="hunnu.sj.raise_money.NewsContentFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,26 @@
<?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:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/record_descri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|top"
android:layout_marginStart="5sp"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_weight="1"
android:text="record"
android:textColor="@android:color/background_dark"
android:textSize="24sp" />
</LinearLayout>
</LinearLayout>

@ -1,26 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_height="match_parent">
<LinearLayout
android:id="@+id/visibility_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="invisible" >
android:visibility="invisible">
<TextView
android:id="@+id/news_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="61dp"
android:gravity="center"
android:padding="10dp"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="161dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/ph1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:srcCompat="@tools:sample/avatars" />
<ImageView
android:id="@+id/ph2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:srcCompat="@tools:sample/avatars" />
<ImageView
android:id="@+id/ph3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:srcCompat="@tools:sample/avatars" />
</LinearLayout>
<TextView
android:id="@+id/news_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="457dp"
android:layout_weight="1"
android:padding="15dp"
android:scrollbars="vertical"
android:textSize="18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<Button
android:id="@+id/browse_donated_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:text="捐助信息" />
<Button
android:id="@+id/longterm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:text="长期捐助" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:onClick="onToMain"
android:text="捐助" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>

@ -3,9 +3,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/news_title_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
android:layout_height="match_parent"></ListView>
</LinearLayout>

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/item_head_icon"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_gravity="center"
android:layout_marginRight="10dp"
app:srcCompat="@mipmap/ic_launcher" />
<LinearLayout
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:singleLine="true"
android:id="@+id/item_info_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:text="title"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:maxLines="2"
android:id="@+id/item_info_des"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="des"
android:textColor="#666666"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>

@ -12,7 +12,7 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<!--侧滑栏用户头像-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"

@ -8,4 +8,5 @@
android:name="hunnu.sj.raise_money.NewsContentFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

@ -4,4 +4,8 @@
android:id="@+id/needhelp"
android:onClick="onNeedHelp"
android:title="@string/need_help" />
<item
android:id="@+id/browse_donate_record"
android:onClick="onBrowseDonateRecord"
android:title="@string/browse_donate_record" />
</menu>

@ -17,6 +17,7 @@
<string name="menu_role">用户角色</string>
<string name="menu_pic">HeadPortrait</string>
<string name="need_help">申请帮助</string>
<string name="browse_donate_record">查看捐款记录</string>
<string name="on_upload_pic">onUploadPic</string>
<!-- TODO: Remove or change this placeholder text -->

Loading…
Cancel
Save