parent
c1bd6ae582
commit
bfe8acad30
@ -1,15 +1,52 @@
|
||||
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;
|
||||
|
||||
public class BrowseRecordActivity extends AppCompatActivity {
|
||||
import java.util.ArrayList;
|
||||
|
||||
import hunnu.sj.raise_money.donate_record.Record;
|
||||
import hunnu.sj.raise_money.donate_record.RecordAdapter;
|
||||
|
||||
public class BrowseRecordActivity extends AppCompatActivity {
|
||||
private ArrayList<Record> records = new ArrayList<>();
|
||||
private ListView lv_record;
|
||||
private RecordAdapter recordAdapter;
|
||||
private String username;
|
||||
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();
|
||||
username = intent.getStringExtra("username");
|
||||
recordAdapter = new RecordAdapter(this,records);
|
||||
lv_record = findViewById(R.id.lv_browse_denate_record);
|
||||
lv_record.setAdapter(recordAdapter);
|
||||
new BrowseRecordThread().start();
|
||||
}
|
||||
|
||||
class BrowseRecordThread extends Thread{
|
||||
@Override
|
||||
public void run() {
|
||||
Message msg =mhandler.obtainMessage();
|
||||
int flags = InfoUtils.getDonateRecords(records,username);
|
||||
msg.what = flags;
|
||||
mhandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
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.donate_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,String username){
|
||||
UserService uService = new UserService();
|
||||
uService.getDonateRecords(recordlist,username);
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package hunnu.sj.raise_money;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import hunnu.sj.raise_money.DataBase.UserService;
|
||||
|
||||
public class NewsUtils {
|
||||
public static int getAllNews(Context context,ArrayList<News> list){//从数据库获取信息到本地
|
||||
UserService uService = new UserService();
|
||||
uService.getAllNews(context,list);
|
||||
return 1;
|
||||
/*for(int i = 0 ;i <100;i++)
|
||||
{
|
||||
News news = new News();
|
||||
news.setTitle("火箭发射成功");
|
||||
news.setDes("地方上的房贷首付读书首付第三方的手房贷首付第三方的手负担");
|
||||
news.setHead_icon(ContextCompat.getDrawable(context, R.drawable.ic_launcher_background));
|
||||
list.add(news);
|
||||
}*/
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package hunnu.sj.raise_money.donate_record;
|
||||
|
||||
public class Record {
|
||||
private long id = 0;
|
||||
private String stu_name = null;
|
||||
private String username = null;
|
||||
private float donatemon = 0;
|
||||
private String time = null;
|
||||
|
||||
public float getDonatemon() {
|
||||
return donatemon;
|
||||
}
|
||||
|
||||
public void setDonatemon(float donatemon) {
|
||||
this.donatemon = donatemon;
|
||||
}
|
||||
|
||||
public String getStu_name() {
|
||||
return stu_name;
|
||||
}
|
||||
|
||||
public void setStu_name(String stu_name) {
|
||||
this.stu_name = stu_name;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
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;
|
||||
|
||||
public class RecordAdapter extends BaseAdapter {
|
||||
private ArrayList<Record> recordlist;
|
||||
private Context context;
|
||||
public RecordAdapter(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,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>
|
Loading…
Reference in new issue