提交 c8a63c28 编写于 作者: S suhy

清理文件

上级 6b8584a6
......@@ -62,12 +62,28 @@
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/fragment_news.xml" value="0.19972826086956522" />
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/fragment_photo.xml" value="0.16964285714285715" />
<entry key="..\:/Users/suhy/Desktop/github/Android/MyHomeWork/app/src/main/res/layout/userhead_item.xml" value="0.14791666666666667" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_ar.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_evalute.xml" value="0.2" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_historical_records.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_login.xml" value="0.264" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_login1.xml" value="0.2" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_main.xml" value="0.176" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_register.xml" value="0.1793478260869565" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_update_photo.xml" value="0.1793478260869565" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/activity_user_information.xml" value="0.1793478260869565" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/add_message.xml" value="0.4" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/appbar.xml" value="0.264" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/drawer_header.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/fragment_chat.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/fragment_home.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/fragment_news.xml" value="0.11822916666666666" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/fragment_photo.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/historyrecord_item.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/msg_right_layout.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/recycler_item.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/layout/userhead_item.xml" value="0.13858695652173914" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/menu/bottom_nav_menu.xml" value="0.15104166666666666" />
<entry key="..\:/Users/suhy/Desktop/github/drift-bottle/MyHomeWork/app/src/main/res/menu/photo_menu.xml" value="0.15104166666666666" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/drawable/icon__1_.xml" value="0.185546875" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_evalute.xml" value="0.16530054644808742" />
<entry key="..\:/Users/suhy/Desktop/github/schoolphoto/MyHomeWork/app/src/main/res/layout/activity_historical_records.xml" value="0.176" />
......
......@@ -39,15 +39,6 @@
<activity
android:name=".activity.ArActivity"
android:exported="false" />
<activity
android:name=".activity.EvaluteActivity"
android:exported="false" />
<activity
android:name=".activity.HistoricalRecordsActivity"
android:exported="false" />
<activity
android:name=".activity.UpdatePhotoActivity"
android:exported="true" />
<activity
android:name=".activity.RegisterActivity"
android:exported="true" />
......
package com.example.myhomework.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.example.myhomework.bean.Evaluate;
import com.example.myhomework.service.EvaluateService;
import com.example.myhomework.service.UserService;
import com.example.myhomework.databinding.ActivityEvaluteBinding;
import com.example.myhomework.databinding.AppbarBinding;
public class EvaluteActivity extends AppCompatActivity {
ActivityEvaluteBinding binding;
AppbarBinding appbarBinding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding=ActivityEvaluteBinding.inflate(getLayoutInflater());
binding.include.textviewToolbar.setText("发表评价");
setContentView(binding.getRoot());
binding.push.setOnClickListener(v->{
String star=binding.ratingBar.getNumStars()+"";
String msg=binding.msg.getText().toString();
if(msg.equals(""))
Toast.makeText(this,"评价内容不能为空",Toast.LENGTH_LONG).show();
Evaluate evaluate=new Evaluate();
evaluate.setUid(UserService.GetUid());
evaluate.setHid(HistoricalRecordsActivity.temhistory.getHid());
evaluate.setMsg(msg);
evaluate.setStar(star);
EvaluateService.addEvaluate(evaluate,this);
});
binding.close.setOnClickListener(v->finish());
}
}
\ No newline at end of file
package com.example.myhomework.activity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.myhomework.bean.HistoryRecord;
import com.example.myhomework.R;
import com.example.myhomework.service.HistoryRecordService;
import com.example.myhomework.service.UserService;
import com.example.myhomework.databinding.ActivityHistoricalRecordsBinding;
import com.example.myhomework.databinding.HistoryrecordItemBinding;
import com.example.myhomework.databinding.AppbarBinding;
import java.util.ArrayList;
public class HistoricalRecordsActivity extends AppCompatActivity {
ActivityHistoricalRecordsBinding binding;
public static HistoryRecord temhistory;
static ArrayList<HistoryRecord> historyRecordArrayList=new ArrayList<>();
HistoryrecordItemBinding itemBinding;
AppbarBinding appbarBinding;
static RecyclerView.Adapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity=this;
binding=ActivityHistoricalRecordsBinding.inflate(getLayoutInflater());
appbarBinding=AppbarBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.include.textviewToolbar.setText("提交历史");
setRecy();
HistoryRecordService.checkHistoryById(UserService.GetUid());
}
private void setRecy(){
adapter = new RecyclerView.Adapter<HistoricalRecordsActivity.MyHolder>() {
@NonNull
@Override
public HistoricalRecordsActivity.MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(HistoricalRecordsActivity.this).inflate(R.layout.historyrecord_item,parent,false);
return new HistoricalRecordsActivity.MyHolder(view);
}
@Override
public void onBindViewHolder(@NonNull HistoricalRecordsActivity.MyHolder holder, int position) {
holder.setIsRecyclable(false);
itemBinding.title.setText(historyRecordArrayList.get(position).getTitle());
itemBinding.msg.setText(historyRecordArrayList.get(position).getMsg());
itemBinding.process.setText(historyRecordArrayList.get(position).getState());
itemBinding.evalute.setOnClickListener(v->{
startActivity(new Intent(HistoricalRecordsActivity.this,EvaluteActivity.class));
temhistory=historyRecordArrayList.get(position);
});
// itemBinding.img.setImageBitmap(HttpUtils.getURLimage("http://47.98.173.217:8080/downloadFile/app_icon.png"));
}
@Override
public int getItemCount() {
return historyRecordArrayList.size();
}
@Override
public int getItemViewType(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
};
binding.recyclerView.setAdapter(adapter);
binding.recyclerView.setLayoutManager(new LinearLayoutManager(HistoricalRecordsActivity.this){
@Override
public boolean isAutoMeasureEnabled() {
return true;
}
});
binding.recyclerView.setNestedScrollingEnabled(false);
}
class MyHolder extends RecyclerView.ViewHolder{
public MyHolder(@NonNull View itemView) {
super(itemView);
itemBinding = HistoryrecordItemBinding.bind(itemView);
}
}
static Activity activity;
public static void recall(ArrayList<HistoryRecord> arrayList){
historyRecordArrayList.clear();
historyRecordArrayList=arrayList;
activity.runOnUiThread(()->adapter.notifyDataSetChanged());
}
}
\ No newline at end of file
......@@ -3,20 +3,16 @@ package com.example.myhomework.activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.airbnb.lottie.LottieAnimationView;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.service.UserService;
import com.example.myhomework.utils.SaveIdPasswordUtils;
import java.util.Map;
......@@ -93,19 +89,5 @@ public class LoginActivity extends AppCompatActivity {
chBOX = findViewById(R.id.checkBox_LoginActivity);
String name = userID.getText().toString();
String password = userPassWord.getText().toString();
UserService.Login(name,password,this);
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(password)) {
Toast.makeText(this,"账户或密码为空",Toast.LENGTH_LONG).show();
} else{
UserService.Login(name,password,this);
if(chBOX.isChecked()){
if(SaveIdPasswordUtils.saveUserInfo(this,name,password)){
GlobalMemory.PrintLog("LoginActivity:账号密码保存成功");
}
}
else{
SaveIdPasswordUtils.delectUserInfo(this);
}
}
}
}
\ No newline at end of file
package com.example.myhomework.activity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ImageView;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.service.UserService;
import com.example.myhomework.utils.HttpUtils;
import com.example.myhomework.utils.PermissionsUtils;
import com.example.myhomework.databinding.ActivityMainBinding;
......@@ -43,29 +30,22 @@ public class MainActivity extends AppCompatActivity {
//NgetWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mainActivity=this;
UserService.ResetUserData();
drawerLayout=binding.drawerLayout;
AppBarConfiguration mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.page_news, R.id.page_photo, R.id.page_chat,R.id.page_home)
.setOpenableLayout(drawerLayout)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(binding.navView, navController);
NavigationUI.setupWithNavController(binding.navigationView,navController);
//binding.navigationView.setCo
// ActionBar actionBar = getSupportActionBar();
// if (actionBar != null) {
// actionBar.hide();
// }
// mainActivity=this;
// UserService.ResetUserData();
// drawerLayout=binding.drawerLayout;
// AppBarConfiguration mAppBarConfiguration = new AppBarConfiguration.Builder(
// R.id.page_news, R.id.page_photo, R.id.page_chat,R.id.page_home)
// .setOpenableLayout(drawerLayout)
// .build();
// NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
// NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
// NavigationUI.setupWithNavController(binding.navView, navController);
// //binding.navigationView.setCo
PermissionsUtils.verifyStoragePermissions(this);
}
public void onRecallSetHead(){
ImageView head1=binding.navigationView.getHeaderView(0).findViewById(R.id.userhead_drawerlayout),
head2=binding.getRoot().findViewById(R.id.imageButton_UserHead_toolbar);
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+UserService.GetUserHead(),head1,this);
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+UserService.GetUserHead(),head2,this);
}
}
......@@ -8,7 +8,6 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.myhomework.service.UserService;
import com.example.myhomework.databinding.ActivityRegisterBinding;
public class RegisterActivity extends AppCompatActivity {
......@@ -28,11 +27,11 @@ public class RegisterActivity extends AppCompatActivity {
register=binding.button;
register.setOnClickListener(v -> {
register1(UID,UserName,UserPassWord1,UserPassWord2);
register(UID,UserName,UserPassWord1,UserPassWord2);
});
}
private void register1(EditText UID,EditText UserID1,EditText UserPassWord1,EditText UserPassWord2) {
private void register(EditText UID,EditText UserID1,EditText UserPassWord1,EditText UserPassWord2) {
//TODO注册检查
String uid=UID.getText().toString().trim();
String name = UserID1.getText().toString().trim();
......@@ -43,7 +42,7 @@ public class RegisterActivity extends AppCompatActivity {
} else if (!password1.equals(password2)) {
Toast.makeText(this,"两次密码不一致",Toast.LENGTH_LONG).show();
} else {
UserService.Register(uid,name,password1,this);
}
}
}
\ No newline at end of file
package com.example.myhomework.activity;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myhomework.utils.FileUtils;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.MenuInflater;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.example.myhomework.bean.HistoryRecord;
import com.example.myhomework.R;
import android.widget.RadioButton;
import android.widget.Toast;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.FileProvider;
import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationData;
import com.example.myhomework.service.HistoryRecordService;
import com.example.myhomework.service.UserService;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
public class UpdatePhotoActivity extends AppCompatActivity {
private MapView mMapView ;
private BaiduMap mBaiduMap;
private LocationClient mLocationClient;
private Button button;
private ImageView imageview;
private Uri imageUri;
private String filename;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SDKInitializer.initialize(getApplicationContext());
SDKInitializer.setCoordType(CoordType.BD09LL);
setContentView(R.layout.activity_update_photo);
ImageView imageView;
imageView = findViewById(R.id.picture);
imageView.setOnClickListener(v -> {
//创建弹出式菜单对象
PopupMenu popup = new PopupMenu(this, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.photo_menu, popup.getMenu());
//绑定菜单项的点击事件
popup.setOnMenuItemClickListener(item->{
switch (item.getItemId()) {
case R.id.photo:
filename= UUID.randomUUID().toString();
File outputImage = new File(getExternalCacheDir(),filename);
try {
if (outputImage.exists()) {
outputImage.delete();
}
outputImage.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT < 24) {
imageUri = Uri.fromFile(outputImage);
} else {
ContentValues contentValues = new ContentValues(1);
contentValues.put(MediaStore.Images.Media.DATA, outputImage.getPath());
imageUri = FileProvider.getUriForFile(this,
getPackageName() + ".fileprovider",
outputImage);
}
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
startActivityForResult(intent,3);
break;
case R.id.select:
openAlbum();
break;
default:
break;
}
return false;
});
popup.show();
});
//获取地图控件引用
mMapView = (MapView)findViewById(R.id.baiduMapView);
//获取到地图
mBaiduMap = mMapView.getMap();
//设置地图放大的倍数
init();
//设置地图定位的一些参数,如定位图标,精度圈颜色等
configure();
//定位初始化
init_location();
button=findViewById(R.id.push);
EditText title,msg;
RadioButton radioButton01,radioButton02,radioButton03,radioButton10,radioButton11;
title=findViewById(R.id.title);
msg=findViewById(R.id.msg);
radioButton01=findViewById(R.id.radioButton01);
radioButton02=findViewById(R.id.radioButton02);
radioButton03=findViewById(R.id.radioButton03);
radioButton10=findViewById(R.id.radioButton10);
radioButton11=findViewById(R.id.radioButton11);
button.setOnClickListener(v->{
String title_s,msg_s;
title_s=title.getText().toString();
msg_s=msg.getText().toString();
if(title_s.equals("")||msg_s.equals("")||img.equals("")){
Toast.makeText(this,"提交失败,内容不能为空",Toast.LENGTH_LONG).show();
return;
}
HistoryRecord historyRecord=new HistoryRecord();
historyRecord.setTitle(title_s);
historyRecord.setMsg(msg_s);
historyRecord.setImg(img);
if(radioButton01.isChecked()){
historyRecord.setQuestion("安全隐患");
}
if(radioButton02.isChecked()){
historyRecord.setQuestion("卫生问题");
}
if(radioButton03.isChecked()){
historyRecord.setQuestion("秩序问题");
}
if(radioButton10.isChecked()){
historyRecord.setLevel("重要");
}
if(radioButton11.isChecked()){
historyRecord.setLevel("一般");
}
historyRecord.setState("已提交");
historyRecord.setUid(UserService.GetUid());
HistoryRecordService.addRecord(historyRecord,this,path);
});
}
//图片
private void openAlbum(){
// Toast.makeText(this,"openAlbum",Toast.LENGTH_LONG).show();
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.setType("image/*");
startActivityForResult(intent,2);//打开相册
}
@Override
protected void onResume()
{
mMapView.onResume();
super.onResume();
}
@Override
protected void onPause()
{
mMapView.onPause();
super.onPause();
}
@Override
protected void onDestroy()
{
mLocationClient.stop();
mBaiduMap.setMyLocationEnabled(false);
mMapView.onDestroy();
mMapView = null;
super.onDestroy();
}
/**
* 继承抽象类BDAbstractListener并重写其onReceieveLocation方法来获取定位数据,并将其传给MapView。
*/
public class MyLocationListener extends BDAbstractLocationListener
{
@Override
public void onReceiveLocation(BDLocation location)
{
//mapView 销毁后不在处理新接收的位置
if (location == null || mMapView == null)
{
return;
}
MyLocationData locData = new MyLocationData.Builder()
.accuracy(location.getRadius())
// 此处设置开发者获取到的方向信息,顺时针0-360
.direction(location.getDirection()).latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
mBaiduMap.setMyLocationData(locData);
}
}
public void init()
{
//设置地图放大的倍数
MapStatus.Builder builder = new MapStatus.Builder();
builder.zoom(18f);
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
}
/**
* 自定义内容:
* 参数说明
* (1)定位模式 地图SDK支持三种定位模式:NORMAL(普通态), FOLLOWING(跟随态), COMPASS(罗盘态)
* (2)是否开启方向
* (3)自定义定位图标 支持自定义定位图标样式,
* (4)自定义精度圈填充颜色
* (5)自定义精度圈边框颜色
*/
public void configure()
{
mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.FOLLOWING, true,
BitmapDescriptorFactory.fromResource(R.drawable.icon_location),
0xAAFFFF88, 0xAA00FF00));
}
/**
* 定位的初始化
*/
public void init_location()
{
mBaiduMap.setMyLocationEnabled(true);
try {
mLocationClient = new LocationClient(UpdatePhotoActivity.this);
} catch (Exception e) {
e.printStackTrace();
}
//通过LocationClientOption设置LocationClient相关参数
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true); // 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
//设置locationClientOption
mLocationClient.setLocOption(option);
//注册LocationListener监听器
MyLocationListener myLocationListener = new MyLocationListener();
mLocationClient.registerLocationListener(myLocationListener);
//开启地图定位图层
mLocationClient.start();
}
String path="";
@SuppressLint("MissingSuperCall")
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
switch (requestCode) {
case 2:
if (Build.VERSION.SDK_INT >= 19) {
Uri uri=data.getData();
path= FileUtils.getPath(this,uri);
img=path.split("/")[path.split("/").length-1];
this.imageview=findViewById(R.id.picture);
this.imageview.setImageURI(uri);
} else {
handleImageBeforeKitKat(data);
Toast.makeText(this,"4.4以下",Toast.LENGTH_LONG).show();
}
break;
case 3:
path= imageUri.getPath();
img=path.split("/")[path.split("/").length-1];
this.imageview=findViewById(R.id.picture);
this.imageview.setImageURI(imageUri);
Bitmap bitmap= null;
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//存入相册
MediaStore.Images.Media.insertImage(this.getContentResolver(),
bitmap,filename, null);
default:
break;
}
}
@TargetApi(19)
private void handleImageBeforeKitKat(Intent data){
Uri uri = data.getData();
String imagePath = getImagePath(uri,null);
displayImage(imagePath);
}
String img="";
private String getImagePath(Uri uri,String selection){
String path =null;
Cursor cursor =getContentResolver().query(uri,null,selection,null,null);
if(cursor!=null){
if(cursor.moveToFirst()){
path=cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
}
cursor.close();
}
return path;
}
private void displayImage(String imagePath){
if(imagePath!=null){
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
this.imageview=findViewById(R.id.picture);
this.imageview.setImageBitmap(bitmap);
}else {
Toast.makeText(this,"未能获得图像",Toast.LENGTH_LONG).show();
}
}
}
\ No newline at end of file
package com.example.myhomework.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.myhomework.R;
public class UserInformationActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_information);
}
}
\ No newline at end of file
package com.example.myhomework.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.myhomework.bean.Msg
import com.example.myhomework.R
import java.lang.IllegalArgumentException
class MsgAdapter(val msgList:List<Msg>):RecyclerView.Adapter<RecyclerView.ViewHolder>(){
//载入右聊天框布局控件
inner class RightViewHolder(val view: View):RecyclerView.ViewHolder(view){
val rightMsg: TextView = view.findViewById(R.id.rightText)
}
//载入左聊天框布局控件
inner class LeftViewHolder(val view:View):RecyclerView.ViewHolder(view){
val leftMsg:TextView = view.findViewById(R.id.leftText)
}
//获取消息类型(左或者右),返回到onCreateViewHolder()方法的viewType参数里面
fun getItemviewType(position: Int): Int {
val msg = msgList[position] //根据当前数据源的元素类型
return msg.type
}
//根据viewType消息类型的不同,构建不同的消息布局(左&右)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if(getItemviewType(viewType)== Msg.LEFT){
val leftView = LayoutInflater.from(parent.context).inflate(R.layout.msg_left_layout,parent,false)
return LeftViewHolder(leftView) //返回控件+布局
}else{
val rightView = LayoutInflater.from(parent.context).inflate(R.layout.msg_right_layout,parent,false)
return RightViewHolder(rightView)
}
}
//对聊天控件的消息文本进行赋值
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val msg = msgList[position]
when(holder){
is LeftViewHolder -> holder.leftMsg.text = msg.content
is RightViewHolder -> holder.rightMsg.text = msg.content
else -> throw IllegalArgumentException()
}
}
//返回项数
override fun getItemCount(): Int {
return msgList.size
}
}
\ No newline at end of file
package com.example.myhomework.adapter;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.myhomework.R;
public class NewItemAdapter extends RecyclerView.Adapter<NewItemAdapter.MyViewHolder> {
private final String title = "今日新闻";
private final int icon = R.drawable.icon_news;
private final String introduce = "这是关于今日的新闻,我也不知道我在干嘛,啦啦啦啦啦啦";
private Activity activity;
public NewItemAdapter(Activity activity){
this.activity=activity;
}
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(activity).inflate(R.layout.recycler_item, parent, false);
MyViewHolder myViewHolder = new MyViewHolder(view);
return myViewHolder;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
holder.iv.setImageResource(icon);
holder.title.setText(title);
holder.introduce.setText(introduce);
}
@Override
public int getItemCount() {
return 10;
}
class MyViewHolder extends RecyclerView.ViewHolder {
ImageView iv;
TextView title;
TextView introduce;
public MyViewHolder(@NonNull View itemview) {
super(itemview);
iv = itemview.findViewById(R.id.imageView);
title = itemview.findViewById(R.id.newsTitle);
introduce = itemview.findViewById(R.id.newsContent);
}
}
}
package com.example.myhomework.adapter
import android.graphics.BitmapFactory
import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.myhomework.bean.UserHead
import com.example.myhomework.R
class UserHeadAdapter(val userHeadList:List<UserHead>):RecyclerView.Adapter<UserHeadAdapter.ViewHolder>(){
lateinit var _view:View
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val userHeadImageView:ImageView = view.findViewById(R.id.img)
val historyMsgTextView:TextView =view.findViewById(R.id.msg)
val userIdTextView:TextView=view.findViewById(R.id.title)
val msgNumImageView:ImageView=view.findViewById(R.id.msgNumImageView)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserHeadAdapter.ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.userhead_item, parent, false)
_view=view
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val userList = userHeadList[position]
// holder.userHeadImageView.setImageURI(userList.userHeadUri)
holder.setIsRecyclable(false)
holder.userHeadImageView.setImageResource(userList.userHeadUri)
holder.userIdTextView.text=userList.id
holder.historyMsgTextView.text=userList.historyMsg
}
private fun getBitmapFromUri(uri: Uri) = _view.context.contentResolver.openFileDescriptor(uri, "r")?.use {
BitmapFactory.decodeFileDescriptor(it.fileDescriptor)
}
override fun getItemCount() = userHeadList.size
}
\ No newline at end of file
package com.example.myhomework.bean;
public class Evaluate {
String eid;
String uid;
String hid;
String msg;
String star;
public String getStar() {
return star;
}
public void setStar(String star) {
this.star = star;
}
public String getEid() {
return eid;
}
public void setEid(String eid) {
this.eid = eid;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getHid() {
return hid;
}
public void setHid(String hid) {
this.hid = hid;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.example.myhomework.bean;
public class HistoryRecord {
String hid;
String title;
String msg;
String img;
String question;
String level;
String state;
String uid;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getHid() {
return hid;
}
public void setHid(String hid) {
this.hid = hid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
package com.example.myhomework.bean
class Msg(val content:String,val type:Int){
//定义静态成员
companion object{
const val RIGHT = 0
const val LEFT = 1
}
};
\ No newline at end of file
package com.example.myhomework.bean
class UserHead(
val userHeadUri:Int,
val id:String,
val historyMsg:String,
val msgNum:Int) {
}
\ No newline at end of file
package com.example.myhomework.fragment
import android.os.Bundle
import android.view.Gravity
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.myhomework.activity.MainActivity
import com.example.myhomework.adapter.MsgAdapter
import com.example.myhomework.adapter.UserHeadAdapter
import com.example.myhomework.bean.Msg
import com.example.myhomework.bean.UserHead
import com.example.myhomework.global.GlobalMemory
import com.example.myhomework.R
import com.example.myhomework.service.UserService
import com.example.myhomework.utils.HttpUtils
class ChatFragment : Fragment() {
private val msgList = ArrayList<Msg>()
private val userList = ArrayList<UserHead>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
val view=inflater.inflate(R.layout.fragment_chat, container, false)
initMsg() //初始化聊天机器人的见面语
val charRecyclerView: RecyclerView =view.findViewById(R.id.chatRecyclerView)
charRecyclerView.layoutManager = LinearLayoutManager(view.context) //布局为线性垂直
val charAdapter = MsgAdapter(msgList) //建立适配器实例
charRecyclerView.adapter = charAdapter //传入适配器
val sendButton: Button =view.findViewById(R.id.sendButton)
sendButton.setOnClickListener{
val messageEditText: EditText =view.findViewById(R.id.messageEditText)
val content:String = messageEditText.text.toString() //获取输入框的文本
if(content.isNotEmpty()){
msgList.add(Msg(content, Msg.RIGHT)) //将输入的消息及其类型添加进消息数据列表中
charAdapter.notifyItemInserted(msgList.size-1) //为RecyclerView添加末尾子项
charRecyclerView.scrollToPosition(msgList.size-1) //跳转到当前位置
messageEditText.setText("") //清空输入框文本
}
}
//用户头像数据recycle
initHead()
val userHeadRecyclerView: RecyclerView =view.findViewById(R.id.userHeadRecyclerView)
userHeadRecyclerView.layoutManager = LinearLayoutManager(view.context) //布局为线性垂直
val userHeadAdapter = UserHeadAdapter(userList) //建立适配器实例
userHeadRecyclerView.adapter=userHeadAdapter //传入适配器
val pagename:TextView= view.findViewById(R.id.textview_toolbar);
pagename.setText("通讯录")
val userhead: ImageView =view.findViewById(R.id.imageButton_UserHead_toolbar)
userhead.setOnClickListener({ v->MainActivity.drawerLayout.openDrawer(Gravity.LEFT) })
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+ UserService.GetUserHead(),userhead,activity)
return view
}
fun initMsg(){
msgList.add(Msg("我说句话试试", Msg.RIGHT))
msgList.add(Msg("聊天信息测试", Msg.LEFT))
}
fun initHead(){
userList.add(UserHead(R.drawable.camera,"大宝","",1))
}
fun reCallMsg(str:String){
msgList.add(Msg(str,Msg.LEFT))
}
}
\ No newline at end of file
package com.example.myhomework.fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.myhomework.activity.HistoricalRecordsActivity;
import com.example.myhomework.activity.MainActivity;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.service.UserService;
import com.example.myhomework.utils.HttpUtils;
import com.example.myhomework.databinding.AppbarBinding;
import com.example.myhomework.databinding.FragmentHomeBinding;
public class HomeFragment extends Fragment {
FragmentHomeBinding binding;
AppbarBinding appbarBinding;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
binding=FragmentHomeBinding.inflate(inflater);
appbarBinding=AppbarBinding.inflate(inflater);
ImageButton userItem=binding.imageButtonUserItemHomePage;
ImageButton usermessage=binding.imageButtonMessageHomePage;
ImageButton contact=binding.imageButtonContactHomePage;
ImageButton settle=binding.imageButtonSettleHomePage;
ImageView userHead=binding.imageViewUserHeadHomepage;
TextView username=binding.textViewUserNameHomePage;
TextView usertype=binding.textViewUserTypeHomePage;
TextView pagename=binding.getRoot().findViewById(R.id.textview_toolbar);
ImageView imageButton=binding.getRoot().findViewById(R.id.imageButton_UserHead_toolbar);
imageButton.setOnClickListener(v->MainActivity.drawerLayout.openDrawer(Gravity.LEFT));
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+
UserService.GetUserHead(),userHead,getActivity());
username.setText(UserService.GetUserNickName());
usertype.setText(UserService.GetUserType());
pagename.setText("主页");
userItem.setOnTouchListener(new ImageButtonOuTouchView(userItem));
usermessage.setOnTouchListener(new ImageButtonOuTouchView(usermessage));
usermessage.setOnClickListener(v -> Navigation.findNavController(getView()).navigate(R.id.page_news));
contact.setOnTouchListener(new ImageButtonOuTouchView(contact));
contact.setOnClickListener(v -> startActivity(new Intent(getActivity(), HistoricalRecordsActivity.class)));
settle.setOnTouchListener(new ImageButtonOuTouchView(settle));
settle.setOnClickListener(v -> Navigation.findNavController(getView()).navigate(R.id.page_chat));
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+ UserService.GetUserHead(),imageButton,getActivity());
return binding.getRoot();
}
private class ImageButtonOuTouchView implements View.OnTouchListener {
ImageButton imageButton;
public ImageButtonOuTouchView(ImageButton imageButton){this.imageButton=imageButton;}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if(motionEvent.getAction()==MotionEvent.ACTION_DOWN){
imageButton.setBackgroundColor(Color.GRAY);
}else if(motionEvent.getAction()==MotionEvent.ACTION_UP){
imageButton.setBackgroundColor(Color.WHITE);
}
return false;
}
}
}
\ No newline at end of file
package com.example.myhomework.fragment;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.myhomework.activity.MainActivity;
import com.example.myhomework.adapter.NewItemAdapter;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.service.UserService;
import com.example.myhomework.utils.HttpUtils;
public class NewsFragment extends Fragment {
private View mview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//新闻
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
mview=inflater.inflate(R.layout.fragment_news, container, false);
ImageView userhead = mview.findViewById(R.id.imageButton_UserHead_toolbar);
RecyclerView recyclerView = mview.findViewById(R.id.recyclerview);
TextView PageName=mview.findViewById(R.id.textview_toolbar);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); //设置为竖直向下
NewItemAdapter newItemAdapter = new NewItemAdapter(getActivity());
recyclerView.setAdapter(newItemAdapter);
PageName.setText("新闻");
userhead.setOnClickListener(v -> MainActivity.drawerLayout.openDrawer(Gravity.LEFT));
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+ UserService.GetUserHead(),userhead,getActivity());
return mview;
}
}
\ No newline at end of file
package com.example.myhomework.fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.myhomework.activity.HistoricalRecordsActivity;
import com.example.myhomework.activity.MainActivity;
import com.example.myhomework.activity.UpdatePhotoActivity;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.R;
import com.example.myhomework.service.UserService;
import com.example.myhomework.utils.HttpUtils;
import com.example.myhomework.utils.PermissionsUtils;
public class PhotoFragment extends Fragment {
private ImageView picture;
private Uri imageUri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view=inflater.inflate(R.layout.fragment_photo, container, false);
Button takePhoto = view.findViewById(R.id.take_photo);
Button history=view.findViewById(R.id.history);
picture = view.findViewById(R.id.picture);
PermissionsUtils.verifyStoragePermissions(getActivity());//获取权限
takePhoto.setOnClickListener(v -> {
Intent intent =new Intent(getActivity(), UpdatePhotoActivity.class);
startActivity(intent);
});
history.setOnClickListener(v ->startActivity(new Intent(getActivity(), HistoricalRecordsActivity.class)));
TextView PageName=view.findViewById(R.id.textview_toolbar);
PageName.setText("随手拍");
ImageView userhead= view.findViewById(R.id.imageButton_UserHead_toolbar);
userhead.setOnClickListener(v -> MainActivity.drawerLayout.openDrawer(Gravity.LEFT));
HttpUtils.setURLimageViewByBitmap(GlobalMemory.FileServerDownloadFileUri+"/"+ UserService.GetUserHead(),userhead,getActivity());
return view;
}
}
\ No newline at end of file
package com.example.myhomework.service;
import android.app.Activity;
import android.widget.Toast;
import com.example.myhomework.bean.Evaluate;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class EvaluateService {
static String TAG="EvaluateService";
private EvaluateService(){}
public static void addEvaluate(Evaluate evaluate, Activity activity){
new Thread(()->{
String eid;
int eid_i = 0;
Connection connection = JDBCUtils.Connection();
String sql="SELECT * from evaluate order by eid DESC";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
eid=resultSet.getString("eid");
eid_i=Integer.valueOf(eid);
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
sql="insert into evaluate values(?,?,?,?,?)";
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,(eid_i+1)+"");
preparedStatement.setString(2,evaluate.getUid());
preparedStatement.setString(3,evaluate.getHid());
preparedStatement.setString(4,evaluate.getMsg());
preparedStatement.setString(5,evaluate.getStar());;
if(preparedStatement.executeUpdate()>=0){
activity.runOnUiThread(()-> Toast.makeText(activity,"提交成功",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"提交成功");
activity.finish();
}else{
activity.runOnUiThread(()->Toast.makeText(activity,"提交失败,服务端连接失败",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"提交失败");
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
}).start();
}
}
package com.example.myhomework.service;
import android.app.Activity;
import android.widget.Toast;
import com.example.myhomework.activity.HistoricalRecordsActivity;
import com.example.myhomework.bean.HistoryRecord;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.utils.HttpUtils;
import com.example.myhomework.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
public class HistoryRecordService {
private static String TAG="HistoryRecordService:";
private HistoryRecordService(){}
public static void addRecord(HistoryRecord historyRecord, Activity activity,String path){
HttpUtils.Post_file(GlobalMemory.FileServerUploadFileUri,historyRecord.getImg(),path);
new Thread(()->{
String hid;
int hid_i = 0;
Connection connection = JDBCUtils.Connection();
String sql="SELECT * from historyrecord order by hid DESC";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
hid=resultSet.getString("hid");
hid_i=Integer.valueOf(hid);
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
sql="insert into historyrecord values(?,?,?,?,?,?,?,?)";
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,(hid_i+1)+"");
preparedStatement.setString(2,historyRecord.getTitle());
preparedStatement.setString(3,historyRecord.getMsg());
preparedStatement.setString(4,historyRecord.getImg());
preparedStatement.setString(5,historyRecord.getQuestion());
preparedStatement.setString(6,historyRecord.getLevel());
preparedStatement.setString(7,historyRecord.getState());
preparedStatement.setString(8,historyRecord.getUid());
if(preparedStatement.executeUpdate()>=0){
activity.runOnUiThread(()->Toast.makeText(activity,"提交成功",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"提交成功");
activity.finish();
}else{
activity.runOnUiThread(()->Toast.makeText(activity,"提交失败,服务端连接失败",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"提交失败");
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
}).start();
}
public static void deleteRecord(){}
public static void checkHistoryById(String id){
new Thread(()->{
ArrayList<HistoryRecord> arrayList=new ArrayList<>();
Connection connection = JDBCUtils.Connection();
String sql="SELECT * from historyrecord where uid='"+id+"'";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
while(resultSet.next()){
HistoryRecord historyRecord=new HistoryRecord();
historyRecord.setHid(resultSet.getString("hid"));
historyRecord.setTitle(resultSet.getString("title"));
historyRecord.setMsg(resultSet.getString("msg"));
historyRecord.setImg(resultSet.getString("img"));
historyRecord.setQuestion(resultSet.getString("question"));
historyRecord.setLevel(resultSet.getString("level"));
historyRecord.setState(resultSet.getString("state"));
historyRecord.setUid(resultSet.getString("uid"));
arrayList.add(historyRecord);
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
HistoricalRecordsActivity.recall(arrayList);
}).start();
}
}
package com.example.myhomework.service;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.widget.Toast;
import com.example.myhomework.activity.LoginActivity;
import com.example.myhomework.activity.MainActivity;
import com.example.myhomework.global.GlobalMemory;
import com.example.myhomework.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class UserService {
private static String uid;
private static String userNickName;
private static String userType;
private static String head;
public static Bitmap userHeadBitmap;
private static String TAG="UserService:";
public static void Login(String id, String password, Activity activity){
new Thread(() -> {
Connection connection = JDBCUtils.Connection();
String sql="SELECT * from user where uid='"+id+"' and password='"+password+"'";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
activity.startActivity(new Intent(activity, MainActivity.class));
activity.runOnUiThread(()-> Toast.makeText(activity,"登陆成功",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"登陆成功");
InitUserData(id);
activity.finish();
}else{
activity.runOnUiThread(()-> Toast.makeText(activity,"账号或密码错误",Toast.LENGTH_LONG).show());
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
activity.runOnUiThread(()-> Toast.makeText(activity,e.getMessage(),Toast.LENGTH_LONG).show());
}
}).start();
}
public static void Register(String uid,String userNickName,String password,Activity activity){
new Thread(() -> {
Connection connection = JDBCUtils.Connection();
String sql="select * from user where uid='"+uid+"'";
PreparedStatement preparedStatement;
ResultSet resultSet;
try {
preparedStatement=connection.prepareStatement(sql);
resultSet=preparedStatement.executeQuery();
if(resultSet.next()){
activity.runOnUiThread(()->Toast.makeText(activity,"注册失败,该账号已被注册",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"注册失败,该账号已被注册");
return;
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
sql="insert into user values(?,?,'普通用户',?)";
try {
preparedStatement=connection.prepareStatement(sql);
preparedStatement.setString(1,uid);
preparedStatement.setString(2,userNickName);
preparedStatement.setString(3,password);
if(preparedStatement.executeUpdate()>=0){
activity.runOnUiThread(()->Toast.makeText(activity,"注册成功",Toast.LENGTH_LONG).show());
activity.startActivity(new Intent(activity, LoginActivity.class));
GlobalMemory.PrintLog(TAG+"注册成功");
activity.finish();
}else{
activity.runOnUiThread(()->Toast.makeText(activity,"注册失败,服务端连接失败",Toast.LENGTH_LONG).show());
GlobalMemory.PrintLog(TAG+"注册失败");
}
}catch (Exception e){
GlobalMemory.PrintLog(TAG+e.getMessage());
GlobalMemory.PrintLog(TAG+sql);
}
}).start();
}
private static void InitUserData(String _uid){
new Thread(() -> {
String muid=_uid;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = JDBCUtils.Connection();
String sql = "SELECT * from user where uid='"+muid+"'";
GlobalMemory.PrintLog(sql);
try {
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
uid=resultSet.getString("uid");
userNickName=resultSet.getString("userNickName");
userType=resultSet.getString("userType");
head=resultSet.getString("head");
GlobalMemory.PrintLog("初始化\nuid:"+uid+"\nname"+userNickName+"\nhead:"+head);
}
} catch (SQLException e) {
GlobalMemory.PrintLog(TAG+e.getMessage());
} finally {
JDBCUtils.closeAll(resultSet,preparedStatement,connection);
}
}).start();
GetUserHead();
}
public static void ResetUserData(){
new Thread(() -> {
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Connection connection = JDBCUtils.Connection();
String sql = "SELECT * from user where uid='"+uid+"'";
GlobalMemory.PrintLog(sql);
try {
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
uid=resultSet.getString("uid");
userNickName=resultSet.getString("userNickName");
userType=resultSet.getString("userType");
head=resultSet.getString("head");
GlobalMemory.PrintLog("初始化\nuid:"+uid+"\nname"+userNickName+"\nhead:"+head);
MainActivity.mainActivity.onRecallSetHead();
}
} catch (SQLException e) {
GlobalMemory.PrintLog(TAG+e.getMessage());
} finally {
JDBCUtils.closeAll(resultSet,preparedStatement,connection);
}
}).start();
}
public static String GetUid(){
return uid;
}
public static String GetUserNickName(){
return userNickName;
}
public static String GetUserType(){
return userType;
}
public static String GetUserHead(){
return head;
}
}
<?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=".activity.EvaluteActivity">
<ImageView
android:id="@+id/close"
android:layout_width="58dp"
android:layout_height="57dp"
android:src="@drawable/icon_close"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<include
android:id="@+id/include"
layout="@layout/appbar"
android:layout_width="358dp"
android:layout_height="48dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
</include>
<RatingBar
android:id="@+id/ratingBar"
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.795"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.332" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="星级评价"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.102"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.34" />
<EditText
android:id="@+id/msg"
android:layout_width="317dp"
android:layout_height="185dp"
android:backgroundTint="#FFFFFF"
android:ems="10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.584" />
<Button
android:id="@+id/push"
android:layout_width="162dp"
android:layout_height="53dp"
android:backgroundTint="#F4F4F4"
android:text="提交"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.546"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.833" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?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=".activity.HistoricalRecordsActivity">
<include
android:id="@+id/include"
layout="@layout/appbar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="680dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -15,7 +15,7 @@
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="?android:attr/windowBackground"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -38,13 +38,5 @@
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
app:headerLayout="@layout/drawer_header"
android:id="@+id/navigation_view"
android:layout_width="260dp"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_gravity="start"
app:menu="@menu/bottom_nav_menu"/>
</androidx.drawerlayout.widget.DrawerLayout>
\ No newline at end of file
<?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=".activity.UpdatePhotoActivity">
<Button
android:id="@+id/push"
android:layout_width="162dp"
android:layout_height="53dp"
android:backgroundTint="#F4F4F4"
android:text="提交"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.976" />
<EditText
android:id="@+id/msg"
android:layout_width="368dp"
android:layout_height="65dp"
android:hint="请输入问题描述"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.48"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.18" />
<EditText
android:id="@+id/title"
android:layout_width="368dp"
android:layout_height="65dp"
android:hint="请输入标题"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.488"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.082" />
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="390dp"
android:layout_height="65dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.467">
<RadioButton
android:id="@+id/radioButton01"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="安全隐患" />
<RadioButton
android:id="@+id/radioButton02"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="卫生问题" />
<RadioButton
android:id="@+id/radioButton03"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="秩序问题" />
</RadioGroup>
<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="312dp"
android:layout_height="80dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.547">
<RadioButton
android:id="@+id/radioButton10"
android:layout_width="189dp"
android:layout_height="match_parent"
android:checked="true"
android:text="重要" />
<RadioButton
android:id="@+id/radioButton11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一般" />
</RadioGroup>
<ImageView
android:id="@+id/picture"
android:layout_width="81dp"
android:layout_height="82dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.063"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.314"
app:srcCompat="@drawable/add"
tools:ignore="MissingConstraints"
/>
<com.baidu.mapapi.map.MapView
android:id="@+id/baiduMapView"
android:layout_width="417dp"
android:layout_height="174dp"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.834"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?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=".activity.UserInformationActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textview_toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:text="我的资料"
android:textColor="@color/white"
android:textSize="24sp" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userHead_UserInformaiton"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/icon_head"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.168"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.199">
</de.hdodenhof.circleimageview.CircleImageView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -3,7 +3,7 @@
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="wrap_content">
android:layout_height="50dp">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
......@@ -29,18 +29,25 @@
android:gravity="center"
android:text="添加漂流瓶"
android:textColor="@color/white"
android:textSize="24sp" />
android:textSize="20sp" />
<ImageButton
android:id="@+id/imageButton_left_toolbar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_width="38dp"
android:layout_height="30dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="-19dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="355dp"
android:layout_marginBottom="8dp"
android:background="@drawable/left" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
</FrameLayout>
\ No newline at end of file
<?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="200dp"
android:background="@color/colorPrimary">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userhead_drawerlayout"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/icon_head"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.50"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.7">
</de.hdodenhof.circleimageview.CircleImageView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?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="160dp">
<ImageView
android:id="@+id/img"
android:layout_width="68dp"
android:layout_height="68dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.087"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.326"
app:srcCompat="@drawable/icon_news" />
<TextView
android:id="@+id/title"
android:layout_width="226dp"
android:layout_height="24dp"
android:text="标题"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.76"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.02" />
<TextView
android:id="@+id/msg"
android:layout_width="243dp"
android:layout_height="51dp"
android:text="详细信息"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.779"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.275" />
<TextView
android:id="@+id/process"
android:layout_width="62dp"
android:layout_height="17dp"
android:text="进度"
android:textColor="#CC0909"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.404"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.566" />
<Button
android:id="@+id/evalute"
android:layout_width="317dp"
android:layout_height="38dp"
android:backgroundTint="#F5F6F6"
android:text="我要评价"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.531"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.959" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="100dp"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_margin="5dp"
android:background="@drawable/left_chat">
<TextView
android:id="@+id/leftText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#191919"
android:textSize="16dp" />
</LinearLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="5dp"
android:background="@drawable/right_chat">
<TextView
android:id="@+id/rightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textColor="#fff"
android:textSize="16dp" />
</LinearLayout>
</FrameLayout>
<?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="150dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="120sp"
android:layout_height="wrap_content"
android:src="@drawable/icon_news"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.945"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/newsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="今日新闻"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.242"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.196" />
<TextView
android:id="@+id/newsContent"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="这是关于今日的新闻,我也不知道我在干嘛,啦啦啦啦啦啦"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.093"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.638" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?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"
android:layout_width="250sp"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/img"
android:layout_width="68dp"
android:layout_height="68dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.087"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
android:background="@drawable/icon_head" />
<TextView
android:id="@+id/title"
android:layout_width="49dp"
android:layout_height="26dp"
android:text="用户ID"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.079"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/msg"
android:layout_width="130dp"
android:layout_height="49dp"
android:text="当前消息"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.866"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<ImageView
android:id="@+id/msgNumImageView"
android:layout_width="48dp"
android:layout_height="51dp"
app:layout_constraintBottom_toTopOf="@+id/msg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.401"
app:layout_constraintStart_toEndOf="@+id/title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -10,15 +10,6 @@
android:id="@+id/page_photo"
android:icon="@drawable/photo"
android:title="@string/title_photo" />
<item
android:id="@+id/page_chat"
android:icon="@drawable/chat"
android:title="通讯"/>
<item
android:id="@+id/page_home"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/title_home" />
</group>
</menu>
\ No newline at end of file
......@@ -12,4 +12,5 @@
<color name="white">#FFFFFFFF</color>
<color name="fragment_background">#FFFFFFFF</color>
<color name="label_text">#8C8383</color>
<color name="transparent">#FFFFFFFF</color>
</resources>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册