|
|
@@ -1,10 +1,18 @@
|
|
|
package com.uas.appme.settings.activity;
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.util.DisplayMetrics;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.view.WindowManager;
|
|
|
import android.widget.BaseAdapter;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
@@ -14,12 +22,16 @@ import com.common.data.CalendarUtil;
|
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
+import com.common.data.StringUtil;
|
|
|
+import com.common.system.DisplayUtil;
|
|
|
import com.core.app.MyApplication;
|
|
|
import com.core.base.BaseActivity;
|
|
|
+import com.core.model.SelectBean;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.TimeUtils;
|
|
|
import com.core.utils.time.wheel.OASigninPicker;
|
|
|
import com.core.widget.MyListView;
|
|
|
+import com.core.widget.view.Activity.SelectActivity;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
@@ -41,9 +53,10 @@ import java.util.List;
|
|
|
public class BComSetEmployeeRestActivity extends BaseActivity implements View.OnClickListener{
|
|
|
private MyListView mComList;
|
|
|
private List<ComRestBean> mList; //进行保存的员工休息数据列表
|
|
|
- private PersonSetingBean mServicePersonList; //获取商家服务人员
|
|
|
private ComRestAdapter myAdapter;
|
|
|
private String current_date;
|
|
|
+ private List<String> serviceMans;
|
|
|
+ private int click_positon;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -60,7 +73,7 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("user/appStoreman")
|
|
|
.add("companyid", 201)
|
|
|
- .add("serviceid", MyApplication.getInstance().mLoginUser.getUserId())
|
|
|
+ .add("serviceid", 10002)
|
|
|
.add("token",MyApplication.getInstance().mAccessToken)
|
|
|
.method(Method.GET)
|
|
|
.build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@@ -69,7 +82,8 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
if (!JSONUtil.validate(o.toString()) || o == null) return;
|
|
|
LogUtil.prinlnLongMsg("appStoreman", o.toString()+"");
|
|
|
try {
|
|
|
- mServicePersonList = JSON.parseObject(o.toString(),PersonSetingBean.class);
|
|
|
+ PersonSetingBean mServicePersonList = JSON.parseObject(o.toString(),PersonSetingBean.class);
|
|
|
+ handleServerMan(mServicePersonList);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -77,16 +91,23 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ private void handleServerMan(PersonSetingBean mServicePersonList) {
|
|
|
+ if (mServicePersonList == null || ListUtils.isEmpty(mServicePersonList.getResult())) return;
|
|
|
+ for (int i=0; i<mServicePersonList.getResult().size();i++)
|
|
|
+ serviceMans.add(mServicePersonList.getResult().get(i).getSm_username());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void initView() {
|
|
|
mList = new ArrayList<>();
|
|
|
- mServicePersonList = new PersonSetingBean();
|
|
|
mComList = (MyListView) findViewById(R.id.com_list);
|
|
|
findViewById(R.id.add_new_rl).setOnClickListener(this);
|
|
|
myAdapter = new ComRestAdapter(this);
|
|
|
myAdapter.setModelList(mList);
|
|
|
mComList.setAdapter(myAdapter);
|
|
|
findViewById(R.id.save_bt).setOnClickListener(this);
|
|
|
+ serviceMans = new ArrayList<>();
|
|
|
|
|
|
//初始化今天日期
|
|
|
String CURRENT_DATE = TimeUtil.getCurrentDate();
|
|
|
@@ -98,7 +119,7 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
if (v.getId() == R.id.add_new_rl){
|
|
|
ComRestBean model = new ComRestBean();
|
|
|
model.setSf_companyid("201");
|
|
|
- model.setSf_username("f方");
|
|
|
+ model.setSf_username("");
|
|
|
model.setSf_companyname(CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_commpany"));
|
|
|
model.setSf_userid(MyApplication.getInstance().mLoginUser.getUserId());
|
|
|
model.setSf_date("");
|
|
|
@@ -181,7 +202,24 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
viewHolder.name_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
-
|
|
|
+ if (ListUtils.isEmpty(serviceMans)) {
|
|
|
+ doInputName(position);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ ArrayList<SelectBean> beans = new ArrayList<>();
|
|
|
+ SelectBean bean = null;
|
|
|
+ for (String e : serviceMans) {
|
|
|
+ bean = new SelectBean();
|
|
|
+ bean.setName(e);
|
|
|
+ bean.setClick(false);
|
|
|
+ beans.add(bean);
|
|
|
+ }
|
|
|
+ Intent intent = new Intent(ct, SelectActivity.class);
|
|
|
+ intent.putExtra("type", 2);
|
|
|
+ intent.putParcelableArrayListExtra("data", beans);
|
|
|
+ intent.putExtra("title", "人员选择");
|
|
|
+ startActivityForResult(intent, 0x01);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -200,6 +238,96 @@ public class BComSetEmployeeRestActivity extends BaseActivity implements View.On
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private PopupWindow popupWindow = null;
|
|
|
+ private void doInputName(final int position) {
|
|
|
+ // 一个自定义的布局,作为显示的内容
|
|
|
+ View contentView = LayoutInflater.from(ct).inflate(
|
|
|
+ R.layout.item_edit_location_pop, null);
|
|
|
+
|
|
|
+ // 设置按钮的点击事件
|
|
|
+ TextView title_tv = (TextView) contentView.findViewById(R.id.title_tv);
|
|
|
+ final EditText editname_et = (EditText) contentView.findViewById(R.id.editname_et);
|
|
|
+ TextView cancel_tv = (TextView) contentView.findViewById(R.id.cancel_tv);
|
|
|
+ TextView sure_tv = (TextView) contentView.findViewById(R.id.sure_tv);
|
|
|
+ title_tv.setText("请输入人员名称");
|
|
|
+
|
|
|
+ DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
|
+ int w_screen = dm.widthPixels;
|
|
|
+ int h_screen = dm.heightPixels;
|
|
|
+ w_screen = DisplayUtil.dip2px(this, 300);
|
|
|
+ h_screen = DisplayUtil.dip2px(this, 145);
|
|
|
+
|
|
|
+ contentView.findViewById(R.id.cancel_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ contentView.findViewById(R.id.sure_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if (StringUtil.isEmpty(editname_et.getText().toString())){
|
|
|
+ ToastMessage("请输入人员名称");
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ mList.get(position).setSf_username(editname_et.getText().toString());
|
|
|
+ myAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ popupWindow = new PopupWindow(contentView, w_screen, h_screen, true);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setOutsideTouchable(false);
|
|
|
+ // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
|
|
|
+ popupWindow.setBackgroundDrawable(getResources().getDrawable(com.uas.appworks.R.drawable.pop_round_bg));
|
|
|
+ // 设置好参数之后再show
|
|
|
+ popupWindow.showAtLocation(contentView, Gravity.CENTER, 0, 0);
|
|
|
+ setbg(0.4f);
|
|
|
+ }
|
|
|
+ private void setbg(float alpha) {
|
|
|
+ setBackgroundAlpha(this, alpha);
|
|
|
+ if (popupWindow == null) return;
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ setBackgroundAlpha(BComSetEmployeeRestActivity.this, 1f);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置页面的透明度
|
|
|
+ * 兼容华为手机(在个别华为手机上 设置透明度会不成功)
|
|
|
+ *
|
|
|
+ * @param bgAlpha 透明度 1表示不透明
|
|
|
+ */
|
|
|
+ public void setBackgroundAlpha(Activity activity, float bgAlpha) {
|
|
|
+ WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
|
|
|
+ lp.alpha = bgAlpha;
|
|
|
+ if (bgAlpha == 1) {
|
|
|
+ activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//不移除该Flag的话,在有视频的页面上的视频会出现黑屏的bug
|
|
|
+ } else {
|
|
|
+ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//此行代码主要是解决在华为手机上半透明效果无效的bug
|
|
|
+ }
|
|
|
+ activity.getWindow().setAttributes(lp);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
+ if (data == null) return;
|
|
|
+ if (resultCode == 0x20) {
|
|
|
+ SelectBean b = data.getParcelableExtra("data");
|
|
|
+ if (b == null) return;
|
|
|
+ String name = StringUtil.isEmpty(b.getName()) ? "" : b.getName();
|
|
|
+ if (requestCode == 0x01) {
|
|
|
+ mList.get(click_positon).setSf_username(name);
|
|
|
+ myAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void doSelectEndDate(final int pos) {
|
|
|
OASigninPicker picker = new OASigninPicker(this);
|
|
|
picker.setRange(CalendarUtil.getYear()+1, CalendarUtil.getMonth(), CalendarUtil.getDay());
|