Browse Source

增加语音播报

茶饮新(现场)
fyf 1 year ago
parent
commit
a1e7a10043
15 changed files with 75 additions and 10 deletions
  1. +17
    -0
      app/src/main/java/com/bonait/bnframework/common/base/BaseFragment.java
  2. +14
    -4
      app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java
  3. +17
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java
  4. +1
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java
  5. +25
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java
  6. +1
    -2
      app/src/main/res/layout/item/layout/item_file_picker_show.xml
  7. BIN
     
  8. BIN
     
  9. BIN
     
  10. BIN
     
  11. BIN
     
  12. BIN
     
  13. BIN
     
  14. BIN
     
  15. BIN
     

+ 17
- 0
app/src/main/java/com/bonait/bnframework/common/base/BaseFragment.java View File

@@ -1,6 +1,7 @@
package com.bonait.bnframework.common.base;

import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.provider.Settings;
import android.view.View;
@@ -98,6 +99,22 @@ public abstract class BaseFragment extends QMUIFragment implements EasyPermissio
fragmentTransaction.commit();
}

/**
* 播放
* @param resid
*/
public void Speak(int resid)
{
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
MediaPlayer mediaPlayer = MediaPlayer.create(getContext(), resid);
mediaPlayer.start();
}
});

}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);


+ 14
- 4
app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java View File

@@ -172,7 +172,11 @@ public class DataBus {
GoodsMake.add(make);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + make.good.name + "]准备配料!");

if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();
if(loadinggoodAdapter!=null)
{
loadinggoodAdapter.Speak(R.raw.plks);
loadinggoodAdapter.refresh();
}
}catch(Exception e){
MessageLog.ShowInfo( "增加订单异常!"+e.getMessage());
}
@@ -202,8 +206,10 @@ public class DataBus {
GoodsMake.get(m).makeMs=makeMs;
GoodsMake.get(m).makeProcess=(int)(((count*1.00)/ GoodsMake.get(m).recipes.size())*100);

if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();

if(loadinggoodAdapter!=null) {
loadinggoodAdapter.Speak(R.raw.plzqsh);
loadinggoodAdapter.refresh();
}
return;
}
}
@@ -236,7 +242,11 @@ public class DataBus {
GoodsMake.remove(good);
}

if(loadinggoodAdapter!=null)loadinggoodAdapter.refresh();
if(loadinggoodAdapter!=null)
{
loadinggoodAdapter.Speak(R.raw.plwc);
loadinggoodAdapter.refresh();
}

}catch(Exception e){
}


+ 17
- 0
app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java View File

@@ -3,6 +3,7 @@ package com.bonait.bnframework.modules.home.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.media.MediaPlayer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -136,6 +137,22 @@ public class loadinggood_adapter extends RecyclerView.Adapter<RecyclerView.ViewH
});
}

/**
* 播放
* @param resid
*/
public void Speak(int resid)
{
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
MediaPlayer mediaPlayer = MediaPlayer.create(conmain, resid);
mediaPlayer.start();
}
});

}

@Override
public int getItemCount() {
return datas.size();


+ 1
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java View File

@@ -99,9 +99,7 @@ public class JiaoYanFragment extends BaseFragment {
menuModes.add(new ResMenuLeft(new JiaoYan_dzcjy_fragment(),"电子秤校验", R.mipmap.dzcjy, R.mipmap.dzcjy_select,true));
menuModes.add(new ResMenuLeft(new JiaoYan_lsjy_fragment(),"流速校验", R.mipmap.lsjy, R.mipmap.lsjy_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_clsfbc_fragment(),"出料算法补偿", R.mipmap.clsfbc, R.mipmap.clsfbc_selectd,false));

menuModes.add(new ResMenuLeft(new JiaoYan_wdsz_fragment(),"温度设置", R.mipmap.lsjy, R.mipmap.lsjy_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_zdqx_fragment(),"自动清洗", R.mipmap.zdqx1, R.mipmap.zdqx1_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_zdbs_fragment(),"自动补水", R.mipmap.zdbs, R.mipmap.zdbs_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_sdkz_fragment(),"手动控制", R.mipmap.sdkz, R.mipmap.sdkz_select,false));
}else
@@ -109,6 +107,7 @@ public class JiaoYanFragment extends BaseFragment {
menuModes.add(new ResMenuLeft(new JiaoYan_dzcjy_fragment(),"电子秤校验", R.mipmap.dzcjy, R.mipmap.dzcjy_select,true));
menuModes.add(new ResMenuLeft(new JiaoYan_lsjy_fragment(),"流速校验", R.mipmap.lsjy, R.mipmap.lsjy_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_wdsz_fragment(),"温度设置", R.mipmap.lsjy, R.mipmap.lsjy_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_zdqx_fragment(),"自动清洗", R.mipmap.zdqx1, R.mipmap.zdqx1_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_zdbs_fragment(),"自动补水", R.mipmap.zdbs, R.mipmap.zdbs_select,false));
menuModes.add(new ResMenuLeft(new JiaoYan_sdkz_fragment(),"手动控制", R.mipmap.sdkz, R.mipmap.sdkz_select,false));
}


+ 25
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_zdqx_fragment.java View File

@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;

import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -82,6 +83,7 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
break;
case R.id.bt_start://开始清洗


if (DataBus.getInstance().ZDQX_IsStart) {

String title = "温馨提示!";
@@ -93,6 +95,7 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Speak(R.raw.qxksqsh);
ExecuteTheRecipe.WritePLC("清洗模式", false,null);
ExecuteTheRecipe.WritePLC("自动清洗开始", false,null);
DataBus.getInstance().ZDQX_IsStart=false;
@@ -132,7 +135,13 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
{
ExecuteTheRecipe.WritePLC("管道自动排水完成",false,null);
ExecuteTheRecipe.WritePLC("管道自动排水",true,null);

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.warning("管道自动排水中,请稍后...");
bt_start.setText("管道排水中");
}
});
final boolean[] IsStopPS = {false};
while (DataBus.getInstance().ZDQX_IsStart && !IsStopPS[0])
{
@@ -143,7 +152,12 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
}
}


getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
bt_start.setText("正在清洗");
}
});
for (BPA_SUGAR item:
DataBus.getInstance().zdqx) {
ExecuteTheRecipe.WritePLC("自动清洗完成",false,null);
@@ -174,6 +188,13 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
ExecuteTheRecipe.WritePLC("管道自动排水完成",false,null);
ExecuteTheRecipe.WritePLC("管道自动排水",true,null);

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.warning("管道自动排水中,请稍后...");
bt_start.setText("管道排水中");
}
});
IsStopPS[0] =false;
while (DataBus.getInstance().ZDQX_IsStart && !IsStopPS[0])
{
@@ -199,6 +220,8 @@ public class JiaoYan_zdqx_fragment extends BaseFragment {
DataBus.getInstance().zdqxchidAdapter.refresh();
}
});

Speak(R.raw.qxwc);
}

} catch (Exception e) {


+ 1
- 2
app/src/main/res/layout/item/layout/item_file_picker_show.xml View File

@@ -22,8 +22,7 @@
android:id="@+id/iv_type"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:src="@mipmap/image1"/>
android:layout_centerVertical="true"/>
</RelativeLayout>




BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


Loading…
Cancel
Save