|
@@ -1,647 +0,0 @@
|
|
|
-package com.taiyi.tyusbsdk.pulse.ui;
|
|
|
-
|
|
|
-import static com.taiyi.tyusbsdk.pulse.ui.MeasureHandsActivity.RESULT_MEASURE_FAIL;
|
|
|
-
|
|
|
-import android.Manifest;
|
|
|
-import android.annotation.SuppressLint;
|
|
|
-import android.app.Activity;
|
|
|
-import android.app.Dialog;
|
|
|
-import android.content.pm.PackageManager;
|
|
|
-import android.os.Build;
|
|
|
-import android.os.CountDownTimer;
|
|
|
-import android.speech.tts.TextToSpeech;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.View;
|
|
|
-import android.view.WindowManager;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.TextView;
|
|
|
-
|
|
|
-import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
-import androidx.core.app.ActivityCompat;
|
|
|
-import androidx.core.content.ContextCompat;
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
-
|
|
|
-import com.taiyi.tyusbsdk.HandType;
|
|
|
-import com.taiyi.tyusbsdk.MeasureType;
|
|
|
-import com.taiyi.tyusbsdk.R;
|
|
|
-import com.taiyi.tyusbsdk.RealTimeMeasureStatus;
|
|
|
-import com.taiyi.tyusbsdk.TYUsbDeviceActivity;
|
|
|
-import com.taiyi.tyusbsdk.UsbEvent;
|
|
|
-import com.taiyi.tyusbsdk.pulse.TaiyiManager;
|
|
|
-import com.taiyi.tyusbsdk.pulse.bean.PulseParamTen;
|
|
|
-import com.taiyi.tyusbsdk.pulse.bean.RealtimeWaveItem;
|
|
|
-import com.taiyi.tyusbsdk.pulse.net.HttpUtil;
|
|
|
-import com.taiyi.tyusbsdk.pulse.net.TokenOverDueHttpImpl;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.AutoScrollRecyclerView;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.DialogTipUtil;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.LoadingView;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.MaiFlowAdapter;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.OnClickNoDoubleListener;
|
|
|
-import com.taiyi.tyusbsdk.pulse.util.scenery.ElectricFanLoadingRenderer;
|
|
|
-
|
|
|
-import org.greenrobot.eventbus.EventBus;
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.Locale;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-public class Measure3DFlowActivity extends TYUsbDeviceActivity {
|
|
|
- TextView mTvHand;
|
|
|
- ImageView mIvCancel;
|
|
|
- TextView mTvCun;
|
|
|
- TextView mTvGuan;
|
|
|
- TextView mTvChi;
|
|
|
- AutoScrollRecyclerView mAsrCun;
|
|
|
- AutoScrollRecyclerView mAsrGuan;
|
|
|
- AutoScrollRecyclerView mAsrChi;
|
|
|
- ImageView mIvHand;
|
|
|
- ConstraintLayout mClLoading;
|
|
|
- LoadingView mLv;
|
|
|
-
|
|
|
- private String measureId;
|
|
|
- private int hand;
|
|
|
-
|
|
|
- private MaiFlowAdapter cunAdapter;
|
|
|
- private MaiFlowAdapter guanAdapter;
|
|
|
- private MaiFlowAdapter chiAdapter;
|
|
|
- private int current = 4;//默认显示4张图
|
|
|
- private int[] changImgIds = new int[]{R.mipmap.mai_0, R.mipmap.chang_2, R.mipmap.chang_4, R.mipmap.chang_6, R.mipmap.chang_8,
|
|
|
- R.mipmap.chang_10, R.mipmap.chang_12, R.mipmap.chang_14, R.mipmap.chang_16, R.mipmap.chang_18, R.mipmap.chang_20,
|
|
|
- R.mipmap.chang_25, R.mipmap.chang_30, R.mipmap.chang_35, R.mipmap.chang_40};
|
|
|
- private int[] xiImgIds = new int[]{R.mipmap.mai_0, R.mipmap.xi_2, R.mipmap.xi_4, R.mipmap.xi_6, R.mipmap.xi_8, R.mipmap.xi_10,
|
|
|
- R.mipmap.xi_12, R.mipmap.xi_14, R.mipmap.xi_16, R.mipmap.xi_18, R.mipmap.xi_20, R.mipmap.xi_25, R.mipmap.xi_30,
|
|
|
- R.mipmap.xi_35, R.mipmap.xi_40};
|
|
|
- private int[] huaImgIds = new int[]{R.mipmap.mai_0, R.mipmap.hua_2, R.mipmap.hua_4, R.mipmap.hua_6, R.mipmap.hua_8, R.mipmap.hua_10
|
|
|
- , R.mipmap.hua_12, R.mipmap.hua_14, R.mipmap.hua_16, R.mipmap.hua_18, R.mipmap.hua_20, R.mipmap.hua_25, R.mipmap.hua_30,
|
|
|
- R.mipmap.hua_35, R.mipmap.hua_40};
|
|
|
-
|
|
|
- private TextToSpeech textToSpeech;
|
|
|
- private CountDownTimer mCountTimer;
|
|
|
- Dialog showDialog;
|
|
|
-
|
|
|
-
|
|
|
- @SuppressLint("CheckResult")
|
|
|
- @Override
|
|
|
- protected void init() {
|
|
|
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
-
|
|
|
- mTvHand = findViewById(R.id.tv_hand);
|
|
|
- mIvCancel = findViewById(R.id.iv_cancel);
|
|
|
- mTvCun = findViewById(R.id.tv_cun);
|
|
|
- mTvGuan = findViewById(R.id.tv_guan);
|
|
|
- mTvChi = findViewById(R.id.tv_chi);
|
|
|
- mAsrCun = findViewById(R.id.asr_cun);
|
|
|
- mAsrGuan = findViewById(R.id.asr_guan);
|
|
|
- mAsrChi = findViewById(R.id.asr_chi);
|
|
|
- mIvHand = findViewById(R.id.iv_hand);
|
|
|
- mClLoading = findViewById(R.id.cl_loading);
|
|
|
- mLv = findViewById(R.id.lv);
|
|
|
-
|
|
|
- measureId = getIntent().getStringExtra("measureId");
|
|
|
- hand = getIntent().getIntExtra("hand", 0);
|
|
|
-
|
|
|
- mIvCancel.setColorFilter(ContextCompat.getColor(this, R.color.text_black));
|
|
|
- mTvHand.setText(hand == 0 ? R.string.measure_left_hand : R.string.measure_right_hand);
|
|
|
- mIvHand.setImageResource(hand == 0 ? R.mipmap.hand_left : R.mipmap.hand_right);
|
|
|
-
|
|
|
- mIvCancel.postDelayed(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- startMeasure(hand == 0 ? HandType.LEFT_HAND : HandType.RIGHT_HAND, MeasureType.STEP_TYPE);
|
|
|
- }
|
|
|
- }, 300);
|
|
|
-
|
|
|
- mAsrCun.post(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- initFlow();
|
|
|
- }
|
|
|
- });
|
|
|
- mIvCancel.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- showCancelDialog();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- ElectricFanLoadingRenderer renderer = new ElectricFanLoadingRenderer.Builder(this).build();
|
|
|
- renderer.setRepeatCount(0);
|
|
|
- mLv.setLoadingRenderer(renderer);
|
|
|
- mLv.startAnimation();
|
|
|
-
|
|
|
-
|
|
|
- mClLoading.setOnClickListener(new OnClickNoDoubleListener() {
|
|
|
- @Override
|
|
|
- public void onNoDoubleClick(View view) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- initTTS();
|
|
|
- }
|
|
|
-
|
|
|
- private void initTTS() {
|
|
|
- textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
|
|
|
- @Override
|
|
|
- public void onInit(int status) {
|
|
|
- if (status == TextToSpeech.SUCCESS) {
|
|
|
-
|
|
|
- int result = textToSpeech.setLanguage(Locale.SIMPLIFIED_CHINESE);
|
|
|
- if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
|
|
|
- Log.d("TextToSpeech", "Not Support Chinese");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- textToSpeech.setPitch(1.0f);
|
|
|
- textToSpeech.setSpeechRate(1.0f);
|
|
|
-
|
|
|
- } else {
|
|
|
- Log.d("TextToSpeech", "Failed");
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void changeFlowImg(AutoScrollRecyclerView asr, MaiFlowAdapter adapter, int[] data) {
|
|
|
- int lastVisibleItemPosition = ((LinearLayoutManager) asr.getLayoutManager()).findLastVisibleItemPosition();
|
|
|
- if (lastVisibleItemPosition != -1) {
|
|
|
- int level = data[0];
|
|
|
- if (level > 14) {
|
|
|
- level = 14;
|
|
|
- }
|
|
|
- int[] imgIds;
|
|
|
- switch (data[1]) {
|
|
|
- case 1:
|
|
|
- imgIds = xiImgIds;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- imgIds = huaImgIds;
|
|
|
- break;
|
|
|
- case 0:
|
|
|
- default:
|
|
|
- imgIds = changImgIds;
|
|
|
- }
|
|
|
- for (int i = lastVisibleItemPosition + 1; i < adapter.getData().size(); i++) {
|
|
|
- adapter.getData().set(i, imgIds[level]);
|
|
|
- }
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void changeWidth(int show) {
|
|
|
- if (current != show) {
|
|
|
- current = show;
|
|
|
- cunAdapter.setWidth(mAsrCun.getWidth() / show);
|
|
|
- guanAdapter.setWidth(mAsrGuan.getWidth() / show);
|
|
|
- chiAdapter.setWidth(mAsrChi.getWidth() / show);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void initFlow() {
|
|
|
- int speed = 100;
|
|
|
- LinearLayoutManager layoutCun = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
|
|
|
- mAsrCun.setLayoutManager(layoutCun);
|
|
|
- if (cunAdapter == null) {
|
|
|
- cunAdapter = new MaiFlowAdapter(mAsrCun.getWidth() / 2);
|
|
|
- }
|
|
|
- ArrayList<Integer> cun = new ArrayList<>();
|
|
|
- for (int i = 0; i < 1000; i++) {
|
|
|
- cun.add(R.mipmap.mai_0);
|
|
|
- }
|
|
|
- cunAdapter.setNewData(cun);
|
|
|
-
|
|
|
- mAsrCun.setAdapter(cunAdapter);
|
|
|
- mAsrCun.openAutoScroll(speed, false);
|
|
|
-
|
|
|
- LinearLayoutManager layoutGuan = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
|
|
|
- mAsrGuan.setLayoutManager(layoutGuan);
|
|
|
- if (guanAdapter == null) {
|
|
|
- guanAdapter = new MaiFlowAdapter(mAsrGuan.getWidth() / 2);
|
|
|
- }
|
|
|
- ArrayList<Integer> guan = new ArrayList<>();
|
|
|
- for (int i = 0; i < 1000; i++) {
|
|
|
- guan.add(R.mipmap.mai_0);
|
|
|
- }
|
|
|
- guanAdapter.setNewData(guan);
|
|
|
- mAsrGuan.setAdapter(guanAdapter);
|
|
|
- mAsrGuan.openAutoScroll(speed, false);
|
|
|
-
|
|
|
- LinearLayoutManager layoutChi = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
|
|
|
- mAsrChi.setLayoutManager(layoutChi);
|
|
|
- if (chiAdapter == null) {
|
|
|
- chiAdapter = new MaiFlowAdapter(mAsrChi.getWidth() / 2);
|
|
|
- }
|
|
|
- ArrayList<Integer> chi = new ArrayList<>();
|
|
|
- for (int i = 0; i < 1000; i++) {
|
|
|
- chi.add(R.mipmap.mai_0);
|
|
|
- }
|
|
|
- chiAdapter.setNewData(chi);
|
|
|
- mAsrChi.setAdapter(chiAdapter);
|
|
|
- mAsrChi.openAutoScroll(speed, false);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void sendMeasureStartCommand() {
|
|
|
- super.sendMeasureStartCommand();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void showCancelDialog() {
|
|
|
-
|
|
|
- showDialog = DialogTipUtil.showSelectDialog(this, getString(R.string.measure_cancel), getString(R.string.measure_cancel_tip), R.string.app_cancel,
|
|
|
- R.string.app_confirm, new DialogTipUtil.OptionClickCallback_I() {
|
|
|
- @Override
|
|
|
- public void leftClick() {
|
|
|
- showDialog = null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void rightClick() {
|
|
|
- sendCancelMeasureCommand();
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected int initLayoutResId() {
|
|
|
- return R.layout.activity_measure_3dflow;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onRealTimeWaveGet(RealtimeWaveItem dataItem) {
|
|
|
- int show = Math.round(dataItem.heart * 4 / 75f);
|
|
|
- if (show < 3) {
|
|
|
- show = 3;
|
|
|
- }
|
|
|
- if (show > 5) {
|
|
|
- show = 5;
|
|
|
- }
|
|
|
- Log.w("MeasureFlowActivity", "heart:" + show + " heart:" + dataItem.heart * 4 / 75f);
|
|
|
- changeFlowImg(mAsrCun, cunAdapter, dataItem.waveCun);
|
|
|
- changeFlowImg(mAsrGuan, guanAdapter, dataItem.waveGuan);
|
|
|
- changeFlowImg(mAsrChi, chiAdapter, dataItem.waveChi);
|
|
|
- changeWidth(2);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onMeasureStatusChanged(RealTimeMeasureStatus status) {
|
|
|
-
|
|
|
-
|
|
|
- textToSpeech.speak(status.getDescription(), TextToSpeech.QUEUE_FLUSH, null);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onMeasureFinished() {
|
|
|
- super.onMeasureFinished();
|
|
|
-
|
|
|
- mAsrCun.openAutoScroll(0, false);
|
|
|
- mAsrGuan.openAutoScroll(0, false);
|
|
|
- mAsrChi.openAutoScroll(0, false);
|
|
|
-
|
|
|
- if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
|
|
- uploadCsv();
|
|
|
- } else {
|
|
|
- popupPermissionTip(Manifest.permission.WRITE_EXTERNAL_STORAGE, R.string.permission_storage_2);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onPermissionGet(int requestCode) {
|
|
|
- uploadCsv();
|
|
|
- }
|
|
|
-
|
|
|
- private void uploadCsv() {
|
|
|
-
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- showLoading();
|
|
|
- }
|
|
|
- });
|
|
|
- String uid = TaiyiManager.getInstance().getUid();
|
|
|
- uploadCSV(uid, new OssInterface() {
|
|
|
- @Override
|
|
|
- public void onStartUpload() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onSuccessUpload(String url) {
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- }
|
|
|
- });
|
|
|
- PulseParamTen pulseParam = PulseParamTen
|
|
|
- .getParams("", hand, "20", "Android", Build.VERSION.SDK_INT + "", uid,
|
|
|
- uid, url, 0, "F");
|
|
|
- uploadPulseData(pulseParam);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailedUpload() {
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- DialogTipUtil.showIKnow(Measure3DFlowActivity.this, getString(R.string.unify_8), new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void showLoading() {
|
|
|
- mClLoading.setVisibility(View.VISIBLE);
|
|
|
- mLv.startAnimation();
|
|
|
- }
|
|
|
-
|
|
|
- private void dismissLoading() {
|
|
|
- mLv.stopAnimation();
|
|
|
- mClLoading.setVisibility(View.GONE);
|
|
|
- }
|
|
|
-
|
|
|
- private void uploadPulseData(PulseParamTen pulseParam) {
|
|
|
- HttpUtil.getInstance().measurePulseSave(pulseParam, new TokenOverDueHttpImpl<String>() {
|
|
|
- @Override
|
|
|
- public void overdue() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void showError(String error) {
|
|
|
- showDialog = DialogTipUtil.showIKnow(Measure3DFlowActivity.this, getString(R.string.measure_data_uploading_failed),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void showResponse(String response) {
|
|
|
- startGetResultStatus();
|
|
|
- }
|
|
|
- });
|
|
|
- /**
|
|
|
- mTYMaiApi.saveMaiReportTen(pulseParam).compose(RxHttpResponseCompose.<BaseBean>compose())
|
|
|
- .subscribe(new ProgressDialogSubscriber<BaseBean>(this) {
|
|
|
- @Override
|
|
|
- public void onNext(BaseBean baseBean) {
|
|
|
- super.onNext(baseBean);
|
|
|
- startGetResultStatus();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean isShowDialog() {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
- super.onError(e);
|
|
|
-
|
|
|
- if (e instanceof ApiException) {
|
|
|
- String code = ((ApiException) e).status_code;
|
|
|
- if (!code.equals("100002") && !code.equals("100121") && !code.equals("200125")) {
|
|
|
- DialogTipUtil.showIKnow(MeasureUSBNewDownActivity.this, getString(R.string.error_http),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- DialogTipUtil.showIKnow(MeasureUSBNewDownActivity.this, e.getMessage() + ",,," + e.toString(),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- **/
|
|
|
- }
|
|
|
-
|
|
|
- private void startGetResultStatus() {
|
|
|
- if (mCountTimer == null) {
|
|
|
- mCountTimer = new CountDownTimer(26000, 3000) {
|
|
|
- @Override
|
|
|
- public void onTick(long millisUntilFinished) {
|
|
|
- getResultStatus();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- showDialog = DialogTipUtil.showIKnow(Measure3DFlowActivity.this, getString(R.string.measure_data_uploading_failed),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
- mCountTimer.start();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void getResultStatus() {
|
|
|
- HttpUtil.getInstance().getMeasurePulseResult(new TokenOverDueHttpImpl<String>() {
|
|
|
- @Override
|
|
|
- public void overdue() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void showError(String error) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void showResponse(String usbResultStatus) {
|
|
|
- if (usbResultStatus != null) {
|
|
|
- dismissLoading();
|
|
|
- Map usbResult = jsonToMap(usbResultStatus);
|
|
|
- int resultCode = Integer.valueOf((String) usbResult.get("measure_result"));
|
|
|
- if (resultCode != 0) {
|
|
|
- setResult(Activity.RESULT_OK);
|
|
|
- finish();
|
|
|
- } else {
|
|
|
-
|
|
|
- showDialog = DialogTipUtil.showIKnow(Measure3DFlowActivity.this, getString(R.string.measure_data_uploading_failed),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- if (mCountTimer != null) {
|
|
|
- mCountTimer.cancel();
|
|
|
- mCountTimer = null;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- /**
|
|
|
- mTYMaiApi.getResultStatus(measureId, mAccessSession).compose(RxHttpResponseCompose.<USBResultStatusBean>compose())
|
|
|
- .subscribe(new ProgressDialogSubscriber<USBResultStatusBean>(this) {
|
|
|
- @Override
|
|
|
- public void onNext(USBResultStatusBean usbResultStatus) {
|
|
|
- super.onNext(usbResultStatus);
|
|
|
- if (usbResultStatus.data != null) {
|
|
|
- dismissLoading();
|
|
|
- if (usbResultStatus.data.measure_result != 0) {
|
|
|
- setResult(Activity.RESULT_OK);
|
|
|
- finish();
|
|
|
- } else {
|
|
|
-
|
|
|
- DialogTipUtil.showIKnow(MeasureUSBNewDownActivity.this, getString(R.string.measure_data_uploading_failed),
|
|
|
- new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- setResult(RESULT_MEASURE_FAIL);
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- if (mCountTimer != null) {
|
|
|
- mCountTimer.cancel();
|
|
|
- mCountTimer = null;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(Throwable e) {
|
|
|
- super.onError(e);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean isShowDialog() {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- **/
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onUsbDetached() {
|
|
|
- super.onUsbDetached();
|
|
|
-
|
|
|
- showDialog = DialogTipUtil.showIKnow(this, getString(R.string.usb_detach_tip), new DialogTipUtil.CommonCallback_I() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String str) {
|
|
|
- EventBus.getDefault().post(new UsbEvent());
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
- textToSpeech.stop();
|
|
|
- textToSpeech.shutdown();
|
|
|
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
|
|
- if (showDialog != null) {
|
|
|
- showDialog.dismiss();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected boolean fitSystemWindows() {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected boolean translucentStatus() {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onBackPressed() {
|
|
|
- showCancelDialog();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @param content json字符串
|
|
|
- * @return 如果转换失败返回null,
|
|
|
- */
|
|
|
- Map<String, Object> jsonToMap(String content) {
|
|
|
- content = content.trim();
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- try {
|
|
|
- if (content.charAt(0) == '[') {
|
|
|
- JSONArray jsonArray = new JSONArray(content);
|
|
|
- for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
- Object value = jsonArray.get(i);
|
|
|
- if (value instanceof JSONArray || value instanceof JSONObject) {
|
|
|
- result.put(i + "", jsonToMap(value.toString().trim()));
|
|
|
- } else {
|
|
|
- result.put(i + "", jsonArray.getString(i));
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (content.charAt(0) == '{'){
|
|
|
- JSONObject jsonObject = new JSONObject(content);
|
|
|
- Iterator<String> iterator = jsonObject.keys();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- String key = iterator.next();
|
|
|
- Object value = jsonObject.get(key);
|
|
|
- if (value instanceof JSONArray || value instanceof JSONObject) {
|
|
|
- result.put(key, jsonToMap(value.toString().trim()));
|
|
|
- } else {
|
|
|
- result.put(key, value.toString().trim());
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- Log.e("异常", "json2Map: 字符串格式错误");
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- Log.e("异常", "json2Map: ", e);
|
|
|
- result = null;
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-}
|