package stu.xuronghao.ledger.activity;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.iflytek.cloud.RecognizerResult;
import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.SpeechUtility;
import com.iflytek.cloud.ui.RecognizerDialog;
import com.iflytek.cloud.ui.RecognizerDialogListener;
import com.wang.avi.AVLoadingIndicatorView;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import stu.xuronghao.ledger.R;
import stu.xuronghao.ledger.adapter.ChatListAdapter;
import stu.xuronghao.ledger.entity.ChatInfo;
import stu.xuronghao.ledger.entity.Cost;
import stu.xuronghao.ledger.entity.Income;
import stu.xuronghao.ledger.entity.User;
import stu.xuronghao.ledger.handler.consts.ConstantVariable;
import stu.xuronghao.ledger.handler.network.DataPuller;
import stu.xuronghao.ledger.handler.DateHandler;
import stu.xuronghao.ledger.handler.validator.StringChecker;
import stu.xuronghao.ledger.handler.validator.Validator;
public class ChatToRecordPage extends AppCompatActivity {
private ChatListAdapter adapter;
private ListView listView;
private List<ChatInfo> infoList;
private User user;
private ChatInfo userInfo;
private Context context;
private String selected;
private AVLoadingIndicatorView indicatorView;
private int typeCode = ConstantVariable.COST_CODE;
private String event;
private String money;
private String remark;
private String dateStr;
private AsyncChatTask asyncChatTask;
private final DataPuller dataPuller = new DataPuller();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat_to_record_page);
user = (User) getIntent().getSerializableExtra(ConstantVariable.USER);
context = this;
listView = findViewById(R.id.lv_chat);
indicatorView = findViewById(R.id.avi_chat);
SpeechUtility.createUtility(context, SpeechConstant.APPID + ConstantVariable.APP_ID);
Button costBtn = findViewById(R.id.btn_Cost_Dialog);
Button incomeBtn = findViewById(R.id.btn_Income_Dialog);
costBtn.setOnClickListener(v -> {
typeCode = ConstantVariable.COST_CODE;
showPusherDialog();
});
incomeBtn.setOnClickListener(v -> {
typeCode = ConstantVariable.INCOME_CODE;
showPusherDialog();
});
ImageView cancel = findViewById(R.id.img_chat_page_cancel);
cancel.setOnClickListener(v -> finish());
ImageView voiceBtn = findViewById(R.id.img_voice);
voiceBtn.setOnClickListener(v -> {
//申请权限
if (ContextCompat.checkSelfPermission(
context, Manifest.permission.RECORD_AUDIO) ==
PackageManager.PERMISSION_GRANTED) {
// You can use the API that requires the permission.
initSpeech();
} else {
// You can directly ask for the permission.
// The registered ActivityResultCallback gets the result of this request.
requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, ConstantVariable.REQUEST_CODE);
}
});
AsyncPullHistoryTask asyncPullHistoryTask = new AsyncPullHistoryTask();
asyncPullHistoryTask.execute();
}
private void showPusherDialog() {
View view = LayoutInflater.from(context).inflate(R.layout.chat_dialog, null, false);
final AlertDialog dialog = new AlertDialog.Builder(context).setView(view).create();
Button cancel = view.findViewById(R.id.btn_Chat_Dialog_Cancel);
Button add = view.findViewById(R.id.btn_Chat_Dialog_Push);
TextView txvEvent = view.findViewById(R.id.txv_Chat_Dialog_Event);
TextView txvAmount = view.findViewById(R.id.txv_Chat_Dialog_Amount);
TextView txvType = view.findViewById(R.id.txv_Chat_Dialog_Type);
TextView txvRemark = view.findViewById(R.id.txv_Chat_Dialog_Remark);
Spinner spinner = view.findViewById(R.id.sp_Chat_Type);
EditText etxEvent = view.findViewById(R.id.etx_Chat_Dialog_Event);
etxEvent.setText(typeCode == ConstantVariable.COST_CODE ? ConstantVariable.TEXT_COST : ConstantVariable.TEXT_INCOME);
txvEvent.setText(typeCode == ConstantVariable.COST_CODE ? ConstantVariable.TEXT_COST_EVENT : ConstantVariable.TEXT_INCOME_EVENT);
txvAmount.setText(typeCode == ConstantVariable.COST_CODE ? ConstantVariable.TEXT_COST_AMOUNT : ConstantVariable.TEXT_INCOME_AMOUNT);
txvType.setText(typeCode == ConstantVariable.COST_CODE ? ConstantVariable.TEXT_COST_TYPE : ConstantVariable.TEXT_INCOME_TYPE);
txvRemark.setText(ConstantVariable.TEXT_REMARK);
ArrayAdapter<String> spAdapter = new ArrayAdapter<>(context, R.layout.spinner_item_sel,
ConstantVariable.getTypeArray(typeCode == ConstantVariable.COST_CODE ? ConstantVariable.COST_TYPE : ConstantVariable.INCOME_TYPE));
spAdapter.setDropDownViewResource(R.layout.spinner_item_drop);
spinner.setAdapter(spAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
selected = ConstantVariable.getTypeByTypeStr(position,
typeCode == ConstantVariable.COST_CODE ? ConstantVariable.COST_TYPE : ConstantVariable.INCOME_TYPE);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
//Not Used
}
});
//向服务器推送信息
add.setOnClickListener(v -> {
//获取输入对象
EditText etxMoney = view.findViewById(R.id.etx_Chat_Dialog_Amount);
EditText etxRemark = view.findViewById(R.id.etx_Chat_Dialog_Remark);
//数据提取
event = etxEvent.getText().toString();
money = etxMoney.getText().toString();
remark = etxRemark.getText().toString();
dateStr = DateHandler.getCurrentDatetime();
if (Validator.checkBillInfoInput(event, money, context)) {
dialog.dismiss();
asyncChatTask = new AsyncChatTask();
asyncChatTask.execute();
}
});
cancel.setOnClickListener(v -> dialog.dismiss());
dialog.show();
}
private void initSpeech() {
RecognizerDialog mDialog = new RecognizerDialog(context, null);
mDialog.setParameter(SpeechConstant.LANGUAGE, ConstantVariable.LANGUAGE);
mDialog.setParameter(SpeechConstant.ACCENT, ConstantVariable.MANDARIN);
mDialog.setParameter(SpeechConstant.ASR_PTT, "1");
mDialog.setListener(new RecognizerDialogListener() {
@Override
public void onResult(RecognizerResult recognizerResult, boolean isLast) {
if (!isLast) {
//获取分词list
List<String> wordList = parseWordArray(recognizerResult.getResultS
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
安卓毕业设计/Android期末作业-“治账app” 安卓客户端,算账app - 不懂运行,下载完可以私聊问,可远程教学 该资源内项目源码是个人的毕设,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! <项目介绍> 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 --------
资源推荐
资源详情
资源评论
收起资源包目录
安卓毕业设计/Android期末作业-“治账app” 安卓客户端,算账app (271个子文件)
adb 0B
gradlew.bat 2KB
.gitignore 208B
.gitignore 6B
build.gradle 3KB
build.gradle 935B
settings.gradle 42B
gradlew 5KB
AAChartView.html 844B
Msc.jar 480KB
Msc.jar 480KB
gradle-wrapper.jar 53KB
ChatToRecordPage.java 17KB
ConstantVariable.java 17KB
AAOptionsConstructor.java 14KB
AAChartView.java 14KB
RecordFrag.java 14KB
AAChartModel.java 11KB
TrendFrag.java 11KB
DataPuller.java 11KB
AAGradientColor.java 11KB
PieFrag.java 10KB
AASeriesElement.java 6KB
Validator.java 6KB
DetailPage.java 5KB
IncomeFrag.java 5KB
LoginPage.java 5KB
AAYAxis.java 5KB
CostFrag.java 5KB
AAXAxis.java 4KB
PushCostFrag.java 4KB
PushIncomeFrag.java 4KB
AALabels.java 4KB
FeedbackPage.java 4KB
UserFrag.java 4KB
PushDataPage.java 3KB
AnnoPage.java 3KB
AADataLabels.java 3KB
ReportFrag.java 3KB
StringChecker.java 3KB
IconHandler.java 3KB
GetHttpResponse.java 3KB
TrendDataAdapter.java 3KB
PostSender.java 3KB
Cost.java 3KB
Income.java 3KB
SignUpPage.java 3KB
AAChart.java 2KB
BillDataAdapter.java 2KB
User.java 2KB
AATooltip.java 2KB
AAColumn.java 2KB
AAOptions.java 2KB
AABar.java 2KB
Feedback.java 2KB
AAColor.java 2KB
DateHandler.java 2KB
ChangePasswdPage.java 2KB
PieDataAdapter.java 2KB
ChatListAdapter.java 2KB
Anno.java 2KB
AALegend.java 2KB
ChangeUsernamePage.java 2KB
GetSender.java 2KB
ColorsHandler.java 2KB
AAMoveOverEventMessageModel.java 2KB
AnnoListAdapter.java 2KB
AAPie.java 2KB
AAChartAnimationType.java 2KB
AASeries.java 2KB
HomePage.java 1KB
AAStyle.java 1KB
ServerPath.java 1KB
AAPlotOptions.java 1KB
ChatInfo.java 1KB
AAPlotBandsElement.java 1KB
AAMarker.java 1KB
AATitle.java 1KB
AABackground.java 1KB
AASubtitle.java 1KB
Product.java 1KB
AAMarkerHover.java 1019B
TrendData.java 994B
AAJSStringPurer.java 947B
AAPlotLinesElement.java 878B
TotalFee.java 853B
AAChartType.java 851B
Sentence.java 835B
AAScrollablePlotArea.java 824B
ListSortUtil.java 820B
SwitchAdapter.java 781B
ExampleInstrumentedTest.java 773B
AAItemStyle.java 725B
AAWaterfall.java 719B
AADataElement.java 714B
AAPane.java 704B
AACredits.java 687B
AAShadow.java 678B
AAHover.java 574B
AnnoInfo.java 572B
共 271 条
- 1
- 2
- 3
资源评论
.Android安卓科研室.
- 粉丝: 4724
- 资源: 2268
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- BetterWMF5.0
- CAXACAD清理工具
- 机械设计极柱焊接sw22可编辑全套技术资料100%好用.zip
- DOCXReadWrite for D11.2 D12 测试可用
- CAD图纸合并插件,喜欢的可以参考
- E000611机械零件配件类网站模板.zip+PHP+Mysql+易优CMS建站模板
- 堆排序算法解析-基于二叉堆的选择排序及应用
- MATLAB车牌识别完整源代码有神经网络和模板识别(源码+报告)
- 机械设计立式输送机sw18可编辑全套技术资料100%好用.zip
- win32汇编环境,在窗口程序中画三角形
- C语言实现的简单停车场管理系统及其基本功能应用
- 机械设计龙门式行车sw19可编辑全套技术资料100%好用.zip
- 光伏并网逆变器,单相光伏并网逆变器,最大功率跟踪,MPPT,光伏建模,并网逆变器,电导增量法,扰动观察法,最大功率跟踪控制,逆变器双闭环控制 提供参考文献
- 基于规则和机器学习的钓鱼邮件筛选系统构建与实施
- 机械设计锂电池在线式自动贴膜机sw18全套技术资料100%好用.zip
- html+css+js网页设计 体育 体育云课堂9个页面
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功