1217 lines
49 KiB
Java
1217 lines
49 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
||
|
||
import static cn.shangyu.gdxzExpert.base.BaseFragment.mActivity;
|
||
import static cn.shangyu.gdxzExpert.utils.HttpMD5SendInfoUtil.hasrealtoken;
|
||
import static cn.shangyu.gdxzExpert.utils.HttpMD5SendInfoUtil.sendJsonPostParamTokenMD5;
|
||
import static cn.shangyu.gdxzExpert.utils.UIUtils.getContext;
|
||
|
||
import android.Manifest;
|
||
import android.content.Context;
|
||
import android.content.DialogInterface;
|
||
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.net.Uri;
|
||
import android.os.Build;
|
||
import android.os.Bundle;
|
||
import android.os.Environment;
|
||
import android.os.Handler;
|
||
import android.provider.MediaStore;
|
||
import android.text.Editable;
|
||
import android.text.InputType;
|
||
import android.text.TextWatcher;
|
||
import android.util.Log;
|
||
import android.view.Gravity;
|
||
import android.view.View;
|
||
import android.view.ViewGroup;
|
||
import android.webkit.WebSettings;
|
||
import android.widget.AdapterView;
|
||
import android.widget.EditText;
|
||
import android.widget.GridView;
|
||
import android.widget.ImageView;
|
||
import android.widget.PopupWindow;
|
||
import android.widget.RadioButton;
|
||
import android.widget.RelativeLayout;
|
||
import android.widget.TextView;
|
||
import android.widget.Toast;
|
||
|
||
import androidx.annotation.NonNull;
|
||
import androidx.core.content.FileProvider;
|
||
import androidx.viewpager.widget.PagerAdapter;
|
||
import androidx.viewpager.widget.ViewPager;
|
||
|
||
import com.bumptech.glide.Glide;
|
||
import com.bumptech.glide.request.RequestOptions;
|
||
import com.github.dfqin.grantor.PermissionListener;
|
||
import com.github.dfqin.grantor.PermissionsUtil;
|
||
import com.google.gson.Gson;
|
||
import com.gyf.immersionbar.ImmersionBar;
|
||
import com.hjq.window.EasyWindow;
|
||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
|
||
import com.zhy.http.okhttp.OkHttpUtils;
|
||
import com.zhy.http.okhttp.callback.StringCallback;
|
||
|
||
import java.io.ByteArrayOutputStream;
|
||
import java.io.File;
|
||
import java.io.FileInputStream;
|
||
import java.io.FileNotFoundException;
|
||
import java.io.FileOutputStream;
|
||
import java.io.IOException;
|
||
import java.io.InputStream;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.ArrayList;
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import cn.shangyu.gdxzExpert.R;
|
||
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||
import cn.shangyu.gdxzExpert.bean.AddBitmaps;
|
||
import cn.shangyu.gdxzExpert.bean.AddCaseNewRecordAdapter;
|
||
import cn.shangyu.gdxzExpert.bean.BaseBeanNew;
|
||
import cn.shangyu.gdxzExpert.bean.PhotoItem;
|
||
import cn.shangyu.gdxzExpert.bean.SimpleBean;
|
||
import cn.shangyu.gdxzExpert.bean.hbvSymbolIdBean;
|
||
import cn.shangyu.gdxzExpert.bean.hbvSymbolIdBeans;
|
||
import cn.shangyu.gdxzExpert.bean.imBean;
|
||
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
||
import cn.shangyu.gdxzExpert.utils.Base64Util;
|
||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
||
import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils;
|
||
import cn.shangyu.gdxzExpert.utils.Url;
|
||
import cn.shangyu.gdxzExpert.view.PhotoView;
|
||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||
import cn.shangyu.gdxzExpert.widget.LoadingPage;
|
||
import okhttp3.Call;
|
||
import okhttp3.MediaType;
|
||
import okhttp3.OkHttpClient;
|
||
import okhttp3.Request;
|
||
import okhttp3.RequestBody;
|
||
import okhttp3.Response;
|
||
|
||
public class HbvdnaActivity extends BaseActivity implements AdapterView.OnItemClickListener {
|
||
|
||
@Override
|
||
public void setTitle() {
|
||
top_title.setText("乙肝表面标志物及HBV DNA");
|
||
}
|
||
String hbvSymbolId;
|
||
EditText hbsag,antiHbs,hbeag,antiHbe,hbvDna;
|
||
View view;
|
||
|
||
|
||
private GridView mGv_photos;
|
||
private Bitmap mAddBitmap;
|
||
private ArrayList<AddBitmaps> mBitmaps;
|
||
private AddBitmaps mAddBitmaps;
|
||
private AddCaseNewRecordAdapter gv_adapter;
|
||
private RelativeLayout rl_addcase_bigphoto;
|
||
private ViewPager mPager;
|
||
private View selectedPhotoView;
|
||
private TextView ll_selected_carmera;// 从照相机
|
||
private TextView ll_selected_photo;// 从相册
|
||
private PopupWindow mPopupWindowDialog;
|
||
private TextView tv_cancel;// 取消
|
||
private Uri photoUri;// 图片路径
|
||
public static final int SELECT_PIC_BY_TACK_PHOTO = 101; // 使用照相机拍照获取图片
|
||
public static final int SELECT_PIC_BY_PICK_PHOTO = 102; // 使用相册中的图片
|
||
private static final int PHOTO_RESOULT = 103;// 照相
|
||
private File temp;
|
||
|
||
TextView new_suifang;
|
||
String baseinfoDataStatus;
|
||
String type;
|
||
@Override
|
||
public View onCreateSuccessedView() {
|
||
view= UIUtils.inflate(R.layout.activity_hbvdna);
|
||
type=getIntent().getStringExtra("type");
|
||
|
||
view.findViewById(R.id.tv2).setOnClickListener(this);
|
||
if ("1".equals(type)) {
|
||
Drawable drawable= getResources().getDrawable(R.drawable.yiwen);
|
||
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
||
((TextView)view.findViewById(R.id.tv1)).setCompoundDrawablePadding(5);
|
||
((TextView)view.findViewById(R.id.tv1)).setCompoundDrawablesWithIntrinsicBounds(null,null,drawable,null);
|
||
view.findViewById(R.id.tv1).setOnClickListener(this);
|
||
}
|
||
hbsag=view.findViewById(R.id.hbsag);
|
||
hbsag.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||
// hbsag.setFilters(new InputFilter[]{new DecimalInputFilter()});
|
||
antiHbs=view.findViewById(R.id.antiHbs);
|
||
antiHbs.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||
// antiHbs.setFilters(new InputFilter[]{new DecimalInputFilter()});
|
||
hbeag=view.findViewById(R.id.hbeag);
|
||
hbeag.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||
// hbeag.setFilters(new InputFilter[]{new DecimalInputFilter()});
|
||
antiHbe=view.findViewById(R.id.antiHbe);
|
||
antiHbe.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||
// antiHbe.setFilters(new InputFilter[]{new DecimalInputFilter()});
|
||
hbvDna=view.findViewById(R.id.hbvDna);
|
||
hbvDna.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||
// hbvDna.setFilters(new InputFilter[]{new DecimalInputFilter()});
|
||
hbvSymbolId=getIntent().getStringExtra("hbvSymbolId");
|
||
new_suifang=view.findViewById(R.id.new_suifang);
|
||
new_suifang.setOnClickListener(this);
|
||
view.findViewById(R.id.change_data).setOnClickListener(this);
|
||
if ("1".equals(type)) {
|
||
|
||
hbsag.addTextChangedListener(new TextWatcher() {
|
||
@Override
|
||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void afterTextChanged(Editable editable) {
|
||
if(editable!=null&&!StringUtil.isEmpty(editable.toString()))
|
||
{
|
||
|
||
if(editable.toString().contains("."))
|
||
{
|
||
String ed[]=editable.toString().split("\\.");
|
||
|
||
if(Integer.valueOf(ed[0])>2000
|
||
||ed.length>1&&(Integer.valueOf(ed[0])==2000&&!StringUtil.isEmpty(ed[1]))&&Integer.valueOf(ed[1])>0)
|
||
{
|
||
hbsag.setTextColor(Color.RED);
|
||
ToastUtil.showToast("乙型肝炎表面抗原大于2000lU/mL,该患者不合格");
|
||
}
|
||
else
|
||
{
|
||
hbsag.setTextColor(Color.parseColor("#ff666666"));
|
||
}
|
||
|
||
}
|
||
else if(Integer.valueOf(editable.toString())>2000)
|
||
{
|
||
|
||
hbsag.setTextColor(Color.RED);
|
||
ToastUtil.showToast("乙型肝炎表面抗原大于2000lU/mL,该患者不合格");
|
||
}
|
||
else
|
||
{
|
||
hbsag.setTextColor(Color.parseColor("#ff666666"));
|
||
}
|
||
}
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
initView();
|
||
handletoken(Url.suifangHbvSymbol);
|
||
return view;
|
||
}
|
||
private void initView() {
|
||
mGv_photos = (GridView) view.findViewById(R.id.gv_case_photos);
|
||
|
||
rl_addcase_bigphoto = view.findViewById(R.id.rl_addcase_bigphoto);
|
||
mPager = (ViewPager) view.findViewById(R.id.pager);
|
||
|
||
mAddBitmap = BitmapFactory.decodeResource(getResources(),
|
||
R.drawable.new_selected);
|
||
mBitmaps = new ArrayList<AddBitmaps>();
|
||
mAddBitmaps = new AddBitmaps(true, mAddBitmap, null);
|
||
// mBitmaps.add(mAddBitmaps);
|
||
gv_adapter = new AddCaseNewRecordAdapter(HbvdnaActivity.this, mBitmaps, mAddBitmaps);
|
||
mGv_photos.setOnItemClickListener(this);
|
||
mGv_photos.setAdapter(gv_adapter);
|
||
}
|
||
|
||
@Override
|
||
public LoadingPage.ResultState onLoad() {
|
||
return LoadingPage.ResultState.STATE_SUCCESSED;
|
||
}
|
||
|
||
@Override
|
||
protected void processClick(View v) {
|
||
switch (v.getId())
|
||
{
|
||
case R.id.tv1:
|
||
showyiwen("乙型肝炎表面抗原(HBsAg)",getString(R.string.hbsag));
|
||
break;
|
||
case R.id.tv2:
|
||
showyiwen("HBV-DNA","低于检测下限填写0");
|
||
break;
|
||
case R.id.new_suifang:
|
||
hideSoftKeyboard();
|
||
v.postDelayed(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
popwindow("确认保存新的信息?");
|
||
}
|
||
},300);
|
||
break;
|
||
case R.id.change_data:
|
||
hideSoftKeyboard();
|
||
v.postDelayed(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
popwindow("确认本数据项已全部完成?");
|
||
}
|
||
},300);
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
private ECAlertDialog buildAlert;
|
||
public void popwindow(String content) {
|
||
buildAlert = ECAlertDialog.buildAlert(HbvdnaActivity.this, content, "取消",
|
||
"确认", new DialogInterface.OnClickListener() {
|
||
@Override
|
||
public void onClick(DialogInterface dialog, int which) {
|
||
// TODO Auto-generated method stub
|
||
buildAlert.dismiss();
|
||
}
|
||
}, new DialogInterface.OnClickListener() {
|
||
@Override
|
||
public void onClick(DialogInterface dialog, int which) {
|
||
if(content.contains("保存"))
|
||
{
|
||
sendpre();
|
||
hideSoftKeyboard();
|
||
}
|
||
else{
|
||
baseinfoDataStatus="2";
|
||
sendpre();
|
||
hideSoftKeyboard();
|
||
}
|
||
|
||
buildAlert.dismiss();
|
||
|
||
}
|
||
});
|
||
buildAlert.setTitle("温馨提示");
|
||
buildAlert.setTitleColor(getResources().getColor(
|
||
R.color.top_title));
|
||
buildAlert.show();
|
||
}
|
||
public void showyiwen(String title,String content)
|
||
{
|
||
EasyWindow.with(HbvdnaActivity.this).setGravity(Gravity.CENTER)
|
||
|
||
.setContentView(R.layout.float_cent_dialogqs).setBackgroundDimAmount(0.5f)
|
||
.setText(R.id.tv_infotitle, title)
|
||
.setText(R.id.tv_tishi, content)
|
||
.setText(android.R.id.message, "确定")
|
||
.setOutsideTouchable(false)
|
||
.setOnClickListener(android.R.id.message, new EasyWindow.OnClickListener<TextView>() {
|
||
|
||
@Override
|
||
public void onClick(EasyWindow<?> window, TextView view) {
|
||
window.cancel();
|
||
}
|
||
}).show();
|
||
}
|
||
public List<imBean> imgs= new ArrayList<>();;
|
||
hbvSymbolIdBeans beans;
|
||
private void gettree()
|
||
{
|
||
showProgressDialog("加载中");
|
||
Map<String, String> headers=new HashMap<>();
|
||
headers.put("x-access-token",token);
|
||
headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName());
|
||
Log.d("okhttp","x-access-token"+token);
|
||
String url = Url.suifangHbvSymbol+hbvSymbolId;
|
||
OkHttpUtils
|
||
.get()
|
||
.url(url)
|
||
.headers(headers)
|
||
.build()
|
||
.execute(new StringCallback()
|
||
{
|
||
|
||
@Override
|
||
public void onError(Call call, Exception e, int id) {
|
||
Log.d("okhttp",e.toString());
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onResponse(String response, int id) {
|
||
Log.d("okhttp",response+"response");
|
||
closeProgressDialog();
|
||
|
||
if(hasrealtoken(response)>0)
|
||
{
|
||
beans= GsonTools.fromGsonToBean(response, hbvSymbolIdBeans.class);
|
||
if(beans.getData()!=null)
|
||
{
|
||
baseinfoDataStatus=beans.getData().getDataStatus();
|
||
if(!StringUtil.isEmpty(beans.getData().getHbsag()))
|
||
{
|
||
hbsag.setText(beans.getData().getHbsag());
|
||
}
|
||
if(!StringUtil.isEmpty(beans.getData().getAntiHbs()))
|
||
{
|
||
antiHbs.setText(beans.getData().getAntiHbs());
|
||
}
|
||
if(!StringUtil.isEmpty(beans.getData().getHbeag()))
|
||
{
|
||
hbeag.setText(beans.getData().getHbeag());
|
||
}
|
||
if(!StringUtil.isEmpty(beans.getData().getAntiHbe()))
|
||
{
|
||
antiHbe.setText(beans.getData().getAntiHbe());
|
||
}
|
||
if("0".equals(beans.getData().getHbeagFalg()))
|
||
{
|
||
((RadioButton)view.findViewById(R.id.tab_rbn_122)).setChecked(true);
|
||
}
|
||
else if("1".equals(beans.getData().getHbeagFalg()))
|
||
{
|
||
((RadioButton)view.findViewById(R.id.tab_rbn_121)).setChecked(true);
|
||
}
|
||
if(!StringUtil.isEmpty(beans.getData().getHbvDna()))
|
||
{
|
||
hbvDna.setText(beans.getData().getHbvDna());
|
||
}
|
||
if(beans.getData().getImgPath()!=null&&beans.getData().getImgPath().size()>0)
|
||
{
|
||
imgs.addAll(beans.getData().getImgPath());
|
||
}
|
||
if(beans.getData().getImgPath()!=null)
|
||
{
|
||
for(imBean urlBean:beans.getData().getImgPath())
|
||
{
|
||
mBitmaps.add(new AddBitmaps(false, null, urlBean.getFileUrl()));
|
||
}
|
||
}
|
||
|
||
if (mBitmaps.size() < 9) {
|
||
mBitmaps.add(mAddBitmaps);
|
||
}
|
||
gv_adapter.notifyDataSetChanged();
|
||
|
||
}
|
||
|
||
}
|
||
else if(hasrealtoken(response)==0)
|
||
{
|
||
gettokens(Url.suifangHbvSymbol);
|
||
}
|
||
else if (hasrealtoken(response)==-1)
|
||
{
|
||
statract();
|
||
}
|
||
else
|
||
{
|
||
BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class);
|
||
ToastUtil.showToast(baseBeanNew.getMsg());
|
||
}
|
||
|
||
}
|
||
});
|
||
|
||
}
|
||
public void statract()
|
||
{
|
||
Intent intent=new Intent(HbvdnaActivity.this,ResearchActivity.class);
|
||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||
intent.putExtra("typename","myproject");
|
||
startActivity(intent);
|
||
return;
|
||
}
|
||
String token= SharePrefUtil.getString(getContext(),"x_access_token","");;
|
||
private void gettokens(String url)
|
||
{
|
||
// showProgressDialog("加载中");
|
||
token= SharePrefUtil.getString(getContext(),"x_access_token","");
|
||
if(!StringUtil.isEmpty(token))
|
||
{
|
||
handletoken(url);
|
||
return;
|
||
}
|
||
sendJsonPostParamTokenMD5(HbvdnaActivity.this,new OnCallBackFromNet() {
|
||
@Override
|
||
public void onCallbackFromThread(String resultJson) {
|
||
Log.d("okhttp",resultJson);
|
||
SimpleBean simpleBean = GsonTools.fromGsonToBean(resultJson,SimpleBean.class);
|
||
token=simpleBean.getData();
|
||
if(token==null)
|
||
{
|
||
ToastUtil.showMessage("Token异常");
|
||
return;
|
||
}
|
||
SharePrefUtil.saveString(getContext(),"x_access_token",token);
|
||
handletoken(url);
|
||
}
|
||
|
||
@Override
|
||
public void onCallBackFromThread(String resultJson, int resultCode) {
|
||
|
||
}
|
||
});
|
||
}
|
||
private void handletoken(String url)
|
||
{
|
||
if(url.contains(Url.suifangHbvSymbol))
|
||
{
|
||
gettree();
|
||
}
|
||
else if(url.contains(Url.suifangHbvSymbolupdate))
|
||
{
|
||
updatedata();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||
hideSoftKeyboard();
|
||
if (mBitmaps.get(position).isAdd()) {
|
||
selectedPhotoView = UIUtils.inflate(R.layout.activity_selected_photo2);
|
||
ll_selected_carmera = (TextView) selectedPhotoView
|
||
.findViewById(R.id.btn_camera);
|
||
ll_selected_photo = (TextView) selectedPhotoView
|
||
.findViewById(R.id.btn_img);
|
||
tv_cancel = (TextView) selectedPhotoView
|
||
.findViewById(R.id.btn_cancle);
|
||
ImageView imageView = (ImageView) selectedPhotoView
|
||
.findViewById(R.id.imageView);
|
||
imageView.setOnClickListener(new View.OnClickListener() {
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
// TODO Auto-generated method stub
|
||
if (mPopupWindowDialog != null
|
||
&& mPopupWindowDialog.isShowing()) {
|
||
mPopupWindowDialog.dismiss();
|
||
}
|
||
}
|
||
});
|
||
initSelectedHeadPopupwindow();
|
||
if (mPopupWindowDialog != null) {
|
||
mPopupWindowDialog.showAtLocation(this.view, Gravity.BOTTOM
|
||
| Gravity.CENTER_HORIZONTAL, 0, ImmersionBar.getNavigationBarHeight(this));
|
||
}
|
||
selectedPhoto();
|
||
} else {
|
||
rl_addcase_bigphoto.setVisibility(View.VISIBLE);
|
||
PagerSetAdapter(position);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化头像选择pop
|
||
*/
|
||
private void initSelectedHeadPopupwindow() {
|
||
// TODO Auto-generated method stub
|
||
mPopupWindowDialog = new PopupWindow(selectedPhotoView,
|
||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||
mPopupWindowDialog.setFocusable(true);
|
||
mPopupWindowDialog.update();
|
||
mPopupWindowDialog.setBackgroundDrawable(new BitmapDrawable(
|
||
getResources(), (Bitmap) null));
|
||
mPopupWindowDialog.setOutsideTouchable(true);
|
||
}
|
||
/**
|
||
* 选择图片
|
||
*/
|
||
private void selectedPhoto() {
|
||
// TODO Auto-generated method stub
|
||
|
||
ll_selected_carmera.setOnClickListener(new View.OnClickListener() {
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
// TODO Auto-generated method stub
|
||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||
|
||
if (PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||
//有访问摄像头的权限
|
||
takePhoto11();// 拍照获取
|
||
} else {
|
||
EasyWindow.with(HbvdnaActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||
|
||
.setContentView(R.layout.float_top_dialog_new).show();
|
||
PermissionsUtil.requestPermission(HbvdnaActivity.this, new PermissionListener() {
|
||
@Override
|
||
public void permissionGranted(@NonNull String[] permissions) {
|
||
EasyWindow.cancelAll();
|
||
//用户授予了访问摄像头的权限
|
||
takePhoto11();// 拍照获取
|
||
}
|
||
@Override
|
||
public void permissionDenied(@NonNull String[] permissions) {
|
||
EasyWindow.cancelAll();
|
||
//用户拒绝了访问摄像头的申请
|
||
|
||
}
|
||
|
||
}, new String[]{ Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||
}
|
||
|
||
}else {
|
||
takePhoto();// 拍照获取
|
||
}
|
||
|
||
|
||
|
||
}
|
||
});
|
||
|
||
ll_selected_photo.setOnClickListener(new View.OnClickListener() {
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
// TODO Auto-generated method
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||
if (PermissionsUtil.hasPermission(HbvdnaActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||
//有访问摄像头的权限,读写内存,网络定位,打电话,读取短信,录音,通讯录
|
||
Intent intent = new Intent(mActivity, PhotoAlbumActivity.class);
|
||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||
intent.putExtra("maxphotonum",9);
|
||
startActivityForResult(intent,
|
||
SELECT_PIC_BY_PICK_PHOTO);
|
||
} else {
|
||
EasyWindow.with(HbvdnaActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||
|
||
.setContentView(R.layout.float_top_dialog_photo).show();
|
||
PermissionsUtil.requestPermission(HbvdnaActivity.this, new PermissionListener() {
|
||
@Override
|
||
public void permissionGranted(@NonNull String[] permissions) {
|
||
EasyWindow.cancelAll();
|
||
Intent intent = new Intent(HbvdnaActivity.this, PhotoAlbumActivity.class);
|
||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||
intent.putExtra("maxphotonum",9);
|
||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||
|
||
}
|
||
@Override
|
||
public void permissionDenied(@NonNull String[] permissions) {
|
||
EasyWindow.cancelAll();
|
||
//用户拒绝了访问读写的申请
|
||
|
||
|
||
}
|
||
|
||
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
||
}
|
||
|
||
}else {
|
||
Intent intent = new Intent(HbvdnaActivity.this, PhotoAlbumActivity.class);
|
||
intent.putExtra("photonum", "" + (mBitmaps.size() - 1));
|
||
intent.putExtra("maxphotonum",9);
|
||
startActivityForResult(intent,SELECT_PIC_BY_PICK_PHOTO);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
});
|
||
tv_cancel.setOnClickListener(new View.OnClickListener() {
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
// TODO Auto-generated method stub
|
||
if (mPopupWindowDialog != null
|
||
&& mPopupWindowDialog.isShowing()) {
|
||
mPopupWindowDialog.dismiss();
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
private void takePhoto11() {
|
||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// 设置打开相机
|
||
|
||
File photoFile = null;
|
||
try {
|
||
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); // 保存到公共共享空间内,可以在资源管理器中找到,其他应用也可以直接访问
|
||
// File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES); 将图片放到应用专属空间内,其他的应用无法访问,也无法查看。随app的卸载而删除
|
||
String imageFileName = "fileName";
|
||
photoFile = File.createTempFile(imageFileName, ".jpg", storageDir);
|
||
// String filePath = photoFile.getAbsolutePath(); 获取到图片的路径,可以在onActivityResult中根据这个路径去获取图片
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
if (photoFile != null) {
|
||
photoUri = FileProvider.getUriForFile(this,getPackageName() + ".fileprovider",
|
||
photoFile);
|
||
SharePrefUtil.saveString(this, "photoUri",
|
||
photoUri + "");
|
||
|
||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||
intent.putExtra(MediaStore.EXTRA_OUTPUT,
|
||
FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + ".fileprovider", photoFile));
|
||
|
||
startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO);
|
||
}
|
||
}
|
||
/**
|
||
* 拍照获取图片
|
||
*/
|
||
private void takePhoto() {
|
||
|
||
String fileName = null;
|
||
// 执行拍照前,应该先判断SD卡是否存在
|
||
String SDState = Environment.getExternalStorageState();
|
||
if (SDState.equals(Environment.MEDIA_MOUNTED)) {
|
||
|
||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE"调用系统的相机
|
||
fileName = String.valueOf(System.currentTimeMillis()) + ".jpg";
|
||
photoUri = getUriForFile(HbvdnaActivity.this,new File(Environment.getExternalStorageDirectory(), fileName));
|
||
// photoUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), fileName));
|
||
// 指定照片保存路径(SD卡),image.jpg为一个临时文件,每次拍照后这个图片都会被替换
|
||
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
|
||
SharePrefUtil.saveString(HbvdnaActivity.this,
|
||
"photoUri", photoUri + "");
|
||
startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO);
|
||
} else {
|
||
Toast.makeText(this, "内存卡不存在", Toast.LENGTH_LONG).show();
|
||
}
|
||
}
|
||
public static Uri getUriForFile(Context context, File file) {
|
||
if (context == null || file == null) {
|
||
throw new NullPointerException();
|
||
}
|
||
Uri uri;
|
||
if (Build.VERSION.SDK_INT >= 24) {
|
||
uri = FileProvider.getUriForFile(context.getApplicationContext(), "cn.shangyu.gdxzExpert.fileprovider", file);
|
||
} else {
|
||
uri = Uri.fromFile(file);
|
||
}
|
||
return uri;
|
||
}
|
||
public void PagerSetAdapter(int p) {
|
||
layout_top.setVisibility(View.GONE);
|
||
mPager.setPageMargin((int) (getResources().getDisplayMetrics().density * 15));
|
||
mPager.setAdapter(new PagerAdapter() {
|
||
@Override
|
||
public int getCount() {
|
||
for (int i = 0; i < mBitmaps.size(); i++) {
|
||
if (mBitmaps.get(i).isAdd()) {
|
||
return mBitmaps.size() - 1;
|
||
}
|
||
}
|
||
return mBitmaps.size();
|
||
}
|
||
|
||
@Override
|
||
public boolean isViewFromObject(View view, Object object) {
|
||
return view == object;
|
||
}
|
||
|
||
@Override
|
||
public Object instantiateItem(ViewGroup container, int position) {
|
||
PhotoView view = new PhotoView(HbvdnaActivity.this);
|
||
view.enable();
|
||
view.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||
if (!mBitmaps.get(position).isAdd()) {
|
||
if(!StringUtil.isEmpty(mBitmaps.get(position).getPath()))
|
||
{
|
||
Glide.with(HbvdnaActivity.this).asBitmap().load(mBitmaps.get(position).getPath())
|
||
.apply(new RequestOptions().error(R.drawable.home_scroll_default))
|
||
.into(view);
|
||
}
|
||
else
|
||
{
|
||
view.setImageBitmap(mBitmaps.get(position).getBitmap());
|
||
}
|
||
|
||
}
|
||
view.setOnClickListener(new View.OnClickListener() {
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
// TODO Auto-generated method stub
|
||
rl_addcase_bigphoto.setVisibility(View.GONE);
|
||
layout_top.setVisibility(View.VISIBLE);
|
||
}
|
||
});
|
||
container.addView(view);
|
||
return view;
|
||
}
|
||
|
||
@Override
|
||
public void destroyItem(ViewGroup container, int position,
|
||
Object object) {
|
||
container.removeView((View) object);
|
||
}
|
||
});
|
||
mPager.setCurrentItem(p);
|
||
}
|
||
private ArrayList<PhotoItem> paths;
|
||
@Override
|
||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||
// TODO Auto-generated method stub
|
||
super.onActivityResult(requestCode, resultCode, data);
|
||
if (mPopupWindowDialog != null && mPopupWindowDialog.isShowing()) {
|
||
mPopupWindowDialog.dismiss();
|
||
}
|
||
LogUtil.i("requestCode = "+requestCode);
|
||
switch (requestCode) {
|
||
case SELECT_PIC_BY_PICK_PHOTO:
|
||
if (data == null) {
|
||
break;
|
||
}
|
||
paths = (ArrayList<PhotoItem>) data.getSerializableExtra("photos");
|
||
mBitmaps.remove(mAddBitmaps);
|
||
showProgressDialog("");
|
||
new Thread() {
|
||
public void run() {
|
||
for (int i = 0; i < paths.size(); i++) {
|
||
InputStream is;
|
||
try {
|
||
is = new FileInputStream(paths.get(i).getPath());
|
||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||
// opts.inJustDecodeBounds = true;
|
||
opts.inTempStorage = new byte[100 * 1024];
|
||
opts.inPreferredConfig = Bitmap.Config.RGB_565;
|
||
opts.inPurgeable = true;
|
||
BitmapFactory.decodeFile(paths.get(i).getPath(),
|
||
opts);
|
||
opts.inSampleSize = calculateInSampleSize(opts,
|
||
720, 1280);
|
||
opts.inInputShareable = true;
|
||
Bitmap bitmap = BitmapFactory.decodeStream(is,
|
||
null, opts);
|
||
mBitmaps.add(new AddBitmaps(false, bitmap, null));
|
||
|
||
} catch (FileNotFoundException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
|
||
}
|
||
handler.sendEmptyMessage(HANDLER_PHOTOS);
|
||
};
|
||
}.start();
|
||
break;
|
||
case SELECT_PIC_BY_TACK_PHOTO:
|
||
photoUri = Uri.parse(SharePrefUtil.getString(
|
||
HbvdnaActivity.this, "photoUri", ""));
|
||
|
||
if (photoUri == null) {
|
||
Toast.makeText(this, "选择图片文件出错", Toast.LENGTH_LONG).show();
|
||
return;
|
||
}
|
||
cropImage(photoUri);
|
||
break;
|
||
case PHOTO_RESOULT:
|
||
Bundle d = data.getExtras();
|
||
if (d != null) {
|
||
Bitmap bm = d.getParcelable("data");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("MMddhhmmss");
|
||
Date dt = new Date();
|
||
String picN = "cy" + sdf.format(dt) + ".jpg";
|
||
temp = new File(this.getCacheDir(), picN);// 放到
|
||
if (temp.exists())
|
||
temp.delete();
|
||
try {
|
||
temp.createNewFile();
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
try {
|
||
bm.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(
|
||
temp));
|
||
} catch (FileNotFoundException e) {
|
||
e.printStackTrace();
|
||
}
|
||
|
||
if (!bm.isRecycled()) {
|
||
bm.recycle();
|
||
bm = null;
|
||
}
|
||
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
public static int calculateInSampleSize(BitmapFactory.Options options,
|
||
int reqWidth, int reqHeight) {
|
||
|
||
final int height = options.outHeight;
|
||
|
||
final int width = options.outWidth;
|
||
|
||
int inSampleSize = 1;
|
||
|
||
if (height > reqHeight || width > reqWidth) {
|
||
|
||
final int heightRatio = Math.round((float) height
|
||
/ (float) reqHeight);
|
||
|
||
final int widthRatio = Math.round((float) width / (float) reqWidth);
|
||
|
||
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
|
||
|
||
}
|
||
|
||
return inSampleSize;
|
||
|
||
}
|
||
private void cropImage(Uri uri) {
|
||
ImageLoader.getInstance().loadImage(photoUri + "",
|
||
new SimpleImageLoadingListener() {
|
||
@Override
|
||
public void onLoadingComplete(String imageUri, View view,
|
||
Bitmap loadedImage) {
|
||
// TODO Auto-generated method stub
|
||
super.onLoadingComplete(imageUri, view, loadedImage);
|
||
|
||
// 拍照图片压缩
|
||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||
loadedImage.compress(Bitmap.CompressFormat.JPEG, 100,
|
||
stream);
|
||
try {
|
||
int options = 100;
|
||
while (stream.toByteArray().length / 1024 > 500) {// 判断如果图片大于500kb,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
|
||
if (options > 0) {
|
||
options -= 10;
|
||
}
|
||
stream.reset();// 重置baos即清空baos
|
||
loadedImage.compress(
|
||
Bitmap.CompressFormat.JPEG, options,
|
||
stream);// 这里压缩50%,把压缩后的数据存放到baos中
|
||
if (stream.toByteArray().length / 1024 < 500) {
|
||
break;
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
mBitmaps.remove(mAddBitmaps);
|
||
mBitmaps.add(new AddBitmaps(false, loadedImage, null));
|
||
if (mBitmaps.size() < 9) {
|
||
mBitmaps.add(mAddBitmaps);
|
||
}
|
||
gv_adapter.notifyDataSetChanged();
|
||
}
|
||
});
|
||
}
|
||
private static final int HANDLER_PHOTOS = 3;
|
||
private Handler handler = new Handler() {
|
||
public void handleMessage(android.os.Message msg) {
|
||
switch (msg.what) {
|
||
case HANDLER_PHOTOS:
|
||
if (mBitmaps.size() < 9) {
|
||
mBitmaps.add(mAddBitmaps);
|
||
}
|
||
closeProgressDialog();
|
||
gv_adapter.notifyDataSetChanged();
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
};
|
||
};
|
||
|
||
private void sendpre()
|
||
{
|
||
if(hbsag.getText()!=null&&!StringUtil.isEmpty(hbsag.getText().toString()))
|
||
{
|
||
if ("1".equals(type))
|
||
{
|
||
if(hbsag.getText().toString().contains("."))
|
||
{
|
||
String ed[]=hbsag.getText().toString().split("\\.");
|
||
if(Integer.valueOf(ed[0])>2000||ed.length>1&&(Integer.valueOf(ed[0])==2000&&!StringUtil.isEmpty(ed[1]))&&Integer.valueOf(ed[1])>0)
|
||
{
|
||
hbsag.setTextColor(Color.RED);
|
||
ToastUtil.showToast("乙型肝炎表面抗原大于2000lU/mL,该患者不合格");
|
||
return;
|
||
}
|
||
|
||
}
|
||
else if(Integer.valueOf(hbsag.getText().toString())>2000)
|
||
{
|
||
hbsag.setTextColor(Color.RED);
|
||
ToastUtil.showToast("乙型肝炎表面抗原大于2000lU/mL,该患者不合格");
|
||
return;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
ToastUtil.showToast("乙型肝炎表面抗原为必填项");
|
||
return;
|
||
}
|
||
if(StringUtil.isEmpty(antiHbs.getText().toString()))
|
||
{
|
||
ToastUtil.showToast("乙型肝炎表面抗体为必填项");
|
||
return;
|
||
}
|
||
if(StringUtil.isEmpty(hbeag.getText().toString()))
|
||
{
|
||
ToastUtil.showToast("乙型肝炎e抗原为必填项");
|
||
return;
|
||
}
|
||
if(StringUtil.isEmpty(antiHbe.getText().toString()))
|
||
{
|
||
ToastUtil.showToast("乙型肝炎e抗体为必填项");
|
||
return;
|
||
}
|
||
if(((RadioButton)view.findViewById(R.id.tab_rbn_121)).isChecked()||
|
||
((RadioButton)view.findViewById(R.id.tab_rbn_122)).isChecked())
|
||
{
|
||
|
||
}
|
||
else
|
||
{
|
||
ToastUtil.showToast("e抗原是否阳性为必填项");
|
||
return;
|
||
}
|
||
if(StringUtil.isEmpty(hbvDna.getText().toString()))
|
||
{
|
||
ToastUtil.showToast("HBV-DNA为必填项");
|
||
return;
|
||
}
|
||
if (mBitmaps.contains(mAddBitmaps)) {
|
||
mBitmaps.remove(mAddBitmaps);
|
||
}
|
||
Log.d("okhttp",""+imgs.size()+" "+mBitmaps.size());
|
||
if(imgs.size()==mBitmaps.size()||mBitmaps.size()==0)
|
||
{
|
||
updatedata();
|
||
}
|
||
else
|
||
{
|
||
new Thread(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
for(AddBitmaps bitmaps:mBitmaps)
|
||
{
|
||
if (!StringUtil.isEmpty(bitmaps.getPath()))
|
||
{
|
||
continue;
|
||
}
|
||
String path="android"+System.currentTimeMillis();
|
||
Base64Util.saveBitmapAsJpg(bitmaps.getBitmap(),path);
|
||
sendimg(path+".jpg");
|
||
}
|
||
}
|
||
}).start();
|
||
}};
|
||
private void sendimg(String fileKey)
|
||
{
|
||
|
||
Map<String, String> paras=new HashMap<>();
|
||
paras.put("fileKey",fileKey);
|
||
Map<String, String> headers=new HashMap<>();
|
||
headers.put("x-access-token",token);
|
||
headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName());
|
||
String url1 = Url.generatePresignedUrl;
|
||
OkHttpUtils
|
||
.get()
|
||
.url(url1)
|
||
.params(paras)
|
||
.headers(headers)
|
||
.build()
|
||
.execute(new StringCallback()
|
||
{
|
||
|
||
@Override
|
||
public void onError(Call call, Exception e, int id) {
|
||
Log.d("okhttp",e.toString());
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onResponse(String response, int id) {
|
||
Log.d("okhttp",response+"sendimg");
|
||
|
||
if(hasrealtoken(response)>0)
|
||
{
|
||
SimpleBean bean=GsonTools.fromGsonToBean(response,SimpleBean.class);
|
||
if(bean.getData()!=null)
|
||
{
|
||
new Thread(
|
||
new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
postfile(bean.getData(),fileKey);
|
||
}
|
||
}
|
||
).start();
|
||
}
|
||
}
|
||
else if(hasrealtoken(response)==0)
|
||
{
|
||
gettokens(fileKey);
|
||
}
|
||
else if (hasrealtoken(response)==-1)
|
||
{
|
||
statract();
|
||
}
|
||
else
|
||
{
|
||
BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class);
|
||
ToastUtil.showToast(baseBeanNew.getMsg());
|
||
}
|
||
|
||
}
|
||
});
|
||
}
|
||
public void postfile( String url, String localFile)
|
||
{
|
||
|
||
File file1 = BaseApplication.getInstance()
|
||
.getApplicationContext().getExternalFilesDir("");
|
||
// 上传文件的URL
|
||
File file = new File(file1,localFile);
|
||
String contentType = "application/gdxz-stream";
|
||
// 通过签名URL上传文件。
|
||
OkHttpClient client = new OkHttpClient();
|
||
Request putRequest = new Request.Builder()
|
||
.url(url)
|
||
.put(RequestBody.create(MediaType.parse(contentType), file))
|
||
.build();
|
||
client.newCall(putRequest).enqueue(new okhttp3.Callback() {
|
||
|
||
|
||
@Override
|
||
public void onFailure(Call call, IOException e) {
|
||
e.printStackTrace();
|
||
Log.d("okhttp ","IOException "+ e.toString());
|
||
|
||
String str=url.split("\\?")[0];
|
||
Log.d("okhttp ","str "+ str);
|
||
imBean tag=new imBean();
|
||
tag.setFileUrl(str);
|
||
tag.setFileKey(str.replace("http://realyworld.oss-cn-beijing.aliyuncs.com/",""));
|
||
imgs.add(tag);
|
||
if(imgs.size()==mBitmaps.size())
|
||
{
|
||
updatedata();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onResponse(Call call, Response response) throws IOException {
|
||
Log.d("okhttp ","response "+ response);
|
||
String str=url.split("\\?")[0];
|
||
Log.d("okhttp ","str "+ str);
|
||
imBean tag=new imBean();
|
||
tag.setFileUrl(str);
|
||
|
||
tag.setFileKey(str.replace("http://realyworld.oss-cn-beijing.aliyuncs.com/",""));
|
||
imgs.add(tag);
|
||
Log.d("okhttp ","imgs "+ imgs.size()+" "+mBitmaps.size());
|
||
if(imgs.size()==mBitmaps.size())
|
||
{
|
||
updatedata();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
private void updatedata()
|
||
{
|
||
hbvSymbolIdBean pro=new hbvSymbolIdBean();
|
||
// if(!StringUtil.isEmpty(beans.getData().getHbsag()))
|
||
// {
|
||
pro.setHbsag(hbsag.getText().toString());
|
||
// hbsag.setText(beans.getData().getHbsag());
|
||
// }
|
||
// if(!StringUtil.isEmpty(beans.getData().getAntiHbs()))
|
||
// {
|
||
pro.setAntiHbs(antiHbs.getText().toString());
|
||
// antiHbs.setText(beans.getData().getAntiHbs());
|
||
// }
|
||
// if(!StringUtil.isEmpty(beans.getData().getHbeag()))
|
||
// {
|
||
pro.setHbeag(hbeag.getText().toString());
|
||
// hbeag.setText(beans.getData().getHbeag());
|
||
// }
|
||
// if(!StringUtil.isEmpty(beans.getData().getAntiHbe()))
|
||
// {
|
||
pro.setAntiHbe(antiHbe.getText().toString());
|
||
// antiHbe.setText(beans.getData().getAntiHbe());
|
||
// }
|
||
if(((RadioButton)view.findViewById(R.id.tab_rbn_122)).isChecked())
|
||
{
|
||
pro.setHbeagFalg("0");
|
||
// ((RadioButton)view.findViewById(R.id.tab_rbn_122)).setChecked(true);
|
||
}
|
||
else if(((RadioButton)view.findViewById(R.id.tab_rbn_121)).isChecked())
|
||
{
|
||
pro.setHbeagFalg("1");
|
||
// ((RadioButton)view.findViewById(R.id.tab_rbn_121)).setChecked(true);
|
||
}
|
||
// if(!StringUtil.isEmpty(beans.getData().getHbvDna()))
|
||
// {
|
||
pro.setHbvDna(hbvDna.getText().toString());
|
||
// hbvDna.setText(beans.getData().getHbvDna());
|
||
// }
|
||
if(baseinfoDataStatus!=null)
|
||
{
|
||
pro.setDataStatus(baseinfoDataStatus);
|
||
}
|
||
pro.setImgPath(imgs);
|
||
pro.setHbvSymbolId(hbvSymbolId);
|
||
Map<String, String> headers=new HashMap<>();
|
||
headers.put("x-access-token",token);
|
||
headers.put("User-Agent", WebSettings.getDefaultUserAgent(UIUtils.getContext())+" "+ UpdateVersionUtils.getVersionName());
|
||
Log.d("okhttp",""+new Gson().toJson(pro));
|
||
OkHttpUtils
|
||
.postString()
|
||
.url(Url.suifangHbvSymbolupdate)
|
||
.headers(headers)
|
||
.content(new Gson().toJson(pro))
|
||
.mediaType(MediaType.parse("application/json; charset=utf-8"))
|
||
.build()
|
||
.execute(new StringCallback()
|
||
{
|
||
|
||
@Override
|
||
public void onError(Call call, Exception e, int id) {
|
||
Log.d("okhttp",e.toString());
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onResponse(String response, int id) {
|
||
Log.d("okhttp",response+"response");
|
||
|
||
if(hasrealtoken(response)>0)
|
||
{
|
||
finish();
|
||
}
|
||
else if(hasrealtoken(response)==0)
|
||
{
|
||
gettokens(Url.suifangHbvSymbolupdate);
|
||
}
|
||
else if (hasrealtoken(response)==-1)
|
||
{
|
||
statract();
|
||
}
|
||
else
|
||
{
|
||
BaseBeanNew baseBeanNew=GsonTools.fromGsonToBean(response,BaseBeanNew.class);
|
||
ToastUtil.showToast(baseBeanNew.getMsg());
|
||
|
||
// ToastUtil.showToast(response);
|
||
}
|
||
|
||
}
|
||
});
|
||
}
|
||
} |