|
|
@@ -1,22 +1,25 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.activity.oa;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
-import android.content.DialogInterface;
|
|
|
+import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.AsyncTask;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
-import android.support.v7.app.AlertDialog;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextWatcher;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
-import android.view.WindowManager;
|
|
|
+import android.view.inputmethod.InputMethodManager;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -73,6 +76,7 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
private ImageView image;
|
|
|
private String baseUrl;
|
|
|
private Uri mNewPhotoUri;
|
|
|
+ private int mo_id = 0;
|
|
|
private boolean isSubmit = false;
|
|
|
|
|
|
@Override
|
|
|
@@ -97,25 +101,14 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
if (!StringUtils.isEmpty(path) && new File(path).isFile())
|
|
|
uploadFile(path);
|
|
|
else
|
|
|
- CodeUtil.getInstance().getCode(ct, "mobile_outsign", new CodeUtil.OnCodeLinstener() {
|
|
|
- @Override
|
|
|
- public void callBack(String code) {
|
|
|
- doSignin(code, 0);
|
|
|
- }
|
|
|
- });
|
|
|
+ doSigninn();
|
|
|
+ } else if (item.getItemId() == android.R.id.home) {
|
|
|
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
+ imm.hideSoftInputFromWindow(text_edit.getWindowToken(), 0);
|
|
|
}
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onStop() {
|
|
|
- super.onStop();
|
|
|
- if (getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
|
|
|
- //隐藏软键盘
|
|
|
- getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
getMenuInflater().inflate(R.menu.menu_push, menu);
|
|
|
@@ -166,29 +159,8 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
private String path = null;
|
|
|
|
|
|
private void showPopup() {
|
|
|
- AlertDialog.Builder builder = new AlertDialog.Builder(ct);
|
|
|
- String[] items = {"拍照", "从相册中选择"};
|
|
|
- builder.setTitle("选择操作");
|
|
|
- builder.setItems(items, new DialogInterface.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
- if (i == 0) {
|
|
|
- //调用拍照
|
|
|
- isTask = true;
|
|
|
- mNewPhotoUri = CameraUtil.getOutputMediaFileUri(OutSigninOKActivity.this, CameraUtil.MEDIA_TYPE_IMAGE);
|
|
|
- CameraUtil.captureImage(OutSigninOKActivity.this, mNewPhotoUri, REQUEST_CODE_CAPTURE_PHOTO);
|
|
|
- } else if (i == 1) {
|
|
|
- if (!getIntent().getBooleanExtra("isImage", false)) {
|
|
|
- Crouton.makeText(ct, "您没有被允许使用系统相册,请使用拍照");
|
|
|
- } else {
|
|
|
- isTask = false;
|
|
|
- //调用系统相册
|
|
|
- CameraUtil.pickImageSimple(OutSigninOKActivity.this, REQUEST_CODE_PICK_PHOTO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- builder.show();
|
|
|
+ mNewPhotoUri = CameraUtil.getOutputMediaFileUri(OutSigninOKActivity.this, CameraUtil.MEDIA_TYPE_IMAGE);
|
|
|
+ CameraUtil.captureImage(OutSigninOKActivity.this, mNewPhotoUri, REQUEST_CODE_CAPTURE_PHOTO);
|
|
|
}
|
|
|
|
|
|
private int getID(String chche) {
|
|
|
@@ -206,17 +178,15 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
|
|
|
private void uploadFile(String path) {
|
|
|
if (StringUtils.isEmpty(path)) return;
|
|
|
- File finalFile = new File(path);
|
|
|
- if (!finalFile.isFile()) return;
|
|
|
+ File waterBitmapToFile = ImageUtil.compressWaterBitmapToFile(path, 100, 300, 300
|
|
|
+ , time_tv.getText().toString().trim(), addr_tv.getText().toString().trim(), 0);
|
|
|
+ if (!waterBitmapToFile.isFile()) return;
|
|
|
RequestParams params = new RequestParams();
|
|
|
params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
params.addBodyParameter("type", "common");
|
|
|
- if (isTask)
|
|
|
- params.addBodyParameter("img", ImageUtil.compressBitmapToFile(path, 100, 300, 300));
|
|
|
- else
|
|
|
- params.addBodyParameter("img", finalFile);
|
|
|
+ params.addBodyParameter("img", waterBitmapToFile);
|
|
|
String url = Constants.getAppBaseUrl(ct) + "mobile/uploadEmployeeAttach.action";
|
|
|
final HttpUtils http = new HttpUtils();
|
|
|
http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
|
|
|
@@ -229,9 +199,7 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
@Override
|
|
|
public void onLoading(long total, long current, boolean isUploading) {
|
|
|
if (isUploading) {
|
|
|
-
|
|
|
} else {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -243,14 +211,10 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
if (validator.validate(responseInfo.result) && JSON.parseObject(responseInfo.result).getBoolean("success")) {
|
|
|
id = getID(JSON.parseObject(responseInfo.result).getString("id"));
|
|
|
}
|
|
|
- CodeUtil.getInstance().getCode(ct, "mobile_outsign", new CodeUtil.OnCodeLinstener() {
|
|
|
- @Override
|
|
|
- public void callBack(String code) {
|
|
|
- doSignin(code, id);
|
|
|
- }
|
|
|
- });
|
|
|
+ doSigninn();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void onFailure(HttpException error, String msg) {
|
|
|
ViewUtil.ToastMessage(ct, "上传失败:" + msg);
|
|
|
@@ -266,22 +230,74 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
path = mNewPhotoUri.getPath();
|
|
|
// path = CameraUtil.getImagePathFromUri(ct, mNewPhotoUri);
|
|
|
if (StringUtils.isEmpty(path)) return;
|
|
|
- ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), image);
|
|
|
+ final File waterBitmapToFile = ImageUtil.compressWaterBitmapToFile(path, 100, 300, 300
|
|
|
+ , time_tv.getText().toString().trim(), addr_tv.getText().toString().trim(), 0);
|
|
|
+// ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), image);
|
|
|
+ ImageLoader.getInstance().displayImage(Uri.fromFile(waterBitmapToFile).toString(), image);
|
|
|
+ image.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ LayoutInflater inflater = LayoutInflater.from(OutSigninOKActivity.this);
|
|
|
+ final View largeImageView = inflater.inflate(R.layout.layout_large_image, null);
|
|
|
+ ImageView imageView = (ImageView) largeImageView.findViewById(R.id.large_image_iv);
|
|
|
+ ImageLoader.getInstance().displayImage(Uri.fromFile(waterBitmapToFile).toString(), imageView);
|
|
|
+ final PopupWindow largeImageWindow = new PopupWindow(largeImageView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
|
+ largeImageWindow.setAnimationStyle(R.style.Animation_CustomPopup);
|
|
|
+ largeImageWindow.setFocusable(true);
|
|
|
+ largeImageWindow.setOutsideTouchable(true);
|
|
|
+ largeImageWindow.showAtLocation(View.inflate(OutSigninOKActivity.this, R.layout.activity_out_signin_ok, null), Gravity.CENTER, 0, 0);
|
|
|
+
|
|
|
+ imageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (largeImageWindow.isShowing()) {
|
|
|
+ largeImageWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
} else {
|
|
|
ToastUtil.showToast(this, R.string.c_take_picture_failed);
|
|
|
}
|
|
|
}
|
|
|
- } else if (requestCode == REQUEST_CODE_PICK_PHOTO) {// 选择一张图片,然后立即调用裁减
|
|
|
+ }
|
|
|
+ /*else if (requestCode == REQUEST_CODE_PICK_PHOTO) {// 选择一张图片,然后立即调用裁减
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
if (data != null && data.getData() != null) {
|
|
|
path = CameraUtil.getImagePathFromUri(ct, data.getData());
|
|
|
+ final File waterBitmapToFile = ImageUtil.compressWaterBitmapToFile(path, 100, 300, 300
|
|
|
+ , time_tv.getText().toString().trim(), addr_tv.getText().toString().trim(), 0);
|
|
|
if (StringUtils.isEmpty(path)) return;
|
|
|
- ImageLoader.getInstance().displayImage(Uri.fromFile(new File(path)).toString(), image);
|
|
|
+ ImageLoader.getInstance().displayImage(Uri.fromFile(waterBitmapToFile).toString(), image);
|
|
|
+ image.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ LayoutInflater inflater = LayoutInflater.from(OutSigninOKActivity.this);
|
|
|
+ final View largeImageView = inflater.inflate(R.layout.layout_large_image, null);
|
|
|
+ ImageView imageView = (ImageView) largeImageView.findViewById(R.id.large_image_iv);
|
|
|
+ ImageLoader.getInstance().displayImage(Uri.fromFile(waterBitmapToFile).toString(), imageView);
|
|
|
+ final PopupWindow largeImageWindow = new PopupWindow(largeImageView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
|
|
+ largeImageWindow.setAnimationStyle(R.style.Animation_CustomPopup);
|
|
|
+ largeImageWindow.setFocusable(true);
|
|
|
+ largeImageWindow.setOutsideTouchable(true);
|
|
|
+ largeImageWindow.showAtLocation(View.inflate(OutSigninOKActivity.this, R.layout.activity_out_signin_ok, null), Gravity.CENTER, 0, 0);
|
|
|
+
|
|
|
+ imageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (largeImageWindow.isShowing()) {
|
|
|
+ largeImageWindow.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
} else {
|
|
|
ToastUtil.showToast(this, R.string.c_photo_album_failed);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -293,8 +309,16 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
String message = (String) msg.getData().get("result");
|
|
|
switch (msg.what) {
|
|
|
case whatSignin:
|
|
|
+ isSubmit = false;
|
|
|
JSONObject json = JSON.parseObject(message);
|
|
|
if (json.containsKey("success") && json.getBoolean("success")) {
|
|
|
+ doNextNet();
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast(ct, "签到失败");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 0x13:
|
|
|
+ if (JSON.parseObject(message).containsKey("success") && JSON.parseObject(message).getBoolean("success")) {
|
|
|
ToastUtil.showToast(ct, "签到成功");
|
|
|
Intent intent = new Intent();
|
|
|
intent.putExtra("result", true);
|
|
|
@@ -311,6 +335,7 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+
|
|
|
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
|
|
|
@Override
|
|
|
protected Void doInBackground(Void... voids) {
|
|
|
@@ -331,18 +356,53 @@ public class OutSigninOKActivity extends BaseActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ private void doSigninn() {
|
|
|
+ if (isSubmit) {
|
|
|
+ Crouton.makeText(ct, "当前正在提交");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isSubmit = true;
|
|
|
+ CodeUtil.getInstance().getId(ct, "MOBILE_OUTSIGN_SEQ", new CodeUtil.OnCodeLinstener() {
|
|
|
+ @Override
|
|
|
+ public void callBack(String code) {
|
|
|
+ if (!StringUtils.isEmpty(code) && isNum(code))
|
|
|
+ mo_id = Integer.valueOf(code);
|
|
|
+ doSignin(mo_id, id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isNum(String chche) {
|
|
|
+ Pattern pattern = Pattern.compile("[0-9]+");
|
|
|
+ Matcher matcher = pattern.matcher(chche);
|
|
|
+ return matcher.matches();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void doNextNet() {
|
|
|
+ progressDialog.show();
|
|
|
+ //获取网络数据
|
|
|
+ String url = baseUrl + "common/submitCommon.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("caller", "Mobile_outsign");
|
|
|
+ param.put("id", mo_id);
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, 0x13, null, null, "post");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 签到
|
|
|
- *
|
|
|
- * @param code 编号
|
|
|
*/
|
|
|
- private void doSignin(String code, int id) {
|
|
|
+ private void doSignin(int mo_id, int id) {
|
|
|
progressDialog.show();
|
|
|
//获取网络数据
|
|
|
String url = baseUrl + "mobile/oa/saveOutSign.action";
|
|
|
final Map<String, Object> param = new HashMap<>();
|
|
|
OutSigninBean bean = new OutSigninBean();
|
|
|
- bean.setMo_code(code);
|
|
|
+ if (mo_id > 0)
|
|
|
+ bean.setMo_id(mo_id);
|
|
|
bean.setMo_address(addr_tv.getText().toString().trim());
|
|
|
bean.setMo_mancode(CommonUtil.getSharedPreferences(this, "erp_username"));
|
|
|
bean.setMo_man(MyApplication.getInstance().mLoginUser.getNickName());
|