1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665 |
- package com.wdkl.callingbed.ui;
- import android.annotation.SuppressLint;
- import android.app.AlarmManager;
- import android.app.PendingIntent;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.pm.PackageManager;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Color;
- import android.graphics.drawable.Drawable;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- import android.net.wifi.WifiManager;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.speech.tts.TextToSpeech;
- import android.support.annotation.Nullable;
- import android.support.design.widget.Snackbar;
- import android.support.v4.content.ContextCompat;
- import android.support.v7.widget.RecyclerView;
- import android.text.TextUtils;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.View;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.RelativeLayout;
- import android.widget.TextView;
- import com.google.gson.Gson;
- import com.squareup.picasso.MemoryPolicy;
- import com.squareup.picasso.NetworkPolicy;
- import com.squareup.picasso.Picasso;
- import com.squareup.picasso.Transformation;
- import com.vvsip.ansip.IVvsipServiceListener;
- import com.vvsip.ansip.VvsipCall;
- import com.wdkl.callingbed.MyApplication;
- import com.wdkl.callingbed.R;
- import com.wdkl.callingbed.adapter.CostAdapter;
- import com.wdkl.callingbed.adapter.DoctorAdapter;
- import com.wdkl.callingbed.base.BaseActivity;
- import com.wdkl.callingbed.common.Constants;
- import com.wdkl.callingbed.entity.AllBroadcastEntity;
- import com.wdkl.callingbed.entity.BroadCastEntity;
- import com.wdkl.callingbed.entity.CostDataEntity;
- import com.wdkl.callingbed.entity.CostDataEntity.CostArray;
- import com.wdkl.callingbed.entity.DoctorDataEntity;
- import com.wdkl.callingbed.entity.DoctorDataEntity.DoctorChargeArray;
- import com.wdkl.callingbed.entity.InitDataEntity;
- import com.wdkl.callingbed.entity.MainDataEntity;
- import com.wdkl.callingbed.entity.MessageEvent;
- import com.wdkl.callingbed.entity.NoticeDataEntity;
- import com.wdkl.callingbed.entity.NoticeEntity;
- import com.wdkl.callingbed.entity.UdpEntity;
- import com.wdkl.callingbed.receive.AlarmReceiver;
- import com.wdkl.callingbed.receive.NetworkConnectChangedReceiver;
- import com.wdkl.callingbed.service.SoundPoolManager;
- import com.wdkl.callingbed.util.BitmapUtils;
- import com.wdkl.callingbed.util.DateUtil;
- import com.wdkl.callingbed.util.DensityUtils;
- import com.wdkl.callingbed.util.DownloadUtil;
- import com.wdkl.callingbed.util.DownloadUtil2;
- import com.wdkl.callingbed.util.FullyLinearLayoutManager;
- import com.wdkl.callingbed.util.LogUtil;
- import com.wdkl.callingbed.util.MarqueeText;
- import com.wdkl.callingbed.util.MediaPlayerManger;
- import com.wdkl.callingbed.util.NetUtil;
- import com.wdkl.callingbed.util.ScreenManagerUtil;
- import com.wdkl.callingbed.util.SharedPreferencesUtil;
- import com.wdkl.callingbed.util.SipUtil.SipCallBackI;
- import com.wdkl.callingbed.util.SipUtil.SipHelperUtil;
- import com.wdkl.callingbed.util.StringUtils;
- import com.wdkl.callingbed.util.TimeUtil;
- import com.wdkl.callingbed.util.ToastUtil;
- import com.wdkl.callingbed.util.TwoDimensionCodeUtil;
- import com.wdkl.callingbed.util.UdpSendUtil;
- import com.wdkl.callingbed.util.VoiceManagerUtil;
- import com.wdkl.callingbed.util.ethernetwifiwithsipconnectstatus.WifiBindSipStatusConnector;
- import com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand;
- import com.wdkl.callingbed.widget.loading.IMediaPlayerVolume;
- import com.wdkl.callingbed.widget.view.MyTextView;
- import com.zhy.http.okhttp.OkHttpUtils;
- import com.zhy.http.okhttp.callback.StringCallback;
- import net.frakbot.jumpingbeans.JumpingBeans;
- import org.greenrobot.eventbus.Subscribe;
- import org.greenrobot.eventbus.ThreadMode;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.File;
- import java.lang.ref.WeakReference;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Date;
- import java.util.List;
- import java.util.Locale;
- import butterknife.Bind;
- import okhttp3.Call;
- import serialporttest.utils.SerialPortUtil;
- import serialporttest.utils.SerialPortUtil.ISerialPortBedOnclickEvent;
- import static com.wdkl.callingbed.common.Constants.CALLINGTIMEOUT;
- import static com.wdkl.callingbed.common.Constants.CALLING_TIME_OUT;
- import static com.wdkl.callingbed.common.Constants.EVENT_MGR_RESET;
- import static com.wdkl.callingbed.common.Constants.EVENT_SIP_INTERNETPING;
- import static com.wdkl.callingbed.common.Constants.EVENT_SIP_REGISTER_STATUS;
- import static com.wdkl.callingbed.common.Constants.NURSE_CALL_TIMEOUT;
- import static com.wdkl.callingbed.common.Constants.STANDBY;
- import static com.wdkl.callingbed.common.Constants.innetSIPAddress;
- import static com.wdkl.callingbed.util.ToastUtil.showToast;
- import static com.wdkl.callingbed.util.ethernetwifiwithsipconnectstatus.WifiBindSipStatusConnector.ethernetStatus;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.closeHeart;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setBedLight;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setDoorLight;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setHandsMIC;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setNurseBrightness;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setSYSBrightness;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setSYSVoice;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setWSHLight;
- import static com.wdkl.callingbed.util.sendcommand.CallingBedSendCommand.setWSHLightFlicker;
- /**
- * Created by 胡博文 on 2017/8/17.
- */
- public class CallingBedActivity extends BaseActivity implements ISerialPortBedOnclickEvent, SerialPortUtil.ISerialPortBedOnclickString, IMediaPlayerVolume, IVvsipServiceListener
- , SipCallBackI, MediaPlayerManger.PlayMusicCompleteListener {
- //初始化数据实体
- private InitDataEntity initDataEntity;
- //主界面数据实体
- private MainDataEntity mainDataEntity;
- //医嘱界面的数据实体
- private DoctorDataEntity doctorDataEntity;
- private List<DoctorChargeArray> doctorChargeArrayList;
- private DoctorAdapter doctorAdapter;
- //花费界面的数据实体
- private CostDataEntity costDataEntity;
- private List<CostArray> costArrayList;
- private CostAdapter costAdapter;
- //通知界面的数据实体
- private NoticeDataEntity noticeDataEntity;
- private List<NoticeDataEntity.NoticeArray> noticeArrayList;
- //通话的状态
- private String CALL_STATUS = Constants.STANDBY;
- //串口工具类
- private SerialPortUtil serialPortUtil;
- private JumpingBeans jbVNurse;
- private JumpingBeans jbVSupport;
- private JumpingBeans jbVCall;
- /**
- * 注册中
- */
- public static final String REGISTERING = "register_ing";
- /**
- * 注册失败
- */
- public static final String REGISTERFAIL = "register_fail";
- /**
- * 注册完成
- */
- public static final String REGISTERCOM = "register_com";
- /**
- * 注册检测wifi强度广播
- */
- public BroadcastReceiver wifiInfoPowerReceiver;
- private static IMediaPlayerVolume iMediaPlayerVolume;
- /**
- * 通话中压低广播音量
- */
- public static void initPlayerVolume(float vol) {
- if (iMediaPlayerVolume != null)
- iMediaPlayerVolume.quietAndRestore(vol);
- }
- @Bind(R.id.activity_calling_bed_layout_rl_main)
- RelativeLayout rlMain;
- @Bind(R.id.activity_calling_bed_layout_rl_right)
- LinearLayout llRight;
- //状态栏
- @Bind(R.id.activity_calling_bed_layout_title)
- View vTitle;
- //状态栏中的信息
- @Bind(R.id.view_title_layout_tv_point)
- TextView tvSipStatePoint;
- @Bind(R.id.view_title_layout_tv_hospital_name)
- TextView tvHospitalName;
- @Bind(R.id.view_title_layout_tv_no)
- TextView tvExtensionNum;
- @Bind(R.id.view_title_layout_tv_time)
- TextView tvTime;
- @Bind(R.id.view_title_layout_iv_current_trust)
- ImageView ivTrust;
- @Bind(R.id.view_title_layout_iv_ethernet)
- ImageView ivEthernet;
- @Bind(R.id.view_title_layout_iv_wifi)
- ImageView ivWifi;
- //所有的页面view
- @Bind(R.id.activity_calling_bed_layout_main)
- View vMain;
- @Bind(R.id.activity_calling_bed_layout_doctor)
- RelativeLayout vDoctor;
- @Bind(R.id.activity_calling_bed_layout_cost)
- View vCost;
- @Bind(R.id.activity_calling_bed_layout_qr_code)
- View vQrCode;
- @Bind(R.id.activity_calling_bed_layout_support)
- View vSupport;
- @Bind(R.id.activity_calling_bed_layout_call)
- View vCall;
- @Bind(R.id.activity_calling_bed_layout_nurse)
- View vNurse;
- @Bind(R.id.activity_calling_bed_layout_welcome)
- View vWelcome;
- @Bind(R.id.activity_calling_bed_layout_main_big_left)
- View vMain_big;
- @Bind(R.id.view_qr_code_layout_qr_code)
- ImageView qrBarcodeImg;
- //侧滑栏的text
- @Bind(R.id.activity_calling_bed_layout_tv_doctor_text)
- TextView tvDoctor;
- @Bind(R.id.activity_calling_bed_layout_tv_version)
- TextView tvVersion;
- @Bind(R.id.activity_calling_bed_layout_tv_cost_text)
- TextView tvCost;
- @Bind(R.id.activity_calling_bed_layout_tv_qr_code_text)
- TextView tvQrCode;
- @Bind(R.id.activity_calling_bed_layout_tv_support_text)
- TextView tvSupport;
- @Bind(R.id.activity_calling_bed_layout_tv_call_text)
- TextView tvCall;
- @Bind(R.id.view_main_layout_tv_broadcasting)
- MarqueeText tvBroadcasting;
- /*主界面id*/
- //侧滑栏
- @Bind(R.id.view_main_layout_left_one_title)
- TextView tvLeftOneTitle;
- @Bind(R.id.view_main_layout_left_one_content)
- TextView tvLeftOneContent;
- @Bind(R.id.view_main_layout_left_two_title)
- TextView tvLeftTwoTitle;
- @Bind(R.id.view_main_layout_left_two_content)
- TextView tvLeftTwoContent;
- @Bind(R.id.view_main_layout_left_three_title)
- TextView tvLeftThreeTitle;
- @Bind(R.id.view_main_layout_left_three_content)
- TextView tvLeftThreeContent;
- @Bind(R.id.view_main_layout_left_four_title)
- TextView tvLeftFourTitle;
- @Bind(R.id.view_main_layout_left_four_content)
- TextView tvLeftFourContent;
- @Bind(R.id.view_main_layout_left_five_title)
- TextView tvLeftFiveTitle;
- @Bind(R.id.view_main_layout_left_five_content)
- TextView tvLeftFiveContent;
- @Bind(R.id.view_main_layout_tv_bed_num)
- TextView tvBedNum;
- @Bind(R.id.view_main_layout_tv_name)
- TextView tvName;
- @Bind(R.id.view_main_layout_tv_detail)
- TextView tvDetail;
- @Bind(R.id.view_main_layout_tv_illness)
- TextView tvIllness;
- @Bind(R.id.view_main_layout_tv_admission)
- TextView tvAdmission;
- @Bind(R.id.view_main_layout_tv_doctor_name)
- TextView tvDoctorName;
- @Bind(R.id.view_main_layout_tv_nurse_name)
- TextView tvNurseName;
- @Bind(R.id.view_main_layout_tv_hosp_number)
- TextView tvHospNumber;
- @Bind(R.id.view_main_layout_tv_hosp_data)
- TextView tvHospData;
- @Bind(R.id.view_main_layout_iv_doctor)
- ImageView ivDoctor;
- @Bind(R.id.view_main_layout_iv_nurse)
- ImageView ivNurse;
- //医嘱界面
- @Bind(R.id.view_doctor_tv_name)
- TextView tvDoctorPageName;
- @Bind(R.id.view_doctor_tv_inpatient_num)
- TextView tvDoctorPageInpatientNum;
- @Bind(R.id.view_doctor_layout_rv_doctor)
- RecyclerView rvDoctor;
- //花费界面
- @Bind(R.id.view_cost_layout_tv_name)
- TextView tvCostPageName;
- @Bind(R.id.view_cost_layout_tv_inpatient_num)
- TextView tvCostPageInpatientNum;
- @Bind(R.id.view_cost_layout_rv_cost)
- RecyclerView rvCost;
- //请求增援界面
- @Bind(R.id.view_support_layout_tv_call_text)
- TextView tvSupportText;
- //呼叫增援界面倒计时
- @Bind(R.id.view_support_layout_tv_call_timeout)
- TextView tvSupportTimeOut;
- //呼叫护工界面
- @Bind(R.id.view_call_layout_tv_call_text)
- TextView tvCallText;
- //呼叫护工界面倒计时
- @Bind(R.id.view_call_layout_tv_call_timeout)
- TextView tvCallTextTimeOut;
- //呼叫护士页面
- @Bind(R.id.view_nurse_layout_tv_call_text)
- TextView tvNurseText;
- //呼叫超时倒计时
- @Bind(R.id.view_nurse_layout_tv_call_timeout)
- TextView tvNurseTimeOut;
- //侧滑栏(增长页面)
- @Bind(R.id.view_main_layout_left_one_title_big)
- TextView tvLeftOneTitle_big;
- @Bind(R.id.view_main_layout_left_one_content_big)
- MarqueeText tvLeftOneContent_big;
- @Bind(R.id.view_main_layout_left_two_title_big)
- TextView tvLeftTwoTitle_big;
- @Bind(R.id.view_main_layout_left_two_content_big)
- MarqueeText tvLeftTwoContent_big;
- @Bind(R.id.view_main_layout_left_three_title_big)
- TextView tvLeftThreeTitle_big;
- @Bind(R.id.view_main_layout_left_three_content_big)
- MarqueeText tvLeftThreeContent_big;
- @Bind(R.id.view_main_layout_left_four_title_big)
- TextView tvLeftFourTitle_big;
- @Bind(R.id.view_main_layout_left_four_content_big)
- MarqueeText tvLeftFourContent_big;
- @Bind(R.id.view_main_layout_left_five_title_big)
- TextView tvLeftFiveTitle_big;
- @Bind(R.id.view_main_layout_left_five_content_big)
- MarqueeText tvLeftFiveContent_big;
- @Bind(R.id.view_main_layout_tv_illness_big)
- TextView tvIllness_big;
- @Bind(R.id.view_main_layout_tv_detail_big)
- TextView tvDetail_big;
- @Bind(R.id.view_main_layout_tv_bed_num_big)
- MarqueeText tvBedNum_big;
- @Bind(R.id.view_main_layout_tv_name_big)
- MarqueeText tvName_big;
- private RelativeLayout rlBottomMessage;
- private ImageView ivWelcome;
- private MyTextView tvNoticeContent;
- private ImageView ivNotice;
- // 语音播报
- private TextToSpeech textToSpeech;
- //开启的线程
- private TimeThread timeThread;
- // /**
- // * 外部物理键==(呼叫护士键)是否按住没松开
- // */
- // boolean isPressingNurseButton = false;
- /**
- * 侧边栏所有的View切换
- */
- private List<View> allViews;
- /**
- * 网络状态
- */
- private NetworkConnectChangedReceiver networkConnectChangedReceiver;
- //原设定:1分钟去检测网络:不通则互相循环切换以太网和wifi去ping网,
- // 发现检测状态虽及时更新到ui上显示,但ping网切换wifi和以太网会延时,需要等待一段时间
- // 现换成:30 秒发送一次检测网络切换信号
- private WifiBindSipStatusConnector wac;
- /**
- * 呼叫超时时间
- */
- private long callTimeOut = (StringUtils.parseInt(Constants.CALLINGTIMEOUT) == 0 ? 30000 : StringUtils.parseInt(Constants.CALLINGTIMEOUT) * 1000);//默认30秒
- /**
- * 时间线程
- */
- //MyHandler Flag值
- private final int TIME_WHAT = 1000;
- private final int INIT_SYSTEM = 2000;//成功
- private final int SYSTEM_DATA_RESPONSE = 2001;
- private final int SYSTEM_DATA_ERROR = 2002;
- private final int MAIN_DATA_RESPONSE = 2003;
- private final int MAIN_DATA_ERROR = 2004;
- private final int UPDATE_BROADCAST = 2005;
- private final int NEW_INCOMING_CALL = 2006;
- private MyHandler handler = new MyHandler(this);
- class MyHandler extends Handler {
- // 弱引用 ,防止内存泄露
- private WeakReference<CallingBedActivity> weakReference;
- public MyHandler(CallingBedActivity callingBedActivity) {
- weakReference = new WeakReference<CallingBedActivity>(callingBedActivity);
- }
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- // 通过 软引用 看能否得到activity示例
- CallingBedActivity handlerMemoryActivity = weakReference.get();
- // 防止内存泄露
- if (handlerMemoryActivity != null) {
- switch (msg.what) {
- case TIME_WHAT:
- String second = TimeUtil.getInstance().getSecond();
- //检测网络状态
- checkNetWorkStatus();
- //刷新时间
- tvTime.setText(TimeUtil.getInstance().getDataTime());
- //刷新通知
- if ("0".equals(second)) {
- getNoticeData();
- }
- //拉起增长页面(20191017 waderson)
- if(MyApplication.have_long_main_page){
- callLongNursePage(second);
- }
- //自动回来主页面 add by waderson 20190707
- comeBackMainPage();
- break;
- case INIT_SYSTEM:
- LogUtil.d("NURSELIGHT", "INIT_SYSTEM");
- setSYSParameter();
- break;
- case SYSTEM_DATA_RESPONSE:
- LogUtil.d("NURSELIGHT", "SYSTEM_DATA_RESPONSE");
- setSYSParameter();
- break;
- case SYSTEM_DATA_ERROR:
- LogUtil.d("NURSELIGHT", "SYSTEM_DATA_ERROR");
- getSystemSettingData();
- break;
- case MAIN_DATA_RESPONSE:
- LogUtil.d("NURSELIGHT", "MAIN_DATA_RESPONSE");
- setSYSParameter();
- break;
- case MAIN_DATA_ERROR:
- LogUtil.d("NURSELIGHT", "MAIN_DATA_ERROR");
- getMainData(1);
- break;
- case UPDATE_BROADCAST:
- checkAndDownloadMP3(0);
- break;
- case NEW_INCOMING_CALL:
- //newCalling();
- break;
- }
- } else {
- // 没有实例不进行操作
- ToastUtil.showToast("请重启机器!");
- }
- }
- }
- boolean netWorkRecovery = true;
- public void checkNetWorkStatus() {
- try {
- //Constants.URL = "http://" + NetUtil.getLocalElement(NetUtil.getLocalInetAddress().toString());
- Constants.URL = "http://" + NetUtil.getLocalElement(3);
- } catch (Exception e) {
- CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
- netWorkRecovery = false;
- e.printStackTrace();
- }
- ConnectivityManager cm = (ConnectivityManager) MyApplication.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE);
- if (cm != null) {
- NetworkInfo networkInfo = cm.getActiveNetworkInfo();
- if (networkInfo != null) {
- if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI || networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
- CallingBedSendCommand.setSipStatus(serialPortUtil, "2");
- if (!netWorkRecovery) {
- //网络好了刷新该机器数据
- resetAPP();
- }
- netWorkRecovery = true;
- } else {
- CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
- netWorkRecovery = false;
- }
- } else {
- CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
- netWorkRecovery = false;
- }
- } else {
- CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
- netWorkRecovery = false;
- }
- }
- private boolean isTimeWorking = true;
- public class TimeThread extends Thread {
- @Override
- public void run() {
- while (isTimeWorking) {
- try {
- Thread.sleep(1000);
- Message msg = handler.obtainMessage();
- msg.what = TIME_WHAT;
- handler.sendMessage(msg);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
- private void stop() {
- if (isTimeWorking) {
- if (timeThread != null && timeThread.isAlive()) {
- timeThread.interrupt();
- timeThread = null;
- }
- isTimeWorking = false;
- }
- }
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- //初始化view
- allViews = new ArrayList<>(Arrays.asList(vMain, vDoctor, vCost, vQrCode, vSupport, vCall, vNurse));
- initReceive();
- //20190415 waderson 测试
- ScreenManagerUtil.setScreenBrightness(context, 210);
- SoundPoolManager.getInstance().init();
- }
- @Override
- public int getLayoutId() {
- //SIP准备工作
- initSip();
- return R.layout.activity_calling_bed_layout;
- }
- @Override
- protected void initView() {
- //更新include 的ui bind 不到
- /*******************************************************/
- rlBottomMessage = vMain.findViewById(R.id.view_main_layout_rl_message);
- ivWelcome = vWelcome.findViewById(R.id.view_welcome_iv_main);
- tvNoticeContent = vMain.findViewById(R.id.view_main_layout_tv_msg);
- ivNotice = vMain.findViewById(R.id.view_main_iv_notice_logo);
- /*******************************************************/
- timeThread = new TimeThread();
- timeThread.start();
- appCheckUpdate();
- }
- @Override
- protected void initUtil() {
- serialPortUtil = ((MyApplication) this.getApplication()).serialPortUtil;
- if (serialPortUtil != null) {
- serialPortUtil.setOnDataReceiveListener(this);
- serialPortUtil.setOnDataReceiveStringListener(this);
- setDoorLight(serialPortUtil, "111");//初始化白色
- }
- iMediaPlayerVolume = this;
- //设置语言
- textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
- @Override
- public void onInit(int i) {
- if (i == TextToSpeech.SUCCESS) {
- int result = textToSpeech.setLanguage(Locale.CHINA);
- if (result == TextToSpeech.LANG_MISSING_DATA
- || result == TextToSpeech.LANG_NOT_SUPPORTED) {
- }
- }
- }
- });
- }
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- if (serialPortUtil != null) {
- serialPortUtil.setOnDataReceiveListener(this);
- serialPortUtil.setOnDataReceiveStringListener(this);
- }
- iMediaPlayerVolume = this;
- }
- @Override
- protected void initData() {
- //以太网和wifi切换
- changeNetConnect();
- //上层实体类
- initDataEntity = (InitDataEntity) getIntent().getExtras().get(Constants.INITENTITY);
- if (null == initDataEntity) {
- return;
- }
- //对于rv 的初始化
- costArrayList = new ArrayList<>();
- costAdapter = new CostAdapter(costArrayList);
- rvCost.setLayoutManager(new FullyLinearLayoutManager(this));
- doctorChargeArrayList = new ArrayList<>();
- doctorAdapter = new DoctorAdapter(doctorChargeArrayList);
- rvDoctor.setLayoutManager(new FullyLinearLayoutManager(this));
- noticeArrayList = new ArrayList<>();
- getMainData(0);
- getSystemSettingData();
- getNoticeData();
- setTrustIcon();
- getBroadcastAudioFiles();
- /**
- * 由于机器性能方面的差异有些机子的串口反应速度比较慢;急速初始化将失效!
- * */
- handler.sendEmptyMessageDelayed(INIT_SYSTEM, 3000);
- }
- /**
- * 初始化SIP
- */
- private void initSip() {
- //=============================================SIP启动服务===================================//
- SipHelperUtil.getInstance(this).sipStartService();
- //=============================================SIP状态回调===================================//
- SipHelperUtil.getInstance(this).setSipCallBack(this);
- //=============================================SIP服务监听===================================//
- sipServiceListener();
- }
- /**
- * 初始化广播
- */
- private void initReceive() {
- //网络状态广播
- networkConnectChangedReceiver = new NetworkConnectChangedReceiver();
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
- registerReceiver(networkConnectChangedReceiver, intentFilter);
- //wifi强度广播
- IntentFilter filter = new IntentFilter();
- filter.addAction("android.SipDemo.INCOMING_CALL");
- wifiInfoPowerReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- int s = NetUtil.obtainWifiInfo(MyApplication.getAppContext());
- LogUtil.d("sss", "wifi强度" + s);
- }
- };
- this.registerReceiver(wifiInfoPowerReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
- }
- /**
- * 以太网和wifi切换
- */
- private void changeNetConnect() {
- wac = new WifiBindSipStatusConnector(null);
- //循环切换网络状态
- wac.sendNetStatus(this);
- //主动连接wifi
- wac.setmHandler(new Handler() {
- @Override
- public void handleMessage(Message msg) {
- // 操作界面
- LogUtil.d("AutoConnectWifi", msg.obj + "");
- super.handleMessage(msg);
- }
- });
- }
- static String state_bk = "";
- /**
- * Sip状态灯显示
- *
- * @param state
- */
- private void updateStatus(final String state) {
- this.runOnUiThread(new Runnable() {
- public void run() {
- switch (state) {
- case REGISTERING:
- tvSipStatePoint.setBackgroundResource(R.color.yellow_color);
- //CallingBedSendCommand.setSipStatus(serialPortUtil, "1");
- break;
- case REGISTERFAIL:
- tvSipStatePoint.setBackgroundResource(R.color.red_color);
- //CallingBedSendCommand.setSipStatus(serialPortUtil, "0");
- break;
- case REGISTERCOM:
- tvSipStatePoint.setBackgroundResource(R.color.green);
- //CallingBedSendCommand.setSipStatus(serialPortUtil, "2");
- //if (!state_bk.equals(REGISTERCOM)) {
- // upDateParameter();
- //}
- break;
- }
- state_bk = state;
- }
- });
- }
- @Override
- public View getLoadingTargetView() {
- return rlMain;
- }
- private void setTitle() {
- if (null != mainDataEntity) {
- tvHospitalName.setText(mainDataEntity.getHospital() + mainDataEntity.getDepartments());
- }
- if (null != initDataEntity) {
- String str = "000000";
- String str_m = str.substring(0, 6 - initDataEntity.getId().length()) + initDataEntity.getId();
- tvExtensionNum.setText("分机号:" + str_m);
- }
- }
- //---------------------------------------------数据请求部分 ---------------------------------------------------------------------
- /**
- * 获得医嘱信息
- */
- private void getDoctorData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- showProgress();
- OkHttpUtils
- .post()
- .url(Constants.URL + Constants.URL_END + Constants.CALLINGBED_DOCTOR)
- .addParams("deviceHumanId", Constants.DEVICE_HUMAN_ID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- hideProgress();
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- try {
- Gson gson = new Gson();
- doctorDataEntity = gson.fromJson(data, DoctorDataEntity.class);
- setDoctorView();
- hideProgress();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * 获得费用信息
- */
- private void getCostData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- showProgress();
- OkHttpUtils
- .post()
- .url(Constants.URL + Constants.URL_END + Constants.CALLINGBED_COST)
- .addParams("deviceHumanId", Constants.DEVICE_HUMAN_ID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- hideProgress();
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- try {
- Gson gson = new Gson();
- costDataEntity = gson.fromJson(data, CostDataEntity.class);
- setCostView();
- hideProgress();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * 获取系统设置信息
- */
- private void getSystemSettingData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- if (!StringUtils.notEmpty(Constants.PartID)) return;
- try {
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.GETSYS_SETING)
- .addParams("PartID", Constants.PartID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- handler.sendEmptyMessage(SYSTEM_DATA_ERROR);
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- LogUtil.d(CallingBedActivity.class, "getSystemSettingData==" + data);
- try {
- JSONObject object = new JSONObject(data);
- if (object.getString("Code").equals("ERROR!")) {
- handler.sendEmptyMessage(SYSTEM_DATA_ERROR);
- } else {
- Constants.MORNING_NIGTH = object.getString("dayOrNight");
- Constants.SCREENLIGHT = object.getString("screenLight");
- Constants.SYSVOICE = object.getString("callVoice");
- Constants.RINGLVOICE = object.getString("ringlVoice");
- Constants.RINGLVOICELOOP = object.getString("ringlVoiceLoop");
- Constants.NURSINGLIGHT = object.getString("nursingLight");
- Constants.CALLINGTIMEOUT = object.getString("CallingTimeOut");
- Constants.SCREENEXTINGUISHTIME = object.getString("screenExtinguishTime");
- //Constants.DOORCALLVOICE = object.getString("DoorSipVol");
- Constants.BEDCALLVOICE = object.getString("BedSipVol");
- handler.sendEmptyMessage(SYSTEM_DATA_RESPONSE);
- setSYSParameter();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 获得通知信息
- */
- private void getNoticeData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- try {
- OkHttpUtils
- .post()
- .url(Constants.URL + Constants.URL_END + Constants.CALLINGBED_NOTICE)
- .addParams("deviceHumanId", Constants.DEVICE_HUMAN_ID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- hideProgress();
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- try {
- Gson gson = new Gson();
- noticeDataEntity = gson.fromJson(data, NoticeDataEntity.class);
- noticeArrayList = noticeDataEntity.getNoticeArray();
- setNoticeView();
- if (null != noticeArrayList) {
- setNoticeClock(noticeArrayList);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 获得主信息
- */
- private void getMainData(final int tag) {
- if (null == initDataEntity.getDeviceHumanId() || "".equals(initDataEntity.getDeviceHumanId())) {
- initDataEntity.setDeviceHumanId("0"); //HumanID 为空 则为0
- }
- LogUtil.d("getMainData", "Constants.URL==" + Constants.URL);
- if (!StringUtils.notEmpty(Constants.URL)) return;
- if (!StringUtils.notEmpty(Constants.PartID)) return;
- LogUtil.d("getMainData", "initDataEntity.getDeviceHumanId(22)==" + initDataEntity.getDeviceHumanId());
- if (Integer.parseInt(initDataEntity.getDeviceHumanId()) != 0) {
- if (0 == tag) showProgress();
- LogUtil.d("getMainData", "Constants.DEVICE_HUMAN_ID==" + Constants.DEVICE_HUMAN_ID);
- OkHttpUtils
- .post()
- .url(Constants.URL + Constants.URL_END + Constants.CALLINGBED_MAIN)
- .addParams("deviceHumanId", Constants.DEVICE_HUMAN_ID)
- .addParams("PartID", Constants.PartID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- LogUtil.d("getMainData", "onError==onError");
- if (0 == tag) hideProgress();
- Constants.UPDATE_PATIENTUPDATE_FLAG = false;
- handler.sendEmptyMessage(MAIN_DATA_ERROR);
- }
- @Override
- public void onResponse(String response, int id) {
- LogUtil.d("getMainData", "onResponse==onResponse");
- String data = response.substring(0, response.length() - 4);
- LogUtil.d("getMainData", "getMainData==data==" + data);
- try {
- Gson gson = new Gson();
- mainDataEntity = gson.fromJson(data, MainDataEntity.class);
- if (null != mainDataEntity) {
- handler.sendEmptyMessage(MAIN_DATA_RESPONSE);
- if (StringUtils.parseInt(initDataEntity.getDeviceHumanId()) != 0) {
- setMainView();
- }
- } else {
- handler.sendEmptyMessage(MAIN_DATA_ERROR);
- }
- if (0 == tag) hideProgress();
- } catch (Exception e) {
- LogUtil.d("getMainData", "Exception==" + e.toString());
- if (0 == tag) hideProgress();
- e.printStackTrace();
- handler.sendEmptyMessage(MAIN_DATA_ERROR);
- }
- Constants.UPDATE_PATIENTUPDATE_FLAG = false;
- }
- });
- } else {
- LogUtil.d("getMainData", "setWelcomeView==succeed==");
- setWelcomeView();
- dismissNurseBrightness();
- }
- }
- /**
- * 获取二维码图片
- */
- private void getQrCodeData() {
- Bitmap logoBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.erlogo);
- qrBarcodeImg.setImageBitmap(TwoDimensionCodeUtil.CreatePicture(Constants.TWO_DIMENSION_CODE_PATH + SerialPortUtil.KEY_ID, 200, 200, logoBitmap, true));
- // if (StringUtils.notEmpty(initDataEntity.getId())) {//现在没有搞这个请求了
- // OkHttpUtils.get().url(Constants.APP_BARCODE_IMG)
- // .addParams("bedid", initDataEntity.getId()).build().execute(new BitmapCallback() {
- // @Override
- // public void onError(Call call, Exception e, int id) {
- // LogUtil.d("getQrCodeData", "onError:" + e.getMessage());
- // }
- //
- // @Override
- // public void onResponse(Bitmap response, int id) {
- // LogUtil.d("getQrCodeData", "response:" + response.toString());
- // qr_Barcode_IMG.setImageBitmap(response);
- // }
- // });
- // }
- }
- /**
- * 检查APP更新版本
- */
- private void appCheckUpdate() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- if (!StringUtils.notEmpty(Constants.PartID)) return;
- try {
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.APP_CHECK_UPDATE)
- .addParams("PartID", Constants.PartID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- Constants.UPDATE_APP_FLAG = false;
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- LogUtil.d(CallingBedActivity.class, "appCheckUpdate==" + data);
- try {
- JSONObject object = new JSONObject(data);
- if (object.getString("Code").equals("OK!")) {
- float APPVersion = StringUtils.parseFloat(StringUtils.deleteCharAt(object.getString("APPVersion"), 0));
- float APPVersion_Now = StringUtils.parseFloat(StringUtils.getAppVersionName(CallingBedActivity.this));
- String downloadURL = object.getString("downloadURL");
- if (APPVersion_Now != APPVersion) {//本来是“<”的;但有个别机器老是不升级成功
- if (StringUtils.notEmpty(downloadURL)) {
- closeHeart();//关闭心跳
- DownloadUtil.APP_VERSION = APPVersion;
- Intent intent = new Intent(CallingBedActivity.this, APPUpdateActivity.class);
- intent.putExtra("downLoadURL", Constants.URL + Constants.URL_END + "/" + downloadURL);
- startActivity(intent);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- Constants.UPDATE_APP_FLAG = false;
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- Constants.UPDATE_APP_FLAG = false;
- }
- }
- /**
- * 刷新各项参数<br></>
- */
- public void upDateParameter() {
- getMainData(0);
- getSystemSettingData();
- getNoticeData();
- }
- //---------------------------------------------U I 更改部 (上)---------------------------------------------------------------------
- /**
- * 托管状态
- */
- private void setTrustIcon() {
- if (initDataEntity.getDeviceHostingID().contains("#")) {
- //隐藏未托管图标
- ivTrust.setImageResource(R.mipmap.ic_trust);
- isTrusting = true;
- } else if (!isTrusting) {
- //显示未托管图标
- ivTrust.setImageResource(R.mipmap.ic_calling_sickbed_bed_wrong_trusteeship);
- }
- try {
- tvVersion.setText("V" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName);
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
- }
- /**
- * 更新欢迎界面
- */
- private void setWelcomeView() {
- Picasso.with(context).load(Constants.URL + Constants.URL_END + "/WDFJ-I/WDFJ-I.png").fit().memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE).into(ivWelcome);
- setTitle();
- vMain.setVisibility(View.GONE);
- vWelcome.setVisibility(View.VISIBLE);
- }
- /**
- * 更新主界面UI
- */
- private void setMainView() {
- if (null != mainDataEntity) {
- //关闭欢迎界面
- vWelcome.setVisibility(View.GONE);
- vMain.setVisibility(View.VISIBLE);
- // Bitmap logoBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.erlogo);
- //ivTwoDimensionalCode.setImageBitmap(TwoDimensionCodeUtil.CreatePicture(Constants.TWO_DIMENSION_CODE_PATH + SerialPortUtil.KEY_ID, 200, 200, logoBitmap, true));
- tvLeftOneTitle.setText(mainDataEntity.getLeftOneTitle());
- tvLeftOneContent.setText(mainDataEntity.getLeftOneContent());
- tvLeftTwoTitle.setText(mainDataEntity.getLeftTwoTitle());
- tvLeftTwoContent.setText(mainDataEntity.getLeftTwoContent());
- tvLeftThreeTitle.setText(mainDataEntity.getLeftThreeTitle());
- tvLeftThreeContent.setText(mainDataEntity.getLeftThreeContent());
- tvLeftFourTitle.setText(mainDataEntity.getLeftFourTitle());
- tvLeftFourContent.setText(mainDataEntity.getLeftFourContent());
- tvLeftFiveTitle.setText(mainDataEntity.getLeftFiveTitle());
- tvLeftFiveContent.setText(mainDataEntity.getLeftFiveContent());
- //增长页面 祁阳人民医院提的(201901017 Waderson)
- tvLeftOneTitle_big.setText(mainDataEntity.getLeftOneTitle());
- tvLeftOneContent_big.setText(mainDataEntity.getLeftOneContent());
- tvLeftTwoTitle_big.setText(mainDataEntity.getLeftTwoTitle());
- tvLeftTwoContent_big.setText(mainDataEntity.getLeftTwoContent());
- tvLeftThreeTitle_big.setText(mainDataEntity.getLeftThreeTitle());
- tvLeftThreeContent_big.setText(mainDataEntity.getLeftThreeContent());
- tvLeftFourTitle_big.setText(mainDataEntity.getLeftFourTitle());
- tvLeftFourContent_big.setText(mainDataEntity.getLeftFourContent());
- tvLeftFiveTitle_big.setText(mainDataEntity.getLeftFiveTitle());
- tvLeftFiveContent_big.setText(mainDataEntity.getLeftFiveContent());
- String name = mainDataEntity.getName();
- if (StringUtils.notEmpty(name)) {
- tvName.setText(name);
- tvName_big.setText(name);
- } else {
- tvName.setText("");
- tvName_big.setText("");
- }
- tvDetail.setText(mainDataEntity.getSex());//"【"+mainDataEntity.getSex()+"】"
- tvDetail_big.setText("[ " + mainDataEntity.getSex() + " ]");//"【"+mainDataEntity.getSex()+"】"
- tvIllness.setText(mainDataEntity.getAgeNum() + "" + mainDataEntity.getAgeUnit());
- tvIllness_big.setText(mainDataEntity.getAgeNum() + "" + mainDataEntity.getAgeUnit());
- //tvHospNumber.setText("入院:" + mainDataEntity.getInpatientNum());
- tvAdmission.setText(" 入住时间: " + mainDataEntity.getAdmissionTime() + " ");
- tvHospData.setText(mainDataEntity.getAdmissionTime());
- tvDoctorName.setText(mainDataEntity.getResponsDoctor());
- tvNurseName.setText(mainDataEntity.getResponsNurse());
- if (null != initDataEntity) {
- tvBedNum.setText(initDataEntity.getDeviceBedNum());
- tvBedNum_big.setText(initDataEntity.getDeviceBedNum());
- }
- /*Picasso.with(context).load(Constants.URL + Constants.URL_END + "/" + mainDataEntity.getResponsDoctorPic()).transform(new Transformation() {
- @Override
- public Bitmap transform(Bitmap source) {
- Bitmap bitmap = BitmapUtils.zoom(source, DensityUtils.dp2px(context, 62), DensityUtils.dp2px(context, 62));
- //圆形处理
- bitmap = BitmapUtils.circleBitmap(bitmap);
- //回收bitmap资源
- source.recycle();
- return bitmap;
- }
- @Override
- public String key() {
- return "";//需要保证返回值不能为null。否则报错
- }
- }).fit().memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE).into(ivDoctor);
- Picasso.with(context).load(Constants.URL + Constants.URL_END + "/" + mainDataEntity.getResponsNursePic()).transform(new Transformation() {
- @Override
- public Bitmap transform(Bitmap source) {
- Bitmap bitmap = BitmapUtils.zoom(source, DensityUtils.dp2px(context, 62), DensityUtils.dp2px(context, 62));
- //圆形处理
- bitmap = BitmapUtils.circleBitmap(bitmap);
- //回收bitmap资源
- source.recycle();
- return bitmap;
- }
- @Override
- public String key() {
- return "";//需要保证返回值不能为null。否则报错
- }
- }).fit().memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE).into(ivNurse);*/
- setTitle();
- }
- }
- /**
- * 设置通知页面
- */
- private void setNoticeView() {
- if (null != noticeArrayList && noticeArrayList.size() > 0) {
- String strNotice = "";
- for (int i = 0; i < noticeArrayList.size(); i++) {
- strNotice += " 【" + (i + 1) + "】 " + noticeArrayList.get(i).getNoticeContent() + " " + noticeArrayList.get(i).getNoticeEndTime();
- }
- if (!TextUtils.isEmpty(strNotice)) {
- ivNotice.setVisibility(View.VISIBLE);
- tvNoticeContent.setVisibility(View.VISIBLE);
- tvNoticeContent.setText(strNotice);
- } else {
- ivNotice.setVisibility(View.INVISIBLE);
- tvNoticeContent.setVisibility(View.INVISIBLE);
- }
- } else {
- ivNotice.setVisibility(View.INVISIBLE);
- tvNoticeContent.setVisibility(View.INVISIBLE);
- }
- }
- /**
- * 设置医嘱界面
- */
- private void setDoctorView() {
- if (null != doctorDataEntity) {
- if (null != doctorDataEntity.getDoctorChargeArray()) {
- doctorChargeArrayList = doctorDataEntity.getDoctorChargeArray();
- }
- doctorAdapter.upDateList(doctorChargeArrayList);
- rvDoctor.setAdapter(doctorAdapter);
- tvDoctorPageName.setText("姓名: " + doctorDataEntity.getName());
- tvDoctorPageInpatientNum.setText("住院号: " + doctorDataEntity.getInpatientNum());
- }
- }
- /**
- * 设置费用界面
- */
- private void setCostView() {
- if (null != costDataEntity) {
- if (null != costDataEntity.getCostArray()) {
- costArrayList = costDataEntity.getCostArray();
- }
- costAdapter.upDateList(costArrayList);
- rvCost.setAdapter(costAdapter);
- tvCostPageName.setText("姓名: " + costDataEntity.getName());
- tvCostPageInpatientNum.setText("住院号: " + costDataEntity.getInpatientNum());
- }
- }
- //---------------------------------------------U I更改部分(下)---------------------------------------------------------------------
- /**
- * 设置闹钟
- */
- int alarmId = 0;
- private void setNoticeClock(List<NoticeDataEntity.NoticeArray> list) {
- for (int i = 0; i < list.size(); i++) {
- if (DateUtil.judgeCurrTime(noticeArrayList.get(i).getNoticeStartTime())) {
- openAlarm(list.get(i).getNoticeStartTime(), i, 0);
- }
- if (DateUtil.judgeCurrTime(noticeArrayList.get(i).getNoticeEndTime())) {
- openAlarm(list.get(i).getNoticeEndTime(), i, 1);
- }
- }
- }
- /**
- * 开启闹钟
- */
- private void openAlarm(String time, int position, int playFlag) {
- Intent intent = new Intent(this, AlarmReceiver.class);
- intent.putExtra("position", position);
- intent.putExtra("playFlag", playFlag);
- alarmId = alarmId + 1;
- PendingIntent pendingIntent = PendingIntent.getBroadcast(this, alarmId, intent, 0);
- AlarmManager alarmManager;
- alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
- Date curDate = new Date(time);//获取当前时间
- long triggerAtMillis = curDate.getTime();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);
- } else {
- alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, pendingIntent);
- }
- }
- /**
- * 按任意键是否关闭广播
- */
- private boolean isCloseBroadcast = false;
- /**
- * 病人需要休息按任意键关闭广播
- */
- private boolean anyKeyCloseBroadcast() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- //=====================停止廣播==================//
- MediaPlayerManger.getInstance().stopMediaPlayer();
- tvBroadcasting.setText("");
- tvBroadcasting.setVisibility(View.INVISIBLE);
- isCloseBroadcast = true;
- }
- });
- return isCloseBroadcast;
- }
- //---------------------------------------------串口点击事件监听----------------------------------------------------------
- @Override
- public void serialPortBedOnclick(byte[] buffer) {
- LogUtil.e("serialPortBedOnclick", "CallingBedActivity: buffer[0]:" + buffer[0] + "buffer[1]:" + buffer[1] + "buffer[2]:" + buffer[2] + "buffer[3]:" + buffer[3] + "buffer[4]:"
- + buffer[4] + "buffer[5]:" + buffer[5]);
- if (buffer[7] == 1) { //卫生间短按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- LogUtil.d(CallingBedActivity.class, "卫生间短按松开");
- UdpSendUtil.sendCall2(initDataEntity);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- if (isNurseStatus) {
- if (flickerStatus) {
- flickerStatus = setWSHLightFlicker(serialPortUtil, false);
- } else {
- flickerStatus = setWSHLightFlicker(serialPortUtil, true);
- }
- } else {
- flickerStatus = setWSHLightFlicker(serialPortUtil, true);
- }
- }
- });
- }
- if (buffer[7] == 2) {//卫生间长按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- LogUtil.d(CallingBedActivity.class, "卫生间长按松开");
- UdpSendUtil.sendCall2(initDataEntity);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- if (isNurseStatus) {
- if (flickerStatus) {
- flickerStatus = setWSHLightFlicker(serialPortUtil, false);
- } else {
- flickerStatus = setWSHLightFlicker(serialPortUtil, true);
- }
- } else {
- flickerStatus = setWSHLightFlicker(serialPortUtil, true);
- }
- }
- });
- }
- //病人需要休息按任意键关闭广播
- for (int i = 0; i < buffer.length; i++) {
- if (buffer[i] == 1 || buffer[i] == 2) {
- if (anyKeyCloseBroadcast()) {
- isCloseBroadcast = false;
- break;
- }
- }
- }
- if (null != vWelcome) {
- //只有在欢迎界面没有显示的时候串口才能用
- if (vWelcome.getVisibility() == View.GONE) {
- //医嘱键短按松开
- if (buffer[0] == 1) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVDoctor();
- }
- });
- }
- //医嘱键长按松开
- if (buffer[0] == 2) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVDoctor();
- //sendMultitapNurse(initDataEntity, mainDataEntity);
- }
- });
- }
- //费用查询键短按松开
- if (buffer[1] == 1) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVCost();
- }
- });
- }
- //费用查询键长按松开
- if (buffer[1] == 2) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVCost();
- }
- });
- }
- //二维码键短按松开
- if (buffer[2] == 1) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVQrCode();
- }
- });
- }
- //二维码键长按松开
- if (buffer[2] == 2) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVQrCode();
- }
- });
- }
- if (buffer[3] == 1) { //请求增援键短按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVSupport();
- }
- });
- }
- if (buffer[3] == 2) {//请求增援键长按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- if (isNurseStatus) {//进入护理后;子机请求转接(add by waderson 20191108)
- UdpSendUtil.sendCall1Transfer(initDataEntity, mainDataEntity);
- } else {
- }
- }
- });
- }
- //呼叫护工键短按松开
- if (buffer[4] == 1) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- clickVCall();
- }
- });
- }
- //呼叫护工键长按松开
- if (buffer[4] == 2) {
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- snackbar.dismiss();//底部snackbar消失
- if (null != callNoticeEntity) {
- if (!Constants.WSHROOM_CALL.equals(callNoticeEntity.getType())) {
- //开始转接拨打各种电话。waderson 2019 03 21
- isTransfer = true;
- SipHelperUtil.getInstance(CallingBedActivity.this).getmSipCallBackI().startCall(callNoticeEntity.getSipAddress());
- } else {
- ToastUtil.showToast(CallingBedActivity.this, "不支持卫生间通话!");
- }
- } else {
- ToastUtil.showToast(CallingBedActivity.this, "当前无呼叫请求");
- }
- }
- });
- }
- if (buffer[5] == 0) { //呼叫护士键按住不动
- LogUtil.d("WWW", "呼叫护士键==0");
- } else if (buffer[5] == 1) {//呼叫护士键短按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- LogUtil.d("WWW", "呼叫护士键==1");
- long curTimeMills = System.currentTimeMillis();
- if (curTimeMills - localMillsCallNurse > 3000) {
- clickVNurse();
- localMillsCallNurse = curTimeMills;
- tvNurseTimeOut.setText("");
- //呼叫超时倒计时开启
- callTypeCallNurse = "1";
- //handsMICStatus = setHandsMIC(serialPortUtil, false);//点击了外部按键就将手柄MIC关掉
- handsMICStatus = setHandsMIC(serialPortUtil, true);//面板mic有回音,需要禁掉
- }
- }
- });
- } else if (buffer[5] == 2) {//呼叫护士键长按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- if (Constants.IS_CALLED == 0) {//当前没有呼叫长按后还是呼叫
- long curTimeMills = System.currentTimeMillis();
- if (curTimeMills - localMillsCallNurse > 3000) {
- clickVNurse();
- localMillsCallNurse = curTimeMills;
- tvNurseTimeOut.setText("");
- //呼叫超时倒计时开启
- callTypeCallNurse = "1";
- //handsMICStatus = setHandsMIC(serialPortUtil, false);//点击了外部按键就将手柄MIC关掉
- handsMICStatus = setHandsMIC(serialPortUtil, true);//面板mic有回音,需要禁掉
- }
- } else if (Constants.IS_CALLED == 1) {//当前有呼叫长按后取消呼叫
- UdpSendUtil.sendHangUp(initDataEntity, mainDataEntity);//长按取消呼叫 add by waderson 20191108
- }
- }
- });
- } else if (buffer[5] == -1) {//按键常态
- LogUtil.d("WWW", "呼叫护士键==-1");
- }
- //------------------------below things was add by Waderson 20171106 -----------------------------------
- if (buffer[6] == 1 || buffer[6] == 2) { //手柄短按松开,手柄长按松开 都要执行
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- LogUtil.d("WWW", "呼叫护士键==-2");
- if (CALL_STATUS.equals(Constants.STANDBY) || CALL_STATUS.equals(Constants.IN_CALLING) || CALL_STATUS.equals(NURSE_CALL_TIMEOUT)) { //待机状态或呼叫超时或通话中可以挂断
- handsMICStatus = setHandsMIC(serialPortUtil, true);
- clickVNurse();
- tvNurseTimeOut.setText("");
- //呼叫超时倒计时开启
- callTypeCallNurse = "2";
- localMillsCallNurse = System.currentTimeMillis();
- } /*else {
- handsMICStatus = setHandsMIC(serialPortUtil, false);
- }*/
- }
- });
- }
- if (buffer[6] == 2) {//手柄长按松开
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- LogUtil.d("WWW", "呼叫护士键==-3");
- if (bedLightStatus) {
- bedLightStatus = setBedLight(serialPortUtil, false, 0);
- // showToast("床头灯关闭");
- } else {
- bedLightStatus = setBedLight(serialPortUtil, true, 0);
- // showToast("床头灯点亮");
- }
- }
- });
- }
- }
- }
- }
- @Override
- public void serialPortBedOnclickString(String str) {
- //LogUtil.d("serialPortBedOnclickString", "CallingBedActivity: " + str);
- }
- //---------------------------------------------串口点击事件监听----------------------------------------------------------
- private long localMillsCallNurse = 0;//呼叫护士拨打的时刻
- private String callTypeCallNurse = "";//1:外部物理按键呼叫;2:手柄按钮呼叫
- /**
- * @param sel 1:外部物理按键呼叫;2:手柄按钮呼叫
- * 呼叫护士超时
- */
- private void autoHangUpCallNurse(String sel) {
- clickVNurse();
- if (sel.equals("1")) {
- handsMICStatus = setHandsMIC(serialPortUtil, false);
- } else {
- if (CALL_STATUS.equals(Constants.STANDBY)) {//待机状态
- handsMICStatus = setHandsMIC(serialPortUtil, true);
- } else {
- handsMICStatus = setHandsMIC(serialPortUtil, false);
- }
- }
- }
- //---------------------------------------------EventBus发送事件监听-------------------------------------------------------
- /**
- * 托管状态
- */
- private boolean isTrusting = false;
- /**
- * 去重
- */
- private boolean isReset = false;
- /**
- * 客户是否执行了转接
- */
- public boolean isTransfer = false;
- UdpEntity callNoticeEntity;
- private long updateAudioTime = 0;
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onMoonEvent(MessageEvent messageEvent) {
- switch (messageEvent.getType()) {
- case Constants.EVENT_UDP:
- UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
- switch (udpEntity.getIndexes()) {
- case "call_1": //子机呼叫护士主机
- showSnackbarPrompt(udpEntity.getBedNumber() + "床呼叫!");
- callNoticeEntity = udpEntity;
- //适配无门口机但是有门灯的情况,门灯直接接到其中一个床位分机,房间内任何一个分机呼叫都需要点亮门灯
- if (serialPortUtil != null && initDataEntity != null && initDataEntity.getDeviceRoomNum().equals(udpEntity.getRoomNumber())) {
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁
- }
- break;
- case "call_2"://卫生间呼叫护士主机
- showSnackbarPrompt(udpEntity.getRoomNumber() + "房卫生间紧急呼叫!");
- callNoticeEntity = udpEntity;
- if (serialPortUtil != null && initDataEntity != null && initDataEntity.getDeviceRoomNum().equals(udpEntity.getRoomNumber())) {
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁
- }
- break;
- case "call_4"://增援呼叫护士主机
- showSnackbarPrompt(udpEntity.getBedNumber() + "床请求增援!");
- callNoticeEntity = udpEntity;
- break;
- case "call_6": //门口机呼叫护士主机
- showSnackbarPrompt(udpEntity.getRoomNumber() + "房门口机呼叫!");
- callNoticeEntity = udpEntity;
- break;
- case "call_8_upremove"://主机通知对应的子机改变自己的UI
- if (Constants.MYSELF_ID.equals(udpEntity.getHeadMachineID())) {
- LogUtil.d(CallingBedActivity.class, "主机上滑Remove掉了。。。");
- if (udpEntity.getType().equals(Constants.SON_CALL)) {
- Constants.IS_CALLED = 0;
- }
- if (!udpEntity.getType().equals(Constants.WSHROOM_CALL)) {//排除卫生间;卫生间是不能呼叫的
- if (!CALL_STATUS.equals(STANDBY)) {
- CALL_STATUS = STANDBY;
- showThisView(vMain);
- }
- } else {
- flickerStatus = setWSHLightFlicker(serialPortUtil, false);
- }
- }
- break;
- case "call_8_transfer"://转接护士主机电话
- LogUtil.d("call_8_transfer", "Constants.MYSELF_ID=="
- + Constants.MYSELF_ID + "\nudpEntity.getBedNumber()==" + udpEntity.getBedNumber()
- + "\nudpEntity.getHeadMachineID()==" + udpEntity.getHeadMachineID());
- if (Constants.MYSELF_ID.equals(udpEntity.getBedNumber()) && !Constants.MYSELF_ID.equals(udpEntity.getHeadMachineID())) {
- //开始连接拨打电话。
- //开始转接 20171219
- //=============================================SIP拨打电话===================================//
- SipHelperUtil.getInstance(this).getmSipCallBackI().startCall(udpEntity.getSipAddress());
- LogUtil.d("call_8_transfer", "Constants.MYSELF_ID "
- + Constants.MYSELF_ID
- + "\nudpEntity.getHeadMachineID() " + udpEntity.getHeadMachineID() + "\nudpEntity.getSipAddress() "
- + udpEntity.getSipAddress() + innetSIPAddress);
- }
- break;
- case "nursing_1": //进入护理
- isNurseStatus = true;
- break;
- case "nursing_2": //退出护理
- flickerStatus = setWSHLightFlicker(serialPortUtil, false);
- isNurseStatus = false;
- //发送UDP通知护士主机,护理已完成
- UdpSendUtil.sendCall1b1(initDataEntity, mainDataEntity);
- break;
- case "noany_request": //护士主机通知外部当前房间无任何请求 20191119 waderson
- if (serialPortUtil != null && initDataEntity != null && initDataEntity.getDeviceRoomNum().equals(udpEntity.getRoomNumber())) {
- setDoorLight(serialPortUtil, "111");//白色
- }
- break;
- case "call_host_exception":
- if (Constants.CALLMAIN_ID.equals(udpEntity.getNurseHostID())) {
- Constants.IS_CALLED = 0;
- if (!CALL_STATUS.equals(STANDBY)) {
- CALL_STATUS = STANDBY;
- showThisView(vMain);
- SipHelperUtil.getInstance(this).getmSipCallBackI().endCall();
- }
- flickerStatus = setWSHLightFlicker(serialPortUtil, false);
- }
- break;
- }
- break;
- case Constants.EVENT_NOTICE:
- if (((NoticeEntity) messageEvent.getMessage()).getAlarmIndex() != -1) {
- if (((NoticeEntity) messageEvent.getMessage()).isAlarmState()) {
- textToSpeech.speak(noticeArrayList.get(((NoticeEntity) messageEvent.getMessage()).getAlarmIndex()).getNoticeContent(), TextToSpeech.QUEUE_FLUSH, null);
- setNoticeView();
- }
- if (!((NoticeEntity) messageEvent.getMessage()).isAlarmState()) {
- noticeArrayList.remove(((NoticeEntity) messageEvent.getMessage()).getAlarmIndex());
- setNoticeView();
- }
- }
- break;
- case Constants.EVENT_SETSYS://系统设置参数
- setSYSParameter();
- break;
- case Constants.EVENT_MGR_PATIENTUPDATE://数据改变刷新本机
- upDateParameter();
- break;
- case Constants.EVENT_MGR_APP_UPDATE://APP更新
- appCheckUpdate();
- break;
- case Constants.EVENT_BROADCAST:
- BroadCastEntity broadCastEntity = (BroadCastEntity) messageEvent.getMessage();
- switch (broadCastEntity.getIndexes()) {
- case "broadcast_update":
- long curTime = System.currentTimeMillis();
- if (curTime - updateAudioTime > 10000) {
- updateAudioTime = curTime;
- getBroadcastAudioFiles();
- }
- break;
- case "broadcast_1":
- boolean isPlay = false;
- switch (Integer.parseInt(broadCastEntity.getZoneId())) {
- case 0:
- if (initDataEntity.getDeviceZone0().equals("1")) {
- isPlay = true;
- }
- break;
- case 1:
- if (initDataEntity.getDeviceZone1().equals("1")) {
- isPlay = true;
- }
- break;
- case 2:
- if (initDataEntity.getDeviceZone2().equals("1")) {
- isPlay = true;
- }
- break;
- case 3:
- if (initDataEntity.getDeviceZone3().equals("1")) {
- isPlay = true;
- }
- break;
- case 4:
- if (initDataEntity.getDeviceZone4().equals("1")) {
- isPlay = true;
- }
- break;
- case 5:
- if (initDataEntity.getDeviceZone5().equals("1")) {
- isPlay = true;
- }
- break;
- }
- if (isPlay) {
- try {
- //=====================停止廣播===================//
- MediaPlayerManger.getInstance().stopMediaPlayer();
- //=====================播放廣播===================//
- String localAudioFile = isLocalAudioExist(broadCastEntity.getPath());
- if (localAudioFile != null) {
- LogUtil.d("broadcast", "play local media, url: " + localAudioFile);
- MediaPlayerManger.getInstance()
- .playMusic(localAudioFile, this, MediaPlayerManger.PLAY);
- } else {
- LogUtil.d("broadcast", "play stream media, url: " + Constants.URL + Constants.URL_END + "/" + broadCastEntity.getPath());
- MediaPlayerManger.getInstance()
- .playMusic(Constants.URL + Constants.URL_END + "/"
- + broadCastEntity.getPath(), this, MediaPlayerManger.PLAY);
- }
- if (!SharedPreferencesUtil.getStringSp(this, "SetUpBroadcastVoice", "voice").equals("")) {
- float voice = Float.parseFloat(SharedPreferencesUtil.getStringSp(this, "SetUpBroadcastVoice", "voice"));
- if (mVolume == 1.0f) {
- MediaPlayerManger.getInstance().setVolume(voice);
- } else {
- MediaPlayerManger.getInstance().setVolume(0);
- }
- }
- if (!broadCastEntity.getVoiceInt().equals("0")) {
- float voice = Float.parseFloat(broadCastEntity.getVoiceInt()) / 100;
- if (mVolume == 1.0f) {
- MediaPlayerManger.getInstance().setVolume(voice);
- } else {
- MediaPlayerManger.getInstance().setVolume(0);
- }
- }
- tvBroadcasting.setVisibility(View.VISIBLE);
- tvBroadcasting.setText("======广播中======");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- break;
- case "broadcast_2":
- try {
- MediaPlayerManger.getInstance().stopMediaPlayer();
- tvBroadcasting.setText("");
- tvBroadcasting.setVisibility(View.INVISIBLE);
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- case "broadcast_v":
- try {
- float voice = Float.parseFloat(broadCastEntity.getVoiceInt()) / 100;
- if (mVolume == 1.0f) {
- MediaPlayerManger.getInstance().setVolume(voice);
- } else {
- MediaPlayerManger.getInstance().setVolume(0);
- }
- SharedPreferencesUtil.putStringSp(this, "SetUpBroadcastVoice", "voice", String.valueOf(voice));
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- }
- case EVENT_SIP_INTERNETPING://循环更新以太网ping信息和sip信息
- SipHelperUtil.getInstance(this).obtainSipInfo();//获取sip信息
- if (ethernetStatus) {
- ivEthernet.setImageResource(R.mipmap.ic_etherneting);
- ivWifi.setImageResource(R.mipmap.ic_wifi_nor);
- } else {
- ivEthernet.setImageResource(R.mipmap.ic_etherneted);
- ivWifi.setImageResource(R.mipmap.ic_wifi_nor);
- }
- break;
- case EVENT_SIP_REGISTER_STATUS://刷新SIP注册状态
- if (messageEvent.getMessage() instanceof String) {
- String status = (String) messageEvent.getMessage();
- updateStatus(status);
- } else if (messageEvent.getMessage() instanceof Integer) {// 22:Sip释放资源 断电重置
- // CallingBedActivity.initPlayerVolum(1.0f);
- // CALL_STATUS = Constants.STANDBY;
- // showThisView(vMain);
- }
- break;
- case EVENT_MGR_RESET:
- resetAPP();
- break;
- // case EVENT_INTERNET_STATUS://刷新网络状态==================================暂时注掉(排除以太网开关硬件问题)===============================
- // switch ((int) messageEvent.getMessage()) {
- // case NetUtil.NETWORK_ETHERNET://本地:打开 Wifi: 关闭
- // ivEthernet.setImageResource(R.mipmap.ic_etherneting);
- // ivWifi.setImageResource(R.mipmap.ic_wifi_nor);
- //
- // break;
- // case NetUtil.NETWORK_WIFI://本地:关闭 Wifi: 打开
- // ivEthernet.setImageResource(R.mipmap.ic_etherneted);
- // ivWifi.setImageResource(R.mipmap.ic_wifi_high);
- // break;
- // case NetUtil.NETWORK_NONE://本地:关闭 Wifi: 关闭
- // ivEthernet.setImageResource(R.mipmap.ic_etherneted);
- // ivWifi.setImageResource(R.mipmap.ic_wifi_nor);
- // break;
- // }
- // SipHelperUtil.getInstance(this).obtainSipInfo();//获取sip信息
- // break;
- }
- }
- Snackbar snackbar;
- /**
- * 在底下弹出呼叫提示
- */
- @SuppressLint("WrongConstant")
- public void showSnackbarPrompt(String message) {
- LogUtil.d("showSnackbarPrompt", "message==" + message);
- // snackbar = Snackbar.make(rlMain, message, Snackbar.LENGTH_LONG)
- snackbar = Snackbar.make(rlMain, message, 60000)
- .setAction("长按转接—>", new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- }
- });
- snackbar.getView().setBackgroundColor(Color.WHITE);
- //click的字体颜色
- snackbar.setActionTextColor(Color.BLUE);
- //内容的字体颜色与大小
- TextView tvSnackbarText = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
- Button snackbarButton = (Button) snackbar.getView().findViewById(android.support.design.R.id.snackbar_action);
- tvSnackbarText.setText(message);
- tvSnackbarText.setTextColor(Color.RED);
- tvSnackbarText.setTextSize(52);
- snackbarButton.setTextSize(30);
- Drawable d = ContextCompat.getDrawable(this, R.drawable.warn);
- d.setBounds(0, 0, d.getMinimumWidth(), d.getMinimumHeight());
- tvSnackbarText.setCompoundDrawables(d, null, null, null);// 给TextView左边添加图标
- tvSnackbarText.setCompoundDrawablePadding(10);
- tvSnackbarText.setGravity(Gravity.CENTER); // 让文字居中
- //snackbar.show();
- }
- /**
- * 重启APP
- */
- public void resetAPP() {
- if (!isReset) {
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- isReset = true;
- Intent mStartActivity = new Intent(context, InitActivity.class);
- int mPendingIntentId = 123456;
- PendingIntent mPendingIntent = PendingIntent.getActivity(context, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
- AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, mPendingIntent);
- System.exit(0);
- }
- }, 2000);
- }
- }
- //---------------------------------------------EventBus发送事件监听----------------------------------------------------------
- //---------------------------------------------设置硬件参数部分(上)-----------------------------------------------------------------
- boolean handsMICStatus = false;//是否是手柄MIC
- boolean flickerStatus = false;//卫生间灯是否在闪烁
- boolean lightStatus = false;//卫生间灯是否开启
- boolean isNurseStatus = false;//护士是否进入了护理
- boolean bedLightStatus = false;//床头灯是否打开.
- /**
- * 设置系统的各项参数,根据后台UDP的指令改变机器的状态(声音大小;亮度;。。。)<br></>
- */
- private void setSYSParameter() {
- if (StringUtils.notEmpty(Constants.MORNING_NIGTH)) {//初始化卫生间按键灯
- flickerStatus = setWSHLightFlicker(serialPortUtil, flickerStatus);
- }
- if (StringUtils.notEmpty(Constants.MORNING_NIGTH) && Constants.MORNING_NIGTH.equals("1")) {//晚上
- lightStatus = setWSHLight(serialPortUtil, true);
- } else {
- lightStatus = setWSHLight(serialPortUtil, false);
- }
- if (StringUtils.isInt(Constants.SCREENLIGHT)) {
- setSYSBrightness(CallingBedActivity.this, StringUtils.parseInt(Constants.SCREENLIGHT));
- }
- if (StringUtils.isInt(Constants.SYSVOICE)) {
- setSYSVoice(CallingBedActivity.this, StringUtils.parseInt(Constants.SYSVOICE));
- }
- if (StringUtils.isInt(Constants.NURSINGLIGHT) && null != mainDataEntity) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- LogUtil.d("NURSELIGHT", "设置护理灯" + Constants.NURSINGLIGHT + "---" + mainDataEntity.getLeftOneColor() + "---" + mainDataEntity.getLeftTwoColor() + "---" + mainDataEntity.getLeftThreeColor() + "---" + mainDataEntity.getLeftFourColor() + "---" + mainDataEntity.getLeftFiveColor());
- setNurseBrightness(serialPortUtil, StringUtils.parseInt(Constants.NURSINGLIGHT), mainDataEntity.getLeftOneColor(), mainDataEntity.getLeftTwoColor(),
- mainDataEntity.getLeftThreeColor(), mainDataEntity.getLeftFourColor(), mainDataEntity.getLeftFiveColor());
- } catch (InterruptedException e) {
- LogUtil.d("NURSELIGHT", "设置护理灯" + "InterruptedException");
- e.printStackTrace();
- }
- }
- }).start();
- }
- VoiceManagerUtil.setCallVoice(CallingBedActivity.this, Integer.parseInt(Constants.BEDCALLVOICE));
- //刷新呼叫超时时间
- callTimeOut = (StringUtils.parseInt(Constants.CALLINGTIMEOUT) == 0 ? 30000 : StringUtils.parseInt(Constants.CALLINGTIMEOUT) * 1000);
- callTimeOutBack = (StringUtils.parseInt(Constants.CALLINGTIMEOUT) <= 0 ? 30 : StringUtils.parseInt(Constants.CALLINGTIMEOUT));//默认180秒
- }
- //---------------------------------------------设置硬件参数部分(下)-----------------------------------------------------------------
- //---------------------------------------------串口点击事件部分(上)---------------------------------------------------------------------
- public void clickVDoctor() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vDoctor)) {
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- if (isVisible(llRight)) {
- showThisView(vDoctor);
- changeTextColor(tvDoctor);
- goneLlRightView(true);
- getDoctorData();
- } else {
- showLlRightView();
- }
- } else {
- if (!isVisible(vSupport) && !isVisible(vCall) && !isVisible(vNurse)) {//排除呼叫状态
- showThisView(vDoctor);
- getDoctorData();
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- public void clickVCost() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vCost)) {
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- if (isVisible(llRight)) {
- showThisView(vCost);
- changeTextColor(tvCost);
- goneLlRightView(true);
- getCostData();
- } else {
- showLlRightView();
- }
- } else {
- if (!isVisible(vSupport) && !isVisible(vCall) && !isVisible(vNurse)) {//排除呼叫状态
- showThisView(vCost);
- getCostData();
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- public void clickVQrCode() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vQrCode)) {
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- if (isVisible(llRight)) {
- showThisView(vQrCode);
- changeTextColor(tvQrCode);
- goneLlRightView(true);
- getQrCodeData();
- } else {
- showLlRightView();
- }
- } else {
- if (!isVisible(vSupport) && !isVisible(vCall) && !isVisible(vNurse)) {//排除呼叫状态
- showThisView(vQrCode);
- getQrCodeData();
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- public void clickVSupport() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vSupport)) {
- CALL_STATUS = STANDBY;
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- if (isVisible(llRight)) {
- showThisView(vSupport);
- changeTextColor(tvSupport);
- goneLlRightView(true);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- UdpSendUtil.sendCall4(initDataEntity, mainDataEntity);
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.SUPPORT_IN_CALL;
- if (null != initDataEntity) {
- jbVSupport = setJumpingBeans(tvSupportText, initDataEntity.getDeviceBedNum() + "床正在请求增援...");
- }
- } else {
- showLlRightView();
- }
- } else {
- if (!isVisible(vCall) && !isVisible(vNurse)) {//排除呼叫状态
- showThisView(vSupport);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- UdpSendUtil.sendCall4(initDataEntity, mainDataEntity);
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.SUPPORT_IN_CALL;
- if (null != initDataEntity) {
- jbVSupport = setJumpingBeans(tvSupportText, initDataEntity.getDeviceBedNum() + "床正在请求增援...");
- }
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- public void clickVCall() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vCall)) {
- CALL_STATUS = STANDBY;
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- if (isVisible(llRight)) {
- showThisView(vCall);
- changeTextColor(tvCall);
- goneLlRightView(true);
- //sendProtectHelp();//呼叫护工还没有做;这个先预留
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.WORK_IN_CALL;
- if (null != initDataEntity) {
- jbVCall = setJumpingBeans(tvCallText, initDataEntity.getDeviceBedNum() + "床正在呼叫护工...");
- }
- } else {
- showLlRightView();
- }
- } else {
- if (!isVisible(vSupport) && !isVisible(vNurse)) {//排除呼叫状态
- showThisView(vCall);
- //sendProtectHelp();//呼叫护工还没有做;这个先预留
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.WORK_IN_CALL;
- if (null != initDataEntity) {
- jbVCall = setJumpingBeans(tvCallText, initDataEntity.getDeviceBedNum() + "床正在呼叫护工...");
- }
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- public boolean callNurse = false;//超时自动取消呼叫了,20191118 之前是长按取消呼叫,后来又改成了根据UI的改变来取消,说让客户一目了然
- public void clickVNurse() {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- timeOfBackMainPage = 0;
- timeOut = callTimeOutBack;
- if (isVisible(vNurse)) {
- callNurse = false;
- UdpSendUtil.sendHangUp(initDataEntity, mainDataEntity);//取消呼叫 add by waderson 20191118
- SipHelperUtil.getInstance(CallingBedActivity.this).getmSipCallBackI().endCall();
- CALL_STATUS = STANDBY;
- showThisView(vMain);
- goneLlRightView(true);
- } else {
- if (isVisible(vMain)) {
- callNurse = true;
- showThisView(vNurse);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- UdpSendUtil.sendCall1(initDataEntity, mainDataEntity);
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.NURSE_IN_CALL;
- if (null != initDataEntity) {
- jbVNurse = setJumpingBeans(tvNurseText, initDataEntity.getDeviceBedNum() + "床已呼叫,等待护士接听中...");
- }
- } else {
- if (!isVisible(vSupport) && !isVisible(vCall)) {//排除呼叫状态
- callNurse = true;
- showThisView(vNurse);
- setDoorLight(serialPortUtil, "200");//门灯红色闪烁 add by waderson 20191119 后来加的门灯控制
- UdpSendUtil.sendCall1(initDataEntity, mainDataEntity);
- SoundPoolManager.getInstance().playSound(2);
- CALL_STATUS = Constants.NURSE_IN_CALL;
- if (null != initDataEntity) {
- jbVNurse = setJumpingBeans(tvNurseText, initDataEntity.getDeviceBedNum() + "床已呼叫,等待护士接听中...");
- }
- } else {
- showToast("请先取消呼叫!");
- }
- }
- }
- }
- //---------------------------------------------串口点击事件部分(下)---------------------------------------------------------------------
- //---------------------------------------------UI更改操作部分(上)---------------------------------------------------------------------
- /**
- * 显示侧边栏
- */
- protected void showLlRightView() {
- changeTextColor(null);
- Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_righttoleft);
- llRight.setAnimation(animation);
- llRight.setVisibility(View.VISIBLE);
- }
- /**
- * 隐藏侧边栏
- */
- protected void goneLlRightView(boolean haveAnimation) {
- if (haveAnimation) {
- Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_lefttoright);
- llRight.setAnimation(animation);
- }
- llRight.setVisibility(View.GONE);
- }
- /**
- * 需要显示的VIEW
- */
- protected void showThisView(View v) {
- //修复主动打床头机ui不变化
- if (v.getVisibility() == View.VISIBLE) return;
- if (!StringUtils.listNotEmpty(allViews)) {
- allViews = new ArrayList<>(Arrays.asList(vMain, vDoctor, vCost, vQrCode, vSupport, vCall, vNurse));
- }
- Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.in_righttoleft);
- Animation closeAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out_righttoleft);
- for (View av : allViews) {
- if (v == av) {
- av.setAnimation(animation);
- av.setVisibility(View.VISIBLE);
- } else {
- if (av.getVisibility() == View.VISIBLE) {
- av.setAnimation(closeAnimation);
- av.setVisibility(View.GONE);
- }
- }
- }
- }
- protected boolean isVisible(View v) {
- return v.getVisibility() == View.VISIBLE;
- }
- /**
- * 设置跳跃字体
- */
- public JumpingBeans setJumpingBeans(TextView textview, String textStr) {
- textview.setText(textStr);
- JumpingBeans jumpingBeans = JumpingBeans.with(textview)
- .makeTextJump(0, textview.getText().length())
- .setIsWave(true)
- .setLoopDuration(2000)
- .build();
- return jumpingBeans;
- }
- /**
- * 侧滑栏的颜色变高亮
- * tvDoctor.setTextColor(ContextCompat.getColor(context, R.color.white));
- */
- private void changeTextColor(TextView textView) {
- tvDoctor.setTextColor(Color.WHITE);
- tvCost.setTextColor(Color.WHITE);
- tvQrCode.setTextColor(Color.WHITE);
- tvSupport.setTextColor(Color.WHITE);
- tvCall.setTextColor(Color.WHITE);
- if (null != textView)
- textView.setTextColor(Color.YELLOW);
- }
- //---------------------------------------------UI更改操作部分(下)---------------------------------------------------------------------
- /**
- * 灭掉护理灯
- */
- public void dismissNurseBrightness() {
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- setNurseBrightness(serialPortUtil, 1, "000000", "000000", "000000", "000000", "000000");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }).start();
- }
- @Override
- protected void onDestroy() {
- super.onDestroy();
- //=======================释放广播=====================//
- MediaPlayerManger.getInstance().releaseMediaPlayer();
- if (textToSpeech != null) {
- textToSpeech.shutdown();//关闭tts引擎
- }
- unregisterReceiver(wifiInfoPowerReceiver);
- unregisterReceiver(networkConnectChangedReceiver);
- serialPortUtil.closeSerialPort();
- timeThread.interrupted();
- //关闭线程
- stop();
- //=============================================SIP关闭服务===================================//
- SipHelperUtil.getInstance(this).unRegisterSip();
- SoundPoolManager.getInstance().release();
- }
- /**
- * --------------------------------sip 的回调操作------------------------------------------
- */
- @Override
- public void startCall(String sipAddress) {//
- //=============================================SIP开始通话===================================//
- SipHelperUtil.getInstance(CallingBedActivity.this).startCall(sipAddress);
- }
- @Override
- public void endCall() {
- //=============================================SIP结束通话===================================//
- SipHelperUtil.getInstance(CallingBedActivity.this).endCall();
- //发送udp让门口机text变白色
- UdpSendUtil.sendCallNoticeDoor(initDataEntity, mainDataEntity, "0");
- }
- @Override
- public void autoTalking() {
- //=============================================SIP自动接听===================================//
- SipHelperUtil.getInstance(CallingBedActivity.this).autoTalking();
- }
- @Override
- public void onNewVvsipCallEvent(VvsipCall call) {
- LogUtil.d("QQWW", "onNewVvsipCallEvent----");
- SipHelperUtil.getInstance(this).addCallObject(call);
- }
- @Override
- public void onRemoveVvsipCallEvent(VvsipCall call) {
- LogUtil.d("QQWW", "onRemoveVvsipCallEvent----call.mState:==" + call.mState);
- SipHelperUtil.getInstance(this).removeCallObject(call);
- }
- @Override
- public void onStatusVvsipCallEvent(VvsipCall call) {
- LogUtil.d("QQWW", "onStatusVvsipCallEvent----call.mState:==" + call.mState + call.isIncomingCall());
- if (!isVisible(vWelcome)) {
- vMain_big.setVisibility(View.GONE);//显示增长页面20191017
- }
- switch (call.mState) {
- case 0://正在呼叫中:子机自动接通 isIncomingCall() = true mState = 0 //正在通话中:isIncomingCall() = true
- //通话中关闭广播
- try {
- MediaPlayerManger.getInstance().stopMediaPlayer();
- tvBroadcasting.setText("");
- tvBroadcasting.setVisibility(View.INVISIBLE);
- } catch (Exception e) {
- e.printStackTrace();
- }
- /*if (CALL_STATUS.equals(Constants.STANDBY)) {
- //主机主动呼叫分机
- CALL_STATUS = Constants.IN_CALLING;
- //正在通话中:isIncomingCall() = true
- //CallingBedActivity.initPlayerVolume(0.0f);
- showThisView(vNurse);
- SoundPoolManager.getInstance().playSound(1);
- tvNurseText.setText("主机请求通话...");
- tvNurseTimeOut.setText("");
- handler.sendEmptyMessageDelayed(NEW_INCOMING_CALL, 2000);
- } else {*/
- //分机主动呼叫主机
- CALL_STATUS = Constants.IN_CALL;
- handsMICStatus = setHandsMIC(serialPortUtil, true);//面板mic有回音,需要禁掉
- //=============================================SIP自动接听===================================//
- SipHelperUtil.getInstance(CallingBedActivity.this).getmSipCallBackI().autoTalking();
- //正在通话中:isIncomingCall() = true
- //CallingBedActivity.initPlayerVolume(0.0f);
- CALL_STATUS = Constants.IN_CALLING;
- showThisView(vNurse);
- //jbVNurse = setJumpingBeans(tvNurseText, "正在通话中...");
- //jbVNurse.stopJumping();
- tvNurseText.setText("正在通话中...");
- tvNurseTimeOut.setText("");
- //}
- if (isTransfer) {
- } else {
- //发送udp让门口机text变绿色
- UdpSendUtil.sendCallNoticeDoor(initDataEntity, mainDataEntity, "2");
- }
- break;
- case 1:
- break;
- case 2://正在通话中:isIncomingCall() = true mState = 2
- break;
- case 3://无人应答/挂断:isIncomingCall() = true mState = 3
- Constants.IS_CALLED = 0;
- CallingBedActivity.initPlayerVolume(1.0f);
- CALL_STATUS = Constants.STANDBY;
- showThisView(vMain);
- if (isTransfer) {
- if (null != callNoticeEntity) {
- UdpSendUtil.sendTransferbedTobed(callNoticeEntity);
- }
- callNoticeEntity = null;//清空转接提示实体;禁止拨号!
- isTransfer = false;
- } else {
- //发送udp让门口机text变白色
- UdpSendUtil.sendCallNoticeDoor(initDataEntity, mainDataEntity, "0");
- }
- break;
- }
- }
- @Override
- public void onRegistrationEvent(int rid, String remote_uri, final int code, String reason) {
- LogUtil.d("QQWW", "onRegistrationEvent----code" + code);
- // LogUtil.d(SipHelperUtil.SipInfoTag, "onRegistrationEvent:"
- // + " \nrid" + rid + " \nremote_uri" + remote_uri + " \ncode" + code + " \nreason" + reason);
- CallingBedActivity.this.runOnUiThread(new Runnable() {
- public void run() {
- if (code >= 200 && code < 300) {
- // Remove the exitRunnable callback from the handler queue
- SipHelperUtil.getInstance(CallingBedActivity.this)
- .getSipRegisterHandler()
- .removeCallbacks(SipHelperUtil.getInstance(CallingBedActivity.this).getSipRegisterRunnable());
- // Run the exit code manually
- SipHelperUtil.getInstance(CallingBedActivity.this)
- .isSuccessRegisterSip();
- }
- }
- });
- }
- private void newCalling() {
- handsMICStatus = setHandsMIC(serialPortUtil, true);//面板mic有回音,需要禁掉
- //=============================================SIP自动接听===================================//
- SipHelperUtil.getInstance(CallingBedActivity.this).getmSipCallBackI().autoTalking();
- //jbVNurse = setJumpingBeans(tvNurseText, "正在通话中...");
- //jbVNurse.stopJumping();
- tvNurseText.setText("正在通话中...");
- tvNurseTimeOut.setText("");
- }
- /**
- * Sip服务监听
- */
- private void sipServiceListener() {
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- SipHelperUtil.getInstance(CallingBedActivity.this).obtainSipInfo();
- }
- }, 0);
- }
- @Override
- public void playMusicComplete(int position) {
- tvBroadcasting.setText("");
- tvBroadcasting.setVisibility(View.INVISIBLE);
- //播放广播恢复默认状态
- Constants.INTIME_BROADCAST = "";
- }
- private float mVolume = 1.0f;
- @Override
- public void quietAndRestore(float volume) {
- mVolume = volume;
- if (volume == 0.0f) {
- MediaPlayerManger.getInstance().setVolume(volume);
- } else {
- if (!SharedPreferencesUtil.getStringSp(this, "SetUpBroadcastVoice", "voice").equals("")) {
- float voice = Float.parseFloat(SharedPreferencesUtil.getStringSp(this, "SetUpBroadcastVoice", "voice"));
- MediaPlayerManger.getInstance().setVolume(voice);
- }
- }
- }
- int timeOfBackMainPage = 0;
- /**
- * 后台设置的呼叫超时时间
- */
- public int callTimeOutBack = (StringUtils.parseInt(Constants.CALLINGTIMEOUT) <= 0 ? 30 : StringUtils.parseInt(Constants.CALLINGTIMEOUT));//默认180秒
- public int timeOut = callTimeOutBack;
- /**
- * 自动回到主页面
- */
- protected void comeBackMainPage() {
- timeOfBackMainPage++;
- timeOut--;
- if (!isVisible(vMain) && timeOfBackMainPage >= callTimeOutBack && !CALL_STATUS.equals(Constants.IN_CALLING) && !isVisible(vWelcome)) {
- // if (callNurse) {//超时自动取消呼叫了,20191118 之前是长按取消呼叫,后来又改成了根据UI的改变来取消,说让客户一目了然
- // callNurse = false;
- // UdpSendUtil.sendHangUp(initDataEntity, mainDataEntity);//取消呼叫 add by waderson 20191118
- // }
- CALL_STATUS = Constants.NURSE_CALL_TIMEOUT;
- showThisView(vMain);
- goneLlRightView(false);
- tvSupportTimeOut.setText("");
- tvCallTextTimeOut.setText("");
- tvNurseTimeOut.setText("");
- timeOut = callTimeOutBack;
- if (null != initDataEntity) {
- getMainData(1);
- }
- } else if (CALL_STATUS.equals(Constants.IN_CALLING)){
- tvNurseTimeOut.setText("");
- } else {
- tvSupportTimeOut.setText(timeOut + " 秒");
- tvCallTextTimeOut.setText(timeOut + " 秒");
- tvNurseTimeOut.setText(timeOut + " 秒");
- }
- if (timeOfBackMainPage >= 100000) timeOfBackMainPage = 0;
- if (timeOut <= -10000) timeOut = callTimeOutBack;
- }
- /**
- * 自动拉起护理项加长页面
- */
- protected void callLongNursePage(String second) {
- if (!isVisible(vWelcome) && !CALL_STATUS.equals(Constants.IN_CALLING)) {
- if ("0".equals(second) || "30".equals(second)) {//一分钟跳4次
- if (isVisible(vMain) && !isVisible(vMain_big)) {
- vMain_big.setVisibility(View.VISIBLE);
- goneLlRightView(false);
- }
- }
- if ("15".equals(second) || "45".equals(second)) {//一分钟跳4次
- if (isVisible(vMain) && isVisible(vMain_big)) {//add by waderson 20191119 后来又说要两个页面轮换显示
- vMain_big.setVisibility(View.GONE);
- goneLlRightView(false);
- }
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////
- //广播的实体
- private ArrayList<AllBroadcastEntity> allBroadcastList = new ArrayList<>();
- //下载广播音频文件
- private void getBroadcastAudioFiles() {
- if (!StringUtils.notEmpty(Constants.PartID)) return;
- try {
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_BROADCAST)
- .addParams("PartID", Constants.PartID)
- .addParams("PartitionNo", "0")
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- LogUtil.d("broadcast", "get broadcast exception: " + e.getMessage());
- e.printStackTrace();
- }
- @Override
- public void onResponse(String response, int id) {
- //去掉 ,OK!
- String data = response.substring(0, response.length() - 4);
- LogUtil.e("broadcast", response);
- try {
- JSONObject jsonObj = new JSONObject(data);
- if (jsonObj.getString("Code").equals("ERROR!")) {
- LogUtil.w("broadcast", "网络错误");
- } else {
- if (jsonObj.getString("Code").equals("OK!")) {
- dealAllBroadcastDatas(jsonObj);
- handler.sendEmptyMessage(UPDATE_BROADCAST);
- } else {
- LogUtil.w("broadcast", "网络错误");
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private void dealAllBroadcastDatas(JSONObject jsonObject) {
- JSONArray jsonArray = null;
- try {
- jsonArray = jsonObject.getJSONArray("FileList");
- } catch (JSONException e) {
- e.printStackTrace();
- return;
- }
- if (!allBroadcastList.isEmpty()) {
- allBroadcastList.clear();
- }
- for (int i = 0; i < jsonArray.length(); i++) {
- Gson gson = new Gson();
- try {
- JSONObject object = jsonArray.getJSONObject(i);
- AllBroadcastEntity broadcastEntity = gson.fromJson(object.toString(), AllBroadcastEntity.class);
- allBroadcastList = getAllBroadcastFileName(broadcastEntity);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }
- private ArrayList<AllBroadcastEntity> getAllBroadcastFileName(AllBroadcastEntity broadcastEntity) {
- String[] data = broadcastEntity.getFileName().split(",");
- ArrayList<AllBroadcastEntity> list = new ArrayList<>();
- for (int i = 0; i < data.length; i++) {
- AllBroadcastEntity entity = new AllBroadcastEntity();
- String[] mark = data[i].split("\\$");
- entity.setFileName(mark[0]);
- if (mark.length > 1) entity.setRemarks(mark[1]);
- list.add(entity);
- }
- return list;
- }
- private void checkAndDownloadMP3(final int index) {
- LogUtil.d("broadcast", "checkAndDownloadMP3 start..." + index);
- if (allBroadcastList != null && allBroadcastList.size() > 0 && index < allBroadcastList.size()) {
- AllBroadcastEntity entity = allBroadcastList.get(index);
- String filePath = entity.getFileName();
- DownloadUtil2.getInstance().download(Constants.URL + Constants.URL_END + "/" + filePath,
- Constants.BROADCAST_AUDIO_PATH, filePath.substring(filePath.lastIndexOf("/") + 1), new DownloadUtil2.OnDownloadListener() {
- @Override
- public void onDownloadSuccess() {
- LogUtil.d("broadcast", "download mp3 finish...");
- checkAndDownloadMP3(index+1);
- }
- @Override
- public void onDownloading(int progress) {
- //LogUtil.d("broadcast", "download mp3 progress: " + progress);
- }
- @Override
- public void onDownloadFailed() {
- LogUtil.d("broadcast", "download mp3 fail...");
- checkAndDownloadMP3(index+1);
- }
- });
- }
- }
- private String isLocalAudioExist(String path) {
- String fileName = path.substring(path.lastIndexOf("/")+1);
- File file = new File(Constants.BROADCAST_AUDIO_PATH + "/" + fileName);
- if (file.exists()) {
- return file.getPath();
- } else {
- return null;
- }
- }
- }
|