|
|
|
@ -1,15 +1,50 @@
|
|
|
|
package com.rehome.zhdcoa.ui.fragment;
|
|
|
|
package com.rehome.zhdcoa.ui.fragment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.rehome.zhdcoa.utils.GsonUtils.GsonToBean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.Contans;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.R;
|
|
|
|
import com.rehome.zhdcoa.base.BaseViewBindingFragment;
|
|
|
|
import com.rehome.zhdcoa.base.BaseViewBindingFragment;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.bean.DeviceOnlineStatusImgBean;
|
|
|
|
import com.rehome.zhdcoa.databinding.FragmentDeviceMonitoringPhotoBinding;
|
|
|
|
import com.rehome.zhdcoa.databinding.FragmentDeviceMonitoringPhotoBinding;
|
|
|
|
import com.rehome.zhdcoa.databinding.FragmentDeviceMonitoringStatisticsBinding;
|
|
|
|
import com.rehome.zhdcoa.databinding.FragmentDeviceMonitoringStatisticsBinding;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.ui.activity.PhotoRiskViewActivity;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.HttpListener;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.NohttpUtils;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.OnAuthenticationLoginListener;
|
|
|
|
|
|
|
|
import com.rehome.zhdcoa.utils.RSAAndroid;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.NoHttp;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.RequestMethod;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.rest.CacheMode;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.rest.OnResponseListener;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.rest.Request;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.rest.RequestQueue;
|
|
|
|
|
|
|
|
import com.yolanda.nohttp.rest.Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.net.ssl.HostnameVerifier;
|
|
|
|
|
|
|
|
import javax.net.ssl.SSLSession;
|
|
|
|
|
|
|
|
import javax.net.ssl.SSLSocketFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class DeviceMonitoringPhotoFragment extends BaseViewBindingFragment<FragmentDeviceMonitoringPhotoBinding> {
|
|
|
|
public class DeviceMonitoringPhotoFragment extends BaseViewBindingFragment<FragmentDeviceMonitoringPhotoBinding> {
|
|
|
|
@ -17,6 +52,10 @@ public class DeviceMonitoringPhotoFragment extends BaseViewBindingFragment<Fragm
|
|
|
|
private String deviceName;
|
|
|
|
private String deviceName;
|
|
|
|
private String areaFullName;
|
|
|
|
private String areaFullName;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<String> onlinePhotoList = new ArrayList<>();
|
|
|
|
|
|
|
|
private List<DeviceOnlineStatusImgBean.DeviceOnlineStatusImg> deviceOnlineStatusImgList = new ArrayList<>();
|
|
|
|
|
|
|
|
private RequestQueue queue;
|
|
|
|
|
|
|
|
|
|
|
|
public DeviceMonitoringPhotoFragment(String deviceCode,String deviceName,String areaFullName){
|
|
|
|
public DeviceMonitoringPhotoFragment(String deviceCode,String deviceName,String areaFullName){
|
|
|
|
this.deviceCode=deviceCode;
|
|
|
|
this.deviceCode=deviceCode;
|
|
|
|
this.deviceName=deviceName;
|
|
|
|
this.deviceName=deviceName;
|
|
|
|
@ -30,11 +69,158 @@ public class DeviceMonitoringPhotoFragment extends BaseViewBindingFragment<Fragm
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void initView() {
|
|
|
|
protected void initView() {
|
|
|
|
|
|
|
|
queue = NoHttp.newRequestQueue(1);
|
|
|
|
|
|
|
|
binding.fivPhoto.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
if(!onlinePhotoList.isEmpty()){
|
|
|
|
|
|
|
|
//设置图片
|
|
|
|
|
|
|
|
String mediaUrl = onlinePhotoList.get(0);
|
|
|
|
|
|
|
|
Intent intent = new Intent(context, PhotoRiskViewActivity.class);
|
|
|
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
|
|
|
|
intent.putExtra("url", mediaUrl);
|
|
|
|
|
|
|
|
intent.putExtra("fileName", "图片预览");
|
|
|
|
|
|
|
|
intent.putExtra("path", "/");
|
|
|
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void initData() {
|
|
|
|
protected void initData() {
|
|
|
|
|
|
|
|
authenticationLoginDeviceAlarmInfoRsa();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void authenticationLoginDeviceAlarmInfoRsa() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//AI三维登录接口
|
|
|
|
|
|
|
|
String userName = Contans.SP.DeviceAlermInfoAccount;
|
|
|
|
|
|
|
|
String strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
|
|
|
|
|
|
|
|
Contans.SP.DeviceAlermInfoPwd,
|
|
|
|
|
|
|
|
RSAAndroid.publicRsaKeyLocal
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
AuthenticationLoginAIUtils.authenticationDeviceAlermInfoRsaNotShowProgress(requireActivity(),userName,strPublicDecode,new OnAuthenticationLoginListener(){
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onAuthenticationSuccess(boolean result, String token) {
|
|
|
|
|
|
|
|
if(token!=null&&token.isEmpty()){
|
|
|
|
|
|
|
|
//登录失败
|
|
|
|
|
|
|
|
showToast("设备状态智能监测及分析平台登录失败");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//登录成功
|
|
|
|
|
|
|
|
//获取照片列表
|
|
|
|
|
|
|
|
//http://10.19.0.17:1700/dserver/device/img/002c00e9?v=1770446858996
|
|
|
|
|
|
|
|
getDevicePhotoList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void getDevicePhotoList() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = Contans.IP + Contans.getDevicePhotoListUrl+"/"+deviceCode;
|
|
|
|
|
|
|
|
Request<String> request = NoHttp.createStringRequest(url, RequestMethod.GET);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NohttpUtils.getInstance().add(requireActivity(),0, request, new HttpListener<String>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint({"SetTextI18n", "DefaultLocale", "NotifyDataSetChanged"})
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSucceed(int what, com.yolanda.nohttp.rest.Response<String> response) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String result = response.get();
|
|
|
|
|
|
|
|
showLog(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeviceOnlineStatusImgBean bean = GsonToBean(result, DeviceOnlineStatusImgBean.class);
|
|
|
|
|
|
|
|
if(bean!=null && bean.getCode()==20000 && bean.isSuccess() && bean.getData()!=null && !bean.getData().isEmpty()){
|
|
|
|
|
|
|
|
deviceOnlineStatusImgList.clear();
|
|
|
|
|
|
|
|
deviceOnlineStatusImgList.addAll(bean.getData());
|
|
|
|
|
|
|
|
onlinePhotoList.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> onlinePhotoListTemp = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String imgDeviceOnlineBaseUrl = Contans.IP + Contans.getImgDeviceOnlineBaseUrl;
|
|
|
|
|
|
|
|
for(DeviceOnlineStatusImgBean.DeviceOnlineStatusImg item : deviceOnlineStatusImgList){
|
|
|
|
|
|
|
|
String fileName = item.getFileName();
|
|
|
|
|
|
|
|
String imgFullUrl = imgDeviceOnlineBaseUrl+fileName;
|
|
|
|
|
|
|
|
onlinePhotoListTemp.add(imgFullUrl);
|
|
|
|
|
|
|
|
onlinePhotoList.add(imgFullUrl);
|
|
|
|
|
|
|
|
showLog(imgFullUrl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
showLog(String.valueOf(onlinePhotoListTemp.size()));
|
|
|
|
|
|
|
|
if(!onlinePhotoList.isEmpty()){
|
|
|
|
|
|
|
|
//设置图片
|
|
|
|
|
|
|
|
String mediaUrl = onlinePhotoList.get(0);
|
|
|
|
|
|
|
|
setDevicePhotoToImageView(mediaUrl);
|
|
|
|
|
|
|
|
binding.tvNoPhoto.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_device_place_big);
|
|
|
|
|
|
|
|
Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
|
|
|
|
|
|
|
|
binding.fivPhoto.setImageDrawable(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onFailed(int what, com.yolanda.nohttp.rest.Response<String> response) {
|
|
|
|
|
|
|
|
showLog("数据加载失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDevicePhotoToImageView(String mediaUrl) {
|
|
|
|
|
|
|
|
Request<Bitmap> request = NoHttp.createImageRequest(mediaUrl);
|
|
|
|
|
|
|
|
request.setCacheMode(CacheMode.NONE_CACHE_REQUEST_NETWORK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(mediaUrl)) {
|
|
|
|
|
|
|
|
Log.i("app", "fullPath is:" + mediaUrl);
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(request.url())) {
|
|
|
|
|
|
|
|
String url = request.url();
|
|
|
|
|
|
|
|
if (url.startsWith("https://219.131.195.3:7100") || url.startsWith("https://219.131.195.3:7011") || url.startsWith("https://219.131.195.3:7081") || url.startsWith("https://219.131.195.3:7082")) {
|
|
|
|
|
|
|
|
SSLSocketFactory socketFactory = NohttpUtils.getSSLSocketFactory(context);
|
|
|
|
|
|
|
|
if (socketFactory != null) {
|
|
|
|
|
|
|
|
request.setSSLSocketFactory(socketFactory);
|
|
|
|
|
|
|
|
request.setHostnameVerifier(new HostnameVerifier() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean verify(String s, SSLSession sslSession) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
queue.add(6, request, new OnResponseListener<>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onStart(int what) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSucceed(int what, Response<Bitmap> response) {
|
|
|
|
|
|
|
|
showLog("--------bitmap-------");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap bitmap = response.get();
|
|
|
|
|
|
|
|
showLog(String.valueOf(bitmap==null));
|
|
|
|
|
|
|
|
Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
|
|
|
|
|
|
|
|
binding.fivPhoto.setImageDrawable(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onFailed(int what, Response<Bitmap> response) {
|
|
|
|
|
|
|
|
// Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_device_place);
|
|
|
|
|
|
|
|
// Drawable drawable = new BitmapDrawable(context.getResources(), bitmap);
|
|
|
|
|
|
|
|
// binding.fiv.setImageDrawable(drawable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onFinish(int what) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Log.i("app", "path is null");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|