|
|
@@ -6,10 +6,12 @@ import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
+import com.afollestad.materialdialogs.MaterialDialog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.config.BaseConfig;
|
|
|
@@ -23,13 +25,14 @@ import com.core.net.utils.NetUtils;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.IntentUtils;
|
|
|
import com.core.utils.ToastUtil;
|
|
|
-import com.modular.apputils.utils.TravelUtils;
|
|
|
import com.modular.apputils.widget.TravelDirectionView;
|
|
|
import com.uas.appworks.OA.platform.model.BusinessTravel;
|
|
|
import com.uas.appworks.R;
|
|
|
+import com.uas.appworks.utils.TravelUtils;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -39,14 +42,19 @@ import java.util.Map;
|
|
|
*/
|
|
|
|
|
|
public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnClickListener {
|
|
|
+ private final String DONE_SUBMIT = "预约/订票";
|
|
|
+ private final String DONE_CANCEL = "查看详情";
|
|
|
+
|
|
|
private Context ct;
|
|
|
private List<BusinessTravel> models;
|
|
|
private String currentName;
|
|
|
- private String cusCode;
|
|
|
+ private String appkey = null;
|
|
|
+ private String appSceret = null;
|
|
|
|
|
|
- public BusinessTravelAdapter(Context ct,String cusCode, List<BusinessTravel> models) {
|
|
|
+ public BusinessTravelAdapter(Context ct, String appkey, String appSceret, List<BusinessTravel> models) {
|
|
|
this.ct = ct;
|
|
|
- this.cusCode = cusCode;
|
|
|
+ this.appkey = appkey;
|
|
|
+ this.appSceret = appSceret;
|
|
|
this.models = models;
|
|
|
this.currentName = CommonUtil.getName();
|
|
|
}
|
|
|
@@ -79,6 +87,7 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
switch (viewType) {
|
|
|
case BusinessTravel.AIR:
|
|
|
case BusinessTravel.TRAIN:
|
|
|
+ case BusinessTravel.UNKOWN:
|
|
|
return new AirViewHolder(parent);
|
|
|
case BusinessTravel.HOTEL:
|
|
|
return new HotelViewHolder(parent);
|
|
|
@@ -92,7 +101,7 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
if (holder != null) {
|
|
|
BusinessTravel model = models.get(position);
|
|
|
if (holder instanceof TitleViewHolder) {
|
|
|
- bindTitleView((TitleViewHolder) holder, model);
|
|
|
+ bindTitleView((TitleViewHolder) holder, model, position);
|
|
|
} else if (holder instanceof BaseViewHlder) {
|
|
|
bindBaseView((BaseViewHlder) holder, model, position);
|
|
|
if (holder instanceof AirViewHolder) {
|
|
|
@@ -105,25 +114,49 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void bindTitleView(TitleViewHolder holder, BusinessTravel model) {
|
|
|
+ private void bindTitleView(TitleViewHolder holder, BusinessTravel model, int position) {
|
|
|
holder.codeTv.setText(model.getCode());
|
|
|
+ holder.addMoreTv.setTag(R.id.tag_key, model);
|
|
|
+ holder.addMoreTv.setTag(R.id.tag_key2, position);
|
|
|
+ holder.addMoreTv.setOnClickListener(this);
|
|
|
+ if (position == 0) {
|
|
|
+ holder.titleLine.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ holder.titleLine.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private final String DONE_SUBMIT = "预约/订票";
|
|
|
- private final String DONE_CANCEL = "查看详情";
|
|
|
|
|
|
private void bindBaseView(BaseViewHlder holder, BusinessTravel model, int position) {
|
|
|
holder.codeTv.setText(model.getTitleAndCode());
|
|
|
- holder.statusTv.setText(model.getStatus());
|
|
|
+ String status = model.getStatus();
|
|
|
+ holder.statusTv.setText(status);
|
|
|
+ if (status.equals(BusinessTravel.EMPTY_STATUS)) {
|
|
|
+ holder.orderInfoRl.setVisibility(View.GONE);
|
|
|
+ holder.userInfoRl.setVisibility(View.GONE);
|
|
|
+ holder.line.setVisibility(View.GONE);
|
|
|
+ model.setExpand(true);
|
|
|
+ holder.subRl.setTag(R.id.tag_key, model);
|
|
|
+ holder.subRl.setTag(R.id.tag_key2, position);
|
|
|
+ holder.subRl.setOnClickListener(this);
|
|
|
+ } else {
|
|
|
+ holder.orderInfoRl.setVisibility(View.VISIBLE);
|
|
|
+ holder.userInfoRl.setVisibility(View.VISIBLE);
|
|
|
+ holder.line.setVisibility(View.VISIBLE);
|
|
|
+ holder.subRl.setOnClickListener(null);
|
|
|
+ }
|
|
|
holder.nameTv.setText(currentName == null ? "**" : currentName);
|
|
|
holder.idCardTv.setText(model.getCttpid());
|
|
|
holder.seatTv.setText(model.getSeat());
|
|
|
- holder.realFeeTv.setText(model.getRealFee());
|
|
|
+ String realFee = model.getRealFee();
|
|
|
+ realFee = TextUtils.isEmpty(realFee) ? "" : (realFee + "元");
|
|
|
+ holder.realFeeTv.setText(realFee);
|
|
|
holder.payTypeTv.setText(model.getPayType());
|
|
|
holder.levelTv.setText(model.getLevel());
|
|
|
holder.expecteFeeTv.setText(model.getExpecteFee());
|
|
|
holder.idTypeTv.setText("二代身份证");
|
|
|
- holder.dateTv.setText(model.getDate());
|
|
|
+ String date = DateFormatUtil.long2Str(model.getStartTime(), DateFormatUtil.YMD);
|
|
|
+ holder.dateTv.setText(date);
|
|
|
if (StringUtil.isEmpty(model.getStatus()) || StringUtil.isEmpty(model.getCode())) {
|
|
|
holder.doneTv.setText(DONE_SUBMIT);
|
|
|
holder.doneTv.setBackgroundResource(R.drawable.text_frame_radian_hint_bg);
|
|
|
@@ -156,9 +189,9 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
holder.toTimeTv.setText(DateFormatUtil.long2Str(model.getEndTime(), "HH:mm"));
|
|
|
//行程
|
|
|
|
|
|
- if (TextUtils.isEmpty(fromCity)||TextUtils.isEmpty(toCity)){
|
|
|
+ if (TextUtils.isEmpty(fromCity) || TextUtils.isEmpty(toCity)) {
|
|
|
holder.tripTv.setText(fromCity + "" + toCity);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
holder.tripTv.setText(fromCity + "-" + toCity);
|
|
|
}
|
|
|
holder.mTravelDirectionView.setData(model.getFlightCode(), model.getAllTime());
|
|
|
@@ -183,8 +216,8 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
if (!StringUtil.isEmpty(model.getCode()) && !StringUtil.isEmpty(model.getStatus())) {
|
|
|
holder.roomsTv.setText("1间");
|
|
|
}
|
|
|
- holder.addressTv.setText(model.getHotelAddress());
|
|
|
- holder.dateTv.setText(DateFormatUtil.long2Str(DateFormatUtil.YMD));
|
|
|
+ String address = TextUtils.isEmpty(model.getHotelAddress()) ? model.getHotelCity() : model.getHotelAddress();
|
|
|
+ holder.addressTv.setText(address);
|
|
|
holder.numberSubTv.setText(model.getNumber() + "人");
|
|
|
}
|
|
|
|
|
|
@@ -197,6 +230,8 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
|
|
|
private class TitleViewHolder extends RecyclerView.ViewHolder {
|
|
|
TextView codeTv;
|
|
|
+ ImageView addMoreTv;
|
|
|
+ View titleLine;
|
|
|
|
|
|
public TitleViewHolder(ViewGroup viewGroup) {
|
|
|
this(getInflater().inflate(R.layout.item_bus_travel_title, viewGroup, false));
|
|
|
@@ -205,6 +240,8 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
public TitleViewHolder(View itemView) {
|
|
|
super(itemView);
|
|
|
codeTv = itemView.findViewById(R.id.codeTv);
|
|
|
+ titleLine = itemView.findViewById(R.id.titleLine);
|
|
|
+ addMoreTv = itemView.findViewById(R.id.addMoreTv);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -214,7 +251,6 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
whenLongTv,
|
|
|
numberSubTv,//人数
|
|
|
numberTv,
|
|
|
- dateTv,
|
|
|
addressTv, //地址
|
|
|
roomsTv;//房间人数
|
|
|
|
|
|
@@ -227,7 +263,6 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
businessNameTv = (TextView) itemView.findViewById(R.id.businessNameTv);
|
|
|
whenLongTv = (TextView) itemView.findViewById(R.id.whenLongTv);
|
|
|
numberTv = (TextView) itemView.findViewById(R.id.numberTv);
|
|
|
- dateTv = (TextView) itemView.findViewById(R.id.dateTv);
|
|
|
roomsTv = (TextView) itemView.findViewById(R.id.roomsTv);
|
|
|
addressTv = (TextView) itemView.findViewById(R.id.addressTv);
|
|
|
numberSubTv = (TextView) itemView.findViewById(R.id.numberSubTv);
|
|
|
@@ -249,10 +284,16 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
idTypeTv, //身份类型
|
|
|
dateTv;//入住时间|返程时间
|
|
|
RelativeLayout subRl;
|
|
|
+ RelativeLayout userInfoRl;
|
|
|
+ RelativeLayout orderInfoRl;
|
|
|
+ View line;
|
|
|
|
|
|
public BaseViewHlder(View itemView) {
|
|
|
super(itemView);
|
|
|
subRl = (RelativeLayout) itemView.findViewById(R.id.subRl);
|
|
|
+ orderInfoRl = (RelativeLayout) itemView.findViewById(R.id.orderInfoRl);
|
|
|
+ line = itemView.findViewById(R.id.line);
|
|
|
+ userInfoRl = (RelativeLayout) itemView.findViewById(R.id.userInfoRl);
|
|
|
codeTv = (TextView) itemView.findViewById(R.id.codeTv);
|
|
|
statusTv = (TextView) itemView.findViewById(R.id.statusTv);
|
|
|
nameTv = (TextView) itemView.findViewById(R.id.nameTv);
|
|
|
@@ -309,117 +350,8 @@ public class BusinessTravelAdapter extends RecyclerView.Adapter<RecyclerView.Vie
|
|
|
if (id == R.id.expandTv) {
|
|
|
model.setExpand(!model.isExpand());
|
|
|
notifyItemChanged(position);
|
|
|
- } else if (R.id.doneTv == id && v instanceof TextView) {
|
|
|
- TextView doneTv = (TextView) v;
|
|
|
- String doneMessage = StringUtil.getText(doneTv);
|
|
|
- if (doneMessage.equals(DONE_CANCEL)) {
|
|
|
- cancel(model);
|
|
|
- } else {
|
|
|
- reserve(model);
|
|
|
- }
|
|
|
- } else if (R.id.changeTv == id) {
|
|
|
- change(model);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void cancel(BusinessTravel model) {
|
|
|
- reserve(model);
|
|
|
- }
|
|
|
-
|
|
|
- private void reserve(BusinessTravel model) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("traverorderno", "RES56884");
|
|
|
- map.put("product", model.getProduct());
|
|
|
- map.put("costname", "成本中心");
|
|
|
- map.put("proname", "所属项目");
|
|
|
- String from = "";
|
|
|
- String fromcode = "";
|
|
|
- String arrive = "";
|
|
|
- String arrivecode = "";
|
|
|
- switch (model.getType()) {
|
|
|
- case BusinessTravel.AIR:
|
|
|
- from = model.getAirStarting();
|
|
|
- fromcode = model.getAirStartingCode();
|
|
|
- arrive = model.getAirDestination();
|
|
|
- arrivecode = model.getAirDestinationCode();
|
|
|
- break;
|
|
|
- case BusinessTravel.TRAIN:
|
|
|
- from = model.getTrainStarting();
|
|
|
- fromcode = model.getTrainStartingCode();
|
|
|
- arrive = model.getTrainDestination();
|
|
|
- arrivecode = model.getTrainDestinationCode();
|
|
|
- break;
|
|
|
- case BusinessTravel.HOTEL:
|
|
|
- from = model.getHotelCity();
|
|
|
- fromcode = model.getHotelCityCode();
|
|
|
- break;
|
|
|
- }
|
|
|
- Map<String, String> routeMap = new HashMap<>();
|
|
|
- routeMap.put("from", from);
|
|
|
- routeMap.put("fromcode", fromcode);
|
|
|
- routeMap.put("arrive", arrive);
|
|
|
- routeMap.put("arrivecode", arrivecode);
|
|
|
- routeMap.put("startdate", DateFormatUtil.long2Str(model.getStartTime(), DateFormatUtil.YMD));
|
|
|
- routeMap.put("arrivedate", DateFormatUtil.long2Str(model.getEndTime(), DateFormatUtil.YMD));
|
|
|
- routeMap.put("isCanModify", "1");
|
|
|
- map.put("route", routeMap);
|
|
|
-
|
|
|
- //个人中心
|
|
|
- Map<String, String> custinfoMap = new HashMap<>();
|
|
|
- custinfoMap.put("backUrl", CommonUtil.getAppBaseUrl(ct));
|
|
|
- custinfoMap.put("isNeedPush", "1");
|
|
|
- custinfoMap.put("cusCode", /*URY*/CommonUtil.getMaster());
|
|
|
- custinfoMap.put("emCode", CommonUtil.getEmcode());
|
|
|
- custinfoMap.put("outOrderno", String.valueOf(model.getId()));
|
|
|
- map.put("custinfo", custinfoMap);
|
|
|
- String p = JSONUtil.map2JSON(map);
|
|
|
- LogUtil.i("p=" + p);
|
|
|
- turn2Web(p);
|
|
|
- }
|
|
|
-
|
|
|
- private void change(BusinessTravel model) {
|
|
|
- LogUtil.i("点击了改签");
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("traverorderno", model.getCode());
|
|
|
- map.put("product", "airgq");
|
|
|
- map.put("costname", "成本中心");
|
|
|
- map.put("proname", "UU互联差旅订票");
|
|
|
- map.put("fpd_id", model.getId());
|
|
|
- map.put("master", CommonUtil.getMaster());
|
|
|
- map.put("baseUrl", CommonUtil.getAppBaseUrl(ct));
|
|
|
- map.put("emCode", TravelUtils.getTraveCode(cusCode,CommonUtil.getMaster()));
|
|
|
- String p = JSONUtil.map2JSON(map);
|
|
|
- turn2Web(p);
|
|
|
- }
|
|
|
-
|
|
|
- private void turn2Web(String p) {
|
|
|
- if (NetUtils.isNetWorkConnected(ct)) {
|
|
|
- String appkey = "y8gd87dsdkencgzk394k7s5c78io35c";
|
|
|
- String appSceret = "e212e142a5c9e0590eefb7d9f1bc91d7";
|
|
|
- String baseUrl = "http://124.254.45.234:8082/oa/caslogin/";
|
|
|
- if (!BaseConfig.isDebug()) {
|
|
|
- appkey = "fjdsfnvg6523fsgjkff879fidsf";
|
|
|
- appSceret = "9891ca5330271eba81ec1332e740c210";
|
|
|
- baseUrl = "http://h5.auvgo.com/";
|
|
|
- }
|
|
|
- String username = CommonUtil.getEmcode();
|
|
|
- String data = appkey + username.toUpperCase() + appSceret;
|
|
|
- String key = Md5Util.toMD5(appSceret).toUpperCase();
|
|
|
- String sign = Md5Util.toMD5(key + data);
|
|
|
- StringBuilder urlBuilder = new StringBuilder(baseUrl);
|
|
|
- urlBuilder.append(appkey + "/");
|
|
|
- urlBuilder.append(username + "/");
|
|
|
- urlBuilder.append(sign);
|
|
|
- try {
|
|
|
- urlBuilder.append("?p=" + URLEncoder.encode(p, "UTF-8"));
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- LogUtil.i(urlBuilder.toString());
|
|
|
- IntentUtils.linkCommonWeb(ct, urlBuilder.toString(), "行旅国际", "", "", false, false, false);
|
|
|
- } else {
|
|
|
- ToastUtil.showToast(ct, R.string.networks_out);
|
|
|
+ } else if (R.id.doneTv == id || R.id.subRl == id || R.id.addMoreTv == id) {
|
|
|
+ TravelUtils.reserve(ct, appkey, appSceret, model);
|
|
|
}
|
|
|
}
|
|
|
|