|
@@ -0,0 +1,200 @@
|
|
|
|
|
+package com.modular.booking.activity.utils;
|
|
|
|
|
+
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
|
+import android.view.View;
|
|
|
|
|
+import android.widget.AdapterView;
|
|
|
|
|
+import android.widget.GridView;
|
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.common.LogUtil;
|
|
|
|
|
+import com.common.data.DateFormatUtil;
|
|
|
|
|
+import com.common.data.ListUtils;
|
|
|
|
|
+import com.common.data.StringUtil;
|
|
|
|
|
+import com.core.app.AppConstant;
|
|
|
|
|
+import com.core.app.Constants;
|
|
|
|
|
+import com.core.app.MyApplication;
|
|
|
|
|
+import com.core.base.OABaseActivity;
|
|
|
|
|
+import com.core.model.SelectBean;
|
|
|
|
|
+import com.core.widget.view.selectcalendar.SelectCalendarActivity;
|
|
|
|
|
+import com.me.network.app.http.HttpClient;
|
|
|
|
|
+import com.me.network.app.http.Method;
|
|
|
|
|
+import com.me.network.app.http.rx.ResultListener;
|
|
|
|
|
+import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
|
|
+import com.modular.apputils.activity.SingleImagePreviewActivity;
|
|
|
|
|
+import com.modular.booking.R;
|
|
|
|
|
+import com.modular.booking.adapter.ItemRoomsSelectAdapter;
|
|
|
|
|
+import com.modular.booking.model.SBMenuModel;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @desc:功能界面 表格选择界面
|
|
|
|
|
+ * 自定义头部
|
|
|
|
|
+ * @author:Arison on 2017/11/1
|
|
|
|
|
+ */
|
|
|
|
|
+public class GridSelectDateActivity extends OABaseActivity {
|
|
|
|
|
+ ItemRoomsSelectAdapter itemAdapter;
|
|
|
|
|
+ private GridView gvTopic;
|
|
|
|
|
+ private List<SBMenuModel> menuModels=new ArrayList<>();
|
|
|
|
|
+ ArrayList<SelectBean> selectBeens = new ArrayList<SelectBean>();
|
|
|
|
|
+ private TextView tvTopDate;
|
|
|
|
|
+ private ImageView back;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
|
+ setContentView(R.layout.activity_grid_select);
|
|
|
|
|
+ gvTopic = (GridView) findViewById(R.id.gv_topic);
|
|
|
|
|
+ initView();
|
|
|
|
|
+ initEvent();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void initView(){
|
|
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.action_service_room, null);
|
|
|
|
|
+ tvTopDate =(TextView)view.findViewById(R.id.tvTopDate);
|
|
|
|
|
+ back=(ImageView)view.findViewById(R.id.book_service_search_back);
|
|
|
|
|
+ ActionBar bar = this.getSupportActionBar();
|
|
|
|
|
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
|
|
+ bar.setBackgroundDrawable( getResources().getDrawable(R.color.antionbarcolor));
|
|
|
|
|
+ bar.setCustomView(view);
|
|
|
|
|
+
|
|
|
|
|
+ back.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ onBackPressed();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (getIntent()!=null){
|
|
|
|
|
+ selectBeens=getIntent().getParcelableArrayListExtra("data");
|
|
|
|
|
+ getSupportActionBar().setTitle(getIntent().getStringExtra("title"));
|
|
|
|
|
+ if (!ListUtils.isEmpty(selectBeens)){
|
|
|
|
|
+ for (int i = 0; i < selectBeens.size(); i++) {
|
|
|
|
|
+ SelectBean selectBean=selectBeens.get(i);
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject object= JSON.parseObject(selectBean.getJson()) ;
|
|
|
|
|
+ SBMenuModel menuModel=new SBMenuModel();
|
|
|
|
|
+ menuModel.setUrl(object.getString("st_imageurl"));
|
|
|
|
|
+ if (StringUtil.isEmpty(object.getString("st_name"))){
|
|
|
|
|
+ menuModel.setTitle(object.getString("sm_username"));//医生
|
|
|
|
|
+ }else{
|
|
|
|
|
+ menuModel.setTitle(object.getString("st_name"));
|
|
|
|
|
+ }
|
|
|
|
|
+ menuModel.setCode(object.getString("sm_userid"));
|
|
|
|
|
+ menuModel.setData(object.toJSONString());
|
|
|
|
|
+ menuModels.add(menuModel);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ LogUtil.d("GridSelectActivity","models:"+JSON.toJSONString(menuModels));
|
|
|
|
|
+ itemAdapter = new ItemRoomsSelectAdapter(mContext, menuModels);
|
|
|
|
|
+ gvTopic.setAdapter(itemAdapter);
|
|
|
|
|
+ }
|
|
|
|
|
+ private static final String TAG = "GridSelectActivity";
|
|
|
|
|
+ public void initEvent(){
|
|
|
|
|
+ tvTopDate.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ //弹出日期
|
|
|
|
|
+ startActivityForResult(new Intent(mContext, SelectCalendarActivity.class)
|
|
|
|
|
+ .putExtra("hasMenu", false)
|
|
|
|
|
+ .putExtra("bookType","0")
|
|
|
|
|
+ .putExtra("type", 3), 0x01);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ gvTopic.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
+ final ItemRoomsSelectAdapter.ViewHolder menuModel = (ItemRoomsSelectAdapter.ViewHolder) view.getTag();
|
|
|
|
|
+ menuModel.tvBookAction.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+// ToastMessage("点击事件!");
|
|
|
|
|
+ LogUtil.d(TAG,"按钮点击事件!");
|
|
|
|
|
+ ToastMessage(""+menuModel.model.getDesc()+menuModel.model.getTitle());
|
|
|
|
|
+
|
|
|
|
|
+ if (menuModel.model.isBooking()){
|
|
|
|
|
+ ToastMessage("包间已满,不可预订!");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ setResult(0x21,new Intent().putExtra("data",menuModel.model));
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+//
|
|
|
|
|
+ menuModel.ivItem.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ LogUtil.d(TAG,"图片点击事件!");
|
|
|
|
|
+ String loginUserId =menuModel.model.getUrl();
|
|
|
|
|
+ Intent intent = new Intent(activity, SingleImagePreviewActivity.class);
|
|
|
|
|
+ intent.putExtra(AppConstant.EXTRA_IMAGE_URI, loginUserId);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
+ if (data == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (requestCode){
|
|
|
|
|
+ case 0x01:
|
|
|
|
|
+ try {
|
|
|
|
|
+ String startTime = data.getStringExtra("startDate");
|
|
|
|
|
+ String displayDate = startTime;
|
|
|
|
|
+ tvTopDate.setText(displayDate);
|
|
|
|
|
+ getBookingDataState(DateFormatUtil.getStrDate4Date(DateFormatUtil.getDate4StrDate(displayDate,"yyyyMMdd"),"yyyyMMdd"));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public void getBookingDataState(String date){
|
|
|
|
|
+ LogUtil.d(TAG,"date:"+date);
|
|
|
|
|
+ //http://113.105.74.135:8092/user/appServiceBusytime?yearmonth=20171109&token=8a07b517fdd94248b7f00d120ab29502&commonid=0&type=餐饮&companyid=10002&client=Android%20Client
|
|
|
|
|
+ HttpClient httpClient=new HttpClient.Builder(Constants.IM_BASE_URL()).build();
|
|
|
|
|
+ httpClient.Api().send(new HttpClient.Builder()
|
|
|
|
|
+ .url("user/appServiceBusytime")
|
|
|
|
|
+ .add("yearmonth",date)
|
|
|
|
|
+ .add("commonid","0")
|
|
|
|
|
+ .add("token", MyApplication.getInstance().mAccessToken)
|
|
|
|
|
+ .method(Method.GET)
|
|
|
|
|
+ .build(),new ResultSubscriber<Object>(new ResultListener<Object>() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onResponse(Object o) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ LogUtil.d(TAG,o.toString());
|
|
|
|
|
+ JSONArray reslut=JSON.parseObject(o.toString()).getJSONArray("reslut");
|
|
|
|
|
+ if (reslut!=null){
|
|
|
|
|
+ for (int i = 0; i <reslut.size() ; i++) {
|
|
|
|
|
+ JSONObject object=reslut.getJSONObject(i);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|