198 lines
5.7 KiB
Java
198 lines
5.7 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
|
|
|
import android.Manifest;
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import android.view.Gravity;
|
|
import android.view.View;
|
|
import android.view.View.OnClickListener;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.github.dfqin.grantor.PermissionListener;
|
|
import com.github.dfqin.grantor.PermissionsUtil;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.hjq.window.EasyWindow;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import cn.shangyu.gdxzExpert.R;
|
|
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
|
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
|
import cn.shangyu.gdxzExpert.utils.KeDaXunFeiUtil;
|
|
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.Url;
|
|
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
|
|
|
/**
|
|
* 我的-设置-意见反馈
|
|
*
|
|
* @author susanyuan
|
|
*
|
|
*/
|
|
|
|
public class AddProclamationActivity extends BaseActivity implements
|
|
OnClickListener, OnCallBackFromNet {
|
|
|
|
private Button bt_submit;
|
|
private EditText et_feedbook;
|
|
private String content;
|
|
boolean isCommen = false;
|
|
private String name, text;
|
|
private String expert_uuid;
|
|
private Button mBt_get_Voice;
|
|
private String hospital_uuid;
|
|
@Override
|
|
public View onCreateSuccessedView() {
|
|
// TODO Auto-generated method stub
|
|
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
|
View view = UIUtils.inflate(R.layout.activity_add_proclamation);
|
|
et_feedbook = (EditText) view.findViewById(R.id.et_feedbook);
|
|
mBt_get_Voice = (Button) view.findViewById(R.id.bt_get_voice);
|
|
|
|
mBt_get_Voice.setOnClickListener(this);
|
|
// 字数限制的
|
|
// et_feedbook.addTextChangedListener(tw);
|
|
bt_submit = (Button) view.findViewById(R.id.bt_submit);
|
|
bt_submit.setOnClickListener(this);
|
|
expert_uuid = SharePrefUtil.getString(AddProclamationActivity.this,
|
|
"uuid", "");
|
|
hospital_uuid=getIntent().getStringExtra("hospital_uuid");
|
|
return view;
|
|
}
|
|
|
|
@Override
|
|
public ResultState onLoad() {
|
|
// TODO Auto-generated method stub
|
|
return ResultState.STATE_SUCCESSED;
|
|
}
|
|
|
|
@Override
|
|
public void setTitle() {
|
|
// TODO Auto-generated method stub
|
|
top_title.setText("修改公告");
|
|
|
|
}
|
|
|
|
/**
|
|
* 提交反馈的信息 submit
|
|
*
|
|
* void
|
|
*/
|
|
public void submit() {
|
|
String content = et_feedbook.getText().toString().trim();
|
|
if (StringUtil.isEmpty(content)) {
|
|
ToastUtil.showMessage("内容不能为空");
|
|
return;
|
|
|
|
}
|
|
showProgressDialog("提交中");
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
param.put("other_uuid", hospital_uuid);
|
|
param.put("user_uuid", expert_uuid);
|
|
param.put("content", content);
|
|
sendJsonPostParamtoNet(Url.getaddProclamation, param, 01, this);
|
|
}
|
|
@Override
|
|
protected void processClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
|
int id = v.getId();
|
|
if (id == R.id.bt_submit) { // 提交
|
|
View view = getWindow().peekDecorView();
|
|
if (view != null) {
|
|
InputMethodManager inputmanger = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
|
}
|
|
submit();
|
|
} else if (id == R.id.bt_get_voice) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
|
if (PermissionsUtil.hasPermission(this, Manifest.permission.RECORD_AUDIO)) {
|
|
//有访问录音
|
|
VoiceUtil = new KeDaXunFeiUtil(AddProclamationActivity.this,
|
|
et_feedbook);
|
|
} else {
|
|
EasyWindow.with(AddProclamationActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
|
|
|
.setContentView(R.layout.float_top_dialog_record).show();
|
|
PermissionsUtil.requestPermission(this, new PermissionListener() {
|
|
@Override
|
|
public void permissionGranted(@NonNull String[] permissions) {
|
|
EasyWindow.cancelAll();
|
|
//用户授予了访问录音的权限
|
|
VoiceUtil = new KeDaXunFeiUtil(AddProclamationActivity.this,
|
|
et_feedbook);
|
|
}
|
|
@Override
|
|
public void permissionDenied(@NonNull String[] permissions) {
|
|
//用户拒绝了访问录音的申请
|
|
EasyWindow.cancelAll();
|
|
}
|
|
|
|
}, new String[]{Manifest.permission.RECORD_AUDIO});
|
|
}
|
|
|
|
}else {
|
|
VoiceUtil = new KeDaXunFeiUtil(AddProclamationActivity.this,
|
|
et_feedbook);
|
|
}
|
|
// VoiceUtil = new KeDaXunFeiUtil(AddProclamationActivity.this,
|
|
// et_feedbook);
|
|
// break;
|
|
}
|
|
}
|
|
|
|
KeDaXunFeiUtil VoiceUtil;
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
// TODO Auto-generated method stub
|
|
if (VoiceUtil != null) {
|
|
VoiceUtil.dissDialog();
|
|
}
|
|
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override
|
|
public void onCallbackFromThread(String resultJson) {
|
|
// TODO Auto-generated method stub
|
|
JSONObject jsob;
|
|
String retcode;
|
|
String message;
|
|
try {
|
|
jsob = new JSONObject(resultJson);
|
|
retcode = jsob.getString("code");
|
|
message = jsob.getString("message");
|
|
if (retcode.equals("1")) {
|
|
ToastUtil.showMessage("提交成功");
|
|
this.finish();
|
|
} else {
|
|
ToastUtil.showMessage(message);
|
|
}
|
|
} catch (JSONException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onCallBackFromThread(String resultJson, int resultCode) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|