正在查看: 爱心e站 v1.0.0 应用的 ActivityRehabilitationMonthSign.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 爱心e站 v1.0.0 应用的 ActivityRehabilitationMonthSign.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.newheyd.JZKFcanjiren.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.igexin.assist.sdk.AssistPushConsts;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.Bean.AvatarBean;
import com.newheyd.JZKFcanjiren.Bean.FuJianBean;
import com.newheyd.JZKFcanjiren.Bean.MessageEvent;
import com.newheyd.JZKFcanjiren.Bean.RehabilitationMonthSignBean;
import com.newheyd.JZKFcanjiren.Bean.UserInfo;
import com.newheyd.JZKFcanjiren.LargerPhoto.ShowLargerPhotoActivity;
import com.newheyd.JZKFcanjiren.MyApplication;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.FileUtil;
import com.newheyd.JZKFcanjiren.Utils.ImageUtil;
import com.newheyd.JZKFcanjiren.Utils.TextUtil;
import com.newheyd.JZKFcanjiren.Utils.ToastUtils;
import com.newheyd.JZKFcanjiren.View.PhotoSelect.entity.Photo;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.config.NewHYConfig;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.model.DataParser;
import com.newheyd.JZKFcanjiren.net.AttachUploadTask;
import com.newheyd.JZKFcanjiren.net.CommonDataListTask;
import com.newheyd.JZKFcanjiren.net.CommonTask;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import com.newheyd.JZKFcanjiren.net.RequestServiceList;
import java.util.ArrayList;
import java.util.HashMap;
import org.greenrobot.eventbus.EventBus;
public class ActivityRehabilitationMonthSign extends BaseActivity implements View.OnClickListener {
private static final String SIGN_STYLE = "attendanceConfirm";
private String id;
private String imageUrl;
private Button mBtnUpload;
private ImageView mIvSignShow;
private TitleView mTitleviewService;
private TextView mTvDelete;
private TextView mTvIdcard;
private TextView mTvMonth;
private TextView mTvName;
private TextView mTvSign;
private TextView mTvState;
private TextView mTvYear;
private String serviceId;
private ArrayList<Photo> mPhotoTotal = new ArrayList<>();
private Photo uploadPhoto = null;
private Photo uploadedPhoto = null;
private RehabilitationMonthSignBean rehabilitationMonthSignBean = null;
private UserInfo userInfo = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_relabilitation_month_sign);
super.onCreate(savedInstanceState);
this.userInfo = MyApplication.getInstance().getUserInfo();
getMonthSign();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1 && resultCode == -1) {
this.imageUrl = data.getStringExtra("imageUrl");
if (this.imageUrl != null && this.imageUrl.length() > 0) {
this.mIvSignShow.setVisibility(0);
this.mTvDelete.setVisibility(0);
this.mTvSign.setVisibility(8);
this.mIvSignShow.setImageResource(0);
Glide.with(this.mContext).load(this.imageUrl).into(this.mIvSignShow);
this.mPhotoTotal.clear();
Photo photo = new Photo(this.imageUrl);
photo.setStyle(SIGN_STYLE);
this.mPhotoTotal.add(photo);
return;
}
this.mIvSignShow.setVisibility(8);
this.mTvDelete.setVisibility(8);
this.mTvSign.setVisibility(0);
}
}
public void getMonthSign() {
HashMap<String, String> params = new HashMap<>();
params.put("id", this.id);
params.put(AssistPushConsts.MSG_TYPE_TOKEN, this.userInfo == null ? "" : this.userInfo.getToken());
NewHYTask task = new CommonDataListTask(RequestServiceList.ATTENDANCECONFIRM_PREADD, params, RehabilitationMonthSignBean.class);
executeRequest(task);
}
public void monthSignAdd() {
HashMap<String, String> params = new HashMap<>();
params.put("serviceId", this.serviceId);
params.put("id", this.id);
params.put("name", this.rehabilitationMonthSignBean.getName());
params.put("citizenId", this.rehabilitationMonthSignBean.getCitizenId());
params.put("areaCode", this.rehabilitationMonthSignBean.getAreaCode());
params.put("year", this.rehabilitationMonthSignBean.getYear());
params.put("month", this.rehabilitationMonthSignBean.getMonth());
params.put(AssistPushConsts.MSG_TYPE_TOKEN, this.userInfo == null ? "" : this.userInfo.getToken());
NewHYTask task = new CommonDataListTask(RequestServiceList.ATTENDANCECONFIRM_ADD, params, RehabilitationMonthSignBean.class);
executeRequest(task);
}
public void postFileToServer(Photo uploadPhoto) {
HashMap<String, String> params = new HashMap<>();
HashMap<String, String> imgParms = new HashMap<>();
params.put("relationId", this.rehabilitationMonthSignBean.getId());
params.put("style", uploadPhoto.getStyle());
params.put(AssistPushConsts.MSG_TYPE_TOKEN, this.userInfo == null ? "" : this.userInfo.getToken());
imgParms.put("uploadifyphoto", uploadPhoto.getUri());
NewHYTask filePostTask = new AttachUploadTask(RequestServiceList.ATTACHMENT_UPLOAD, params, imgParms, new HashMap());
executeRequest(filePostTask);
}
public void getAttchFile(String id) {
if (!TextUtil.isEmpty(id)) {
HashMap<String, String> params = new HashMap<>();
params.put(AssistPushConsts.MSG_TYPE_TOKEN, this.userInfo == null ? "" : this.userInfo.getToken());
params.put("relationId", id);
params.put("style", SIGN_STYLE);
NewHYTask getFileTask = new CommonDataListTask(RequestServiceList.ATTACHMENT_CALLBACK, params, FuJianBean.class);
executeRequest(getFileTask);
}
}
public void attachmentDel() {
ChoiceTishiDialog("您确定删除签名吗?", false, new BaseActivity.OnChoiceDialogYes() {
@Override
public void onChoiceDialogYes(DialogInterface dialogInterface, int i) {
ActivityRehabilitationMonthSign.this.deleteAttchFile();
}
}, new BaseActivity.OnChoiceDialogNo() {
@Override
public void onChoiceDialogNo(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
}
public void deleteAttchFile() {
HashMap<String, String> params = new HashMap<>();
params.put(AssistPushConsts.MSG_TYPE_TOKEN, this.userInfo == null ? "" : this.userInfo.getToken());
params.put("id", this.uploadedPhoto.getId());
params.put("style", this.uploadedPhoto.getStyle());
CommonTask getFileTask = new CommonTask(RequestServiceList.ATTACHMENT_DELETE, params);
executeRequest(getFileTask);
}
@Override
public void onResponseBefore(NewHYTask task) {
switch (task.getService()) {
case ATTENDANCECONFIRM_PREADD:
case ATTACHMENT_UPLOAD:
case ATTACHMENT_CALLBACK:
case ATTACHMENT_DELETE:
case ATTENDANCECONFIRM_ADD:
showProgress(NewHYConfig.LOADING_HINT, false);
break;
}
}
@Override
public void onResponseAfter(NewHYTask task) {
switch (task.getService()) {
case ATTENDANCECONFIRM_PREADD:
case ATTACHMENT_UPLOAD:
case ATTACHMENT_CALLBACK:
case ATTACHMENT_DELETE:
case ATTENDANCECONFIRM_ADD:
cancleProgress();
break;
}
}
@Override
public void onResponseSuccessful(NewHYTask task, BaseResult object) {
FuJianBean bean;
switch (task.getService()) {
case ATTENDANCECONFIRM_PREADD:
DataParser<RehabilitationMonthSignBean> mResult = (DataParser) object;
if (mResult.getObjects().size() > 0) {
this.rehabilitationMonthSignBean = mResult.getObjects().get(0);
freshData();
break;
}
break;
case ATTACHMENT_UPLOAD:
this.mPhotoTotal.remove(0);
if (this.mPhotoTotal == null || this.mPhotoTotal.size() == 0) {
MessageEvent event = new MessageEvent("签名上传成功", NewHYConfig.SIGN_UPLOAD_SUCCDSS);
EventBus.getDefault().post(event);
ToastUtils.showLongToast(this.mContext, "签名上传成功");
this.mTitleviewService.postDelayed(new Runnable() {
@Override
public void run() {
ActivityRehabilitationMonthSign.this.finish();
}
}, 300L);
break;
} else {
this.uploadPhoto = this.mPhotoTotal.get(0);
postFileToServer(this.uploadPhoto);
break;
}
break;
case ATTACHMENT_CALLBACK:
DataParser<FuJianBean> mResultList = (DataParser) object;
ArrayList<FuJianBean> fuJianList = mResultList.getObjects();
if (fuJianList.size() != 0) {
for (int i = 0; i < fuJianList.size(); i++) {
bean = fuJianList.get(i);
switch (bean.style) {
case "attendanceConfirm":
this.uploadedPhoto = new Photo(bean.getId(), NewHYConfig.ROOT + bean.getFilePath() + bean.getNewFileName(), bean.getFileName());
this.uploadedPhoto.setStyle(SIGN_STYLE);
break;
}
}
freshSign();
break;
}
break;
case ATTACHMENT_DELETE:
this.uploadedPhoto = null;
this.mIvSignShow.setImageResource(0);
this.mIvSignShow.setVisibility(8);
this.mTvDelete.setVisibility(8);
this.mTvSign.setVisibility(0);
break;
case ATTENDANCECONFIRM_ADD:
DataParser<RehabilitationMonthSignBean> mResultAttach = (DataParser) object;
if (mResultAttach.getObjects().size() > 0) {
this.rehabilitationMonthSignBean = mResultAttach.getObjects().get(0);
if (this.mPhotoTotal.size() > 0) {
this.uploadPhoto = this.mPhotoTotal.get(0);
postFileToServer(this.uploadPhoto);
break;
}
}
break;
}
}
public void freshSign() {
if (this.uploadedPhoto != null && !isNull(this.uploadedPhoto.getUri())) {
this.mIvSignShow.setVisibility(0);
this.mTvSign.setVisibility(8);
Glide.with(this.mContext).load(this.uploadedPhoto.uri).into(this.mIvSignShow);
} else {
this.mIvSignShow.setVisibility(8);
this.mTvDelete.setVisibility(8);
this.mTvSign.setVisibility(0);
}
}
public void freshData() {
String stateName;
this.mTvName.setText("姓名:" + this.rehabilitationMonthSignBean.getName());
String state = this.rehabilitationMonthSignBean.getState();
if ("1".equals(state)) {
stateName = "未签名";
this.mTvState.setTextColor(this.mContext.getResources().getColor(R.color.main_color));
} else {
stateName = "已签名";
this.mTvState.setTextColor(this.mContext.getResources().getColor(R.color.text_color_gray_darker));
}
this.mTvState.setText(stateName);
this.mTvIdcard.setText("身份证号:" + this.rehabilitationMonthSignBean.getCitizenId());
this.mTvMonth.setText("月度:" + this.rehabilitationMonthSignBean.getMonth());
this.mTvYear.setText("年度:" + this.rehabilitationMonthSignBean.getYear());
if ("1".equals(state)) {
this.mBtnUpload.setVisibility(0);
freshSign();
} else {
this.mBtnUpload.setVisibility(8);
getAttchFile(this.id);
}
}
@Override
public void onResponseError(NewHYTask task, BaseResult object) {
switch (task.getService()) {
case ATTENDANCECONFIRM_PREADD:
case ATTACHMENT_UPLOAD:
case ATTACHMENT_CALLBACK:
case ATTACHMENT_DELETE:
case ATTENDANCECONFIRM_ADD:
ToastUtils.showLongToast(this.mContext, object.getMsg());
break;
}
}
@Override
public void onServerError(NewHYTask task, int failedType) {
switch (task.getService()) {
case ATTENDANCECONFIRM_PREADD:
case ATTACHMENT_UPLOAD:
case ATTACHMENT_CALLBACK:
case ATTACHMENT_DELETE:
case ATTENDANCECONFIRM_ADD:
onResultShow(failedType);
break;
}
}
@Override
public void initViews() {
this.mTitleviewService = (TitleView) findViewById(R.id.titleview_service);
this.mTvName = (TextView) findViewById(R.id.tv_name);
this.mTvState = (TextView) findViewById(R.id.tv_state);
this.mTvIdcard = (TextView) findViewById(R.id.tv_idcard);
this.mTvYear = (TextView) findViewById(R.id.tv_year);
this.mTvMonth = (TextView) findViewById(R.id.tv_month);
this.mTvSign = (TextView) findViewById(R.id.tv_sign);
this.mIvSignShow = (ImageView) findViewById(R.id.iv_showsign);
this.mTvDelete = (TextView) findViewById(R.id.tv_delete);
this.mBtnUpload = (Button) findViewById(R.id.btn_upload);
}
@Override
public void getExtraParam() {
this.id = getIntent().getStringExtra("id");
this.serviceId = getIntent().getStringExtra("serviceId");
}
@Override
public void setListener() {
this.mTitleviewService.setOnTitleClik(new TitleView.BackListenner() {
@Override
public void BackSet() {
ActivityRehabilitationMonthSign.this.finish();
}
}, null);
this.mTvSign.setOnClickListener(this);
this.mIvSignShow.setOnClickListener(this);
this.mTvDelete.setOnClickListener(this);
this.mBtnUpload.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tv_sign:
Intent intentSign = new Intent(this.mContext, (Class<?>) SignViewActivity.class);
startActivityForResult(intentSign, 1);
break;
case R.id.iv_showsign:
ArrayList<AvatarBean> photos = new ArrayList<>();
AvatarBean avatarBean = null;
if (this.uploadedPhoto != null) {
avatarBean = new AvatarBean(this.uploadedPhoto.getUri());
} else if (!isNull(this.imageUrl)) {
avatarBean = new AvatarBean(this.imageUrl);
avatarBean.setLocal(true);
}
if (avatarBean != null) {
photos.add(avatarBean);
Intent intent = new Intent(this.mContext, (Class<?>) ShowLargerPhotoActivity.class);
intent.putExtra("position", 0);
intent.putExtra("photos", photos);
startActivity(intent);
break;
}
break;
case R.id.tv_delete:
if (this.uploadedPhoto != null && !isNull(this.uploadedPhoto.getId())) {
attachmentDel();
} else if (!isNull(this.imageUrl)) {
ImageUtil.deleteTempFile(this.mContext);
FileUtil.deleteFile(this.imageUrl);
this.mIvSignShow.setVisibility(8);
this.mTvDelete.setVisibility(8);
this.mTvSign.setVisibility(0);
this.mPhotoTotal.clear();
}
this.imageUrl = "";
break;
case R.id.btn_upload:
doUpload();
break;
}
}
public void doUpload() {
if (this.mPhotoTotal.size() == 0) {
ToastUtils.showLongToast(this.mContext, "请输入手写签名!");
} else {
ChoiceTishiDialog("确定上传手写签名吗?", false, new BaseActivity.OnChoiceDialogYes() {
@Override
public void onChoiceDialogYes(DialogInterface dialogInterface, int i) {
ActivityRehabilitationMonthSign.this.monthSignAdd();
}
}, new BaseActivity.OnChoiceDialogNo() {
@Override
public void onChoiceDialogNo(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
}
}
}