|
//package com.electric.chargingpile.activity;
//
//import android.app.Activity;
//import com.electric.chargingpile.view.AlertDialog;
//import android.content.Intent;
//import android.content.SharedPreferences;
//import android.content.pm.ActivityInfo;
//import android.graphics.Rect;
//import android.hardware.Camera;
//import android.hardware.Camera.AutoFocusCallback;
//import android.hardware.Camera.PreviewCallback;
//import android.hardware.Camera.Size;
//import android.os.Bundle;
//import android.os.Handler;
//import android.text.TextUtils;
//import android.util.Log;
//import android.view.KeyEvent;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.view.animation.Animation;
//import android.view.animation.TranslateAnimation;
//import android.widget.Button;
//import android.widget.FrameLayout;
//import android.widget.ImageView;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.electric.chargingpile.R;
//import com.electric.chargingpile.application.MainApplication;
//import com.electric.chargingpile.camera.CameraManager;
//import com.electric.chargingpile.camera.CameraPreview;
//import com.electric.chargingpile.manager.ProfileManager;
//import com.electric.chargingpile.util.DES3;
//import com.electric.chargingpile.util.JsonUtils;
//import com.electric.chargingpile.util.LoadingDialog;
//import com.electric.chargingpile.util.Md5Util;
//import com.electric.chargingpile.util.ToastUtil;
//import com.zhy.http.okhttp.OkHttpUtils;
//import com.zhy.http.okhttp.callback.StringCallback;
//
//import net.sourceforge.zbar.Config;
//import net.sourceforge.zbar.Image;
//import net.sourceforge.zbar.ImageScanner;
//import net.sourceforge.zbar.Symbol;
//import net.sourceforge.zbar.SymbolSet;
//
//import java.io.IOException;
//import java.lang.reflect.Field;
//import java.net.URLEncoder;
//
//import okhttp3.Call;
//
//public class MyCaptureActivity extends Activity implements OnClickListener {
// private static final String TAG = "MyCaptureActivity";
// private Camera mCamera;
// private CameraPreview mPreview;
// private Handler autoFocusHandler;
// private CameraManager mCameraManager;
//
// private TextView scanResult, capture_flashlight, tv_input_code;
// private FrameLayout scanPreview;
// private Button scanRestart;
// private RelativeLayout scanContainer;
// private RelativeLayout scanCropView;
// private ImageView scanLine;
//
// private Rect mCropRect = null;
// private boolean barcodeScanned = false;
// private boolean previewing = true;
// private ImageScanner mImageScanner = null;
// private boolean flag = true;
// private LoadingDialog dialog;
// private String stubGroupId;
// private String password = "";
// private ImageView iv_back;
//
// static {
// System.loadLibrary("iconv");
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_my_capture);
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// dialog = new LoadingDialog(this);
// dialog.setCanceledOnTouchOutside(false);
// findViewById();
// addEvents();
// initViews();
//
// }
//
// private void findViewById() {
// scanPreview = (FrameLayout) findViewById(R.id.capture_preview);
// scanResult = (TextView) findViewById(R.id.capture_scan_result);
// scanRestart = (Button) findViewById(R.id.capture_restart_scan);
// scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
// scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
// scanLine = (ImageView) findViewById(R.id.capture_scan_line);
// capture_flashlight = (TextView) findViewById(R.id.capture_flashlight);
// capture_flashlight.setOnClickListener(this);
// tv_input_code = (TextView) findViewById(R.id.tv_input_code);
// tv_input_code.setOnClickListener(this);
// iv_back = (ImageView) findViewById(R.id.iv_back);
// iv_back.setOnClickListener(this);
// }
//
// private void addEvents() {
// scanRestart.setOnClickListener(new OnClickListener() {
// public void onClick(View v) {
//
// }
// });
// }
//
// private void scanRestart() {
// if (barcodeScanned) {
// barcodeScanned = false;
// if (null == mCamera) {
// mCamera = mCameraManager.getCamera();
// }
// mCamera.setPreviewCallback(previewCb);
// mCamera.startPreview();
// previewing = true;
// mCamera.autoFocus(autoFocusCB);
// }
// }
//
// public void light() {
// if (this.flag) {
// mCameraManager.openLight();
// this.flag = false;
// this.capture_flashlight.setText("关灯");
// return;
// }
// mCameraManager.offLight();
// this.flag = true;
// this.capture_flashlight.setText("开灯");
// }
//
// private void initViews() {
// mImageScanner = new ImageScanner();
// mImageScanner.setConfig(0, Config.X_DENSITY, 3);
// mImageScanner.setConfig(0, Config.Y_DENSITY, 3);
//
// autoFocusHandler = new Handler();
// mCameraManager = new CameraManager(this);
// try {
// mCameraManager.openDriver();
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// mCamera = mCameraManager.getCamera();
// mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
// scanPreview.addView(mPreview);
//
// TranslateAnimation animation = new TranslateAnimation(
// Animation.RELATIVE_TO_PARENT, 0.0f,
// Animation.RELATIVE_TO_PARENT, 0.0f,
// Animation.RELATIVE_TO_PARENT, 0.0f,
// Animation.RELATIVE_TO_PARENT, 0.85f);
// animation.setDuration(3000);
// animation.setRepeatCount(-1);
// animation.setRepeatMode(Animation.REVERSE);
// scanLine.startAnimation(animation);
// }
//
// @Override
// public void onPause() {
// Log.e(TAG, "onPause: 11");
// super.onPause();
//// scanRestart();
//// releaseCamera();
// }
//
// @Override
// protected void onDestroy() {
// super.onDestroy();
// releaseCamera();
// }
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// System.out.println("Page01 -->onKeyDown: keyCode: " + keyCode);
// if (KeyEvent.KEYCODE_HOME == keyCode) {
// System.out.println("HOME has been pressed yet ...");
// // android.os.Process.killProcess(android.os.Process.myPid());
// Toast.makeText(getApplicationContext(), "HOME 键已被禁用...",
// Toast.LENGTH_LONG).show();
// return true;
// }
// return super.onKeyDown(keyCode, event); // 不会回到 home 页面
// }
//
// @Override
// protected void onResume() {
// super.onResume();
// scanRestart();
// }
//
// private void releaseCamera() {
// if (mCamera != null) {
// previewing = false;
// mCamera.setPreviewCallback(null);
// mCamera.release();
// mCamera = null;
// }
// }
//
// private Runnable doAutoFocus = new Runnable() {
// public void run() {
// if (previewing)
//
// mCamera.autoFocus(autoFocusCB);
// }
// };
//
// PreviewCallback previewCb = new PreviewCallback() {
// public void onPreviewFrame(byte[] data, Camera camera) {
// try {
// Size size = camera.getParameters().getPreviewSize();
//
// // 这里需要将获取的data翻转一下,因为相机默认拿的的横屏的数据
// byte[] rotatedData = new byte[data.length];
// for (int y = 0; y < size.height; y++) {
// for (int x = 0; x < size.width; x++)
// rotatedData[x * size.height + size.height - y - 1] = data[x
// + y * size.width];
// }
//
// // 宽高也要调整
// int tmp = size.width;
// size.width = size.height;
// size.height = tmp;
//
// initCrop();
//
// Image barcode = new Image(size.width, size.height, "Y800");
// barcode.setData(rotatedData);
// barcode.setCrop(mCropRect.left, mCropRect.top, mCropRect.width(),
// mCropRect.height());
//
// int result = mImageScanner.scanImage(barcode);
// String resultStr = null;
//
// if (result != 0) {
// SymbolSet syms = mImageScanner.getResults();
// for (Symbol sym : syms) {
// resultStr = sym.getData();
// }
// }
//
// if (!TextUtils.isEmpty(resultStr)) {
// previewing = false;
// mCamera.setPreviewCallback(null);
// mCamera.stopPreview();
//
// barcodeScanned = true;
//// ToastUtil.showToast(getApplicationContext(),resultStr,Toast.LENGTH_SHORT);
//// Log.e(TAG, "onPreviewFrame: result="+resultStr );
//
// getChargingPile(resultStr);
//
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// };
//
// // Mimic continuous auto-focusing
// AutoFocusCallback autoFocusCB = new AutoFocusCallback() {
// public void onAutoFocus(boolean success, Camera camera) {
// autoFocusHandler.postDelayed(doAutoFocus, 1000);
// }
// };
//
// /**
// * 初始化截取的矩形区域
// */
// private void initCrop() {
// int cameraWidth = mCameraManager.getCameraResolution().y;
// int cameraHeight = mCameraManager.getCameraResolution().x;
//
// /** 获取布局中扫描框的位置信息 */
// int[] location = new int[2];
// scanCropView.getLocationInWindow(location);
//
// int cropLeft = location[0];
// int cropTop = location[1] - getStatusBarHeight();
//
// int cropWidth = scanCropView.getWidth();
// int cropHeight = scanCropView.getHeight();
//
// /** 获取布局容器的宽高 */
// int containerWidth = scanContainer.getWidth();
// int containerHeight = scanContainer.getHeight();
//
// /** 计算最终截取的矩形的左上角顶点x坐标 */
// int x = cropLeft * cameraWidth / containerWidth;
// /** 计算最终截取的矩形的左上角顶点y坐标 */
// int y = cropTop * cameraHeight / containerHeight;
//
// /** 计算最终截取的矩形的宽度 */
// int width = cropWidth * cameraWidth / containerWidth;
// /** 计算最终截取的矩形的高度 */
// int height = cropHeight * cameraHeight / containerHeight;
//
// /** 生成最终的截取的矩形 */
// mCropRect = new Rect(x, y, width + x, height + y);
// }
//
// private int getStatusBarHeight() {
// try {
// Class<?> c = Class.forName("com.android.internal.R$dimen");
// Object obj = c.newInstance();
// Field field = c.getField("status_bar_height");
// int x = Integer.parseInt(field.get(obj).toString());
// return getResources().getDimensionPixelSize(x);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return 0;
// }
//
// @Override
// public void onClick(View v) {
// switch (v.getId()) {
// case R.id.capture_flashlight:
// light();
// break;
// case R.id.tv_input_code:
// startActivity(new Intent(getApplication(), InputCodeActivity.class));
// finish();
// break;
// case R.id.iv_back:
// finish();
// break;
// }
// }
//
// private void checkJd(final String chargingCode) {
// String url = MainApplication.url + "/zhannew/basic/web/index.php/polyelectric/info?pile_code=" + chargingCode;
// Log.e("jd_url===", url);
// OkHttpUtils.get()
// .url(url)
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
// dialog.cancel();
// String code = JsonUtils.getKeyResult(response, "code");
// if (code.equals("200")) {
// String group_id = JsonUtils.getKeyResult(response, "group_id");
// startJdCharging(group_id, chargingCode);
// } else {
// String error_messge = JsonUtils.getKeyResult(response, "error_message");
// if (!error_messge.equals("")) {
// ToastUtil.showToast(getApplicationContext(), error_messge, Toast.LENGTH_SHORT);
// new Handler().postDelayed(new Runnable() {
// public void run() {
// scanRestart();
// }
// }, 1500);
//
// }
// }
// }
// });
// }
//
// private void startJdCharging(String zhan_id, String zhuang_id) {
// dialog.show();
// long appTime1 = System.currentTimeMillis() / 1000;
// long updatetime = appTime1 - MainMapActivity.cha - 3;
// String token = String.valueOf(updatetime);
// String s = "group_id=" + zhan_id + "&pile_code=" + zhuang_id + "&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a";
// Log.e("s_url==", s);
// final String url = MainApplication.url + "/zhannew/basic/web/index.php/polyelectric/start?ver=1.0&sign=" + Md5Util.md5(s) + "&timer=" + token + "&group_id=" + zhan_id + "&user_id=" + MainApplication.userId + "&pile_code=" + zhuang_id;
// Log.e("jd_url==", url);
// OkHttpUtils.get()
// .url(url)
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
// Log.e("start===", response);
// dialog.cancel();
// String code = JsonUtils.getKeyResult(response, "code");
// if (code != null) {
// if (code.equals("400")) {
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// new AlertDialog(MyCaptureActivity.this).builder()
// .setMsg(error_message)
// .setNegativeButton("确定", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mCamera != null) {
// scanRestart();
// }
//// startActivity(new Intent(getApplication(),ChargingStatusActivity.class));
//
//// startCharging();
// }
// }).show();
//
//
// } else if (code.equals("200")) {
// Intent intent = new Intent(getApplication(), ChargingStatusActivity.class);
//// intent.putExtra("stubId",zhuang_num);
//// intent.putExtra("stubGroupId",stubGroupId);
// intent.putExtra("type", "jd");
// startActivity(intent);
// if (mCamera != null) {
// scanRestart();
// }
// finish();
// } else if (code.equals("104")) {
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// new AlertDialog(MyCaptureActivity.this).builder()
// .setMsg("您的余额不足1元,可能无法满\n足您此次充电")
// .setPositiveButton("去充值", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startActivity(new Intent(getApplication(), AccountRechargeActivity.class));
// }
// }).setNegativeButton("取消", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mCamera != null) {
// scanRestart();
// }
//// startActivity(new Intent(getApplication(),ChargingStatusActivity.class));
// }
// }).show();
// } else if (code.equals("0")) {
// if (mCamera != null) {
// scanRestart();
// }
// ToastUtil.showToast(getApplicationContext(), "该桩正在充电中,请移步到附近充电桩", Toast.LENGTH_SHORT);
// } else if (code.equals("40000")) {
// if (mCamera != null) {
// scanRestart();
// }
// ToastUtil.showToast(getApplicationContext(), "未插充电枪或该桩已离线", Toast.LENGTH_SHORT);
// } else if (code.equals("600")) {
// if (mCamera != null) {
// scanRestart();
// }
// ToastUtil.showToast(getApplicationContext(), "由于网络原因,您有一笔订单未结算,请稍候再试", Toast.LENGTH_SHORT);
// } else {
// if (mCamera != null) {
// scanRestart();
// }
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// ToastUtil.showToast(getApplicationContext(), error_message, Toast.LENGTH_SHORT);
// }
// }
// }
// });
// }
//
// private void checkoutInfo(final String zhuang_num) {
// long appTime1 = System.currentTimeMillis() / 1000;
// Log.i("appTime(long)---", appTime1 + "");
// long updatetime = appTime1 - MainMapActivity.cha - 3;
// Log.i("updatetime(long)---", updatetime + "");
// Log.i("cha---", MainMapActivity.cha + "");
// String token = String.valueOf(updatetime);
// final String url = MainApplication.url + "/zhannew/basic/web/index.php/xxapi/info" +
// "?stubId=" + zhuang_num + "&supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&ver=1.0&sign="
// + Md5Util.md5("stubId=" + zhuang_num + "&supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a");
//
// Log.e("url", url);
// OkHttpUtils
// .get()
// .url(url)
// .build()
// .connTimeOut(20000)
// .readTimeOut(20000)
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
// Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show();
// dialog.cancel();
// }
//
// @Override
// public void onResponse(String response) {
// Log.e("response====", response);
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String code = JsonUtils.getKeyResult(response, "code");
// dialog.cancel();
// if (code != null) {
// if (code.equals("104")) {
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// new AlertDialog(MyCaptureActivity.this).builder()
// .setMsg("您的余额不足1元,可能无法满\n足您此次充电")
// .setPositiveButton("去充值", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startActivity(new Intent(getApplication(), AccountRechargeActivity.class));
// }
// }).setNegativeButton("取消", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mCamera != null) {
// scanRestart();
// }
// }
// }).show();
// } else if (code.equals("106")) {
// if (mCamera != null) {
// scanRestart();
// }
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// ToastUtil.showToast(getApplicationContext(), "无此电桩,请重新扫码", Toast.LENGTH_SHORT);
// } else if (code.equals("301")) {
// if (mCamera != null) {
// scanRestart();
// }
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// ToastUtil.showToast(getApplicationContext(), "终端系统错误", Toast.LENGTH_SHORT);
// } else if (code.equals("200")) {
//// 00:空闲,01:充电中,02:故障,03:车位占用,04:维护中,
//// 05:离线,06:在建中,07:升级中,99:删除
//
// String data = JsonUtils.getKeyResult(response, "data");
// Log.e("data===", data);
// String status = JsonUtils.getKeyResult(data, "status");
// if (status.equals("00")) {
// stubGroupId = JsonUtils.getKeyResult(data, "stubGroupId");
// try {
// startCharging(zhuang_num);
// } catch (Exception e) {
// e.printStackTrace();
// }
//
//
// } else if (status.equals("01")) {
// new AlertDialog(MyCaptureActivity.this).builder()
// .setMsg("充电中")
// .setNegativeButton("确定", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// scanRestart();
//// startActivity(new Intent(getApplication(),ChargingStatusActivity.class));
// }
// }).show();
// } else if (status.equals("02")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "故障", Toast.LENGTH_SHORT);
// } else if (status.equals("03")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "车位占用", Toast.LENGTH_SHORT);
// } else if (status.equals("04")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "维护中", Toast.LENGTH_SHORT);
// } else if (status.equals("05")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "离线", Toast.LENGTH_SHORT);
// } else if (status.equals("06")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "在建中", Toast.LENGTH_SHORT);
// } else if (status.equals("07")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "升级中", Toast.LENGTH_SHORT);
// } else if (status.equals("99")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "删除", Toast.LENGTH_SHORT);
// }
// } else if (code.equals("600")) {
// scanRestart();
// ToastUtil.showToast(getApplicationContext(), "由于网络原因,您有一笔订单未结算,请稍候再试", Toast.LENGTH_SHORT);
// } else {
// ToastUtil.showToast(getApplicationContext(), "无此电桩,请重新扫码", Toast.LENGTH_SHORT);
// scanRestart();
// }
// } else {
// ToastUtil.showToast(getApplicationContext(), "code为空", Toast.LENGTH_SHORT);
// }
// }
// });
// }
//
// private void sp() {
// SharedPreferences sharedPreferences = getApplication().getSharedPreferences("userInfo",
// Activity.MODE_PRIVATE);
// password = sharedPreferences.getString("password", "");
// }
//
// private void startCharging(final String zhuang_num) throws Exception {
// sp();
// dialog.show();
// long appTime1 = System.currentTimeMillis() / 1000;
// long updatetime = appTime1 - MainMapActivity.cha - 3;
// String token = String.valueOf(updatetime);
// String s = "password=" + DES3.encode(password) + "&stubGroupId=" + stubGroupId + "&stubId=" + zhuang_num + "&supplier=" + "星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a";
// final String url = MainApplication.url + "/zhannew/basic/web/index.php/charge/start" +
// "?password=" + URLEncoder.encode(DES3.encode(password)) + "&stubGroupId=" + stubGroupId + "&stubId=" + zhuang_num + "&supplier=" + URLEncoder.encode("星星充电") + "&timer=" + token + "&user_id=" + MainApplication.userId + "&ver=1.0&sign="
// + Md5Util.md5(s);
// Log.e("urlstart===", URLEncoder.encode(url));
// OkHttpUtils.get()
// .url(url)
// .build()
// .connTimeOut(10000)
// .readTimeOut(10000)
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
// Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show();
// dialog.cancel();
// }
//
// @Override
// public void onResponse(String response) {
// Log.e("start===", response);
// dialog.cancel();
// String code = JsonUtils.getKeyResult(response, "code");
// if (code != null) {
// if (code.equals("400")) {
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
// new AlertDialog(MyCaptureActivity.this).builder()
// .setMsg(error_message)
// .setNegativeButton("确定", new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (mCamera != null) {
// scanRestart();
// }
//// startActivity(new Intent(getApplication(),ChargingStatusActivity.class));
//
//// startCharging();
// }
// }).show();
//
//
// } else if (code.equals("200")) {
// Intent intent = new Intent(getApplication(), ChargingStatusActivity.class);
//// intent.putExtra("stubId",zhuang_num);
//// intent.putExtra("stubGroupId",stubGroupId);
// intent.putExtra("type", "xx");
// startActivity(intent);
// if (mCamera != null) {
// scanRestart();
// }
// finish();
// } else {
// if (mCamera != null) {
// scanRestart();
// }
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// String urll = "http://123.57.6.131/zhannew/basic/web/index.php/log/write";
// OkHttpUtils.post()
// .url(urll)
// .addParams("url", url)
// .addParams("code", code)
// .addParams("message", error_message)
// .addParams("type", "android")
// .build()
// .execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
//
// }
// });
//
// ToastUtil.showToast(getApplicationContext(), error_message, Toast.LENGTH_SHORT);
// }
// }
// }
// });
// }
//
// private void checkTlD(final String chargingCode) {
// final String url = MainApplication.url + "/zhannew/basic/web/index.php/special/info?pile_id=" + chargingCode + "&user_id=" + MainApplication.userId;
// Log.e("checkTlD_url===", url);
// dialog.show();
// OkHttpUtils.get().url(url).build().execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
// dialog.cancel();
// Log.e("checkTlD_response", response);
// String code = JsonUtils.getKeyResult(response, "code");
// if (code.equals("200")) {
// String group_id = JsonUtils.getKeyResult(response, "group_id");
// String eletype = JsonUtils.getKeyResult(response, "eletype");
// Intent intent = new Intent(getApplicationContext(), TLDLoadingActivity.class);
// intent.putExtra("eletype", eletype);
// intent.putExtra("chargingCode", chargingCode);
// intent.putExtra("group_id", group_id);
// startActivity(intent);
// finish();
//
//// startTLD(chargingCode,group_id);
// } else {
// String error_messge = JsonUtils.getKeyResult(response, "error_message");
// Toast.makeText(getApplicationContext(), error_messge, Toast.LENGTH_SHORT).show();
// new Handler().postDelayed(new Runnable() {
// public void run() {
// if (mCamera != null) {
// scanRestart();
// }
// }
// }, 1500);
// }
// }
// });
// }
//
// private void getChargingPile(final String result) {
// String url = MainApplication.url + "/zhannew/basic/web/index.php/interface/info?flag=1&user_id=" + MainApplication.userId + "&url=" + result;
// Log.e(TAG, "getChargingPile: url=" + url);
// OkHttpUtils.get().url(url).build().execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
// Log.e(TAG, "onResponse: getChargingPile11=" + response);
// String code = JsonUtils.getKeyResult(response, "code");
// if (code.equals("200")) {
// String group_id = JsonUtils.getKeyResult(response, "group_id");
// String eletype = JsonUtils.getKeyResult(response, "eletype");
// String type = JsonUtils.getKeyResult(response, "type");
// String pile_code = JsonUtils.getKeyResult(response, "pile_code");
// if (type.equals("jd")) {
// startHssy(pile_code, group_id, type);
// } else {
// Intent intent = new Intent(getApplicationContext(), TLDLoadingActivity.class);
// intent.putExtra("type", type);
// intent.putExtra("eletype", eletype);
// intent.putExtra("chargingCode", pile_code);
// intent.putExtra("group_id", group_id);
// startActivity(intent);
// finish();
// }
//
// } else {
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// ToastUtil.showToast(getApplicationContext(), error_message, Toast.LENGTH_SHORT);
// new Handler().postDelayed(new Runnable() {
// public void run() {
// if (mCamera != null) {
// scanRestart();
// }
//
// }
// }, 1500);
// }
// }
// });
// }
//
// private void startHssy(String pile_code, String group_id, String type) {
// long appTime1 = System.currentTimeMillis() / 1000;
// long updatetime = appTime1 - MainMapActivity.cha - 3;
// String token = String.valueOf(updatetime);
// String s = "group_id=" + group_id + "&password=" + MainApplication.userPassword + "&pile_code=" + pile_code + "&timer=" + token + "&type=" + type + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a";
// String url = MainApplication.url + "/zhannew/basic/web/index.php/interface/start_v2?" +
// "ver=1.0&type=" + type + "&timer=" + token + "&user_id=" + MainApplication.userId + "&pile_code="
// + pile_code + "&group_id=" + group_id + "&password=" + MainApplication.userPassword + "&sign=" + Md5Util.md5(s);
// Log.e(TAG, "startHssy: url=" + url);
// OkHttpUtils.get().url(url).build().execute(new StringCallback() {
// @Override
// public void onError(Call call, Exception e) {
//
// }
//
// @Override
// public void onResponse(String response) {
// Log.e(TAG, "onResponse: startHssy=" + response);
// String code = JsonUtils.getKeyResult(response, "code");
// if (code.equals("200")) {
// MainApplication.isAppStart = true;
// ProfileManager.getInstance().setAppStart(getApplicationContext(), MainApplication.isAppStart);
// startActivity(new Intent(getApplicationContext(), ChargingStatusActivity.class));
// finish();
// } else {
// String error_message = JsonUtils.getKeyResult(response, "error_message");
// ToastUtil.showToast(getApplicationContext(), error_message, Toast.LENGTH_SHORT);
// new Handler().postDelayed(new Runnable() {
// public void run() {
// if (mCamera != null) {
// scanRestart();
// }
// }
// }, 1500);
// }
// }
// });
// }
//
//
//}
|