예제 #1
0
 /**
  * 会员未支付订单 2014-8-14下午2:49:19
  *
  * @author wangmingyu
  */
 @InjectHttpOk({10, 11, 27})
 public void resultOk(ResponseEntity r) {
   dismissDialog();
   if (ResultParse.isResultOK(r, activity)) {
     switch (r.getKey()) {
       case 10:
         List<OrdrDetail> list = new ArrayList<OrdrDetail>();
         list = Handler_Json.jsonToBean(OrdrDetail.class, "list", r.getContentAsString());
         installData(list);
         break;
       case 11: // 查询订单组列表
         positionJson = r.getContentAsString();
         child = Handler_Json.jsonToBean(OrderDetailEntity.class, "list", r.getContentAsString());
         if (child != null) {
           order_center_list.expandGroup(groupPosition);
           if (Handler_String.isBlank(((OrderDetailEntity) oca.getChild(0, 0)).getCardNo())) {
             footerView.findViewById(R.id.rl_type_card).setVisibility(View.GONE);
             footerView.findViewById(R.id.rl_type_money).setVisibility(View.VISIBLE);
           } else {
             footerView.findViewById(R.id.rl_type_card).setVisibility(View.VISIBLE);
             footerView.findViewById(R.id.rl_type_money).setVisibility(View.GONE);
             TextView cardNo = (TextView) footerView.findViewById(R.id.tv_card_No);
             TextView cardPoint = (TextView) footerView.findViewById(R.id.tv_card_point);
             Selector selector = Selector.from(ReservationDto.class);
             selector.select(" * ");
             selector.where("cardNo", "=", ((OrderDetailEntity) oca.getChild(0, 0)).getCardNo());
             ReservationDto rd =
                 Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE).findFirst(selector);
             String card_no_6 = rd.getCardNo().substring(rd.getCardNo().length() - 6);
             cardNo.setText(getString(R.string._card_wh, card_no_6));
             cardPoint.setText(getString(R.string.usable_card_idx, rd.getCardRemainingIdx()));
           }
           order_center_list.addFooterView(footerView);
           oca.notifyDataSetChanged();
         }
         break;
       case 27: // 取消订单
         try {
           List<HashMap<String, String>> cancelList =
               Handler_Json.jsonToList("orderCancelList", r.getContentAsString());
           for (int i = 0; i < cancelList.size(); i++) {
             Ioc.getIoc()
                 .getDb("/sdcard/MTM/", Constants.APP_DATABASE)
                 .delete(
                     SubmittedOrderEntity.class,
                     WhereBuilder.b("orderNo", "=", cancelList.get(i).get("orderNo")));
           }
           // group.remove(groupPosition);
           // 获取当前未支付订单数量
           eventBus.post(new MSGCountEntity());
           group.clear();
           oca.notifyDataSetChanged();
           rl_tools.setVisibility(View.GONE);
         } catch (Exception e) {
           e.printStackTrace();
         }
         break;
     }
   }
 }
예제 #2
0
  /**
   * **********************************************
   *
   * @return void 返回类型
   * @throws @Title: init @Description: TODO(初始化数据) 设定文件
   * @date 2014-11-19 ***********************************************
   */
  @InjectInit
  public void init() {
    db = Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE);
    dataList = new ArrayList<HashMap<String, String>>();
    initView();
    mImageFetcher = new ImageDownloader(getActivity(), 300);
    mImageFetcher.setLoadingImage(R.drawable.default_load_image);
    eventBus.register(this, "onEventPostRoomList");

    // 设置list列表间距
    srla =
        new ConditionsRoomAdapter(
            activity, listview_roomlist, dataList, R.layout.reservation_screeningroom_item);
    listview_roomlist.setAdapter(srla);
    // 这里是设置里面的文字 可以不设置 默认有
    PullToRefreshManager.getInstance().setRelease_label("松开后刷新");
    PullToRefreshManager.getInstance()
        .setUpdateTime(org.apache.http.impl.cookie.DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
    showDialog();
    ajaxRoomList(1);
    ajaxPOST();
    gallery_hotel.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), HotelViewPagerActivity.class));
          }
        });
    search_layout.setVisibility(View.GONE);
  }
  /** @Function init @Description 初始化方法 初始化控件 @Input 无 @Return 无返回值 */
  @InjectInit
  public void init() {
    textview_title.setVisibility(View.VISIBLE);
    getSupportActionBar().setTitle("");
    title_center_layout.setVisibility(View.VISIBLE);
    foodTopDown.setVisibility(View.VISIBLE);
    eventBus.register(this, "onEventRefreshPayDetailData");
    cardType = 99; // 默认筛选条件是间夜消费
    // 初始化消费筛选列表
    setPayDetailFilterDataList();
    internetConfig = new InternetConfig();
    internetConfig.setKey(1);
    intent = getIntent();
    // 消费信息查询条件
    filtermap =
        (Map<String, String>) Handler_Json.JsonToHashMap(intent.getStringExtra("payDetailFilter"));
    filtermap.put("pageNo", pageNo + "");
    filtermap.put("pageCount", UrlParams.PAGESIZE + "");
    pageUtil = new PageUtil();

    adapter =
        new HotelCardPayDetailAdapter(
            hotelcard_pay_detail_list, mapList, R.layout.mem_hotelcard_pay_detail);
    hotelcard_pay_detail_list.setAdapter(adapter);
    showDialog(); // 打开模式层
    // 调用消费明细信息接口
    FastHttpHander.ajaxString(
        Url.METHOD_CARDCONSUMEARRAY,
        intent.getStringExtra("payDetailFilter"),
        internetConfig,
        this);
  }
예제 #4
0
 @InjectInit
 public void init() {
   MSGInfoEntity msg = new MSGInfoEntity();
   eventBus.post(msg);
   lv_list.setEmptyView(null_layout);
   datalist = new ArrayList<HashMap<String, String>>();
   pageUtil = new PageUtil();
   // getMsgTime();
   setAdpater();
   showDialog();
   getMsgList();
 }
예제 #5
0
  @InjectInit
  private void init() {
    int width = activity.getResources().getDisplayMetrics().widthPixels;
    LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(width, width / 3);
    FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(width, width / 3);
    RelativeLayout linearLayout3 = (RelativeLayout) mView.findViewById(R.id.linearLayout3);
    imageView6 = (ImageView) mView.findViewById(R.id.imageView6);
    restaurant_orderseat_image = (IMGGallery) mView.findViewById(R.id.restaurant_orderseat_image);
    restaurant_orderseat_image.setLayoutParams(layoutParams2);
    RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(width, width / 3);
    imageView6.setLayoutParams(layoutParams3);
    linearLayout3.setLayoutParams(layoutParams1);
    eventBus = EventBus.getDefault();

    home_page = (ImageView) mView.findViewById(R.id.home_page);
    jzyd = (RelativeLayout) mView.findViewById(R.id.jzyd);
    jzyd_layout = (RelativeLayout) mView.findViewById(R.id.jzyd_layout);
    jzyd_layout.setOnClickListener(onClickListener);
    OnEventChange();

    // 初始化轮询
    initGallery();
  }
예제 #6
0
/**
 * 未支付 作者:qqqqq on 2015/7/10 10:34 由于 ExpandableList 子列表数据异步加载 不及时,故把 adapter 写成内部类来调用
 * 邮箱:[email protected]
 */
public class OrderGroupFragment extends BaseFragment {
  public ArrayList<OrdrDetail> group; // 组列表

  @InjectView(R.id.order_center_list)
  private ExpandableListView order_center_list;

  @InjectView(R.id.null_layout)
  private LinearLayout null_layout;

  @InjectView(R.id.tx_select_card)
  private TextView tx_select_card; // 底部工具条 选择度假卡 按钮

  @InjectView(R.id.tx_tool_left)
  private TextView tx_tool_left; // 底部工具条 左侧按钮

  @InjectView(R.id.tx_tool_right)
  private TextView tx_tool_right; // 底部工具条 右侧按钮

  @InjectView(R.id.rl_tools)
  private RelativeLayout rl_tools;
  /** 底部工具栏 view 初始化 */
  //    private TextView tx_tool_left, tx_tool_right, tx_select_card;
  //    private RelativeLayout rl_tools;
  private int page = 1;

  public OrderCenterGroupAdapter oca; // 声明未支付订单组 适配器
  private int groupPosition; // 记录当前点击组id

  private ArrayList<String> tempPosition;
  public ArrayList<OrderDetailEntity> child; // 子集合列表
  public CommonAlert alert;
  private String positionJson; // 用于记录当前选择的数据
  public CountDownTimer countDownTimer;
  EventBus eventBus = EventBus.getDefault();
  View footerView;

  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    this.inflater = inflater;
    View rootView = inflater.inflate(R.layout.fragment_item_list, container, false);
    // fragment注解必须走这里
    Handler_Inject.injectFragment(this, rootView);
    initNoPayExpandableListView();
    return rootView;
  }

  /** 初始化底部菜单 */
  private void initToolBar() {

    tx_tool_left.setText("取消订单");
    tx_tool_left.setOnClickListener(onClick);
    tx_tool_right.setText("支付订单");
    tx_tool_right.setOnClickListener(onClick);
    Animation animation = AnimationUtils.loadAnimation(activity, R.anim.push_bottom_in);
    rl_tools.startAnimation(animation);
    rl_tools.setVisibility(View.VISIBLE);
  }

  /** 底部菜单 click 事件 */
  View.OnClickListener onClick =
      new View.OnClickListener() {
        @Override
        public void onClick(View view) {
          switch (view.getId()) {
            case R.id.tx_tool_left:
              // 取消订单
              cancelOrderConfrim();
              break;
            case R.id.tx_tool_right:
              // 支付订单
              confirmPost();
              break;
          }
        }
      };

  // 取消订单提示
  public void cancelOrderConfrim() {
    alert = new CommonAlert(activity);
    alert.setMessage("您将要取消一份已经提交但尚未支付的酒店订单组(含" + child.size() + "间房)");
    alert.setTitle("请确认操作");
    alert.setNegativeButton(
        "取消订单",
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            cancelOrder();
            alert.dismiss();
          }
        });
    alert.setPositiveButton(
        "保留订单",
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            //                startActivityForResult(new Intent(context,
            //                        LoginAndRegisterFragmentActivity.class).putExtra("tabType",
            //                        "cardlogin"), 2);
            alert.dismiss();
          }
        });
  }

  // 提示支付
  public void confirmPost() {
    alert = new CommonAlert(activity);
    alert.setMessage("您是否要立刻支付该订单?(订单有效时间为30分钟,超过后该订单自动失效,您需要重新下单)");
    alert.setTitle("订单已提交");
    alert.setNegativeButton(
        "稍后支付",
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            //                startActivity(intent);
            alert.dismiss();
          }
        });
    alert.setPositiveButton(
        "立即支付",
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent(activity, OrderCenterPayActivity.class);
            intent.putExtra("orderId", group.get(groupPosition).getOrderIdGroup());
            intent.putExtra(
                "failureTime", ((OrdrDetail) oca.getGroup(groupPosition)).getFailureTime());
            intent.putExtra("cardNo", ((OrderDetailEntity) oca.getChild(0, 0)).getCardNo());
            intent.putExtra("orderDetail", positionJson);
            startActivity(intent);
            alert.dismiss();
          }
        });
  }

  /** 获取异步信息传递 */
  Handler handler =
      new Handler() {
        public void handleMessage(Message msg) {
          Bundle bundle = msg.getData();
          int position = bundle.getInt("groupPosition");
          boolean isChecked = bundle.getBoolean("isChecked");
          if (!isChecked) {
            order_center_list.collapseGroup(groupPosition);
            tx_tool_right.setVisibility(View.GONE);
            //                tx_tool_right.setEnabled(false);
            //                tx_tool_left.setEnabled(false);
            order_center_list.removeFooterView(footerView);
          } else {
            tx_tool_right.setVisibility(View.VISIBLE);
            //                tx_tool_right.setEnabled(true);
            //                tx_tool_left.setEnabled(true);
          }
          //            Animation animation = null;

        }
      };

  @Override
  public void onResume() {
    super.onResume();
    //        initNoPayExpandableListView();
  }

  @Override
  public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);
    if (isVisibleToUser) {
      // fragment可见时执行加载数据或者进度条等
      if (group == null) {
        group = new ArrayList<>();
      }
      ajaxOrder();
    } else {
      // 不可见时不执行操作
    }
  }

  // 初始化未支付订单组
  private void initNoPayExpandableListView() {
    initFooterView();

    rl_tools.setVisibility(View.GONE);
    tempPosition = new ArrayList<>();
    if (null != countDownTimer) {
      countDownTimer.cancel();
      countDownTimer = null;
    }

    order_center_list.setEmptyView(null_layout);
    child = new ArrayList<>();
    child.add(new OrderDetailEntity());
    group = new ArrayList<OrdrDetail>();
    oca =
        new OrderCenterGroupAdapter(
            order_center_list, group, child, R.layout.order_group_item, handler);
    order_center_list.setAdapter(oca);
    // 禁用当前 组 点击事件(嵌套 listView 出现事件冲突)

    // 监听是否有展开的group
    order_center_list.setOnGroupExpandListener(
        new ExpandableListView.OnGroupExpandListener() {
          @Override
          public void onGroupExpand(int groupPosition) {
            for (int i = 0; i < oca.getGroupCount(); i++) {
              if (i != groupPosition && order_center_list.isGroupExpanded(groupPosition)) {
                order_center_list.collapseGroup(i);
              }
            }
          }
        });
    // 禁用当前 组 点击事件(嵌套 listView 出现事件冲突)
    order_center_list.setOnGroupClickListener(
        new ExpandableListView.OnGroupClickListener() {
          @Override
          public boolean onGroupClick(
              ExpandableListView expandableListView, View view, int groupPos, long l) {
            groupPosition = groupPos;

            boolean expanded = expandableListView.isGroupExpanded(groupPosition);

            if (!expanded) {
              // 在这加载数据,推荐使用AsycnTask之类的在另一个线程里做喽
              orderGroupDetailResult(group.get(groupPosition).getOrderIdGroup());

              return true;
            } else {
              tx_tool_right.setVisibility(View.GONE);
              order_center_list.removeFooterView(footerView);
            }
            return false;
          }
        });
    //        ajaxOrder();
    //        if(MapVo.get("ticket")==null){
    //            getNoLoginOrder();
    //        }else{
    //            checkTicket(MapVo.get("ticket") + "");
    //        }
  }

  /**
   * * 验证登录状态
   *
   * @param ticket 登录票据
   */
  private void checkTicket(String ticket) {
    showDialog();
    String url = Url.MEM_TICKET_VALID;
    JsonObject json = new JsonObject();
    json.addProperty("ticket", ticket);
    InternetConfig config = new InternetConfig();
    config.setKey(9);
    FastHttpHander.ajaxString(url, json.toString(), config, this);
  }

  @InjectHttpOk(9)
  private void checkTicketResult(ResponseEntity r) {
    dismissDialog();
    Map<String, String> map = r.getHeaders();
    if ("OK".equals(map.get(HeaderConst.MYMHOTEL_STATUS))) {
      // Toast.makeText(context, msgArray[1], Toast.LENGTH_SHORT).show();
      ajaxOrder();
    } else {
      getNoLoginOrder();
    }
  }

  private void initFooterView() {
    LayoutInflater inflater = LayoutInflater.from(activity);
    footerView = inflater.inflate(R.layout.order_group_footer, null);
  }

  /** 未支付订单 */
  private void getNoLoginOrder() {
    Selector selector = Selector.from(SubmittedOrderEntity.class);
    selector.select(" * ");
    List<SubmittedOrderEntity> list =
        Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE).findAll(selector);

    if (list != null && list.size() > 0) {
      initToolBar();
      OrdrDetail orderDetail = new OrdrDetail();
      Long time =
          DateUtil.getStartAndEndToTimes(
              DateUtil.formatDateTime(new Date(), "yyyy-MM-dd HH:mm:ss"),
              list.get(0).getCreateTime());
      orderDetail.setFailureTime(DateUtil.timer(time));
      String orderGroupId = "";
      String orderGroupNo = "";
      for (int i = 0; i < list.size(); i++) {
        if (Handler_String.isBlank(orderGroupId) || i != (list.size() - 1)) {
          orderGroupNo += list.get(i).getOrderNo() + ",";
          orderGroupId += list.get(i).getOrderId() + ",";
        } else {
          orderGroupId += list.get(i).getOrderId();
          orderGroupNo += list.get(i).getOrderNo();
        }
      }
      Ioc.getIoc().getLogger().d("订单组id:" + orderGroupId);
      orderDetail.setOrderIdGroup(orderGroupId);
      group.add(orderDetail);
      oca.notifyDataSetChanged();
    }
  }

  /** 未支付订单查询 */
  private void ajaxOrder() {
    showDialog();
    JsonObject json = new JsonObject();
    json.addProperty("pageNo", page);
    json.addProperty("pageCount", 100);
    json.addProperty("statusKind", 1);
    InternetConfig config1 = new InternetConfig();
    config1.setKey(10);
    // 未支付订单查询
    FastHttpHander.ajaxString(Url.MEMBER_ORDER_ARRAY, json.toString(), config1, this);
  }

  /** 订单详情(多组查询) */
  private void orderGroupDetailResult(String orderIdList) {
    showDialog();
    JsonObject json = new JsonObject();
    json.addProperty("orderIdList", orderIdList);
    InternetConfig config1 = new InternetConfig();
    config1.setKey(11);
    // 未支付订单查询
    FastHttpHander.ajaxString(Url.ORDER_DETAIL_ARRAY, json.toString(), config1, this);
  }

  /** 取消订单接口 */
  private void cancelOrder() {
    showDialog();
    JsonObject jsonParam = new JsonObject();
    jsonParam.addProperty("orderNoList", group.get(groupPosition).getOrderNoGroup());
    Ioc.getIoc().getLogger().i("取消预订接口参数:" + jsonParam.toString());
    InternetConfig config = new InternetConfig();
    config.setKey(27);
    FastHttpHander.ajaxString(
        Url.HOTELRESERVE_ACCURATE_CLEARRESERVE, jsonParam.toString(), config, this);
  }

  /**
   * 会员未支付订单 2014-8-14下午2:49:19
   *
   * @author wangmingyu
   */
  @InjectHttpOk({10, 11, 27})
  public void resultOk(ResponseEntity r) {
    dismissDialog();
    if (ResultParse.isResultOK(r, activity)) {
      switch (r.getKey()) {
        case 10:
          List<OrdrDetail> list = new ArrayList<OrdrDetail>();
          list = Handler_Json.jsonToBean(OrdrDetail.class, "list", r.getContentAsString());
          installData(list);
          break;
        case 11: // 查询订单组列表
          positionJson = r.getContentAsString();
          child = Handler_Json.jsonToBean(OrderDetailEntity.class, "list", r.getContentAsString());
          if (child != null) {
            order_center_list.expandGroup(groupPosition);
            if (Handler_String.isBlank(((OrderDetailEntity) oca.getChild(0, 0)).getCardNo())) {
              footerView.findViewById(R.id.rl_type_card).setVisibility(View.GONE);
              footerView.findViewById(R.id.rl_type_money).setVisibility(View.VISIBLE);
            } else {
              footerView.findViewById(R.id.rl_type_card).setVisibility(View.VISIBLE);
              footerView.findViewById(R.id.rl_type_money).setVisibility(View.GONE);
              TextView cardNo = (TextView) footerView.findViewById(R.id.tv_card_No);
              TextView cardPoint = (TextView) footerView.findViewById(R.id.tv_card_point);
              Selector selector = Selector.from(ReservationDto.class);
              selector.select(" * ");
              selector.where("cardNo", "=", ((OrderDetailEntity) oca.getChild(0, 0)).getCardNo());
              ReservationDto rd =
                  Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE).findFirst(selector);
              String card_no_6 = rd.getCardNo().substring(rd.getCardNo().length() - 6);
              cardNo.setText(getString(R.string._card_wh, card_no_6));
              cardPoint.setText(getString(R.string.usable_card_idx, rd.getCardRemainingIdx()));
            }
            order_center_list.addFooterView(footerView);
            oca.notifyDataSetChanged();
          }
          break;
        case 27: // 取消订单
          try {
            List<HashMap<String, String>> cancelList =
                Handler_Json.jsonToList("orderCancelList", r.getContentAsString());
            for (int i = 0; i < cancelList.size(); i++) {
              Ioc.getIoc()
                  .getDb("/sdcard/MTM/", Constants.APP_DATABASE)
                  .delete(
                      SubmittedOrderEntity.class,
                      WhereBuilder.b("orderNo", "=", cancelList.get(i).get("orderNo")));
            }
            // group.remove(groupPosition);
            // 获取当前未支付订单数量
            eventBus.post(new MSGCountEntity());
            group.clear();
            oca.notifyDataSetChanged();
            rl_tools.setVisibility(View.GONE);
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
      }
    }
  }

  @InjectHttpErr({9, 10, 11, 27})
  public void resultErr(ResponseEntity r) {
    if (r.getKey() == 9) {
      getNoLoginOrder();
    }
    dismissDialog();
    Toast.makeText(activity, ErrorMessageEnum.SYSTEM_EXCEPTION.getName(), Toast.LENGTH_SHORT)
        .show();
  }

  // 过滤精准未支付订单
  private void installData(List<OrdrDetail> list) {
    if (group != null) group.clear();
    else group = new ArrayList<>();
    if (null != list) {
      for (int i = 0; i < list.size(); i++) {
        OrdrDetail od = list.get(i);
        // 只获取 精准订单
        if ("0".equals(od.getOrderType())
            && OrderStateEnum.notPay.getCode().equals(od.getStatus())) {
          group.add(od);
        }
      }
    }

    if (group.size() > 0) {
      initToolBar();
    } else {
      rl_tools.setVisibility(View.GONE);
      DbUtils db = Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE);
      db.deleteAll(SubmittedOrderEntity.class);
      // 获取当前未支付订单数量
      postMsgCount(group.size());
    }
    oca.notifyDataSetChanged();
  }

  private void postMsgCount(int count) {
    MSGCountEntity msg = new MSGCountEntity();
    msg.setCount(count);
    msg.setActivity(activity);
    eventBus.post(msg);
  }

  @Override
  public void onDestroyView() {
    dismissDialog();
    Ioc.getIoc().getLogger().d("切换fragment");
    if (null != countDownTimer) {
      countDownTimer.cancel();
      countDownTimer.onFinish();
      countDownTimer = null;
      Ioc.getIoc().getLogger().d("清除计时器");
    }
    oca = null;
    super.onDestroyView();
  }

  @Override
  public void onDestroy() {
    Ioc.getIoc().getLogger().d("销毁fragment");
    dismissDialog();
    if (null != countDownTimer) {
      countDownTimer.cancel();
      countDownTimer.onFinish();
      countDownTimer = null;
      Ioc.getIoc().getLogger().d("清除计时器");
    }

    super.onDestroy();
  }

  ////////////////////////////////////////////////////////////////////////////////////////////////////
  // 由于 ExpandableList 子列表数据异步加载 不及时,故把 adapter 写成内部类来调用
  public class OrderCenterGroupAdapter extends BaseExpandableListAdapter {

    private Context context;
    private List<OrdrDetail> group; // 组列表
    //        private ArrayList<OrderDetailEntity> child;
    private int layout_id;
    int lastItem = -1;
    int result = 0;
    private Thread thread;
    ViewHolder viewHolder = null;
    ExpandableListView listView = null;
    Handler handler = null;
    private Map<Integer, Boolean> checkStatusMap = new HashMap<Integer, Boolean>();

    public OrderCenterGroupAdapter(
        ExpandableListView listView,
        List<OrdrDetail> group,
        ArrayList<OrderDetailEntity> child,
        int layout_id,
        Handler handler) {
      this.context = listView.getContext();
      this.listView = listView;
      this.group = group;
      this.layout_id = layout_id;
      //            this.child=child;
      this.handler = handler;
      int position = 0;
      for (int i = 0; i < group.size(); i++) {
        checkStatusMap.put(position++, false);
      }
      //        LvHeightUtil.setListViewHeightBasedOnChildren(listView);
    }

    public class ViewHolder {

      CheckBox order_checkBox; // 选择按钮
      ImageView del_img; // 删除按钮
      RelativeLayout relative_layout5;
      ImageView hotel_order_detail_down;

      TextView order_heard_show; // 用于显示精准预订 入住离店时间 或 传统预订 订单号
      TextView hotel_order_payState;
      TextView confirm_no;
      TextView create_order_date; // 创建时间
      TextView order_check_in_date; // 入住和离店时间
      TextView text_count_days;
      TextView hotel_room_type,
          hotel_order_inroom_day,
          hotel_order_outroom_day,
          hotel_order_no,
          tx_guest_name,
          tx_guest_phone,
          point_value,
          price_value;
    }

    @Override
    public int getGroupCount() {
      return group.size();
    }

    @Override
    public int getChildrenCount(int i) {

      return group.get(i).getOrderIdGroup().split(",").length;
    }

    @Override
    public Object getGroup(int i) {
      return group.get(i);
    }

    @Override
    public Object getChild(int i, int i1) {
      return child.get(i1);
    }

    @Override
    public long getGroupId(int i) {
      return i;
    }

    @Override
    public long getChildId(int i, int i1) {
      return i1;
    }

    @Override
    public boolean hasStableIds() {
      return true;
    }

    @Override
    public View getGroupView(
        final int groupPosition, boolean isExpanded, View convertView, ViewGroup viewGroup) {

      if (convertView == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(layout_id, null);

        viewHolder.hotel_order_payState =
            (TextView) convertView.findViewById(R.id.hotel_order_payState);
        viewHolder.create_order_date = (TextView) convertView.findViewById(R.id.create_order_date);
        viewHolder.del_img = (ImageView) convertView.findViewById(R.id.del_img);
        viewHolder.hotel_order_payState =
            (TextView) convertView.findViewById(R.id.hotel_order_payState);
        viewHolder.relative_layout5 =
            (RelativeLayout) convertView.findViewById(R.id.relative_layout5);
        viewHolder.hotel_order_detail_down =
            (ImageView) convertView.findViewById(R.id.hotel_order_detail_down);
        viewHolder.order_checkBox = (CheckBox) convertView.findViewById(R.id.order_checkBox);
        viewHolder.order_check_in_date =
            (TextView) convertView.findViewById(R.id.order_check_in_date);

        viewHolder.order_checkBox.setFocusable(false);
        viewHolder.order_checkBox.setClickable(false);
        Timers(
            timerCount(group.get(groupPosition).getFailureTime()),
            viewHolder.order_check_in_date,
            groupPosition);
        convertView.setTag(viewHolder);
      } else {
        viewHolder = (ViewHolder) convertView.getTag();
      }
      if (isExpanded) {
        viewHolder.order_checkBox.setChecked(true);
      } else {
        viewHolder.order_checkBox.setChecked(false);
      }
      viewHolder.order_checkBox.setOnCheckedChangeListener(
          new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
              // 异步传递信息
              Message msg = new Message();
              Bundle build = new Bundle();
              build.putInt("groupPosition", groupPosition);
              build.putBoolean("isChecked", b);
              msg.setData(build);
              handler.sendMessage(msg);
            }
          });
      //            RelativeLayout relative_layout = (RelativeLayout)
      // convertView.findViewById(R.id.relative_layout5);
      //            relative_layout.setVisibility(View.GONE);
      viewHolder.hotel_order_payState.setBackgroundResource(R.drawable.order_red);
      viewHolder.hotel_order_payState.setText(
          OrderStateEnum.getOrderStateEnumName(group.get(groupPosition).getStatus()));
      viewHolder.order_checkBox.setText("已经提交订单 请在倒计时结束前支付");
      //
      // viewHolder.create_order_date.setText(group.get(groupPosition).getOrderInfo().getCreateDate());
      viewHolder.order_check_in_date.setText("剩余支付时间 " + group.get(groupPosition).getFailureTime());
      return convertView;
    }

    @Override
    public View getChildView(
        int groupPosition, int childPosition, boolean b, View view, ViewGroup viewGroup) {
      //        OrderCenterItemAdapter carStyleAdapter = new OrderCenterItemAdapter(context,new
      // HashMap<String ,String>(),R.layout.order_center_child_item);

      ViewHolder viewHolder1 = null;
      if (view == null) {
        viewHolder1 = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(context);
        view = inflater.inflate(R.layout.order_group_middle, null);
        viewHolder1.order_heard_show = (TextView) view.findViewById(R.id.order_heard_show);
        viewHolder1.hotel_room_type = (TextView) view.findViewById(R.id.hotel_room_type);
        viewHolder1.hotel_order_inroom_day =
            (TextView) view.findViewById(R.id.hotel_order_inroom_day);
        viewHolder1.hotel_order_outroom_day =
            (TextView) view.findViewById(R.id.hotel_order_outroom_day);
        viewHolder1.hotel_order_no = (TextView) view.findViewById(R.id.hotel_order_no);
        viewHolder1.tx_guest_name = (TextView) view.findViewById(R.id.tx_guest_name);
        viewHolder1.tx_guest_phone = (TextView) view.findViewById(R.id.tx_guest_phone);
        viewHolder1.point_value = (TextView) view.findViewById(R.id.point_value);
        viewHolder1.price_value = (TextView) view.findViewById(R.id.price_value);
        viewHolder1.text_count_days = (TextView) view.findViewById(R.id.text_count_days);

        view.setTag(viewHolder1);
      } else {
        viewHolder1 = (ViewHolder) view.getTag();
      }
      if (child != null) {

        viewHolder1.hotel_order_inroom_day.setText(
            DateUtil.formatStringDateTime(
                child.get(childPosition).getRoomInfo().getStartDate(), "MM月dd日"));
        viewHolder1.hotel_order_outroom_day.setText(
            DateUtil.formatStringDateTime(
                child.get(childPosition).getRoomInfo().getEndDate(), "MM月dd日"));
        viewHolder1.order_heard_show.setText(child.get(childPosition).getRoomInfo().getHotelName());
        viewHolder1.hotel_room_type.setText(
            child.get(childPosition).getRoomInfo().getViewIntro()
                + child.get(childPosition).getRoomInfo().getRoomTypeName()
                + "-"
                + child.get(childPosition).getRoomInfo().getFloorName()
                + "-"
                + child.get(childPosition).getRoomInfo().getRoomCode()
                + " "
                + child.get(childPosition).getRoomInfo().getBedTypeContent());
        int subday =
            DateUtil.nDaysBetweenTwoDate(
                child.get(childPosition).getRoomInfo().getStartDate(),
                child.get(childPosition).getRoomInfo().getEndDate());
        viewHolder1.text_count_days.setText(
            context.getString(R.string._subday, subday + "")); // 共计天数
      }
      return view;
    }

    private Long timerCount(String failureTime) {
      Long s = 0L;
      if (!Handler_String.isBlank(failureTime)) {
        String[] date = failureTime.split(":");
        s = Long.valueOf(date[0]) * 3600; // 小时
        s += Long.valueOf(date[1]) * 60; // 分钟
        s += Long.valueOf(date[2]); // 秒
      }
      return s;
    }

    // 计算倒计时,防止 多数据 计算倒计时或 及多次创建对象 出现内存占用过多 使用一个现成处理
    private void Timers(Long time, final TextView view, final int groupPosition) {
      countDownTimer =
          new CountDownTimer(time * 1000, 1000) {
            @Override
            public void onTick(long l) {
              if (getActivity() != null && group != null && group.size() > 0) { // 防止在切换时无限调用

                group.get(groupPosition).setFailureTime(DateUtil.timer(l / 1000));
                Ioc.getIoc().getLogger().d(DateUtil.timer(l / 1000));
                notifyDataSetChanged();
              } else {
                cancel();
              }
            }

            @Override
            public void onFinish() {
              if (getActivity() != null && group != null && group.size() > 0) { // 防止在切换时无限调用
                group.get(groupPosition).setFailureTime("00:00:00");
              }
              notifyDataSetChanged();
            }
          }.start();
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
      return true;
    }
  }
}
예제 #7
0
 private void postMsgCount(int count) {
   MSGCountEntity msg = new MSGCountEntity();
   msg.setCount(count);
   msg.setActivity(activity);
   eventBus.post(msg);
 }
/**
 * @copyright bupt
 * @author 李洁
 * @date 2014-11-19 @Description 会员中心--卡消费明细列表
 */
@InjectLayer(
    value = R.layout.mem_hotelcard_pay_detail_list,
    parent = R.id.center_common,
    isFull = false,
    isTitle = true)
public class HotelCardPayDetailActivity extends CommonActivity {
  @InjectView(value = R.id.title_center_layout)
  LinearLayout title_center_layout;

  EventBus eventBus = EventBus.getDefault();

  @InjectView(value = R.id.hotelcard_pay_detail_list)
  ListView hotelcard_pay_detail_list;

  @InjectView(value = R.id.scrollView1, pull = true)
  ScrollView scrollView1;

  ArrayList<HashMap<String, String>> mapList = new ArrayList<HashMap<String, String>>();
  HotelCardPayDetailAdapter adapter; // 适配器

  @InjectView(value = R.id.foodTopDown)
  ImageView foodTopDown;

  InternetConfig internetConfig; // 网络配置
  PageUtil pageUtil;
  int count;
  int pageNo = 1;
  // 筛选
  ArrayList<HashMap<String, String>> payDetailmapList;
  // 筛选条件
  Map<String, String> filtermap = new HashMap<String, String>();
  Intent intent;
  int cardType;

  /** @Function init @Description 初始化方法 初始化控件 @Input 无 @Return 无返回值 */
  @InjectInit
  public void init() {
    textview_title.setVisibility(View.VISIBLE);
    getSupportActionBar().setTitle("");
    title_center_layout.setVisibility(View.VISIBLE);
    foodTopDown.setVisibility(View.VISIBLE);
    eventBus.register(this, "onEventRefreshPayDetailData");
    cardType = 99; // 默认筛选条件是间夜消费
    // 初始化消费筛选列表
    setPayDetailFilterDataList();
    internetConfig = new InternetConfig();
    internetConfig.setKey(1);
    intent = getIntent();
    // 消费信息查询条件
    filtermap =
        (Map<String, String>) Handler_Json.JsonToHashMap(intent.getStringExtra("payDetailFilter"));
    filtermap.put("pageNo", pageNo + "");
    filtermap.put("pageCount", UrlParams.PAGESIZE + "");
    pageUtil = new PageUtil();

    adapter =
        new HotelCardPayDetailAdapter(
            hotelcard_pay_detail_list, mapList, R.layout.mem_hotelcard_pay_detail);
    hotelcard_pay_detail_list.setAdapter(adapter);
    showDialog(); // 打开模式层
    // 调用消费明细信息接口
    FastHttpHander.ajaxString(
        Url.METHOD_CARDCONSUMEARRAY,
        intent.getStringExtra("payDetailFilter"),
        internetConfig,
        this);
  }

  /** @Function resultOk @Description 消费明细列表响应结果 @Input r:响应结果封装实体类 @Return 无返回值 */
  @InjectHttpOk(1)
  public void resultOk(ResponseEntity r) {
    Ioc.getIoc().getLogger().i("消费明细列表返回结果【" + r + "】");
    try {

      // 返回结果格式化处理后OK进行数据处理
      if (ResultParse.isResultOK(r, this)) {
        count = getTotalCount(r.getContentAsString());

        if (count == 0) {
          mapList.clear();
          adapter.notifyDataSetChanged(); // 列表变化
          cancelDialog();
          return;
        }

        this.getMapList(r.getContentAsString());
        adapter.notifyDataSetChanged(); // 列表变化
      }

      pageUtil.isEndRefreshPage(); // 结束刷新
      cancelDialog();

    } catch (Exception e) {
      cancelDialog();
    }
  }

  /**
   * @Function pageRefresh @Description 分页
   *
   * @input type:1:向下翻页 2,向上翻页
   * @return 无返回值
   */
  @InjectPullRefresh
  public void pageRefresh(int type) {
    // 消费列表接口分页
    Ioc.getIoc().getLogger().i("红树林卡消费接口:[" + Url.METHOD_CARDCONSUMEARRAY + "]");
    internetConfig.setKey(1);
    switch (type) {
      case InjectView.PULL: // 向下翻页
        pageNo++;
        if (pageNo > count) {
          pageUtil.isEndDownPage(); // 结束翻页
          return;
        }
        // 设置输入参数
        filtermap.put("pageNo", pageNo + "");
        filtermap.put("pageCount", UrlParams.PAGESIZE + "");
        showDialog();
        // 调用后接口
        FastHttpHander.ajaxString(
            Url.METHOD_CARDCONSUMEARRAY, Handler_Json.beanToJson(filtermap), internetConfig, this);

        break;
      case InjectView.DOWN:
        pageUtil.isEndDownPage();
        break;
    }
  }

  /** @Function resultErr @Description 请求结果失败处理 @Input r:请求结果封装实体类 @Return 无返回值 */
  @InjectHttpErr(value = {1})
  public void resultErr(ResponseEntity r) {
    switch (r.getKey()) {
        // 消费明细
      case 1:
        Ioc.getIoc().getLogger().i("消费明细接口获取失败,请检查网络或者接口");
        Toast.makeText(this, "消费明细接口获取失败,请检查网络或者接口", Toast.LENGTH_SHORT).show();
        break;
    }

    cancelDialog();
  }

  /**
   * @Function onEventRefreshPayDetailData @Description 根据请求条件 调用消费明细接口 @Input
   * entity:请求参数实体类数据 @Return 无返回值
   */
  public void onEventRefreshPayDetailData(MenuRefreshEventEntity entity) {
    // 排序方式
    if (!Handler_String.isBlank(entity.getMenuKindCode())
        && !Handler_String.isBlank(entity.getMenuKindName())) {
      cardType = Integer.parseInt(entity.getMenuKindCode());
      textview_title.setText(entity.getMenuKindName());
      mapList.clear();
      pageNo = 1;
      // 设置输入参数
      if (entity.getMenuKindCode().equals("0")) {
        filtermap.put("cardType", "");
      } else {
        filtermap.put("cardType", entity.getMenuKindCode());
      }
      filtermap.put("pageNo", pageNo + "");
      filtermap.put("pageCount", UrlParams.PAGESIZE + "");

      showDialog(); // 打开模式层
      // 调用消费明细信息接口
      FastHttpHander.ajaxString(
          Url.METHOD_CARDCONSUMEARRAY, Handler_Json.beanToJson(filtermap), internetConfig, this);
    }

    foodTopDown.setImageResource(R.drawable.arrow_down_white);
  }

  /** @Function titleClick @Description 标题单机时间 @Input view:被点击的控件 @Return 无返回值 */
  @InjectMethod(
      @InjectListener(
          ids = {R.id.textview_title},
          listeners = {OnClick.class}))
  public void titleClick(View view) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("menuKindCode", cardType + "");
    MenuCategoryPopupWindow menu = new MenuCategoryPopupWindow(this, payDetailmapList, map);
    menu.showAsDropDown(getActionBarToolbar(), 0, 0);
    foodTopDown.setImageResource(R.drawable.arrow_up_white);
    //		Animation at=AnimationUtils.loadAnimation(this, R.anim.push_bottom_out);
    //		at.setDuration(300);
    //		menu.startAnimation(at);

  }

  /** @Function setPayDetailFilterDataList @Description 设置消费明细条件列表 @Input 无 @Return 无返回值 */
  private void setPayDetailFilterDataList() {
    payDetailmapList = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> map1 = new HashMap<String, String>();
    map1.put("value", "间夜点数");
    map1.put("code", "99");

    HashMap<String, String> map2 = new HashMap<String, String>();
    map2.put("value", "预分红账户");
    map2.put("code", "40");

    HashMap<String, String> map3 = new HashMap<String, String>();
    map3.put("value", "提现账户");
    map3.put("code", "50");

    HashMap<String, String> map4 = new HashMap<String, String>();
    map4.put("value", "红树林币账户");
    map4.put("code", "00");

    HashMap<String, String> map5 = new HashMap<String, String>();
    map5.put("value", "娱乐吧账户(casino币)");
    map5.put("code", "20");

    HashMap<String, String> map6 = new HashMap<String, String>();
    map6.put("value", "积分账户");
    map6.put("code", "30");

    payDetailmapList.add(map1);
    payDetailmapList.add(map2);
    payDetailmapList.add(map3);
    payDetailmapList.add(map4);
    payDetailmapList.add(map5);
    payDetailmapList.add(map6);
  }

  /**
   * @Function getMapList @Description 格式化消费订单列表,封装到适配器中 @Input jsonString:消费明细json格式 @Return 无返回值
   */
  public ArrayList<HashMap<String, String>> getMapList(String jsonString) {
    ArrayList<HashMap<String, String>> list =
        (ArrayList<HashMap<String, String>>) Handler_Json.jsonToListOrMap("list", jsonString);
    for (HashMap<String, String> map : list) {
      // 格式化时间
      Handler_Time costDate = Handler_Time.getInstance(map.get("costDate").toString());

      HashMap<String, String> hashMap = new HashMap<String, String>();
      hashMap.put(
          "hotel_card_recordType",
          map.get("unitName").toString() + "-" + map.get("recordType").toString());
      hashMap.put(
          "hotel_card_costime",
          DateUtil.formatStringDateTime(map.get("costDate").toString(), "yyyy.MM.dd  HH:mm"));
      hashMap.put("hotel_card_unitcost", map.get("unitCost").toString());

      mapList.add(hashMap);
    }

    return mapList;
  }
  /**
   * 红树林卡消费列表信息总条数
   *
   * @param jsonString 红树林卡消费明细json数据
   */
  public int getTotalCount(String jsonString) {
    return Integer.parseInt(Handler_Json.getValue("count", jsonString).toString());
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    eventBus.unregister(this);
    cancelDialog();
  }
}
 @Override
 protected void onDestroy() {
   super.onDestroy();
   eventBus.unregister(this);
   cancelDialog();
 }
예제 #10
0
/**
 * **********************************************
 *
 * @copyright:bupt
 * @author: 王明雨
 * @date:2014-11-19 @Description: (条件筛选房间) ************************************************
 */
public class ConditionsRoomFragment extends BaseFragment {
  @InjectView(value = R.id.listview_roomlist, down = true, pull = true)
  ListView listview_roomlist;

  IMGGallery gallery_hotel;
  LinearLayout indicator_container;
  TextView text_startDate;
  TextView text_endDate;
  TextView text_count_days;
  TextView text_hotelname;
  TextView text_hotelidx;
  public View heardView;

  @InjectView(value = R.id.search_layout)
  RelativeLayout search_layout;
  /**
   * 图片下载器
   *
   * @author wangmingyu 2014-9-17
   */
  // 图片集合
  private ArrayList<HashMap<String, String>> imgList = new ArrayList<HashMap<String, String>>();
  // 房间列表集合
  private ArrayList<HashMap<String, String>> dataList;
  // 当前选中图片itemid
  private int preSelImgIndex = 0;
  // 筛选房间适配器
  private ConditionsRoomAdapter srla;
  // 图片适配器
  private ImagePagerAdapter ipaAdapter;
  // 目前位置 保存的预订选择信息
  private ReservationDto rd;
  private EventBus eventBus = EventBus.getDefault();
  private int pageNo = 1; // 当前页数
  public static ImageDownloader mImageFetcher = null;
  DbUtils db = null;

  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater; // 出事化布局文件
    View rootView = inflater.inflate(R.layout.reservation_conditions_room_main, container, false);
    // fragment注解必须走这里
    Handler_Inject.injectFragment(this, rootView);
    return rootView;
  }

  /**
   * **********************************************
   *
   * @param type 设定文件
   * @return void 返回类型
   * @throws @Title: callListView @Description: TODO(上滑 下滑 监控)
   * @date 2014-11-19 ***********************************************
   */
  @InjectPullRefresh
  protected void callListView(int type) {
    // 这里的type来判断是否是下拉还是上拉
    switch (type) {
      case InjectView.PULL:
        ajaxRoomList(pageNo);
        break;

      case InjectView.DOWN:
        dataList.clear();
        srla.notifyDataSetChanged();
        ajaxRoomList(1);
        break;
    }
  }

  /**
   * **********************************************
   *
   * @return void 返回类型
   * @throws @Title: init @Description: TODO(初始化数据) 设定文件
   * @date 2014-11-19 ***********************************************
   */
  @InjectInit
  public void init() {
    db = Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE);
    dataList = new ArrayList<HashMap<String, String>>();
    initView();
    mImageFetcher = new ImageDownloader(getActivity(), 300);
    mImageFetcher.setLoadingImage(R.drawable.default_load_image);
    eventBus.register(this, "onEventPostRoomList");

    // 设置list列表间距
    srla =
        new ConditionsRoomAdapter(
            activity, listview_roomlist, dataList, R.layout.reservation_screeningroom_item);
    listview_roomlist.setAdapter(srla);
    // 这里是设置里面的文字 可以不设置 默认有
    PullToRefreshManager.getInstance().setRelease_label("松开后刷新");
    PullToRefreshManager.getInstance()
        .setUpdateTime(org.apache.http.impl.cookie.DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
    showDialog();
    ajaxRoomList(1);
    ajaxPOST();
    gallery_hotel.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            startActivity(new Intent(getActivity(), HotelViewPagerActivity.class));
          }
        });
    search_layout.setVisibility(View.GONE);
  }

  /**
   * @return void 返回类型
   * @throws @Title: initView @Description: 初始化控件
   */
  public void initView() {
    LayoutInflater inflater = android.view.LayoutInflater.from(getActivity());
    heardView = inflater.inflate(R.layout.reservation_conditions_room, null);
    listview_roomlist.addHeaderView(heardView);
    gallery_hotel = (IMGGallery) heardView.findViewById(R.id.gallery_hotel);
    indicator_container = (LinearLayout) heardView.findViewById(R.id.indicator_container);
    text_startDate = (TextView) heardView.findViewById(R.id.text_startDate);
    text_endDate = (TextView) heardView.findViewById(R.id.text_endDate);
    text_count_days = (TextView) heardView.findViewById(R.id.text_count_days);
    text_hotelname = (TextView) heardView.findViewById(R.id.text_hotelname);
    text_hotelidx = (TextView) heardView.findViewById(R.id.text_hotelidx);

    rd = (ReservationDto) MapVo.get("reservtion");
    text_hotelname.setText(rd.getHotelName());
    text_hotelidx.setText(rd.getProjectIdx());
    text_startDate.setText(rd.getStartDate());
    text_endDate.setText(rd.getEndDate());
    int subDay = DateUtil.nDaysBetweenTwoDate(rd.getStartDate(), rd.getEndDate());
    text_count_days.setText(getString(R.string._subday, subDay));
  }

  /** 获取未提交订单 */
  private List<OrderCenterEntity> getNotSubOrder(String startDate, String endDate) {

    Selector selector = Selector.from(OrderCenterEntity.class);
    selector.select(" * ");
    selector.where("startDate", "=", startDate);
    selector.and("endDate", "=", endDate);
    List<OrderCenterEntity> list = db.findAll(selector);

    return list;
  }

  /**
   * **********************************************
   *
   * @return void 返回类型
   * @throws @Title: ajaxPOST @Description: (酒店介绍 图片列表 请求操作) 设定文件
   * @date 2014-11-19 ***********************************************
   */
  private void ajaxPOST() {
    rd = (ReservationDto) MapVo.get("reservtion");
    if (rd == null) {
      Toast.makeText(activity, "数据异常,请重新选择酒店及入住时间", Toast.LENGTH_SHORT).show();
    } else {
      if (rd.getHotelCode() != null && rd.getHotelCode() != "") {
        String jsonParams = "{'hotelCode':" + rd.getHotelCode() + "}";
        InternetConfig config = new InternetConfig();
        config.setKey(111);
        FastHttpHander.ajaxString(Url.HOTELRESERVE_ASSET_BULIDING_ARRAY, jsonParams, config, this);
      } else {
        Toast.makeText(activity, "数据异常,请重新选择酒店及入住时间", Toast.LENGTH_SHORT).show();
      }
    }
  }

  /**
   * **********************************************
   *
   * @param r 设定文件
   * @return void 返回类型
   * @throws @Title: fastResult @Description: (酒店楼宇接口 返回)
   * @date 2014-11-19 ***********************************************
   */
  @InjectHttpOk(value = {111})
  protected void fastResult(ResponseEntity r) {
    System.out.println(r.getStatus());
    switch (r.getStatus()) {
      case FastHttp.result_ok:
        if (ResultParse.reservationIsResultOK(r, activity)) {
          imgList = Handler_Json.JsonToCollection(r.getContentAsString());
          // InitFocusIndicatorContainer();
          // initGallery();
          ipaAdapter = new ImagePagerAdapter(activity, imgList, indicator_container);

          gallery_hotel.setAdapter(ipaAdapter);
          ipaAdapter.notifyDataSetChanged();
          gallery_hotel.setFocusable(true);
        }
        break;
      case FastHttp.result_net_err:
        Toast.makeText(activity, "网络异常 ,请检查您确保开启无线网络", Toast.LENGTH_SHORT).show();
        break;
    }
  }

  /**
   * **********************************************
   *
   * @param r 设定文件
   * @return void 返回类型
   * @throws @Title: result @Description: (推荐房间返回)
   * @date 2014-11-19 ***********************************************
   */
  @InjectHttpOk(1)
  public void result(ResponseEntity r) {
    dismissDialog();
    switch (r.getStatus()) {
      case FastHttp.result_ok:
        ArrayList<HashMap<String, String>> list = null;
        try {
          // if (ResultParse.reservationIsResultOK(r, activity)) {
          String json = Handler_Json.getValue("list", r.getContentAsString()).toString();
          String s = Handler_Json.getValue("pageNo", r.getContentAsString()).toString();
          pageNo = Integer.valueOf(s) + 1;
          if (!"".equals(json)) { // 判断查询数据是否为空 ,
            list = Handler_Json.JsonToCollection(json);
            getList(list);
          } else { // 为空数据 初始化当前页数1 ,展示无数据图片
            // pageNo = 1;
            // dataList.clear();
            Toast.makeText(activity, "无数据", Toast.LENGTH_SHORT).show();
          }
          Ioc.getIoc().getLogger().i(" 完成 刷新");
          // }
        } catch (Exception e) {
          e.printStackTrace();
        }

        break;
      case FastHttp.result_net_err:
        Toast.makeText(activity, "请求错误", Toast.LENGTH_SHORT).show();
        break;
    }
    // 完成 加载更多
    PullToRefreshManager.getInstance().onFooterRefreshComplete();
    // 完成 刷新
    PullToRefreshManager.getInstance().onHeaderRefreshComplete();

    // 关闭顶部的下拉
    PullToRefreshManager.getInstance().headerUnable();
    // 打开顶部的下拉
    PullToRefreshManager.getInstance().headerEnable();
    // 关闭底部的加载
    PullToRefreshManager.getInstance().footerUnable();
    // 打开顶部的加载
    PullToRefreshManager.getInstance().footerEnable();
  }

  /**
   * **********************************************
   *
   * @param r 返回信息
   * @return void 返回类型
   * @throws @Title: resultErr @Description: (http请求错误返回方法)
   * @date 2014-11-19 ***********************************************
   */
  @InjectHttpErr(value = {1, 111})
  private void resultErr(ResponseEntity r) {
    Ioc.getIoc().getLogger().e(r.getContentAsString());
    dismissDialog();
    Toast.makeText(activity, "请求错误", Toast.LENGTH_SHORT).show();
  }

  /**
   * **********************************************
   *
   * @param list 设定文件
   * @return void 返回类型
   * @throws @Title: getList @Description: TODO(为适配器装载数据)
   * @date 2014-11-19 ***********************************************
   */
  private void getList(ArrayList<HashMap<String, String>> list) {

    // RoomResourceDto
    if (list != null) {
      // dataList.clear();
      List<OrderCenterEntity> orderList = getNotSubOrder(rd.getStartDate(), rd.getEndDate());

      for (int i = 0; i < list.size(); i++) {

        HashMap<String, String> hashMap = new HashMap<String, String>();
        HashMap<String, String> r = list.get(i);
        if (orderList != null) {
          for (int j = 0; j < orderList.size(); j++) {
            if (orderList.get(j).getRoomCode().equals(r.get("roomCode"))) {
              hashMap.put("img_sel", "1"); // 是否存在 1是 空或0 不是
            }
          }
        }
        hashMap.put(
            "text_room_name",
            r.get("roomTypeName") + "-" + r.get("floorName") + "-" + r.get("roomCode"));
        hashMap.put("text_myExam_content", r.get("viewIntro"));
        hashMap.put("text_room_idx", getString(R.string._room_idx, r.get("roomIdx")));
        // hashMap.put("text_room_idx",
        // getString(R.string._room_idx,rd.get("roomIdx")));
        //                if (null != rd.getCardNo() && !"".equals(rd.getCardNo())) {
        //                    hashMap.put("text_pointsNight", r.get("idx") + "间夜");
        //                } else {
        //                    hashMap.put("text_pointsNight",
        //                            getString(R.string._price, r.get("price")));
        //                }
        hashMap.put("text_pointsNight", getString(R.string._price, r.get("price")));
        hashMap.put("text_infarIntro", r.get("infarIntro"));
        hashMap.put("roomCode", r.get("roomCode"));
        hashMap.put("image_myExam_infoIcon", r.get("logoUrl")); // rd.get("logoUrl")

        hashMap.put("btn_reservation", "预订");
        dataList.add(hashMap);
      }
    }
    srla.notifyDataSetChanged();
  }

  /**
   * **********************************************
   *
   * @param parent
   * @param view
   * @param position
   * @param id 设定文件
   * @return void 返回类型
   * @throws @Title: itemClick @Description: TODO(酒店图片轮播点击事件)
   * @date 2014-11-19 ***********************************************
   */
  @InjectMethod(
      @InjectListener(
          ids = {R.id.gallery_hotel},
          listeners = {OnItemClick.class}))
  public void itemClick(AdapterView<?> parent, View view, int position, long id) {
    Toast.makeText(activity, "酒店预览", Toast.LENGTH_SHORT).show();
  }

  /**
   * **********************************************
   *
   * @param parent 父类
   * @param v 当前控件
   * @param selIndex 当前下标
   * @param id 设定文件 id
   * @return void 返回类型
   * @throws @Title: itemSelected @Description: TODO(切换图片选择背景)
   * @date 2014-11-19 ***********************************************
   */
  @InjectMethod(
      value =
          @InjectListener(
              ids = {R.id.gallery_hotel},
              listeners = {OnItemSelected.class}))
  public void itemSelected(AdapterView<?> parent, View v, int selIndex, long id) {

    selIndex = selIndex % imgList.size();
    if (imgList.size() > 1) {
      // 修改上一次选中项的背景
      ImageView preSelImg = (ImageView) indicator_container.findViewById(preSelImgIndex);
      preSelImg.setImageResource(R.drawable.ic_focus);
      // 修改当前选中项的背景
      ImageView curSelImg = (ImageView) indicator_container.findViewById(selIndex);
      curSelImg.setImageResource(R.drawable.ic_focus_select);
      // text_hotelName.setText(selIndex + "");
      preSelImgIndex = selIndex;
    }
  }

  /**
   * **********************************************
   *
   * @param page 设定文件
   * @return void 返回类型
   * @throws @Title: ajaxRoomList @Description: TODO(获取房间列表)
   * @date 2014-11-19 ***********************************************
   */
  private void ajaxRoomList(int page) {
    RoomResourceParamDto rrpd = new RoomResourceParamDto();
    rrpd.setStartDate(rd.getStartDate());
    rrpd.setEndDate(rd.getEndDate());
    rrpd.setHotelCode(rd.getHotelCode());
    rrpd.setCardNo(rd.getCardNo());
    rrpd.setPageNo(page + "");
    rrpd.setPageCount("5");
    ArrayList<HashMap<String, String>> conditions =
        (ArrayList<HashMap<String, String>>) MapVo.get("conditions");
    if (conditions != null) {
      rrpd.setBuildingCode(conditions.get(3).get("text_type_code") + "");
      rrpd.setFloorCode(conditions.get(4).get("text_type_code") + "");
      rrpd.setInfarIntro(conditions.get(2).get("text_type_code") + "");
      rrpd.setRoomTypeCode(conditions.get(0).get("text_type_code") + "");
      rrpd.setViewCode(conditions.get(1).get("text_type_code") + "");
      rrpd.setRoomIdxRange(conditions.get(5).get("text_type_code") + "");
    }
    InternetConfig config = new InternetConfig();
    config.setKey(1);
    String json = Handler_Json.beanToJson(rrpd);
    Ioc.getIoc().getLogger().i(json);
    FastHttpHander.ajaxString(Url.HOTELRESERVE_ASSET_RECOMMENDROOMARRAY, json, config, this);
  }

  /**
   * **********************************************
   *
   * @param rle 设定文件
   * @return void 返回类型
   * @throws @Title: onEventPostRoomList @Description: TODO(该方法用于 重新请求房间列表 注: 公共方法根据ioc 反射定位方法)
   * @date 2014-11-19 ***********************************************
   */
  public void onEventPostRoomList(RoomListEventEntity rle) {
    // menu.showMenu();
    showDialog();
    dataList.clear(); // 筛选房间 清空当前列表
    ajaxRoomList(1); // 筛选模式下 总是第一页
  }

  @Override
  public void onDestroy() {
    super.onDestroy();
    gallery_hotel.destroy();
    MapVo.remove("conditions");
  }
}
예제 #11
0
/**
 * ***********************************************
 *
 * @copyright:bupt
 * @author: 王明雨
 * @date:2015-1-9 @Description:TODO (消息中心) ************************************************
 */
public class MSGInfoFragment extends BaseFragment {
  EventBus eventBus = EventBus.getDefault();

  @InjectView(value = R.id.lv_list, down = true, pull = true)
  public ListView lv_list;

  private String cardNo;
  private String subType;
  private int pageNo = 1;
  PageUtil pageUtil; // 分页
  ArrayList<HashMap<String, String>> datalist;

  @InjectView(value = R.id.null_layout)
  public LinearLayout null_layout;

  MSGInfoAdapter adapter;

  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater;
    View rootView = inflater.inflate(R.layout.acitivity_consumption_list, container, false);
    Handler_Inject.injectFragment(this, rootView);
    return rootView;
  }

  @InjectInit
  public void init() {
    MSGInfoEntity msg = new MSGInfoEntity();
    eventBus.post(msg);
    lv_list.setEmptyView(null_layout);
    datalist = new ArrayList<HashMap<String, String>>();
    pageUtil = new PageUtil();
    // getMsgTime();
    setAdpater();
    showDialog();
    getMsgList();
  }

  /**
   * *********************************************** @Title: click @Description: TODO(点击空数据页面 加载信息)
   *
   * @param view 设定文件
   * @return void 返回类型
   * @throws
   * @date 2015-2-6 ***********************************************
   */
  @InjectMethod(
      @InjectListener(
          ids = {R.id.img_null_data},
          listeners = {OnClick.class}))
  public void click(View view) {
    getMsgList();
  }

  @InjectMethod(
      @InjectListener(
          ids = {R.id.lv_list},
          listeners = {OnItemClick.class}))
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    TextView text_url = (TextView) view.findViewById(R.id.tx_content_url);
    Intent intent = new Intent().setClass(activity, WebViewAactiviy.class);
    intent.putExtra("url", text_url.getText() + "");
    intent.putExtra("title", "消息详情");
    activity.startActivity(intent);
  }

  @Override
  public void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    eventBus.unregister(this);
  }

  @InjectPullRefresh
  public void callListView(int type) {
    // 这里的type来判断是否是下拉还是上拉
    switch (type) {
      case InjectView.DOWN:
        pageNo = 1;
        getMsgList();
        break;
      case InjectView.PULL:
        getMsgList();
        break;
    }
  }

  /**
   * *********************************************** @Title: getMsgList @Description: TODO(获取消息列表)
   * 设定文件
   *
   * @return void 返回类型
   * @throws
   * @date 2015-2-6 ***********************************************
   */
  private void getMsgList() {
    // showDialog();
    String url = Url.SERVICE_MSG_ARRAY_URL;
    JsonObject json = new JsonObject();
    json.addProperty("pageNo", pageNo);
    json.addProperty("pageCount", 10);
    json.addProperty("msgTime", "");
    InternetConfig config = new InternetConfig();
    config.setKey(1);
    config.setHead(CommonUtils.inHeaders());
    FastHttpHander.ajaxString(url, json.toString(), config, this);
  }

  @InjectHttpOk(1)
  public void resultOk(ResponseEntity r) {
    dismissDialog();
    if (ResultParse.isResultOK(r, activity)) {
      ArrayList<HashMap<String, String>> list =
          Handler_Json.jsonToList("list", r.getContentAsString());
      String page = (String) Handler_Json.getValue("pageNo", r.getContentAsString());
      String time = (String) Handler_Json.getValue("sysDateTime", r.getContentAsString());
      MangrovePayApp.msgTime = time;
      MangrovePayApp.app.setData("msgTime", time);
      Ioc.getIoc().getLogger().i("-------------------------");
      Ioc.getIoc().getLogger().i("-------------系统时间:" + MangrovePayApp.msgTime);
      if (!Handler_String.isBlank(page)) {
        pageNo = Integer.valueOf(page) + 1;
      }
      initData(list, page);
    }
  }

  @InjectHttpErr(value = {1, 3})
  public void resultErr(ResponseEntity r) {
    dismissDialog();
    Ioc.getIoc().getLogger().i("接口请求异常:" + r.getContentAsString());
    if (r.getKey() == 1) {
      pageUtil.isEndDownPage();
      Toast.makeText(activity, ErrorMsgEnum.NET_ERROR.getName(), Toast.LENGTH_SHORT).show();
    }
  }
  //	private void getMsgTime(){
  //		String url=Url.SERVICE_SYSDATE_URL;
  //		InternetConfig config=new InternetConfig();
  //		config.setKey(3);
  //		config.setHead(CommonUtils.inHeaders());
  //		FastHttpHander.ajaxString(url, "", config, this);
  //	}
  //	@InjectHttpOk(value={3})
  //	public void getMsgTimeOK(ResponseEntity r){
  //		try {
  //			Map<String, String> map = r.getHeaders();
  //			// 获取头部信息
  //		//	String[] msgArray = map.get(HeaderConst.MYMHOTEL_MESSAGE).split("\\|");
  //			// 成功 返回OK
  //			if ("OK".equals(map.get(HeaderConst.MYMHOTEL_STATUS))) {
  //				// Toast.makeText(context, msgArray[1], Toast.LENGTH_SHORT).show();
  //				String time= (String) Handler_Json.getValue("sysDateTime", r.getContentAsString());
  //				MangrovePayApp.msgTime=time;
  //				MangrovePayApp.app.setData("msgTime", time);
  //				Ioc.getIoc().getLogger().i("-------------------------");
  //				Ioc.getIoc().getLogger().i("-------------系统时间:"+	MangrovePayApp.msgTime);
  //			}// 失败
  //		} catch (Exception e) {
  //			Ioc.getIoc().getLogger().i("-------------系统时间错误:");
  //			e.printStackTrace();
  //		}
  //	}

  /**
   * *********************************************** @Title: initData @Description: TODO(组装数据)
   *
   * @param list
   * @param page 设定文件
   * @return void 返回类型
   * @throws
   * @date 2015-2-6 ***********************************************
   */
  private void initData(ArrayList<HashMap<String, String>> list, String page) {
    pageUtil.isEndDownPage();
    if (null != list && list.size() > 0) {
      HashMap<String, String> m = null;
      if ("1".equals(page)) {
        datalist.clear();
      }
      ArrayList<HashMap<String, String>> datas = new ArrayList<HashMap<String, String>>();

      for (HashMap<String, String> map : list) {
        m = new HashMap<String, String>();
        m.put("tx_content_url", map.get("msgCntUrl"));
        m.put("tx_msg_title", map.get("msgTitle"));
        m.put("tx_msg_content", "");
        m.put("tx_msg_time", DateUtil.formatDateToDay(map.get("msgTime")));
        datalist.add(m);
      }
      datalist.addAll(datas);
      adapter.notifyDataSetChanged();
    }
  }
  /**
   * *********************************************** @Title: setAdpater @Description: TODO(初始化
   * listview 需要的 组件) 设定文件
   *
   * @return void 返回类型
   * @throws
   * @date 2015-2-5 ***********************************************
   */
  private void setAdpater() {

    adapter = new MSGInfoAdapter(lv_list, datalist, R.layout.acitivity_msg_item);
    lv_list.setAdapter(adapter);
  }
}
예제 #12
0
 @Override
 public void onDestroy() {
   // TODO Auto-generated method stub
   super.onDestroy();
   eventBus.unregister(this);
 }