cn.longchou.wholesale.activity.VehicleDetailActivity.java Source code

Java tutorial

Introduction

Here is the source code for cn.longchou.wholesale.activity.VehicleDetailActivity.java

Source

 package cn.longchou.wholesale.activity;

 import android.content.Intent;
 import android.graphics.Color;
 import android.graphics.Paint;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.support.v4.view.ViewPager;
 import android.support.v4.view.ViewPager.OnPageChangeListener;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RatingBar;
 import android.widget.RelativeLayout;
 import android.widget.RelativeLayout.LayoutParams;
 import android.widget.ScrollView;
 import android.widget.TextView;

 import com.bumptech.glide.Glide;
 import com.google.gson.Gson;
 import com.lidroid.xutils.HttpUtils;
 import com.lidroid.xutils.exception.HttpException;
 import com.lidroid.xutils.http.RequestParams;
 import com.lidroid.xutils.http.ResponseInfo;
 import com.lidroid.xutils.http.callback.RequestCallBack;
 import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;

 import java.util.ArrayList;
 import java.util.List;

 import cn.longchou.wholesale.R;
 import cn.longchou.wholesale.adapter.HomePagerAdapter;
 import cn.longchou.wholesale.adapter.LicensePlateAdapter;
 import cn.longchou.wholesale.base.BaseActivity;
 import cn.longchou.wholesale.domain.AttentionAddDelete;
 import cn.longchou.wholesale.domain.CarVisitCount;
 import cn.longchou.wholesale.domain.CartAddDelete;
 import cn.longchou.wholesale.domain.HomePage.Cars;
 import cn.longchou.wholesale.domain.MaintenanceReports;
 import cn.longchou.wholesale.domain.VehicleDetails;
 import cn.longchou.wholesale.domain.VehicleDetails.CarPreview;
 import cn.longchou.wholesale.domain.VehicleDetails.Certifications;
 import cn.longchou.wholesale.domain.VehicleDetails.CheckReports;
 import cn.longchou.wholesale.domain.VehicleDetails.MustKnow;
 import cn.longchou.wholesale.domain.VehicleDetails.Primarys;
 import cn.longchou.wholesale.global.Constant;
 import cn.longchou.wholesale.utils.PreferUtils;
 import cn.longchou.wholesale.utils.SystemUtils;
 import cn.longchou.wholesale.utils.UIUtils;
 import cn.longchou.wholesale.view.ListViewForScrollView;
 import cn.sharesdk.framework.ShareSDK;
 import cn.sharesdk.onekeyshare.OnekeyShare;

 /**
  * 
  * @Description: 
  * 
  * @author kangkang
  * 
  * @date 2016116 ?1:49:11
  * 
  */
 public class VehicleDetailActivity extends BaseActivity {

     private ImageView mBack;
     private TextView mTitle;
     private TextView mParamsMore;
     private TextView mNoticeMore;
     private TextView mCarDescrip;
     private TextView mOldMoney;
     private TextView mCheckReport;
     private TextView mMachine;
     private TextView mBones;
     private ListViewForScrollView mLvLicense;
     private ViewPager mViewPager;
     private int items[] = { R.drawable.header_image1, R.drawable.header_image2, R.drawable.header_image3 };
     private TextView mTvCarId;
     private LinearLayout mLLCarId;
     private TextView mPager;
     private TextView mAttention;
     private TextView mJoinCar;
     private TextView mBudgetNow;

     //?
     private boolean isAttention;
     //?
     private boolean isCartCar;
     private TextView mCarInColor;
     private TextView mCarColor;
     private TextView mUseNature;
     private TextView mCarIdentification;
     private TextView mRecordDate;
     private TextView mReleaseDate;
     private TextView mEmissionStand;
     private TextView mAnnual;
     private TextView mCompulsory;
     private TextView mOnTime;
     private TextView mDrivingDistance;
     private TextView mEmmisionStand;
     private TextView mCarLocation;
     private RatingBar mRBExterior;
     private RatingBar mRBTrim;
     private CheckReports checkReports;
     private TextView mManufacturer;
     private TextView mLevel;
     private TextView mBodyWork;
     private TextView mMotor;
     private List<MustKnow> listKnow;
     private LinearLayout mLLMustKnow;
     private TextView mKnow;
     private TextView mMaterial;
     private TextView mMoney;
     private TextView mMoney_Wan;
     private ImageView mMark;
     private TextView mEarnest;
     private Cars cars;
     private VehicleDetails data;
     private List<String> carImags;
     private ScrollView mScrollView;
     private ImageView mScrollUp;
     private TextView mEarnestText;
     LinearLayout mLMaintenance;
     Handler handler = new Handler() {
         public void handleMessage(android.os.Message msg) {
             switch (msg.what) {
             case 1:
                 mScrollView.fullScroll(ScrollView.FOCUS_UP);
                 mScrollView.scrollTo(10, 10);
                 break;

             default:
                 break;
             }
         };
     };
     private TextView mDail;
     private TextView mShare;

     @Override
     public void initView() {
         setContentView(R.layout.activity_cartcar_detail);

         mBack = (ImageView) findViewById(R.id.iv_my_news_back);
         mTitle = (TextView) findViewById(R.id.tv_my_news_title);

         mScrollView = (ScrollView) findViewById(R.id.sv_car_detail);

         // ?
         mParamsMore = (TextView) findViewById(R.id.tv_car_detail_params_more);

         // ?
         mNoticeMore = (TextView) findViewById(R.id.tv_car_detail_notice_more);

         mCarDescrip = (TextView) findViewById(R.id.tv_car_detail_descripe);

         // 
         mOldMoney = (TextView) findViewById(R.id.tv_car_detail_old_money);

         // 
         mCheckReport = (TextView) findViewById(R.id.tv_car_detail_check_report);

         // ?
         mMachine = (TextView) findViewById(R.id.tv_car_detail_machine_more);

         // 
         mBones = (TextView) findViewById(R.id.tv_car_detail_bone_more);

         // ?
         mLvLicense = (ListViewForScrollView) findViewById(R.id.lv_license_plate);

         // 
         mViewPager = (ViewPager) findViewById(R.id.vp_car_detail);

         // id
         mTvCarId = (TextView) findViewById(R.id.tv_car_detail_car_id);

         // id
         mLLCarId = (LinearLayout) findViewById(R.id.ll_car_id);

         // ?
         mPager = (TextView) findViewById(R.id.tv_car_detail_car_number);

         // 
         mAttention = (TextView) findViewById(R.id.tv_car_detail_attention);
         // 
         mJoinCar = (TextView) findViewById(R.id.tv_car_detail_join_cart);
         // ?
         mBudgetNow = (TextView) findViewById(R.id.tv_car_detail_budget_now);

         /**??*/

         //
         mCarInColor = (TextView) findViewById(R.id.tv_car_detail_car_in_color);
         //
         mCarColor = (TextView) findViewById(R.id.tv_car_detail_car_color);
         //
         mUseNature = (TextView) findViewById(R.id.tv_car_detail_use_nature);
         //?
         mCarIdentification = (TextView) findViewById(R.id.tv_car_detail_car_identification);
         //
         mRecordDate = (TextView) findViewById(R.id.tv_car_detail_record_date);
         //
         mReleaseDate = (TextView) findViewById(R.id.tv_car_detail_release_date);
         //
         mEmissionStand = (TextView) findViewById(R.id.tv_car_detail_emission_standards);
         //
         mAnnual = (TextView) findViewById(R.id.tv_car_detail_annual_verification);
         //
         mCompulsory = (TextView) findViewById(R.id.tv_car_detail_compulsory);

         /**??*/

         //
         mOnTime = (TextView) findViewById(R.id.tv_car_detail_on_time);
         //
         mDrivingDistance = (TextView) findViewById(R.id.tv_car_detail_driving_distance);
         //
         mEmmisionStand = (TextView) findViewById(R.id.tv_car_detail_emmision_stand);
         //
         mCarLocation = (TextView) findViewById(R.id.car_detail_car_location);

         /***/

         //
         mRBExterior = (RatingBar) findViewById(R.id.rb_car_detail_report_exterior);
         //
         mRBTrim = (RatingBar) findViewById(R.id.rb_car_detail_report_trim);

         /**?*/

         mManufacturer = (TextView) findViewById(R.id.tv_car_detail_params_manufacturer);
         mLevel = (TextView) findViewById(R.id.tv_car_detail_params_level);
         mBodyWork = (TextView) findViewById(R.id.tv_car_detail_params_bodywork);
         mMotor = (TextView) findViewById(R.id.tv_car_detail_params_motor);

         /**?*/
         //?
         mLLMustKnow = (LinearLayout) findViewById(R.id.ll_notice_car_plate_others);
         //?
         mKnow = (TextView) findViewById(R.id.tv_notice_car_plate_others);
         //???
         mMaterial = (TextView) findViewById(R.id.tv_car_detail_must_know_material);

         //
         mMoney = (TextView) findViewById(R.id.tv_car_detail_money);
         mMoney_Wan = (TextView) findViewById(R.id.tv_car_detail_moeny_wan);

         //
         mMark = (ImageView) findViewById(R.id.iv_car_detail_mark);

         //
         mEarnest = (TextView) findViewById(R.id.tv_car_detail_earnest);

         //
         mEarnestText = (TextView) findViewById(R.id.tv_car_detail_earnest_text);

         mScrollUp = (ImageView) findViewById(R.id.iv_car_detail_scrool_up);

         mDail = (TextView) findViewById(R.id.tv_dail_1);

         mShare = (TextView) findViewById(R.id.tv_car_detail_share);

         mLMaintenance = (LinearLayout) findViewById(R.id.ll_car_detail_maintenance);
     }

     @Override
     public void initData() {
         mTitle.setText("");
         //
         mOldMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

         cars = (Cars) getIntent().getExtras().getSerializable("cars");

         //??
         setAttention();

         //??
         setCartCat();

         mTvCarId.setText("ID:" + cars.carID);

         mCarDescrip.setText(cars.carName);
         boolean isCertified = PreferUtils.getBoolean(getApplicationContext(), "isCertified", false);
         if (isCertified) {
             if ("".equals(cars.carPrice)) {
                 mMoney.setTextColor(Color.GRAY);
                 mMoney.setTextSize(12);
                 mMoney_Wan.setVisibility(View.GONE);
             } else {

                 mMoney_Wan.setVisibility(View.VISIBLE);
             }
             //?
             mMoney.setText(cars.carPrice + "");
             //?
             mEarnestText.setVisibility(View.VISIBLE);
             mEarnest.setText(cars.carSubscription + "");
         } else {
             //??????
             mMoney.setText("??");
             mMoney.setTextSize(14);
             mMoney_Wan.setVisibility(View.GONE);

             //??
             mEarnestText.setVisibility(View.INVISIBLE);

         }

         mMark.setImageResource(R.drawable.miao);

         //
         getSerVerCarVisitData();

         getServerData(cars);

         mScrollView.fullScroll(ScrollView.FOCUS_UP);
         handler.sendEmptyMessage(1);

         getCarMaintenanceData();
     }

     private void getCarMaintenanceData() {
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestMaintenance + cars.carID;
         http.send(HttpMethod.POST, url, new RequestCallBack<String>() {
             @Override
             public void onSuccess(ResponseInfo<String> responseInfo) {
                 Gson gson = new Gson();
                 MaintenanceReports json = gson.fromJson(responseInfo.result, MaintenanceReports.class);
                 List<MaintenanceReports.MaintenanceReport> maintenanceReports = json.maintenanceReports;
                 if (maintenanceReports != null) {
                     for (int i = 0; i < maintenanceReports.size(); i++) {
                         ImageView image = new ImageView(VehicleDetailActivity.this);
                         Glide.with(VehicleDetailActivity.this).load(maintenanceReports.get(i).imgUrl).into(image);
                         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                                 LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                         params.bottomMargin = 20;
                         image.setLayoutParams(params);
                         mLMaintenance.addView(image);
                     }
                 }

             }

             @Override
             public void onFailure(HttpException e, String s) {

             }
         });
     }

     //
     private void getSerVerCarVisitData() {
         String token = PreferUtils.getString(getApplicationContext(), "token", null);
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestVerticalVisit;
         RequestParams params = new RequestParams();
         if (!TextUtils.isEmpty(token)) {
             params.addBodyParameter("Token", token);
         }
         params.addBodyParameter("Car_whole_id", cars.carID + "");
         http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

             @Override
             public void onFailure(HttpException arg0, String arg1) {
                 // TODO Auto-generated method stub

             }

             @Override
             public void onSuccess(ResponseInfo<String> resultInfo) {
                 String result = resultInfo.result;
                 Gson gson = new Gson();
                 CarVisitCount data = gson.fromJson(result, CarVisitCount.class);
                 if (data != null) {
                     if (data.success) {
                         //                   UIUtils.showToastSafe(result);
                     }
                 }
             }
         });
     }

     //??
     private void setCartCat() {
         isCartCar = cars.inCart;

     }

     //??
     private void setAttention() {
         isAttention = cars.isFollow;

         if (!isAttention) {
             mAttention.setText("");
             Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention_no);
             drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
             mAttention.setCompoundDrawables(null, drawable, null, null);
         } else {
             mAttention.setText("?");
             Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention);
             drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
             mAttention.setCompoundDrawables(null, drawable, null, null);
         }

     }

     private void getServerData(Cars cars) {
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestCarDetail;
         RequestParams params = new RequestParams();
         params.addBodyParameter("c", "as");
         params.addBodyParameter("carID", cars.carID + "");
         http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

             @Override
             public void onFailure(HttpException arg0, String arg1) {
                 // TODO Auto-generated method stub

             }

             @Override
             public void onSuccess(ResponseInfo<String> resultInfo) {
                 String result = resultInfo.result;
                 //            System.out.println("result:"+result);
                 parseData(result);

             }
         });

     }

     protected void parseData(String result) {
         Gson gson = new Gson();
         data = gson.fromJson(result, VehicleDetails.class);
         if (null != data) {
             carImags = data.carImags;
             //
             setImageData();
             Certifications certifications = data.certifications;
             CarPreview carPreview = data.carPreview;
             checkReports = data.checkReports;
             Primarys primarys = data.primarys;
             //?
             setBaseParams(primarys);
             //??
             setCertification(certifications);
             //
             setForData(carPreview);
             //
             setCheckReport(checkReports);
             listKnow = VehicleDetails.getInstance().getMustKnows(data.mustKnows);
             //?
             setMastKnow();
             mOldMoney.setText("" + data.originalPrice + "");

             mScrollView.fullScroll(ScrollView.FOCUS_UP);
         }
         mScrollView.scrollTo(10, 10);
         handler.sendEmptyMessage(1);

     }

     private void setImageData() {

         // ??
         setImageSource();

         // 
         setViewPagerPercent();

         // ??
         //      setCarIdPosition();

         mPager.setText("1/" + carImags.size());

     }

     //?
     private void setMastKnow() {
         if (VehicleDetails.getInstance().mOthers != null) {
             mLLMustKnow.setVisibility(View.VISIBLE);
             mKnow.setText(VehicleDetails.getInstance().mOthers);
         } else {
             mLLMustKnow.setVisibility(View.GONE);
         }

         if (VehicleDetails.getInstance().mMaterial != null) {
             mMaterial.setText(VehicleDetails.getInstance().mMaterial);
         }
         //??list????

         if (listKnow != null || listKnow.size() > 0) {
             LicensePlateAdapter adapter = new LicensePlateAdapter(getApplicationContext(), listKnow);
             mLvLicense.setAdapter(adapter);
         }

     }

     //?
private void setBaseParams(Primarys data) {
   mManufacturer.setText(data.);
   mLevel.setText(data.);
   mBodyWork.setText(data.);
   mMotor.setText(data.?);
}

     //
private void setCheckReport(CheckReports data) {
   mRBExterior.setRating(data.);
   mRBTrim.setRating(data.);
      
}

     //
private void setForData(CarPreview data) {
   mOnTime.setText(data.);;
   mDrivingDistance.setText(data.);
   mEmmisionStand.setText(data.);
   mCarLocation.setText(data.);
      
}

     //??
private void setCertification(Certifications data) {
   mUseNature.setText(data.);
   mRecordDate.setText(data.);
   mReleaseDate.setText(data.);
   mEmissionStand.setText(data.);
   mAnnual.setText(data.);
   mCompulsory.setText(data.);
   mCarInColor.setText(data.);
   mCarColor.setText(data.);
   mCarIdentification.setText(data.VIN?);
}

     // ??
     private void setCarIdPosition() {
         RelativeLayout.LayoutParams params = (LayoutParams) mLLCarId.getLayoutParams();
         params.topMargin = mViewPager.getLayoutParams().height * 9 / 10;
         mLLCarId.setLayoutParams(params);

     }

     private void setImageSource() {
         List<ImageView> images = new ArrayList<ImageView>();
         for (int i = 0; i < carImags.size(); i++) {
             ImageView image = new ImageView(getApplicationContext());
             //         int height = mViewPager.getLayoutParams().height;
             //         int width = mViewPager.getLayoutParams().width;
             //         image.setMinimumWidth(width);
             //         image.setMinimumHeight(height);
             //         image.setBackgroundResource(items[i]);
             Glide.with(this).load(carImags.get(i)).placeholder(R.drawable.car_detail_default).into(image);
             images.add(image);

         }

         HomePagerAdapter adapter = new HomePagerAdapter(VehicleDetailActivity.this, images, carImags, "image");
         mViewPager.setAdapter(adapter);

     }

     // viewpager
     private void setViewPagerPercent() {
         // ?
         int screenHeight = SystemUtils.getScreenWidth(getApplicationContext()) * 2 / 3;
         RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) mViewPager
                 .getLayoutParams();
         params.width = SystemUtils.getScreenWidth(getApplicationContext());
         params.height = screenHeight;
         mViewPager.setLayoutParams(params);
     }

     @Override
     public void initListener() {
         mBack.setOnClickListener(this);

         mScrollUp.setOnClickListener(this);

         // ?
         mParamsMore.setOnClickListener(this);

         // ?
         mNoticeMore.setOnClickListener(this);

         // 
         mCheckReport.setOnClickListener(this);

         // 
         mMachine.setOnClickListener(this);

         mDail.setOnClickListener(this);

         // 
         mBones.setOnClickListener(this);

         mShare.setOnClickListener(this);

         mAttention.setOnClickListener(this);
         mJoinCar.setOnClickListener(this);
         mBudgetNow.setOnClickListener(this);

         mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

             @Override
             public void onPageSelected(int position) {

                 mPager.setText(position + 1 + "/" + carImags.size());
                 //            image.setOnTouchListener(new TouchListener(carImags.get(position)));

             }

             @Override
             public void onPageScrolled(int arg0, float arg1, int arg2) {
                 // TODO Auto-generated method stub

             }

             @Override
             public void onPageScrollStateChanged(int arg0) {

             }
         });

     }

@Override
public void processClick(View v) {
   switch (v.getId()) {
   case R.id.iv_my_news_back:
      finish();
      break;
   case R.id.tv_dail:
      Intent intent1 = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "4008596677"));
         startActivity(intent1);
      break;

   case R.id.tv_car_detail_params_more:
      Intent intentParams = new Intent(VehicleDetailActivity.this,
            BaseParamsDetailActivity.class);
      Bundle bundleParams=new Bundle();
      bundleParams.putSerializable("cars", cars);
      intentParams.putExtras(bundleParams);
      startActivity(intentParams);
      break;

   case R.id.tv_car_detail_notice_more:
      Intent intentNotice = new Intent(VehicleDetailActivity.this,
            NoticeDetailActivity.class);
      Bundle bundleNotice=new Bundle();
      bundleNotice.putSerializable("cars", cars);
      intentNotice.putExtras(bundleNotice);
      startActivity(intentNotice);
      break;

   case R.id.tv_car_detail_check_report:
   case R.id.tv_car_detail_machine_more:

      Intent intentCheck = new Intent(VehicleDetailActivity.this,
            TestReportActivity.class);
      Bundle bundle=new Bundle();
      bundle.putSerializable("cars", cars);
      intentCheck.putExtras(bundle);
      startActivity(intentCheck);
      break;
   case R.id.tv_car_detail_bone_more:
      //?
      if (checkReports.??) {
         Intent intentBone = new Intent(VehicleDetailActivity.this,
               TestReportActivity.class);
         Bundle bundle1=new Bundle();
         bundle1.putSerializable("cars", cars);
         intentBone.putExtras(bundle1);
         startActivity(intentBone);
      } //??
      else {
         // ?
         mMachine.setText("");
         mMachine.setTextColor(Color.rgb(51, 51, 51));
      }
      break;
   case R.id.tv_car_detail_attention:
      boolean isLogin = PreferUtils.getBoolean(getApplicationContext(), "isLogin", false);
      if(isLogin)
      {
         showAttention();
      }else{
         Intent intent=new Intent(VehicleDetailActivity.this,LoginActivity.class);
         startActivity(intent);
      }
         
      break;
   case R.id.tv_car_detail_join_cart:

      boolean isLogin1 = PreferUtils.getBoolean(getApplicationContext(), "isLogin", false);
      if(isLogin1)
      {
         showCartCar();
      }else{
         Intent intent=new Intent(VehicleDetailActivity.this,LoginActivity.class);
         startActivity(intent);
      }
         
      break;
   case R.id.tv_car_detail_budget_now:
      boolean isCertified = PreferUtils.getBoolean(getApplicationContext(), "isCertified", false);
      if(isCertified)
      {
         showBudget();
      }else{
         UIUtils.showToastSafe("??!");
      }
         
      break;
   case R.id.iv_car_detail_scrool_up:
      mScrollView.fullScroll(ScrollView.FOCUS_UP);
      break;
      //
   case R.id.tv_car_detail_share:
      showShare();
      break;
   default:
      break;
   }
}

     private void showShare() {
         ShareSDK.initSDK(this);
         OnekeyShare oks = new OnekeyShare();
         //sso?
         oks.disableSSOWhenAuthorize();

         // Notification  2.5.9??
         //oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
         // title??????QQ
         oks.setTitle("");
         // titleUrlQQ
         oks.setTitleUrl("http://sharesdk.cn");
         // text??
         oks.setText("");
         // imagePathLinked-In???
         //oks.setImagePath("/sdcard/test.jpg");//?SDcard?
         // url??
         oks.setUrl("http://sharesdk.cn");
         // comment?QQ
         oks.setComment("");
         // site??QQ
         oks.setSite(getString(R.string.app_name));
         // siteUrl?QQ
         oks.setSiteUrl("http://sharesdk.cn");

         // ?GUI
         oks.show(this);
     }

     //?
     private void showAttention() {
         //,?
         if (isAttention) {
             isAttention = false;
             mAttention.setText("");
             Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention_no);
             drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
             mAttention.setCompoundDrawables(null, drawable, null, null);

             //?
             deleteAttention();

         } //
         else {
             isAttention = true;
             mAttention.setText("?");
             Drawable drawable = getResources().getDrawable(R.drawable.car_detail_attention);
             drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
             mAttention.setCompoundDrawables(null, drawable, null, null);

             //
             addAttention();
         }
     }

     //
     protected void addAttention() {

         String token = PreferUtils.getString(this, "token", null);
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestAddFavorite;
         RequestParams params = new RequestParams();
         params.addBodyParameter("c", "as");
         params.addBodyParameter("Token", token);
         params.addBodyParameter("carID", cars.carID + "");
         http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

             @Override
             public void onFailure(HttpException arg0, String arg1) {
                 // TODO Auto-generated method stub

             }

             @Override
             public void onSuccess(ResponseInfo<String> resultInfo) {
                 String result = resultInfo.result;
                 Gson gson = new Gson();
                 AttentionAddDelete data = gson.fromJson(result, AttentionAddDelete.class);
                 if (TextUtils.isEmpty(data.errorReason) && data.success) {
                     UIUtils.showToastSafe("?");

                 }

             }
         });

     }

     //?
     private void deleteAttention() {

         String token = PreferUtils.getString(this, "token", null);
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestRemoveFavorite;
         RequestParams params = new RequestParams();
         params.addBodyParameter("c", "as");
         params.addBodyParameter("Token", token);
         params.addBodyParameter("carID", cars.carID + "");
         http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

             @Override
             public void onFailure(HttpException arg0, String arg1) {

             }

             @Override
             public void onSuccess(ResponseInfo<String> resultInfo) {
                 String result = resultInfo.result;
                 Gson gson = new Gson();
                 AttentionAddDelete data = gson.fromJson(result, AttentionAddDelete.class);
                 if (TextUtils.isEmpty(data.errorReason) && data.success) {
                     UIUtils.showToastSafe("??");

                 }

             }
         });

     }

     //?
     private void showCartCar() {
         if (isCartCar) {
             UIUtils.showToastSafe("?");
         } else {
             isCartCar = true;
             addCartData();
         }
     }

     //?
     protected void addCartData() {
         String token = PreferUtils.getString(this, "token", null);
         HttpUtils http = new HttpUtils();
         String url = Constant.RequestAddToCart;
         RequestParams params = new RequestParams();
         params.addBodyParameter("c", "as");
         params.addBodyParameter("Token", token);
         params.addBodyParameter("carID", cars.carID + "");
         http.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {

             @Override
             public void onFailure(HttpException arg0, String arg1) {
                 // TODO Auto-generated method stub

             }

             @Override
             public void onSuccess(ResponseInfo<String> resultInfo) {
                 String result = resultInfo.result;
                 Gson gson = new Gson();
                 CartAddDelete data = gson.fromJson(result, CartAddDelete.class);
                 if (TextUtils.isEmpty(data.errorMsg)) {
                     UIUtils.showToastSafe("?");
                     //               CarsManager.getInstance().joinCartCar(cars);
                     int TotalCars = PreferUtils.getInt(getApplicationContext(), "totalCars", 0);
                     MainActivity.getBadgeViewText().show();
                     int cars = TotalCars + 1;
                     MainActivity.getBadgeViewText().setText(cars + "");
                     PreferUtils.putInt(getApplicationContext(), "totalCars", cars);
                 } else {
                     UIUtils.showToastSafe(data.errorMsg);
                 }
             }
         });

     }

     //??
     private void showBudget() {
         Intent intent = new Intent(this, BudgetConfirmActivity.class);
         Bundle bundle = new Bundle();
         bundle.putSerializable("cars", cars);
         intent.putExtras(bundle);
         startActivity(intent);

     }

 }