Browse Source

更新界面22

茶饮新(现场)
fyf 11 months ago
parent
commit
3600d5b40e
6 changed files with 122 additions and 17 deletions
  1. +4
    -0
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +2
    -8
      app/src/main/java/com/bonait/bnframework/common/base/BaseFragment.java
  3. +108
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/MediaPlayerHelper.java
  4. +5
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java
  5. +2
    -8
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java
  6. +1
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java

+ 4
- 0
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -3,11 +3,13 @@ package com.bonait.bnframework.business;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.media.MediaPlayer;
import android.os.Handler;
import android.util.Log;

import androidx.annotation.NonNull;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.QueryDB;
@@ -26,6 +28,7 @@ import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.RTrig;
import com.bonait.bnframework.common.helper.ThreadManager;
@@ -298,6 +301,7 @@ public class ExecuteTheRecipe {
try {
if(IsMakeGood && GoodMake!=null)
{

ArrayList<ResGoodsRecipe> recipes= GoodMake.recipes;
//复位完成信号
WritePLC("手自切换", true,null);


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

@@ -19,6 +19,7 @@ import com.bonait.bnframework.common.filepicker.PickerManager;
import com.bonait.bnframework.common.filepicker.adapter.FilePickerShowAdapter;
import com.bonait.bnframework.common.filepicker.adapter.OnFileItemClickListener;
import com.bonait.bnframework.common.filepicker.util.OpenFile;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.arch.QMUIFragment;
@@ -105,14 +106,7 @@ public abstract class BaseFragment extends QMUIFragment implements EasyPermissio
*/
public void Speak(int resid)
{
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
MediaPlayer mediaPlayer = MediaPlayer.create(getContext(), resid);
mediaPlayer.start();
}
});

MediaPlayerHelper.getInstance().PlaySound(resid);
}

@Override


+ 108
- 0
app/src/main/java/com/bonait/bnframework/common/helper/MediaPlayerHelper.java View File

@@ -0,0 +1,108 @@
package com.bonait.bnframework.common.helper;

import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.DataBus;

import java.io.IOException;
import java.util.Random;

/**
* MediaPlayerHelper
* 媒体工具类,使用单例设计模式保证使用的媒体对象只有一个
*/
public class MediaPlayerHelper {

MediaPlayer mPlayer=null;
public Context context=null;

//region 单例模式
private static MediaPlayerHelper mInstance; //实例变量设置私有,防止直接通过类名访问

private MediaPlayerHelper() {
//默认构造函数私有,防止类外直接new创建对象
}

public static synchronized MediaPlayerHelper getInstance() { //静态同步方法作为唯一的实例对象获取方式
if (mInstance==null) {
mInstance = new MediaPlayerHelper();
}
return mInstance;
}
//endregion
public void SetConText(Context v)
{
this.context=v;
}

//释放
public void Release()
{
if (mPlayer != null && mPlayer.isPlaying()) {
mPlayer.stop();
mPlayer.release(); }

}
public int GetStringID(String str)
{
if(str=="配料开始")return R.raw.plks;///下面把要写的rawid 复制粘贴到此处
else if(str=="配料完成")return R.raw.plwc;///下面把要写的rawid 复制粘贴到此处
else if(str=="配料中请稍后")return R.raw.plzqsh;///下面把要写的rawid 复制粘贴到此处
else if(str=="清洗开始请稍后")return R.raw.qxksqsh;///下面把要写的rawid 复制粘贴到此处
else if(str=="清洗完成")return R.raw.qxwc;///下面把要写的rawid 复制粘贴到此处
else return R.raw.plwc;
}

public int GetSJ()
{
Random rand = new Random();
int randNum = rand.nextInt(5);
if(randNum==0)return R.raw.plks;///下面把要写的rawid 复制粘贴到此处
else if(randNum==1)return R.raw.plwc;///下面把要写的rawid 复制粘贴到此处
else if(randNum==2)return R.raw.plzqsh;///下面把要写的rawid 复制粘贴到此处
else if(randNum==3)return R.raw.qxksqsh;///下面把要写的rawid 复制粘贴到此处
else if(randNum==4)return R.raw.qxwc;///下面把要写的rawid 复制粘贴到此处
else return R.raw.plwc;
}

//播放语音
public void PlaySound(String text)
{
if(context==null )
{
return;
}

if (mPlayer!=null){ //判断当mPlayer不为空的时候
mPlayer.stop(); //先结束上一个播放内容
mPlayer.release();
}
mPlayer = MediaPlayer.create(context, GetStringID(text)); //添加本地资源
mPlayer.setLooping(false);//设置不循环
mPlayer.start(); //开始播放
}
//播放语音
public void PlaySound(int id)
{
if(context==null )
{
return;
}
if (mPlayer!=null){ //判断当mPlayer不为空的时候
mPlayer.stop(); //先结束上一个播放内容
mPlayer.release();
}
mPlayer = MediaPlayer.create(context, id); //添加本地资源
mPlayer.setLooping(false);//设置不循环
mPlayer.start(); //开始播放
}
public int getResource(String resName){
int resId = context.getResources().getIdentifier(resName,"raw",context.getPackageName());
return resId;
}

}


+ 5
- 1
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java View File

@@ -15,6 +15,7 @@ import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
@@ -51,7 +52,7 @@ public class BottomNavigationMainActivity extends BaseActivity {
setContentView(R.layout.activity_bottom_navigation_main);

ButterKnife.bind(this);
MediaPlayerHelper.getInstance().SetConText(getBaseContext());
mNavigateTabBar.onRestoreInstanceState(savedInstanceState);
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.gongneng, R.mipmap.gongneng_selected, "功能"));
mNavigateTabBar.addTab(null, new MainNavigateTabBar.TabParam(R.mipmap.jiaoyan, R.mipmap.jiaoyan_selected, "校验"));
@@ -63,12 +64,15 @@ public class BottomNavigationMainActivity extends BaseActivity {
mNavigateTabBar.setTabSelectListener(mOnNavigationItemSelectedListener);
initFragment();
Init();


}

@Override
protected void onDestroy() {
//关闭PLC连接
ConfigData.getInstance().ColsePLC();
MediaPlayerHelper.getInstance().Release();
super.onDestroy();
}



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

@@ -27,6 +27,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SUBORDER;
import com.bonait.bnframework.common.db.res.MakeStatus;
import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
@@ -143,14 +144,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter<RecyclerView.ViewH
*/
public void Speak(int resid)
{
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
MediaPlayer mediaPlayer = MediaPlayer.create(conmain, resid);
mediaPlayer.start();
}
});

MediaPlayerHelper.getInstance().PlaySound(resid);
}

@Override


+ 1
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/JiaoYan_lsjy_fragment.java View File

@@ -30,6 +30,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.helper.WrapContentLinearLayoutManager;
import com.bonait.bnframework.common.linktab.LinkMode;
import com.bonait.bnframework.common.linktab.TopItemDecoration;


Loading…
Cancel
Save