首页 > 其他分享 >2023/5/24每日随笔 项目基本实现

2023/5/24每日随笔 项目基本实现

时间:2023-05-24 23:22:37浏览次数:35  
标签:24 imagePath String show uri System 2023 println 随笔

今天,上了几节课,然后进行项目的完善与基本实现

一:实现了调用相册,将地址提取

二:实现了图片提取加分类

三:实现了添加后更新

四:结果展示

五:项目问题以及可能出现bug

一:实现了调用相册,将地址提取

具体更改的这个方法:完整代码来自《第一行代码》调用相册和使用相机。更改后调用的相册可以将照片地址提出。

private String handleImageOnKitKat(Intent data) {
String imagePath = null;
Uri uri = data.getData();
if(DocumentsContract.isDocumentUri(this, uri)) {
//如果是document类型的uri,则通过document id处理
String docId = DocumentsContract.getDocumentId(uri);
if("com.android.providers.media.documents".equals(uri.getAuthority())) {

Toast.makeText(this, "success01", Toast.LENGTH_SHORT).show();
String id = docId.split(":")[1];
String secletion = MediaStore.Images.Media._ID + "=" + id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, secletion);
System.out.println("imagePath = " + imagePath);

} else if("com.android.providers.downloads.documents".equals(uri.getAuthority())) {

Toast.makeText(this, "success02", Toast.LENGTH_SHORT).show();
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
imagePath = getImagePath(contentUri, null);
System.out.println("imagePath = " + imagePath);

}
} else if("content".equalsIgnoreCase(uri.getScheme())) {
Toast.makeText(this, "success03", Toast.LENGTH_SHORT).show();
//如果是content类型的Uri,则使用普通方式处理
imagePath = getImagePath(uri, null);
System.out.println("imagePath = " + imagePath);

} else if("file".equalsIgnoreCase(uri.getScheme())) {
//如果是file类型的uri,则直接获取文件路径
Toast.makeText(this, "success04", Toast.LENGTH_SHORT).show();
imagePath = uri.getPath();

}
displayImage(imagePath);
return imagePath;
}
二:实现了图片提取加分类
Main main = new Main();
String response = main.qiuqiu(String.valueOf(imagePath));
System.out.println("response = " + response);
System.out.println("response = " + response.replaceAll(" ","").trim());
Chatgpt chatgpt = new Chatgpt();
String message = "”" + response + "”,请严格按照以下格式回答:支付时间为“XXXX年XX月XX日”。消费类型为“?”。“餐饮美食”、“生活日用”、“交通出行”、“休闲娱乐”、“医疗保健”、“投资理财”、“其他消费”、在给出的这些选出消费类型,消费金额为“?”,消费内容为“?”。";
String information = chatgpt.response(message);
//String message = "”" + information + "”,请严格按照以下格式回答:支付时间为“XXXX年XX月XX日”。消费类型为“?”。“餐饮美食”、“生活日用”、“交通出行”、“休闲娱乐”、“医疗保健”、“投资理财”、“其他消费”、在给出的这些选出消费类型,消费金额为“?”,消费内容为“?”。";
System.out.println("information = " + information);
PaymentInfoExtractor paymentInfoExtractor = new PaymentInfoExtractor();
String time_show = paymentInfoExtractor.dealtime(information);
String type_show =paymentInfoExtractor.dealtype(information);
String money_show =paymentInfoExtractor.dealmoney(information);
String resourse_show =paymentInfoExtractor.deal(information);
System.out.println("time = " + time_show);
System.out.println("type = " + type_show);
System.out.println("money = " + money_show);
System.out.println("resourse = " + resourse_show);
time.setText(time_show);
money.setText(money_show);
sourse.setText(resourse_show);
int position = 0;
if(type_show.equals("生活日用")) {
position = 1;
}
调用我写的类
三:实现了添加后更新
Button CameraButton = (Button) getActivity().findViewById(R.id.Camera_Button);
CameraButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getActivity(), CameraAndAlbum.class);
Bundle bundle = new Bundle();
bundle.putInt("User_id",User_id);
intent.putExtras(bundle);
startActivityForResult(intent,2);
}
});
采用activity的返回结果
四:结果展示

五:项目问题以及可能出现bug

项目最大的问题就是chatgpt的不确定性,每个时刻给出的回答都不一样,需要对其进行更改维护。

然后,有时候会出现这个界面,是最差的结果。

 然后,随机性比较强,因为以前很多次都是一个回答。


 























 

标签:24,imagePath,String,show,uri,System,2023,println,随笔
From: https://www.cnblogs.com/JIANGzihao0222/p/17429857.html

相关文章

  • 5.24
    题目描述:定义一个时间类,小时和分钟是其两个私有成员数据。输入一个起始时间和一个结束时间(起始时间早于结束时间),通过运算符重载-(减号),计算这两个时间相隔多少分钟。说明:这两个时间在同一天之内,且采用24小时计时分式,即从00:00-23:59。输入格式:测试输入包含若干测试用例,每......
  • 5.24每日总结
      今天完成了python的一个餐厅点餐系统。  功能:实现菜品的添加、修改、删除,订单的增加、删除、清空,计算总价。     ......
  • 5.24 3.2
    一、问题如果整数A的全部因子(包括1,不括A本身)之和等于B;且整数B的全部因子(包括1不包括B本身)之和等于A,则将整数A和B称为亲密数。求3000以内的全部亲密数。二、分析根据问题描述,该问题可以转化为:给定整数A,判断A是否有亲密数。为解决该问题,首先定义变量a,并为......
  • 每日总结 5.24
    今日进行了增删改查的继续学习,熟悉之前的代码书写。case"add":Stringname=request.getParameter("name");Stringpassword=request.getParameter("password");Students=newStudent(name,password);d.add(s)......
  • 每日总结-23.5.24
    packagesan;importjava.sql.*;publicclassThesql{publicConnectionconnect;publicThesql()throwsException{Class.forName("com.mysql.jdbc.Driver");Stringurl="jdbc:mysql://localhost:3306/web?useUnicode=......
  • 2023.5.24
     1#include<iostream>2#include<iomanip>3usingnamespacestd;4classHorse5{6public:7Horse()8{9cout<<"Horse申请了空间..."<<endl;10}11virtual~Horse()12{13......
  • 2022-2023年的jlu.test,和校园网出口的流量备忘
    2022年8月疫情结束,学生开学,jlu.test流量升高;2023年12月疫情放开,学生提前离校流量下降;2023年2月学生开始返校;2023年4月末除了南岭校区,其他校区的流量都切换到本地。2022年下半年的几次封校,流量出现陡增。今年流量比较正常,5月1日放假,流量下降不少。     20220325出......
  • 2023.5 路桥中学高一期末程序素养检测
    参考答案(个人编写)Aa,b=map(int,input().split())c=int(input())print(c-a+b)Ba=float(input())print("%.2lf"%(a*9/5+32))Ca=float(input())ifa>3:a=int(a)print(((a+1-3)*2+10))else:print(10)Da......
  • 2023.5.24每日总结
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"&g......
  • 2023.5.24——软件工程站立会议(阶段二)
    站立会议内容:1.整个项目预期的任务量:目前已经花的时间:剩余的时间:2.任务看板照片: 3.团队照片: 4.产品状态:最新做好的功能:正在完成中5.燃尽图:......