com.findcab.activity.LocationOverlay.java Source code

Java tutorial

Introduction

Here is the source code for com.findcab.activity.LocationOverlay.java

Source

package com.findcab.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager.LayoutParams;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.jpush.android.api.JPushInterface;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.MKGeneralListener;
import com.baidu.mapapi.map.MKEvent;
import com.baidu.mapapi.map.MapController;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Overlay;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.mapapi.search.MKAddrInfo;
import com.baidu.mapapi.search.MKBusLineResult;
import com.baidu.mapapi.search.MKDrivingRouteResult;
import com.baidu.mapapi.search.MKPoiResult;
import com.baidu.mapapi.search.MKSearch;
import com.baidu.mapapi.search.MKSearchListener;
import com.baidu.mapapi.search.MKSuggestionResult;
import com.baidu.mapapi.search.MKTransitRouteResult;
import com.baidu.mapapi.search.MKWalkingRouteResult;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.findcab.R;
import com.findcab.handler.BaseHandler;
import com.findcab.handler.ConversationsHandler;
import com.findcab.handler.DriversHandler;
import com.findcab.handler.TripsHandler;
import com.findcab.mywidget.MyToast;
import com.findcab.object.ConversationInfo;
import com.findcab.object.Drivers;
import com.findcab.object.DriversInfo;
import com.findcab.object.Passengers;
import com.findcab.object.TripsInfo;
import com.findcab.util.Constant;
import com.findcab.util.HttpTools;
import com.findcab.util.MapUtility;
import com.findcab.util.MyItemizedOverlay;
import com.findcab.util.MyJpushTools;
import com.findcab.util.Tools;

public class LocationOverlay extends Activity implements OnClickListener, BDLocationListener {

    public static MapView mMapView = null;
    public static BMapManager mBMapMan = null;
    private MapController mapController; // ?mMapView?,?
    public List<OverlayItem> mGeoList = new ArrayList<OverlayItem>();// overlayitem
    private LocationClient mLocClient;

    private double lat;// ?
    private double lng;// 
    private GeoPoint pt = null; // ?
    List<GeoPoint> pList;// ?
    public static View mPopView = null; // markView
    private String mStrKey = "8BB7F0E5C9C77BD6B9B655DB928B74B6E2D838FD";
    //   LocationListener mLocationListener = null;
    int iZoom = 0;

    /**
     * callingTitle
     */
    private RelativeLayout callingTitle;
    private Button locate;
    private Button setting;
    private TextView title;
    /**
     * waitingTitle
     */
    private RelativeLayout waitingTitle;
    private TextView waittingTimeEdit;
    private TextView cab_count;

    /**
     * answerTitle
     */
    private RelativeLayout answerTitle;
    private TextView answerTitleName;
    private TextView answerTitleInfo;
    private TextView answerTitleDistance;
    private TextView answerTitlTime;
    private Button answerCallDriver;
    /**
     * callingBottom
     */
    private LinearLayout callingBottom;
    private Button call;
    /**
     * waitingBottom
     */
    private LinearLayout waitingBottom;
    private Button waitingCancle;
    /**
     * answerBottom
     */
    private LinearLayout answerBottom;
    private Button answerCancle;
    /**
     * dialog
     */
    private RelativeLayout timeOutDialog;
    private Button timeOutDialogBtnCancel;
    private Button timeOutDialogBtnContiune;
    private RelativeLayout dialog1;
    private Button dialog1BtnCancle;
    private Button dialog1BtnContiune;
    private RelativeLayout dialog2;
    private Button dialog2Btn1;
    private Button dialog2Btn2;
    private Button dialog2Btn3;
    private Button dialog2Btn4;

    private Context context;

    public static String address; // addresmyMKSearchListener??
    private String end;
    private String start;
    private String androidDevice;

    private boolean isCall;
    private boolean isGetConversation = false; // ???
    private boolean isAccept = true;

    private List<DriversInfo> driversList; // ?
    ConversationInfo lastConversation = null;// ??
    private Drivers acceptInfo;
    private Passengers info;
    private List<ConversationInfo> listLastConversation = new ArrayList<ConversationInfo>();

    public static final int LAND = 1;// 
    public static final int SEND = 2;// ??
    public static final int CANCLE_CALLING = 3;// ??
    public static final int TIMEOUT = 4;// ??
    public static final int CANCLE_ANSWER = 5;// ??
    private int judgeCancle;

    private int state;
    public static final int NORM = 1;// ?
    public static final int CALLING = 2;// 
    public static final int ANSER = 3;// 

    private final int WAITING = 90;// ??()
    private int waitingTime = WAITING;
    public static boolean isWaiting = false;// ??
    // private boolean isWaiting = false;// ??
    private boolean isStartCount = true;// ????

    private int premium;// 
    private int psID;// id
    private int ConversationID;
    private boolean isListern = false;
    private TelephonyManager manager;

    /**
     * handler?
     */
    static final int MESSAGE_CONVERSATIONS_CHANGE = 10001;
    static final int MESSAGE_DRIVERS_CHANGE = 10002;
    static final int MESSAGE_PASSAGERS_CHANGE = 10003;

    // ?LocationOverlayhandler?
    Handler handlerMain = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case MESSAGE_CONVERSATIONS_CHANGE:
                MyToast toast1 = new MyToast(context, "?");
                toast1.startMyToast();
                getConversations();
                break;
            case MESSAGE_DRIVERS_CHANGE:
                MyToast toast2 = new MyToast(context, "?");
                toast2.startMyToast();
                break;
            case MESSAGE_PASSAGERS_CHANGE:
                MyToast toast = new MyToast(context, "");
                toast.startMyToast();
                break;

            }
        }

    };

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        context = getApplicationContext();
        initManager();
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.mapview);
        Tools.init();
        iniView();

        // ????????????
        MyJpushTools.setAlias(context, "passenger_" + psID);
        Log.e("???", "passenger_" + psID);
    }

    @Override
    protected void onStart() {
        super.onStart();
        initMyBroadcastReceiver();// ?
    }

    @Override
    protected void onStop() {
        //      unregisterReceiver(MyReceiver);// activity
        super.onStop();
    }

    public class MyMKSearchListener implements MKSearchListener {

        @Override
        public void onGetAddrResult(MKAddrInfo arg0, int arg1) {
            // TODO Auto-generated method stub
            if (arg0 == null) {
                System.out.println("??");
            } else {

                GeoPoint point = arg0.geoPt;
                System.out.println("?" + arg0.strAddr + ",??" + point.getLatitudeE6() + ","
                        + point.getLongitudeE6());

                if (address == null) {
                    address = arg0.strAddr;

                }
            }
        }

        @Override
        public void onGetBusDetailResult(MKBusLineResult arg0, int arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1) {
            // TODO Auto-generated method stub

        }

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

        }

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

        }

        @Override
        public void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1) {
            // TODO Auto-generated method stub

        }

    }

    /**
     * @param locationName
     * @return ??? simsunny
     */
    private GeoPoint getGeo(String locationName) {
        JSONObject object = MapUtility.getLocationInfo(locationName);
        GeoPoint point = MapUtility.getGeoPoint(object);
        return point;
    }

    /**
     * ?BMapManager
     */
    private void initManager() {
        context = this;
        if (mBMapMan == null) {
            mBMapMan = new BMapManager(this);
        }
        mBMapMan.init(mStrKey, new MyGeneralListener());

    }

    private void iniView() {

        manager = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);

        manager.listen(new PhoneCallListener(), PhoneStateListener.LISTEN_CALL_STATE);

        System.out.println("?locationOverlay-------------------------->");

        // id
        SharedPreferences sharedata = getSharedPreferences("data", 0);
        psID = sharedata.getInt("psID", 0);
        isWaiting = false;

        if (!HttpTools.isNetworkAvailable(context)) {
            //         Toast.makeText(context, "", Toast.LENGTH_SHORT).show();
            MyToast toast = new MyToast(context, "");
            toast.startMyToast();
        }

        mMapView = (MapView) findViewById(R.id.bmapView);

        /**
         * callingTitle
         */
        callingTitle = (RelativeLayout) findViewById(R.id.map_calling_title);
        locate = (Button) findViewById(R.id.map_calling_title_btn_fresh);
        locate.setOnClickListener(this);
        setting = (Button) findViewById(R.id.map_calling_title_btn_setting);
        setting.setOnClickListener(this);
        title = (TextView) findViewById(R.id.map_calling_title_txt);

        /**
         * waitingTitle
         */
        waitingTitle = (RelativeLayout) findViewById(R.id.map_waiting_title);
        cab_count = (TextView) findViewById(R.id.map_waiting_title_txt_cab_count);
        waittingTimeEdit = (TextView) findViewById(R.id.map_waiting_title_waitintTxt);
        /**
         * answerTitle
         */
        answerTitle = (RelativeLayout) findViewById(R.id.map_answer_title);
        answerTitleName = (TextView) findViewById(R.id.map_driver_head_text);
        answerTitleInfo = (TextView) findViewById(R.id.map_driver_air_text);
        answerTitleDistance = (TextView) findViewById(R.id.map_driver_distance_text);
        answerTitlTime = (TextView) findViewById(R.id.map_driver_time_text);
        answerCallDriver = (Button) findViewById(R.id.map_driver_call_button);
        answerCallDriver.setOnClickListener(this);
        /**
         * callingBottom
         */
        callingBottom = (LinearLayout) findViewById(R.id.map_calling_bottom);
        call = (Button) findViewById(R.id.map_calling_bottom_btn_call);
        call.setOnClickListener(this);
        /**
         * waitingBottom
         */
        waitingBottom = (LinearLayout) findViewById(R.id.map_waiting_bottom);
        waitingCancle = (Button) findViewById(R.id.map_waiting_bottom_btn_cancel);
        waitingCancle.setOnClickListener(this);

        /**
         * answerBottom
         */
        answerBottom = (LinearLayout) findViewById(R.id.map_answer_bottom);
        answerCancle = (Button) findViewById(R.id.map_answr_bottom_btn_cancel);
        answerCancle.setOnClickListener(this);

        androidDevice = Tools.getDeviceId(context);
        /**
         * dialog
         */
        timeOutDialog = (RelativeLayout) findViewById(R.id.map_dialog_timeout);
        timeOutDialogBtnCancel = (Button) findViewById(R.id.dialog_frist_cancel);
        timeOutDialogBtnCancel.setOnClickListener(this);
        timeOutDialogBtnContiune = (Button) findViewById(R.id.dialog_frist_contiune);
        timeOutDialogBtnContiune.setOnClickListener(this);

        dialog1 = (RelativeLayout) findViewById(R.id.map_dialog1);
        dialog1BtnCancle = (Button) findViewById(R.id.dialog_two_cancel);
        dialog1BtnCancle.setOnClickListener(this);
        dialog1BtnContiune = (Button) findViewById(R.id.dialog_two_contiune);
        dialog1BtnContiune.setOnClickListener(this);

        dialog2 = (RelativeLayout) findViewById(R.id.map_dialog2);
        dialog2Btn1 = (Button) findViewById(R.id.dialog_three_1);
        dialog2Btn1.setOnClickListener(this);
        dialog2Btn2 = (Button) findViewById(R.id.dialog_three_2);
        dialog2Btn2.setOnClickListener(this);
        dialog2Btn3 = (Button) findViewById(R.id.dialog_three_3);
        dialog2Btn3.setOnClickListener(this);
        dialog2Btn4 = (Button) findViewById(R.id.dialog_three_4);
        dialog2Btn4.setOnClickListener(this);

        mPopView = super.getLayoutInflater().inflate(R.layout.popview_title, null);
        mMapView.addView(mPopView, new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
                null, MapView.LayoutParams.TOP_LEFT));
        mPopView.setVisibility(View.GONE);

        // ?
        iZoom = mMapView.getZoomLevel();

        // mapview???
        // return boolean
        mMapView.setDoubleClickZooming(false);

        mMapView.setClickable(false);

        // MapController?
        mapController = mMapView.getController();

        //  ?[3,18]
        mapController.setZoom(15);

        mLocClient = new LocationClient(this);

        LocationClientOption option = new LocationClientOption();
        option.setOpenGps(true);// gps
        option.setCoorType("bd09ll"); // ??
        mLocClient.setLocOption(option);
        mLocClient.registerLocationListener(this);// ?BDLocationListener?
        mLocClient.start();

    }

    class MyGeneralListener implements MKGeneralListener {
        @Override
        public void onGetNetworkState(int iError) {
            Log.d("MyGeneralListener", "onGetNetworkState error is " + iError);
        }

        @Override
        public void onGetPermissionState(int iError) {
            Log.d("MyGeneralListener", "onGetPermissionState error is " + iError);
            if (iError == MKEvent.ERROR_PERMISSION_DENIED) {

            }
        }
    }

    @Override
    protected void onPause() {
        // mBMapMan.getLocationManager().removeUpdates(mLocationListener);
        // mLocationOverlay.disableMyLocation();
        // mLocationOverlay.disableCompass();
        // mBMapMan.stop();
        isGetConversation = false;
        super.onPause();
    }

    @Override
    protected void onResume() {
        // mBMapMan.getLocationManager().requestLocationUpdates(mLocationListener);
        // mLocationOverlay.enableMyLocation();
        // mLocationOverlay.enableCompass();
        mBMapMan.start();
        // isGetConversation = true;
        String fromActivity3 = getIntent().getStringExtra("fromDialog3");
        if (fromActivity3 != null) {

            if (fromActivity3.equals("dialog3")) {
                showNorm();
            }
        }

        super.onResume();
    }

    protected void onDestory() {
        isGetConversation = false;
        if (lastConversation != null) {
            String id = String.valueOf(ConversationID);
            System.out.print("?ID----------------------->" + ConversationID);
            changeConversationsStatus("-1", id);
        }
        super.onDestroy();
    }

    /**
     * MKSearchListener?,??
     * 
     * @author liufeng
     */

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {

        case R.id.map_calling_title_btn_fresh:

            // pt??
            if (HttpTools.checkNetWork(context)) {

                if (pt != null) {
                    // mMapView.refresh();
                    mMapView.getController().animateTo(pt);
                    MyToast toast = new MyToast(context, "?");
                    toast.startMyToast();
                    getDrivers();
                    // mMapView.refresh();

                } else {
                    //               Toast.makeText(LocationOverlay.this, "?", Toast.LENGTH_SHORT).show();
                    MyToast toast = new MyToast(context, "?");
                    toast.startMyToast();
                }
            }

            break;
        case R.id.map_calling_title_btn_setting:
            Intent i1 = new Intent(context, SettingActivity.class);
            startActivity(i1);
            break;
        case R.id.map_calling_bottom_btn_call:

            Intent i = new Intent(context, CallActivity.class);
            startActivityForResult(i, SEND);
            break;
        // calling??
        case R.id.map_waiting_bottom_btn_cancel:
            // ??
            judgeCancle = CANCLE_CALLING;
            showDialog1();
            if (lastConversation != null) {
                String id = String.valueOf(ConversationID);
                System.out.print("?ID----------------------->" + ConversationID);
                changeConversationsStatus("-1", id);
            } else {
                Log.e("??", "CANCLE_CALLING");
            }
            break;
        // answer??
        case R.id.map_answr_bottom_btn_cancel:

            isGetConversation = false;// ??????
            judgeCancle = CANCLE_ANSWER;
            if (lastConversation != null) {
                String id = String.valueOf(ConversationID);
                System.out.print("?ID----------------------->" + ConversationID);
                changeConversationsStatus("-1", id);
            } else {
                Log.e("???", "CANCLE_ANSWER");
            }
            // Intent i2 = new Intent();
            // startActivityForResult(i2, CANCLE_ANSWER);

            showDialog1();
            break;
        // answer??
        case R.id.map_driver_call_button:
            Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + acceptInfo.getMobile()));
            startActivity(intent);
            break;
        // dialog_??
        case R.id.dialog_frist_cancel:
            isGetConversation = false;

            if (lastConversation != null) {
                String id = String.valueOf(ConversationID);
                System.out.print("?ID----------------------->" + ConversationID);
                changeConversationsStatus("-1", id);
            } else {
                Log.e("??", "CANCLE_ANSWER");
            }

            showNorm();
            break;
        // dialog_?
        case R.id.dialog_frist_contiune:
            isGetConversation = false;
            timeOutDialog.setVisibility(View.GONE);
            getDrivers();
            sendTrips();
            break;
        // dialog??
        case R.id.dialog_two_cancel:
            isGetConversation = false;// ????????
            if (lastConversation != null) {
                String id = String.valueOf(lastConversation.getId());
                changeConversationsStatus("-1", id);
            }
            showDialog2();
            break;
        // dialog?
        case R.id.dialog_two_contiune:
            dialog1.setVisibility(View.GONE);
            // calling?answer?
            if (judgeCancle == CANCLE_CALLING) {
                // getDrivers();
                // sendTrips();
                // judgeCancle=0;
            } else if (judgeCancle == CANCLE_ANSWER) {

                getDrivers();
                sendTrips();
                // judgeCancle=0;
            } else {

            }
            break;
        // ???call?
        case R.id.dialog_three_1:
            showNorm();
            break;
        case R.id.dialog_three_2:
            showNorm();
            break;
        case R.id.dialog_three_3:
            showNorm();
            break;
        case R.id.dialog_three_4:
            showNorm();
            break;
        default:
            break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        // System.out.println("requestCode------------------------------->"+requestCode);
        switch (requestCode) {

        case SEND:
            if (data != null) {
                TripsInfo tempInfo = new TripsInfo();
                if (data.hasExtra("appointent")) {
                    tempInfo.setAppointment(data.getStringExtra("appointent"));
                }
                if (data.hasExtra("create_at")) {
                    tempInfo.setCreated_at(data.getStringExtra("create_at"));
                }
                if (data.hasExtra("end")) {
                    tempInfo.setEnd(data.getStringExtra("end"));
                }
                if (data.hasExtra("end_lat")) {
                    tempInfo.setEnd_lat(data.getStringExtra("end_lat"));
                }
                if (data.hasExtra("end_lng")) {
                    tempInfo.setEnd_lng(data.getStringExtra("end_lng"));
                    end = data.getStringExtra("end");
                }
                if (data.hasExtra("id")) {
                    tempInfo.setId(data.getIntExtra("id", 0));
                }
                if (data.hasExtra("passenger_id")) {
                    tempInfo.setPassenger_id(data.getIntExtra("passenger_id", 0));
                }
                if (data.hasExtra("start")) {
                    tempInfo.setStart(data.getStringExtra("start"));
                    start = data.getStringExtra("start");
                }
                if (data.hasExtra("start_lat")) {
                    tempInfo.setStart_lat(data.getStringExtra("start_lat"));
                }
                if (data.hasExtra("start_lng")) {
                    tempInfo.setStart_lng(data.getStringExtra("start_lng"));
                }
                //???
                getConversations();
                callingHandler.sendEmptyMessage(Constant.SUCCESS);
            }

            break;
        case CANCLE_CALLING:
            // ??

            sendTrips();
            break;

        case TIMEOUT:

            waitingTime = WAITING;
            // isWaiting = true;
            // isStartCount = true;

            getDrivers();
            sendTrips();
            break;

        case CANCLE_ANSWER:

            String id = String.valueOf(lastConversation.getId());
            changeConversationsStatus("1", id);
            break;

        default:
            break;
        }

    }

    /**
     * ??
     */
    private void getDrivers() {

        if (HttpTools.checkNetWork(context)) {
            // getDrivers???
            new Thread(new Runnable() {
                @SuppressWarnings("unchecked")
                public void run() {

                    try {

                        Map<String, String> map = new HashMap<String, String>();
                        map.put("driver[lat]", String.valueOf(lat));
                        map.put("driver[lng]", String.valueOf(lng));
                        map.put("driver[androidDevice]", androidDevice);
                        Log.e("?", lat + "-" + lng);
                        driversList = (List<DriversInfo>) HttpTools.getAndParse(Constant.DRIVERS, map,
                                new DriversHandler());

                        if (driversList != null && driversList.size() > 0) {

                            System.out.println("??------>" + driversList.size());
                            messageHandler.sendEmptyMessage(Constant.SUCCESS);

                        } else {

                            messageHandler.sendEmptyMessage(Constant.FAILURE);
                        }
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }).start();

        }
    }

    /**
     * ??
     */
    private void getDriverInfo(final int id) {
        if (HttpTools.checkNetWork(context)) {
            new Thread(new Runnable() {
                public void run() {

                    try {
                        // ?id????
                        String result = (String) HttpTools.getAndParse(context,
                                Constant.DRIVER_INFO + String.valueOf(id), null, new BaseHandler());
                        System.out.println(
                                "??conversation---------------->"
                                        + result);

                        JSONObject jsonObject = new JSONObject(result);
                        JSONObject object = jsonObject.getJSONObject("driver");

                        acceptInfo = new Drivers(object);

                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    if (acceptInfo != null) {
                        acceptHandler.sendEmptyMessage(Constant.SUCCESS);
                    }

                }
            }).start();
        }
    }

    TripsInfo tripsInfo;
    private String name;
    private String password;

    /**
     * ?
     */
    private void sendTrips() {
        if (HttpTools.checkNetWork(context)) {

            new Thread(new Runnable() {
                public void run() {
                    try {

                        GeoPoint p = getGeo(end);
                        double tripLat = p.getLatitudeE6() / (1e6);
                        double tripLng = p.getLongitudeE6() / (1e6);
                        System.out.println("the tripLat of the end ------------> " + tripLat);
                        System.out.println("the tripLng of the end ------------> " + tripLng);
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("trip[passenger_id]", String.valueOf(psID));
                        map.put("trip[start]", start);
                        map.put("trip[start_lat]", String.valueOf(lat));
                        map.put("trip[start_lng]", String.valueOf(lng));
                        map.put("trip[end]", end);
                        map.put("trip[price]", String.valueOf(premium));
                        // map.put("trip[appointment]",
                        // String.valueOf(premium));//???
                        map.put("trip[end_lat]", String.valueOf(tripLat));
                        map.put("trip[end_lng]", String.valueOf(tripLng));

                        // passenger_idtrips_id
                        tripsInfo = (TripsInfo) HttpTools.postAndParse(Constant.TRIPS, map, new TripsHandler());

                        if (tripsInfo != null) {
                            // ??? ??isGetConversation???
                            isGetConversation = true;
                            getConversations();
                            callingHandler.sendEmptyMessage(Constant.SUCCESS);

                        }
                    } catch (Exception e) {
                        // TODO: handle exception
                        e.printStackTrace();
                    }

                }
            }).start();

        }
    }

    /**
     * ???
     */
    private void getConversations() {
        if (HttpTools.checkNetWork(context)) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        Map<String, String> map = new HashMap<String, String>();
                        map.put("from_id", String.valueOf(psID));// passergetid

                        lastConversation = (ConversationInfo) HttpTools.getAndParse(context, Constant.CONVERSATIONS,
                                map, new ConversationsHandler());

                        if (lastConversation != null) {

                            int to_id = lastConversation.getTo_id();
                            int Status = lastConversation.getStatus();
                            System.out.println("?--------------------->" + lastConversation.getId());
                            System.out.println(
                                    "??--------------------->" + lastConversation.getStatus());

                            if (Status == 1) {// ?

                                isAccept = true;
                                isGetConversation = false;
                                ConversationID = lastConversation.getId();
                                System.out.println("ConversationID=------------------------" + ConversationID);
                                getDriverInfo(to_id);

                            } else if (Status == 2) {// ??

                                isAccept = false;
                                isGetConversation = true;
                                acceptHandler.sendEmptyMessage(Constant.SUCCESS);

                            } else if (Status == 4) {// ??

                                state = NORM;
                                fullHandler.sendEmptyMessage(Constant.SUCCESS);
                            } else if (Status == 0) { // ?
                                // callingHandler.sendEmptyMessage(Constant.SUCCESS);
                            }
                        }

                        // ??
                        //                  try {
                        //                     Thread.sleep(1000);
                        //                  } catch (InterruptedException e) {
                        //                     // TODO Auto-generated catch block
                        //                     e.printStackTrace();
                        //                  }
                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            }).start();
        }
    }

    /**
     * ??
     */
    private void changeConversationsStatus(final String status, final String id) {
        if (HttpTools.checkNetWork(context)) {
            new Thread(new Runnable() {
                public void run() {

                    try {
                        Map<String, String> map = new HashMap<String, String>();

                        String status_desc = "";
                        if (status.equals("-1")) {

                            status_desc = "giveup";
                        }
                        if (status.equals("1")) {

                            status_desc = "accept";
                        }
                        if (status.equals("2")) {

                            status_desc = "reject";
                        }
                        if (status.equals("3")) {

                            status_desc = "finish";
                        }
                        map.put("conversation[status]", status);
                        map.put("conversation[status_desc]", status_desc);

                        //                  String result = (String) HttpTools.postAndParse(
                        //                        Constant.CONVERSATIONS + id + "/", map,
                        //                        new BaseHandler());

                        //                  // if (result != null) {
                        //                  //
                        //                  // normHandler.sendEmptyMessage(Constant.SUCCESS);
                        //                  // }

                        //????

                        //                  ConversationInfo conversation = (ConversationInfo)HttpTools.postAndParse(Constant.CONVERSATIONS + id + "/", map,new BaseHandler());            
                        //                  if(conversation != null){
                        //                     lastConversation.setStatus(status);
                        //                  }

                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            }).start();
        }
    }

    /**
     * 
     */
    private void signOut() {

        if (HttpTools.checkNetWork(context)) {

            new Thread(new Runnable() {

                public void run() {

                    // ?

                    Map<String, String> map = new HashMap<String, String>();
                    map.put("passenger[androidDevice]", androidDevice);

                    try {
                        String resultString = (String) HttpTools.getAndParse(Constant.SIGNOUT, map,
                                new BaseHandler());
                        JSONObject jsonObject = new JSONObject(resultString);
                        if (jsonObject.has("message")) {
                            System.out.println("message--->" + jsonObject.getString("message"));

                            //                     //??
                            //                     SharedPreferences share = getSharedPreferences("data", 0);
                            //                     Editor editor = share.edit();
                            //                     editor.clear();
                            //                     editor.commit();

                            exitPro(context);
                            finish();

                            return;
                        }

                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    exitPro(context);
                }

            }).start();
        }
    }

    /**
     * ?
     */
    private void showNorm() {

        callingTitle.setVisibility(View.VISIBLE);
        waitingTitle.setVisibility(View.GONE);
        answerTitle.setVisibility(View.GONE);

        callingBottom.setVisibility(View.VISIBLE);
        waitingBottom.setVisibility(View.GONE);
        answerBottom.setVisibility(View.GONE);

        timeOutDialog.setVisibility(View.GONE);
        dialog1.setVisibility(View.GONE);
        dialog2.setVisibility(View.GONE);

        isWaiting = false;
        waitingTime = WAITING;
        isGetConversation = false;

        mapController.animateTo(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), null);
        getDrivers();

    }

    /**
     * ?
     */
    private void showCalling() {

        callingTitle.setVisibility(View.GONE);
        waitingTitle.setVisibility(View.VISIBLE);
        answerTitle.setVisibility(View.GONE);
        callingBottom.setVisibility(View.GONE);
        waitingBottom.setVisibility(View.VISIBLE);
        answerBottom.setVisibility(View.GONE);

        mapController.animateTo(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), null);

        if (driversList != null) {
            cab_count.setText("" + String.valueOf(driversList.size()) + "?");
        }
        isWaiting = true;
        isStartCount = true;
        waitingTime = WAITING;
        countBackwards();
        isStartCount = false; // ??

    }

    /**
     * ??
     */
    private void showCalled(Drivers info) {

        // waitingTitleprogressBar????,dialog
        isWaiting = false;

        callingTitle.setVisibility(View.GONE);
        waitingTitle.setVisibility(View.GONE);
        answerTitle.setVisibility(View.VISIBLE);
        callingBottom.setVisibility(View.GONE);
        waitingBottom.setVisibility(View.GONE);
        answerBottom.setVisibility(View.VISIBLE);

        answerTitleName.setText("?" + info.getName() + "");
        answerTitleInfo.setText(info.getCar_license());

        displapDriversForAnswer(info);
    }

    //   /**
    //    * ?gps
    //    * 
    //    * @return
    //    */
    //   private boolean initGPS() {
    //      LocationManager locationManager = (LocationManager) this
    //            .getSystemService(Context.LOCATION_SERVICE);
    //
    //      // GPS????
    //      if (!locationManager
    //            .isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
    //         Toast.makeText(this, "GPS is not open,Please open it!",
    //               Toast.LENGTH_SHORT).show();
    //         // Intent intent = new
    //         // Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    //         // startActivityForResult(intent, 0);
    //
    //         return false;
    //      } else {
    //         Toast.makeText(this, "GPS is ready", Toast.LENGTH_SHORT);
    //      }
    //      return true;
    //   }

    //   /**
    //    * ?GPS?
    //    */
    //   private void initLocation() {
    //
    //      LocationManager locationManager;
    //      String serviceName = Context.LOCATION_SERVICE;
    //      locationManager = (LocationManager) this.getSystemService(serviceName);
    //      // ?
    //      Criteria criteria = new Criteria();
    //      criteria.setAccuracy(Criteria.ACCURACY_FINE);
    //      criteria.setAltitudeRequired(false);
    //      criteria.setBearingRequired(false);
    //      criteria.setCostAllowed(true);
    //      criteria.setPowerRequirement(Criteria.POWER_LOW);
    //
    //      String provider = locationManager.getBestProvider(criteria, true);
    //      Location location = locationManager.getLastKnownLocation(provider);
    //      if (location != null) {
    //
    //         lat = (int) location.getLatitude();
    //         lng = (int) location.getLongitude();
    //
    //         pt = new GeoPoint((int) (location.getLatitude() * 1e6),
    //               (int) (location.getLongitude() * 1e6));
    //
    //         mMapView.getController().animateTo(pt);
    //         // mapController.setCenter(pt);
    //
    //         // ????
    //         // mMKSearch.reverseGeocode(point);
    //
    //         // mMKSearch.reverseGeocode(new GeoPoint((int) (lat * 1e6),
    //         // (int) (lng * 1e6)));
    //         // getAddress(lat, lng);
    //      }
    //   }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        if (keyCode == KeyEvent.KEYCODE_BACK) {

            //         exitDialog(context);
            //??home?
            Intent intents = new Intent(Intent.ACTION_MAIN);
            intents.addCategory(Intent.CATEGORY_HOME);
            intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intents);
        }
        return super.onKeyDown(keyCode, event);
    }

    /**
     * ??
     */
    private void save(String name, String password) {
        Editor sharedata = getSharedPreferences("data", 0).edit();

        sharedata.putString("password", password);

        sharedata.putString("name", name);

        sharedata.commit();

    }

    /**
     * 
     */
    private void getData() {
        SharedPreferences sharedata = getSharedPreferences("data", 0);
        name = sharedata.getString("name", "");
        password = sharedata.getString("password", "");

    }

    /**
     * 
     */
    Handler fullHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

            case Constant.SUCCESS:
                //            Tools.myToast(context, "??");
                MyToast toast = new MyToast(context, "??");
                toast.startMyToast();
                showNorm();
                break;
            case Constant.FAILURE:

                break;

            }
        }
    };

    Handler normHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

            case Constant.SUCCESS:
                showNorm();
                isListern = false;

                break;

            }
        }
    };
    /**
     * ???
     */
    Handler messageHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

            case Constant.SUCCESS:

                displayDrivers(true);
                title.setText("5" + String.valueOf(driversList.size()) + "");
                //            title.setTextSize(20);

                break;
            case Constant.FAILURE:
                //            Tools.myToast(context, "??");
                MyToast toast = new MyToast(context, "??");
                toast.startMyToast();
                break;

            }
        }
    };
    // ??
    Handler callingHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

            case Constant.SUCCESS:
                showCalling();
                break;
            case Constant.FAILURE:

                break;

            }
        }
    };
    /**
     * ??
     */
    Handler acceptHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

            case Constant.SUCCESS:

                System.out.println("acceptInfo.getName()---" + acceptInfo.getName());
                if (isAccept) {

                    showCalled(acceptInfo);
                    isListern = true;
                    //               listernConversation();

                } else {
                    isGetConversation = true;// ?????
                }

                break;
            case Constant.FAILURE:

                break;

            }
        }
    };

    Handler waitingHandler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {

            case WAITING:
                if (waitingTime >= 0) {
                    waittingTimeEdit.setText("" + waitingTime);
                    break;
                } else if (waitingTime == -1) {

                    isWaiting = false;
                    isGetConversation = false;// ??????
                    if (lastConversation != null) {
                        // String id = String.valueOf(lastConversation.getId());
                        String id = String.valueOf(ConversationID);
                        Log.e("?ID----------------------->", "=" + ConversationID);
                        changeConversationsStatus("-1", id);
                    }
                    showTimeOutDialog();
                    waitingTime = WAITING;//718,1063,1093
                    // Intent i = new Intent(context, DialogFrist.class);
                    // startActivityForResult(i, TIMEOUT);

                    break;
                } else {

                }
            }
        }
    };

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // TODO Auto-generated method stub
        menu.add(0, 1, 1, "");
        menu.add(0, 2, 2, "");
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        if (item.getItemId() == 1) {
            save("", "");
            signOut();
        }
        return true;
    }

    /**
     * 
     * 
     * @param context
     */
    public void exitPro(Context context) {

        // ?Application
        String packName = context.getPackageName();
        ActivityManager activityMgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        activityMgr.restartPackage(packName);
        activityMgr.killBackgroundProcesses(packName);
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    public void exitDialog(final Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);

        View aalayout = View.inflate(context, R.layout.exit, null);

        builder.setView(aalayout);
        builder.setNegativeButton("?", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

            }
        });
        builder.setPositiveButton("", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (info != null) {

                    signOut();
                } else {

                    exitPro(context);
                }
            }
        });

        builder.create().show();
    }

    @Override
    public void onReceiveLocation(BDLocation location) {

        // TODO Auto-generated method stub
        System.out.println("---------------------------->onReceiveLocation");
        if (HttpTools.checkNetWork(context)) {

            lat = location.getLatitude();
            lng = location.getLongitude();

            System.out.println("onReceiveLocationlat---------------->" + lat);
            System.out.println("onReceiveLocationlng---------------->" + lng);
            pt = new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6));

            // ??????
            MKSearch search = new MKSearch();
            search.init(mBMapMan, new MyMKSearchListener());
            // ??????? MKSearchListeneronGetAddrResult
            search.reverseGeocode(pt);

            OverlayItem item = new OverlayItem(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), "", "");

            Drawable maker = getResources().getDrawable(R.drawable.person);
            item.setMarker(maker);
            mGeoList.add(item); // List<OverlayItem> mGeoList overlayitem

            MyItemizedOverlay overlay = new MyItemizedOverlay(context, maker, mGeoList, true);

            overlay.onTap(pt, mMapView);//

            List<Overlay> list = mMapView.getOverlays();
            list.clear();

            mMapView.getOverlays().add(0, overlay);
            mMapView.refresh();
            mapController.animateTo(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), null);

            // ??
            getDrivers();
        }
    }

    @Override
    public void onReceivePoi(BDLocation arg0) {
        // TODO Auto-generated method stub

    }

    /**
     * 
     * 
     * @param start
     *            simsunny
     */
    private void countBackwards() {

        // isWaiting = true;

        if (isStartCount) {

            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (isWaiting) {

                        try {
                            Thread.currentThread().sleep(1000);
                            Message msg = new Message();
                            waitingTime--;
                            msg.what = WAITING;
                            waitingHandler.sendMessage(msg);

                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

                }
            }).start();

        }

    }

    //   private void listernConversation() {
    //      if (HttpTools.checkNetWork(context)) {
    //         new Thread(new Runnable() {
    //            public void run() {
    //               while (isListern) {
    //
    //                  lastConversation = (ConversationInfo) HttpTools
    //                        .getAndParse(Constant.CONVERSATIONS,
    //                              ConversationID,
    //                              new ConversationHandler());
    //                  try {
    //                     Thread.currentThread().sleep(1000);
    //                  } catch (InterruptedException e) {
    //                     // TODO Auto-generated catch block
    //                     e.printStackTrace();
    //                  }
    //                  if (lastConversation != null) {
    //
    //                     int Status = lastConversation.getStatus();
    //
    //                     if (Status == 4) {// ?
    //                        normHandler.sendEmptyMessage(Constant.SUCCESS);
    //
    //                     } else {
    //
    //                     }
    //                  }
    //               }
    //            }
    //         }).start();
    //      }
    //   }

    private void displapDriversForAnswer(Drivers info) {

        Drawable marker = getResources().getDrawable(R.drawable.cear);
        marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
        mGeoList.clear();

        OverlayItem item1 = new OverlayItem(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), "", "");

        Drawable maker1 = getResources().getDrawable(R.drawable.person);
        item1.setMarker(maker1);
        mGeoList.add(item1);

        int size = driversList.size();
        OverlayItem item = null;
        double driverLat, driverLng;
        DriversInfo drivers;
        Drawable maker = getResources().getDrawable(R.drawable.cear);

        driverLat = Double.parseDouble(info.getLat());
        driverLng = Double.parseDouble(info.getLng());
        item = new OverlayItem(new GeoPoint((int) (driverLat * 1e6), (int) (driverLng * 1e6)), info.getName(), " ");
        item.setMarker(maker);
        mGeoList.add(item);

        for (int i = 0; i < mGeoList.size(); i++) {
            System.out.println("?mGeoList---------->" + mGeoList.get(i).getTitle());
        }

        MyItemizedOverlay overlay = new MyItemizedOverlay(context, maker, mGeoList, info);

        mMapView.getOverlays().clear();// ??mGeoList
        mMapView.getOverlays().add(0, overlay);
        mMapView.refresh();

    }

    /**
     * ?
     * 
     * @param isDisplay
     */
    private void displayDrivers(boolean isDisplay) {

        if (isDisplay) {

            Drawable marker = getResources().getDrawable(R.drawable.cear);
            marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());

            for (int i = 0; i < mGeoList.size(); i++) {
                System.out.println("??mGeoList---------->" + mGeoList.get(i).getTitle());
            }

            // for (int i = 1; i < mGeoList.size(); i++) {
            // mGeoList.remove(i);
            // }
            mGeoList.clear();
            OverlayItem item1 = new OverlayItem(new GeoPoint((int) (lat * 1e6), (int) (lng * 1e6)), "", "");

            Drawable maker1 = getResources().getDrawable(R.drawable.person);
            item1.setMarker(maker1);
            mGeoList.add(item1);
            for (int i = 0; i < mGeoList.size(); i++) {
                System.out.println("mGeoList---------->" + mGeoList.get(i).getTitle());
            }

            int size = driversList.size();
            OverlayItem item = null;
            double driverLat, driverLng;
            DriversInfo drivers;
            Drawable maker = getResources().getDrawable(R.drawable.cear);

            for (int i = 0; i < size; i++) {
                drivers = driversList.get(i);
                driverLat = drivers.getLat();
                driverLng = drivers.getLng();

                item = new OverlayItem(new GeoPoint((int) (driverLat * 1e6), (int) (driverLng * 1e6)),
                        drivers.getName(), " ");
                item.setMarker(maker);
                mGeoList.add(item);
            }

            for (int i = 0; i < mGeoList.size(); i++) {
                System.out.println("??mGeoList---------->" + mGeoList.get(i).getTitle());
            }

            MyItemizedOverlay overlay = new MyItemizedOverlay(context, maker, mGeoList, driversList);

            mMapView.getOverlays().clear();// ??mGeoList
            for (int i = 0; i < mGeoList.size(); i++) {
                System.out.println("cleae?mGeoList---------->" + mGeoList.get(i).getTitle());
            }
            mMapView.getOverlays().add(0, overlay);
            for (int i = 0; i < mGeoList.size(); i++) {
                System.out.println("add?mGeoList---------->" + mGeoList.get(i).getTitle());
            }
            mMapView.refresh();
        }
    }

    /**
     * TimeOutDialog simsunny
     */
    private void showTimeOutDialog() {
        timeOutDialog.setVisibility(View.VISIBLE);
        dialog1.setVisibility(View.GONE);
        dialog2.setVisibility(View.GONE);
    }

    /**
     * Dialog1 simsunny
     */
    private void showDialog1() {
        timeOutDialog.setVisibility(View.GONE);
        dialog1.setVisibility(View.VISIBLE);
        dialog2.setVisibility(View.GONE);
    }

    /**
     * dialog2 simsunny
     */
    private void showDialog2() {
        timeOutDialog.setVisibility(View.GONE);
        dialog1.setVisibility(View.GONE);
        dialog2.setVisibility(View.VISIBLE);
    }

    private class PhoneCallListener extends PhoneStateListener {
        private boolean bphonecalling = false;

        @Override
        public void onCallStateChanged(int state, String incomingnumber) {
            // seems the incoming number is this call back always ""
            if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
                bphonecalling = true;
            } else if (TelephonyManager.CALL_STATE_IDLE == state && bphonecalling) {

                bphonecalling = false;

                Intent intent = new Intent();

                intent.setClass(LocationOverlay.this, LocationOverlay.class);
                //
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                // intent.setFlags( Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                startActivity(intent);

                // startActivity(intent);
            }
            super.onCallStateChanged(state, incomingnumber);
        }
    }

    /**
     * ?
     */
    private void initMyBroadcastReceiver() {
        IntentFilter filter = new IntentFilter();
        filter.addAction("cn.jpush.android.intent.REGISTRATION");// SDKintent
        filter.addAction("cn.jpush.android.intent.UNREGISTRATION");
        filter.addAction("cn.jpush.android.intent.MESSAGE_RECEIVED");// SDK?intent
        filter.addAction("cn.jpush.android.intent.NOTIFICATION_RECEIVED");// SDK??intent
        filter.addAction("cn.jpush.android.intent.NOTIFICATION_OPENED");// ?intent
        filter.addCategory("com.findcab");
        getApplicationContext().registerReceiver(MyReceiver, filter); // 
    }

    /**
     * ,?
     */
    private BroadcastReceiver MyReceiver = new BroadcastReceiver() {
        private static final String TAG = "MyReceiver";

        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle bundle = intent.getExtras();

            if (bundle.containsKey("cn.jpush.android.ALERT")) {
                Log.e(TAG,
                        "???: " + bundle.getString("cn.jpush.android.ALERT"));

                // ?
                refreshViewByJPushInfo(bundle.getString("cn.jpush.android.ALERT"));
            }
        }

        // ? intent extra ?
        private String printBundle(Bundle bundle) {
            StringBuilder sb = new StringBuilder();
            for (String key : bundle.keySet()) {
                if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
                    sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
                } else {
                    sb.append("\nkey:" + key + ", value:" + bundle.getString(key));
                }
            }
            return sb.toString();
        }
    };

    // ??handler?;1,conversation_change 2,drivers_change
    // 3,passagers_change
    private void refreshViewByJPushInfo(String text) {
        if (text.equals("conversations")) {
            handlerMain.sendEmptyMessage(MESSAGE_CONVERSATIONS_CHANGE);
        } else if (text.equals("drivers")) {
            handlerMain.sendEmptyMessage(MESSAGE_DRIVERS_CHANGE);
        } else if (text.equals("passagers")) {
            handlerMain.sendEmptyMessage(MESSAGE_PASSAGERS_CHANGE);
        } else {

        }
    }

}