|
|
@@ -0,0 +1,295 @@
|
|
|
+package com.modular.booking.activity.business;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.baidu.mapapi.search.core.PoiInfo;
|
|
|
+import com.common.data.DateFormatUtil;
|
|
|
+import com.common.data.StringUtil;
|
|
|
+import com.core.app.MyApplication;
|
|
|
+import com.core.base.BaseActivity;
|
|
|
+import com.core.selectcalendar.SelectCalendarActivity;
|
|
|
+import com.core.selectcalendar.bean.DataState;
|
|
|
+import com.core.widget.NScrollerGridView;
|
|
|
+import com.core.widget.view.Activity.SearchLocationActivity;
|
|
|
+import com.core.widget.view.model.SearchPoiParam;
|
|
|
+import com.modular.booking.R;
|
|
|
+import com.modular.booking.model.BookingModel;
|
|
|
+import com.uas.appcontact.model.contacts.ContactsModel;
|
|
|
+import com.uas.appcontact.ui.activity.ContactsActivity;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @desc:商务预约新增界面
|
|
|
+ * @author:Arison on 2017/9/7
|
|
|
+ */
|
|
|
+public class BBookingAddActivity extends BaseActivity implements View.OnClickListener {
|
|
|
+ private TextView tvBookObject;
|
|
|
+ private RelativeLayout companyAddRl;
|
|
|
+ private RelativeLayout rlObject;
|
|
|
+ private TextView tvBookTimes;
|
|
|
+ private RelativeLayout remarkRl;
|
|
|
+ private RelativeLayout topic_rl;
|
|
|
+ private EditText tv_book_topic;
|
|
|
+ private TextView tvBookAddress;
|
|
|
+ private double latitude;
|
|
|
+ private double longitude;
|
|
|
+ private int imId;
|
|
|
+ private String startTime;
|
|
|
+ private String endTime;
|
|
|
+ private EditText et_book_content;
|
|
|
+ BookingModel model;
|
|
|
+ private Button bt_commit;
|
|
|
+ private NScrollerGridView gv_topic;
|
|
|
+ List<DataState> dataStates;
|
|
|
+ GridDataAdapter adapter;
|
|
|
+ private String phone;
|
|
|
+ private String[] mTypes = {"商务洽谈", "开会", "外出娱乐", "吃饭", "卡拉OK", "其它"};
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_bbooking_add);
|
|
|
+ initView();
|
|
|
+ initEvent();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initEvent() {
|
|
|
+ findViewById(R.id.submit_btn).setOnClickListener(this);
|
|
|
+ rlObject.setOnClickListener(this);
|
|
|
+ companyAddRl.setOnClickListener(this);
|
|
|
+ remarkRl.setOnClickListener(this);
|
|
|
+ topic_rl.setOnClickListener(this);
|
|
|
+
|
|
|
+ gv_topic.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ GridDataAdapter.ViewModle modle = (GridDataAdapter.ViewModle) view.getTag();
|
|
|
+ tv_book_topic.setText(modle.tv_text.getText().toString());
|
|
|
+ tv_book_topic.setSelection(modle.tv_text.getText().toString().length());
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initView() {
|
|
|
+ getSupportActionBar().setTitle(getString(R.string.booking_business));
|
|
|
+
|
|
|
+ tvBookObject = (TextView) findViewById(R.id.tv_book_object);
|
|
|
+ companyAddRl = (RelativeLayout) findViewById(R.id.company_add_rl);
|
|
|
+ tvBookTimes = (TextView) findViewById(R.id.tv_book_times);
|
|
|
+ remarkRl = (RelativeLayout) findViewById(R.id.remark_rl);
|
|
|
+ rlObject = (RelativeLayout) findViewById(R.id.rl_object);
|
|
|
+
|
|
|
+ topic_rl = (RelativeLayout) findViewById(R.id.topic_rl);
|
|
|
+ tvBookAddress = (TextView) findViewById(R.id.tv_book_address);
|
|
|
+ et_book_content = (EditText) findViewById(R.id.et_book_content);
|
|
|
+
|
|
|
+ tv_book_topic = (EditText) findViewById(R.id.tv_book_topic);
|
|
|
+ gv_topic = (NScrollerGridView) findViewById(R.id.gv_topic);
|
|
|
+ bt_commit = (Button) findViewById(R.id.submit_btn);
|
|
|
+ tv_book_topic.setText("商务洽谈");
|
|
|
+
|
|
|
+ if (getIntent() != null && getIntent().getExtras() != null) {
|
|
|
+ model = getIntent().getExtras().getParcelable("model");
|
|
|
+ if (model != null) {
|
|
|
+ tvBookObject.setText(model.getAb_bman());
|
|
|
+ tvBookTimes.setText(model.getAb_starttime().substring(0, 10) + " " + model.getAb_starttime().substring(11, 16) + "-"
|
|
|
+ + model.getAb_endtime().substring(11, 16));
|
|
|
+ tvBookAddress.setText(model.getAb_address());
|
|
|
+ et_book_content.setText(model.getAb_content());
|
|
|
+ longitude = Double.valueOf(model.getAb_longitude());
|
|
|
+ latitude = Double.valueOf(model.getAb_latitude());
|
|
|
+ imId = Integer.valueOf(model.getAb_bmanid());
|
|
|
+ startTime = model.getAb_starttime();
|
|
|
+ endTime = model.getAb_endtime();
|
|
|
+ ((Button) findViewById(R.id.submit_btn)).setText(getString(R.string.booking_change));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataStates = new ArrayList<>();
|
|
|
+ for (String str : mTypes) {
|
|
|
+ DataState dataState = new DataState();
|
|
|
+ dataState.setValue(str);
|
|
|
+ dataStates.add(dataState);
|
|
|
+ }
|
|
|
+
|
|
|
+ adapter = new GridDataAdapter(this, dataStates);
|
|
|
+ gv_topic.setAdapter(adapter);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ int i = v.getId();
|
|
|
+ if (i == R.id.submit_btn) {
|
|
|
+
|
|
|
+ } else if (i == R.id.topic_rl) {
|
|
|
+
|
|
|
+ } else if (i == R.id.company_add_rl) {
|
|
|
+ //时间
|
|
|
+ if (!StringUtil.isEmpty(tvBookObject.getText().toString())) {
|
|
|
+ startActivityForResult(new Intent(mContext, SelectCalendarActivity.class)
|
|
|
+ .putExtra("startDate", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS))
|
|
|
+ .putExtra("endDate", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS))
|
|
|
+ .putExtra("hasMenu", false)
|
|
|
+ .putExtra("imId", imId)
|
|
|
+ .putExtra("type", 1)
|
|
|
+ , 0x24);
|
|
|
+ } else {
|
|
|
+ ToastMessage("请先选择预约对象!");
|
|
|
+ }
|
|
|
+ } else if (i == R.id.remark_rl) {
|
|
|
+ //地址
|
|
|
+ Intent intent = new Intent(ct, SearchLocationActivity.class);
|
|
|
+ SearchPoiParam poiParam = new SearchPoiParam();
|
|
|
+ poiParam.setType(2);
|
|
|
+ poiParam.setTitle("地图搜索");
|
|
|
+ poiParam.setRadius(300);
|
|
|
+ //poiParam.setContrastLatLng(new LatLng(companyLocation.getLocation().longitude, companyLocation.getLocation().latitude));
|
|
|
+ poiParam.setResultCode(0x23);
|
|
|
+ poiParam.setDistanceTag(MyApplication.getInstance().getResources().getString(R.string.rice));
|
|
|
+ intent.putExtra("data", poiParam);
|
|
|
+ startActivityForResult(intent, 0x23);
|
|
|
+ } else if (i == R.id.rl_object) {
|
|
|
+ if (model != null) {
|
|
|
+ ToastMessage("预约对象不能更改!");
|
|
|
+ } else {
|
|
|
+ //"com.modular.contact.ContactsActivity"
|
|
|
+ Intent intent = new Intent(this, ContactsActivity.class);
|
|
|
+ intent.putExtra("type", 1);
|
|
|
+ intent.putExtra("title", getString(R.string.booking_object_name));
|
|
|
+ intent.putExtra("isSingleSelect",false);
|
|
|
+ startActivityForResult(intent,0x01);
|
|
|
+ }
|
|
|
+ } else if (i == R.id.rl_company) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ if (data == null) return;
|
|
|
+ switch (requestCode) {
|
|
|
+ case 0x01://对象
|
|
|
+ ArrayList<ContactsModel> models=data.getParcelableArrayListExtra("data");
|
|
|
+ //拿到多个预约对象,需要下拉他们的企业信息
|
|
|
+ StringBuilder names=new StringBuilder("");
|
|
|
+ for (int i=0;i<models.size();i++){
|
|
|
+ names.append(models.get(i).getName()+",");
|
|
|
+ }
|
|
|
+ tvBookObject.setText(names.toString());
|
|
|
+ break;
|
|
|
+ case 0x02://企业
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 0x23://地址
|
|
|
+ PoiInfo poi = data.getParcelableExtra("resultKey");
|
|
|
+ if (poi == null) return;
|
|
|
+ tvBookAddress.setText(poi.address + poi.name);
|
|
|
+ latitude = poi.location.latitude;
|
|
|
+ longitude = poi.location.longitude;
|
|
|
+ break;
|
|
|
+ case 0x24://时间
|
|
|
+ startTime = data.getStringExtra("startDate");
|
|
|
+ endTime = data.getStringExtra("endDate");
|
|
|
+ String displayDate = startTime.substring(11, 16) + "-" + endTime.substring(11, 16);
|
|
|
+ tvBookTimes.setText(displayDate);
|
|
|
+ break;
|
|
|
+ case 0x11://主题
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public class GridDataAdapter extends BaseAdapter {
|
|
|
+
|
|
|
+ private Context ct;
|
|
|
+ private List<DataState> mData = new ArrayList<>();
|
|
|
+ private LayoutInflater inflater;
|
|
|
+ private int selected = -1;
|
|
|
+
|
|
|
+ GridDataAdapter(Context ct, List<DataState> data) {
|
|
|
+ this.ct = ct;
|
|
|
+ this.mData = data;
|
|
|
+ this.inflater = LayoutInflater.from(ct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return mData.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return mData.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getSelected() {
|
|
|
+ return selected;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSelected(int selected) {
|
|
|
+ this.selected = selected;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ GridDataAdapter.ViewModle modle = null;
|
|
|
+
|
|
|
+ if (convertView == null) {
|
|
|
+ convertView = inflater.inflate(R.layout.item_simple_text, parent, false);
|
|
|
+ modle = new GridDataAdapter.ViewModle();
|
|
|
+ modle.tv_text = (TextView) convertView.findViewById(R.id.tv_text);
|
|
|
+ convertView.setTag(modle);
|
|
|
+ } else {
|
|
|
+ modle = (GridDataAdapter.ViewModle) convertView.getTag();
|
|
|
+ }
|
|
|
+ modle.tv_text.setText(mData.get(position).getValue());
|
|
|
+ if (mData.get(position).isClicked()) {
|
|
|
+ modle.clicked = true;
|
|
|
+ modle.tv_text.setTextColor(mContext.getResources().getColor(R.color.black));
|
|
|
+ modle.tv_text.setBackgroundResource(R.drawable.bg_select_blue);
|
|
|
+ if (selected == position) {
|
|
|
+ modle.tv_text.setSelected(true);
|
|
|
+ modle.tv_text.setTextColor(mContext.getResources().getColor(R.color.white));
|
|
|
+ } else {
|
|
|
+ modle.tv_text.setSelected(false);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ modle.clicked = false;
|
|
|
+ modle.tv_text.setTextColor(mContext.getResources().getColor(R.color.light_gray));
|
|
|
+ modle.tv_text.setBackgroundResource(R.drawable.bg_select_red);
|
|
|
+ modle.tv_text.setSelected(false);
|
|
|
+ }
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ class ViewModle {
|
|
|
+ TextView tv_text;
|
|
|
+ boolean clicked;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|