充电桩app代码

ClaimSurveyTwoActivity.java 103KB

    package com.electric.chargingpile.activity; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.app.TimePickerDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.provider.MediaStore; import android.util.Base64; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.RelativeLayout; import android.widget.Switch; import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; import android.widget.ToggleButton; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.LocationSource; import com.amap.api.maps.MapView; import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.BitmapDescriptor; import com.amap.api.maps.model.BitmapDescriptorFactory; import com.amap.api.maps.model.CameraPosition; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.MyLocationStyle; import com.amap.api.services.core.AMapException; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.geocoder.GeocodeResult; import com.amap.api.services.geocoder.GeocodeSearch; import com.amap.api.services.geocoder.RegeocodeQuery; import com.amap.api.services.geocoder.RegeocodeResult; import com.electric.chargingpile.R; import com.electric.chargingpile.application.MainApplication; import com.electric.chargingpile.data.Zhan; import com.electric.chargingpile.engine.GlideEngine; import com.electric.chargingpile.util.Bimp; import com.electric.chargingpile.util.DES3; import com.electric.chargingpile.util.FileUtils; import com.electric.chargingpile.util.ImageItem; import com.electric.chargingpile.util.OkHttpUtil; import com.electric.chargingpile.util.PhotoUtils; import com.electric.chargingpile.util.PublicWay; import com.electric.chargingpile.util.Res; import com.electric.chargingpile.util.SharedPreferencesUtil; import com.electric.chargingpile.util.StatusConstants; import com.electric.chargingpile.util.UploadUtil; import com.electric.chargingpile.util.Util; import com.electric.chargingpile.view.CustomProgressDialog; import com.electric.chargingpile.view.ObservableScrollView; import com.google.android.gms.appindexing.Action; import com.google.android.gms.appindexing.AppIndex; import com.google.android.gms.appindexing.Thing; import com.google.android.gms.common.api.GoogleApiClient; import com.luck.picture.lib.PictureSelector; import com.luck.picture.lib.animators.AnimationType; import com.luck.picture.lib.config.PictureConfig; import com.luck.picture.lib.config.PictureMimeType; import com.luck.picture.lib.entity.LocalMedia; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; import com.umeng.analytics.MobclickAgent; import com.yalantis.ucrop.view.OverlayView; import org.json.JSONException; import org.json.JSONObject; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; public class ClaimSurveyTwoActivity extends Activity implements View.OnClickListener, AMap.OnCameraChangeListener, LocationSource, AMap.OnMapLoadedListener, GeocodeSearch.OnGeocodeSearchListener, AMapLocationListener, AMap.InfoWindowAdapter, AMap.OnMapClickListener, AMap.OnMapTouchListener { private ImageView ivBack, ivType; private ImageView inBtn, outBtn; Bitmap bm = null; private TextView shareList, tvO, tvT, tvTh, tvF, tvFi, zhuangType, costWay, shareNext; // private static LocationClient mLocClient; // public MyLocationListenner myListener = new MyLocationListenner(); // BaiduMapOptions mapOptions; private TimePickerDialog tpd_open = null; private TimePickerDialog tpd_close = null; private String camePath;//拍照路径 // private LocationMode mCurrentMode; private static final String PHOTO_FILE_NAME = "android.jpg"; private static final String PHOTO_FILE_PATH = getPath(PhotoUtils.CACHE_DIR); private File tempFile; private static final int PHOTO_REQUEST_CAMERA = 1; private static final int PHOTO_REQUEST_GALLERY = 2; private String gd_jing, gd_wei; String ls_jing, ls_wei; private boolean isTouch = false; // private static MyLocationConfiguration.LocationMode mCurrentMode; // public static BitmapDescriptor mCurrentMarker; // public static boolean isFirstLoc = true; private BitmapDescriptor bdLocation = BitmapDescriptorFactory .fromResource(R.drawable.icon_zhen2_0); // private BitmapDescriptor bdLocation1 = BitmapDescriptorFactory .fromResource(R.drawable.icon_borange); // BitmapDescriptor bdyes = BitmapDescriptorFactory // .fromResource(R.drawable.icon_sgreen); // // BitmapDescriptor bdno = BitmapDescriptorFactory // .fromResource(R.drawable.icon_sorange); // // BitmapDescriptor bigno = BitmapDescriptorFactory.fromResource(R.drawable.icon_borange); // // BitmapDescriptor bigyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgreen); // private Marker mMarker; // private InfoWindow mInfoWindow; private RelativeLayout rl_map; private Switch sh_cost; private Button submitLocation; private ImageView test, iv1, iv2, iv3, iv4, iv_back; private LinearLayout ll_tvOne, ll_tvTwo, ll_tvThree, ll_tvFour, ll_buchong, ll_type, ll_costWay; private List<Zhan> list = new ArrayList<Zhan>(); private Zhan zhan; // private static MapView mMapView; // private static BaiduMap mBaiduMap; // private MapStatus mapStatus; private Marker mMarker, mMarker1; private float minZoomLevel; private float maxZoomLevel; RadioGroup.OnCheckedChangeListener radioButtonListener; Button requestLocButton; // boolean isFirstLoc = true;// 是否首次定位 ToggleButton carType; private String suit_car2 = "国标"; // BitmapDescriptor mCurrentMarker; // GeoCoder mSearch = null; private static boolean isGetData = false; public static LatLng center = null; public static LatLng llposition = null; private static String location; private static String city; private static String district; private EditText et_share_address; private Button confirmButton; private Button cancleButton; private PopupWindow popupWindow; private ObservableScrollView scrollView; // OverlayOptions ooyes=null; // OverlayOptions oono=null; // OverlayOptions oo=null; // OverlayOptions oobd=null; // private Marker mMarkerYes; // private Marker mMarkerNo; // private Marker mMarkerCenter; private View popupWindowView; private ImageView iv_list; Context mContext; LatLng selectedCenter = null; TextView tv; private String park = "1"; private ImageView ib_loaction, ib_add, ib_jian; private RelativeLayout tv_notice; // private String cost = "收费"; private EditText zhanName, fastNum, slowNum, parkCost, chargeCost, et_serviceCost, et_remark; private CustomProgressDialog pd_info; private String zhan_id, poi_jing, poi_wei, zhan_address, zhan_name; private RadioButton rb_guo, rb_te, rb_shang, rb_xia; private RadioGroup rg_claimtype, rg_park; public static Bitmap bimap; private GridView noScrollgridview; private GridAdapter adapter; private View parentView; private PopupWindow pop = null; private LinearLayout ll_popup; private TextView open_time, close_time; private MapView mapView; private AMap aMap; private UiSettings mUiSettings; private AMapLocationClient mlocationClient; private OnLocationChangedListener mListener; private AMapLocationClientOption mLocationOption; private GeocodeSearch geocoderSearch; boolean isFirstLoc = true; // 是否首次定位 /** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroidStudio for more information. */ private GoogleApiClient client; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tempFile = getFile(PHOTO_FILE_PATH + "/" + PHOTO_FILE_NAME); Res.init(this); bimap = BitmapFactory.decodeResource( getResources(), R.drawable.icon_defaultadd1105); PublicWay.activityList.add(this); // parentView = getLayoutInflater().inflate(R.layout.activity_selectimg, null); // setContentView(parentView); setContentView(R.layout.activity_claim_survey_two); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); list = new ArrayList<>(); mContext = this; // map = new HashMap<>(); initView(); Init(); initMap(); // firstSelect(); // initData(); // sp(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); } // public static void firstSelect() { // if (!isFirstLoc) { // isFirstLoc = true; //// tvLocation.setText("正在定位中..."); // mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; // mBaiduMap // .setMyLocationConfigeration(new MyLocationConfiguration( // mCurrentMode, true, mCurrentMarker)); // mBaiduMap.setMapStatus(MapStatusUpdateFactory // .newMapStatus(new MapStatus.Builder().zoom(15f).build())); // mBaiduMap.setMyLocationEnabled(true); // mLocClient.start(); // // } // // // } private void initDate() { zhan_id = getIntent().getStringExtra("zhan_id"); zhan_address = getIntent().getStringExtra("zhan_address"); poi_jing = getIntent().getStringExtra("poi_jing"); poi_wei = getIntent().getStringExtra("poi_wei"); zhan_name = getIntent().getStringExtra("zhan_name"); // Log.e("!!!",zhan_name); } // private void sp(){ // SharedPreferences sharedPreferences= getSharedPreferences("userClaimInfo", // Activity.MODE_PRIVATE); // poi_jing =sharedPreferences.getString("jing", ""); // poi_wei =sharedPreferences.getString("wei", ""); // zhan_id =sharedPreferences.getString("zhan_id", ""); // suit_car2 =sharedPreferences.getString("suit_car2", ""); // zhan_address =sharedPreferences.getString("zhan_address", ""); // fast_num =sharedPreferences.getString("fast_num", ""); // slow_num =sharedPreferences.getString("slow_num", ""); // stop_cost =sharedPreferences.getString("stop_cost", ""); // charge_cost =sharedPreferences.getString("charge_cost", ""); // cost_type =sharedPreferences.getString("cost_type", ""); // zhan_name =sharedPreferences.getString("zhan_name", ""); // // // Log.e("share1_data", "zhan_address=" + zhan_address + ",poi_jing=" + poi_jing + ",poi_wei=" + poi_wei // + ",costType=" + cost_type + ",suit_car2=" + suit_car2 + ",fast_num=" + fast_num + ",slow_num=" + slow_num // + ",stop_cost=" + stop_cost + ",zhan_name=" + zhan_name + ",charge_cost=" + charge_cost+ ",zhan_id=" + zhan_id); // // } public void createDialog() { if (pd_info == null) { pd_info = CustomProgressDialog.createDialog(mContext); pd_info.setMessage(mContext.getResources().getString( R.string.version_updating)); pd_info.show(); } } public void dismissDialog() { if (pd_info != null) { pd_info.dismiss(); pd_info = null; } } public void Init() { pop = new PopupWindow(ClaimSurveyTwoActivity.this); View view = getLayoutInflater().inflate(R.layout.item_popupwindows, null); ll_popup = (LinearLayout) view.findViewById(R.id.ll_popup); pop.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); pop.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); pop.setBackgroundDrawable(new BitmapDrawable()); pop.setFocusable(true); pop.setOutsideTouchable(true); pop.setContentView(view); final RelativeLayout parent = (RelativeLayout) view.findViewById(R.id.parent); LinearLayout ll_zhaoxiang = (LinearLayout) view.findViewById(R.id.ll_zhaoxiang); ll_zhaoxiang.setVisibility(View.GONE); Button bt1 = (Button) view .findViewById(R.id.item_popupwindows_camera); bt1.setVisibility(View.GONE); Button bt2 = (Button) view .findViewById(R.id.item_popupwindows_Photo); Button bt3 = (Button) view .findViewById(R.id.item_popupwindows_cancel); parent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub pop.dismiss(); ll_popup.clearAnimation(); } }); bt1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // ls_jing = llposition.longitude photo(); pop.dismiss(); // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // ((Activity) mContext).startActivityForResult(intent, 2); ll_popup.clearAnimation(); aMap.clear(); } }); bt2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Intent intent = new Intent(ClaimSurveyTwoActivity.this, // AlbumActivity4claim.class); // startActivity(intent); // overridePendingTransition(R.anim.activity_translate_in, R.anim.activity_translate_out); // startActivityForResult(intent, 1); openPhotoAlbum(); pop.dismiss(); ll_popup.clearAnimation(); } }); bt3.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { pop.dismiss(); ll_popup.clearAnimation(); } }); noScrollgridview = (GridView) findViewById(R.id.noScrollgridview); noScrollgridview.setSelector(new ColorDrawable(Color.TRANSPARENT)); adapter = new GridAdapter(this); adapter.update(); noScrollgridview.setAdapter(adapter); noScrollgridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (arg2 == Bimp.tempSelectBitmap.size()) { Log.i("ddddddd", "----------"); ll_popup.startAnimation(AnimationUtils.loadAnimation(ClaimSurveyTwoActivity.this, R.anim.activity_translate_in)); pop.showAtLocation(parent, Gravity.CENTER, 0, 0); } else { Intent intent = new Intent(ClaimSurveyTwoActivity.this, GalleryActivity4Claim.class); intent.putExtra("position", "1"); intent.putExtra("ID", arg2); startActivity(intent); } } }); // } @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void initView() { initDate(); // et_chargeCost = (EditText) findViewById(R.id.et_charge_cost); et_serviceCost = (EditText) findViewById(R.id.et_serviceCost); scrollView = (ObservableScrollView) findViewById(R.id.sv); // scrollView.setScrollViewListener(this); rl_map = (RelativeLayout) findViewById(R.id.rl_map); inBtn = (ImageView) findViewById(R.id.zoomin1); outBtn = (ImageView) findViewById(R.id.zoomout1); inBtn.setOnClickListener(this); outBtn.setOnClickListener(this); // et_zyNum = (EditText) findViewById(R.id.et_zyNum); // parkLocation = (ToggleButton) findViewById(R.id.car_location); // parkLocation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // @Override // public void onCheckedChanged(CompoundButton compoundButton, boolean b) { // if(b){ // Log.e("!!!!","地下"); // park = "0"; // }else{ // Log.e("!!!!","地上"); // park = "1"; // } // } // }); shareNext = (TextView) findViewById(R.id.share_next); shareNext.setOnClickListener(this); et_serviceCost = (EditText) findViewById(R.id.et_serviceCost); et_remark = (EditText) findViewById(R.id.et_remarkclaim); et_remark = (EditText) findViewById(R.id.et_remarkclaim); zhanName = (EditText) findViewById(R.id.et_zhanName); zhanName.setText(zhan_name); fastNum = (EditText) findViewById(R.id.et_fastNum); slowNum = (EditText) findViewById(R.id.et_slowNum); parkCost = (EditText) findViewById(R.id.et_parkCost); chargeCost = (EditText) findViewById(R.id.et_chargeCost); costWay = (TextView) findViewById(R.id.tv_costtype); costWay.setOnClickListener(this); ib_loaction = (ImageView) findViewById(R.id.ib_location); ib_loaction.setOnClickListener(this); tv_notice = (RelativeLayout) findViewById(R.id.tv_notice); tv_notice.setOnClickListener(this); // iv_list = (ImageView) findViewById(R.id.tv_share_list); // iv_list.setOnClickListener(this); rg_claimtype = (RadioGroup) findViewById(R.id.rg_claimtype); rg_claimtype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == rb_guo.getId()) { suit_car2 = "国标"; } if (checkedId == rb_te.getId()) { suit_car2 = "特斯拉"; } } }); rg_park = (RadioGroup) findViewById(R.id.rg_park); rg_park.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == rb_shang.getId()) { park = "1"; } if (checkedId == rb_xia.getId()) { park = "0"; } } }); rb_guo = (RadioButton) findViewById(R.id.rb_guo); rb_guo.setOnClickListener(this); rb_te = (RadioButton) findViewById(R.id.rb_te); rb_te.setOnClickListener(this); rb_shang = (RadioButton) findViewById(R.id.rb_shang); rb_shang.setOnClickListener(this); rb_xia = (RadioButton) findViewById(R.id.rb_xia); rb_xia.setOnClickListener(this); ivBack = (ImageView) findViewById(R.id.iv_back); ivBack.setOnClickListener(this); open_time = (TextView) findViewById(R.id.tv_prefect_start_time); open_time.setOnClickListener(this); close_time = (TextView) findViewById(R.id.tv_ferfect_time); close_time.setOnClickListener(this); // View v = mapView.getChildAt(0); // v.setOnTouchListener(new View.OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // if(event.getAction() == MotionEvent.ACTION_SCROLL){ // scrollView.requestDisallowInterceptTouchEvent(false); // }else{ // scrollView.requestDisallowInterceptTouchEvent(true); // } // return false; // } // }); // mMapView.setOnDragListener(new View.OnDragListener() { // @Override // public boolean onDrag(View v, DragEvent event) { // if (event.getAction() == MotionEvent.ACTION_SCROLL){ // scrollView.requestDisallowInterceptTouchEvent(false); // }else { // scrollView.requestDisallowInterceptTouchEvent(true); // } // return false; // } // }); et_share_address = (EditText) findViewById(R.id.et_share_address); zhuangType = (TextView) findViewById(R.id.tv_zhuangType); // add = (TextView) findViewById(R.id.tv_add); // rl_charge_cost_style = (RelativeLayout) findViewById(R.id.rl_charge_cost_style); // rl_charge_cost_style.setOnClickListener(this); // rl_open_object = (RelativeLayout) findViewById(R.id.rl_open_object); // rl_open_object.setOnClickListener(this); // rl_perfect_belong = (RelativeLayout) findViewById(R.id.rl_perfect_belong); // rl_perfect_belong.setOnClickListener(this); // et_address = (EditText) findViewById(R.id.et_address_detail); // suit_car = getIntent().getStringExtra("suit_car"); // sf_cost = getIntent().getStringExtra("sf_cost"); // et_address.setText(zhan_address); // et_name = (EditText) findViewById(R.id.et_name_detail); //setEditTextCursorLocation(et_name); // et_fast_num = (EditText) findViewById(R.id.et_prefect_fast_no); // et_slow_num = (EditText) findViewById(R.id.et_prefect_slow_no); // et_style = (TextView) findViewById(R.id.et_charge_style_detail); //// et_open_object = (TextView) findViewById(R.id.et_open_object); // et_belong = (EditText) findViewById(R.id.et_perfect_work_detail); // et_phone = (EditText) findViewById(R.id.et_perfect_phone_detail); // tv_run_state = (TextView) findViewById(R.id.tv_run_state); // tv_suit_car = (TextView) findViewById(R.id.tv_prefect_suit_detail); // tv_belong_type = (TextView) findViewById(R.id.tv_perfect_belong_detail); // tv_submit = (TextView) findViewById(R.id.tv_submit); // tv_submit.setOnClickListener(this); // tv_belong_style = (TextView) findViewById(R.id.tv_perfect_work_style); // tv_next = (TextView) findViewById(R.id.tv_next); // tv_next.setOnClickListener(this); // iv_run_state = (ImageView) findViewById(R.id.iv_run_state); // iv_run_state.setOnClickListener(this); iv_back = (ImageView) findViewById(R.id.iv_back); // image = (ImageView) findViewById(R.id.iv_photo1); // image1 = (ImageView) findViewById(R.id.iv_photo2); // image1.setOnClickListener(this); // image2 = (ImageView) findViewById(R.id.iv_photo3); // image2.setOnClickListener(this); iv_back.setOnClickListener(this); // iv_ferfect_change_suit = (ImageView) findViewById(R.id.iv_prefect_change_suit); // iv_ferfect_change_suit.setOnClickListener(this); // iv_perfect_change_belong = (ImageView) findViewById(R.id.iv_perfect_change_belong); // iv_perfect_change_belong.setOnClickListener(this); open_time = (TextView) findViewById(R.id.tv_prefect_start_time); open_time.setOnClickListener(this); close_time = (TextView) findViewById(R.id.tv_ferfect_time); close_time.setOnClickListener(this); // holiday_open = (TextView) findViewById(R.id.tv_holiday_start_time); // holiday_open.setOnClickListener(this); // holiday_close = (TextView) findViewById(R.id.tv_holiday_stop_time); // holiday_close.setOnClickListener(this); // ll_addPhotot = (LinearLayout) findViewById(R.id.ll_add_photo); // ll_addPhotot.setOnClickListener(this); // iv_cost = (ImageView) findViewById(R.id.iv_change_cost); // iv_cost.setOnClickListener(this); // ll_uploadPhoto = (LinearLayout) findViewById(R.id.ll_uploadPhoto); // ll_uploadPhoto.setOnClickListener(this); // uploadPhoto = (ImageView) findViewById(R.id.uploadPhoto); // addPhoto = (LinearLayout) findViewById(R.id.ll_add_photo); // addPhoto.setOnClickListener(this); // mBaiduMap = mMapView.getMap(); // MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(14.0f); // mMapView.showZoomControls(false); // mBaiduMap.setMapStatus(msu); // mBaiduMap.setMyLocationEnabled(true); // mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() { // // @Override // public boolean onMapPoiClick(MapPoi poi) { // llposition = poi.getPosition(); // initOverlay1(); // return false; // } // // @Override // public void onMapClick(LatLng point) { // llposition = point; // // initOverlay1(); // getAddress(); // } // }); // // mLocClient = new LocationClient(this); // mLocClient.registerLocationListener(myListener); // LocationClientOption option = new LocationClientOption(); // option.setOpenGps(true); // option.setCoorType("bd09ll"); // option.setScanSpan(1000); // mLocClient.setLocOption(option); // mLocClient.start(); } // @Override // public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) { //// super.onScrollChanged(l, t, oldl, oldt); // // if (oldy > y && oldy - y > 40) {// 向下 // rl_map.setVisibility(View.VISIBLE); // System.out.println("向下滑动"); //// if (mListener != null) //// mListener.scrollOritention(SCROLL_DOWN); // // } else if (oldy < y && y - oldy > 40) {// 向上 // rl_map.setVisibility(View.GONE); // System.out.println("向上滑动"); //// if (mListener != null) //// mListener.scrollOritention(SCROLL_UP); //// } // } // } // class TouchListenerImpl implements View.OnTouchListener { // @Override // public boolean onTouch(View view, MotionEvent motionEvent) { // switch (motionEvent.getAction()) { // case MotionEvent.ACTION_UP: // rl_map.setVisibility(View.GONE); // System.out.println("向上滑动"); // break; // // case MotionEvent.ACTION_DOWN: // rl_map.setVisibility(View.VISIBLE); // System.out.println("向下滑动"); // break; //// case MotionEvent.ACTION_MOVE: //// int scrollY=view.getScrollY(); //// int height=view.getHeight(); //// int scrollViewMeasuredHeight=scrollView.getChildAt(0).getMeasuredHeight(); //// if(scrollY==0){ //// System.out.println("滑动到了顶端 view.getScrollY()="+scrollY); //// rl_map.setVisibility(View.VISIBLE); //// } //// if((scrollY+height)==scrollViewMeasuredHeight){ //// rl_map.setVisibility(View.GONE); //// System.out.println("滑动到了底部 scrollY="+scrollY); //// System.out.println("滑动到了底部 height="+height); //// System.out.println("滑动到了底部 scrollViewMeasuredHeight="+scrollViewMeasuredHeight); //// } //// break; // // default: // break; // } // return false; // } // // }; // iv_open = (ImageView) findViewById(R.id.iv_change_open); // iv_open.setOnClickListener(this); // list.add(share_pic_one); // list.add(share_pic_two); // list.add(share_pic_three); // Intent intent = new Intent(this, ShareTwoActivity.class); // intent.putExtra("jing", llposition.longitude); // intent.putExtra("wei", llposition.latitude); // intent.putExtra("city", city); // intent.putExtra("district", location); // intent.putExtra("zhuangType",zhuangType.getText().toString()); // intent.putExtra("zhan_address",et_share_address.getText().toString()); // intent.putExtra("fast_num",fastNum.getText().toString()); // intent.putExtra("slow_num",slowNum.getText().toString()); // intent.putExtra("stop_cost",parkCost.getText().toString()); // intent.putExtra("other_cost",serviceCost.getText().toString()); // intent.putExtra("charge_cost_way", costWay.getText().toString()); // intent.putExtra("zhan_name", zhanName.getText().toString()); // startActivity(intent); // private void initData(){ // zhan_address = getIntent().getStringExtra("zhan_address"); // poi_jing = getIntent().getDoubleExtra("jing", 0); // poi_wei = getIntent().getDoubleExtra("wei", 0); // costType = getIntent().getStringExtra("cost_type"); // suit_car2 = getIntent().getStringExtra("suit_car2"); // fast_num = getIntent().getStringExtra("fast_num"); // slow_num = getIntent().getStringExtra("slow_num"); // stop_cost = getIntent().getStringExtra("stop_cost"); // charge_cost = getIntent().getStringExtra("charge_cost"); // zhan_name = getIntent().getStringExtra("zhan_name"); // // Log.e("share1_data", "zhan_address=" + zhan_address + ",poi_jing=" + poi_jing + ",poi_wei=" + poi_wei // + ",costType=" + costType + ",suit_car2=" + suit_car2 + ",fast_num=" + fast_num + ",slow_num=" + slow_num // + ",stop_cost=" + stop_cost + ",zhan_name=" + zhan_name + ",charge_cost=" + charge_cost); // // } public void initOverlay() { // isFirstLoc = false; aMap.clear(); MarkerOptions oobd = new MarkerOptions().position(llposition) .icon(bdLocation1).zIndex(9).draggable(true).title(zhan_address).period(30); mMarker = (Marker) (aMap.addMarker(oobd)); mMarker.showInfoWindow(); // et_share_address.setText(zhan_address); // getAddress(new LatLonPoint(llposition.latitude,llposition.longitude)); } public void initOverlay1() { aMap.clear(); MarkerOptions oobd1 = new MarkerOptions().position(llposition) .icon(bdLocation).zIndex(9).draggable(true); mMarker1 = (Marker) (aMap.addMarker(oobd1)); getAddress(new LatLonPoint(llposition.latitude, llposition.longitude)); } // private void getAddress() { // mSearch = GeoCoder.newInstance(); // mSearch.setOnGetGeoCodeResultListener(this); // mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(llposition)); // } public void getAddress(final LatLonPoint latLonPoint) { RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200, GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系 geocoderSearch.getFromLocationAsyn(query);// 设置同步逆地理编码请求 } private void userGrowUp() { Log.i("!!!!!!!!", "加积分"); new Thread(new Runnable() { @Override public void run() { String url = "http://www.d1ev.com/api/app/score?userid=" + MainApplication.userPhone + "&type=add"; submit(url); } }).start(); } private void submit(String sms) { Log.e("url", sms); Request request = new Request.Builder().url(sms).build(); Response response = null; try { if (request == null) { Message msg = new Message(); msg.what = 3; handler.sendMessage(msg); return; } response = OkHttpUtil.execute(request); if (response.code() == 200) { String json = ""; try { json = response.body().string(); Message msg = new Message(); msg.obj = json; msg.what = 1; handler.sendMessage(msg); Log.e("url", json); } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 3; handler.sendMessage(msg); } } } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 3; handler.sendMessage(msg); } } @Override public void onClick(View v) { // if (imm.isActive()) { // View view = getWindow().peekDecorView(); // if (view != null) { // imm.hideSoftInputFromWindow(view.getWindowToken(), 0); // } // } // this.mapStatus = mBaiduMap.getMapStatus(); switch (v.getId()) { // case R.id.tv_share_list: // startActivity(new Intent(getApplication(),ClaimListActivity.class)); // break; case R.id.rb_guo: rb_guo.setBackgroundResource(R.drawable.icon_guoselected1105); rb_te.setBackgroundResource(R.drawable.icon_tenormal1105); break; case R.id.rb_te: rb_guo.setBackgroundResource(R.drawable.icon_guonormal1105); rb_te.setBackgroundResource(R.drawable.icon_teselected1105); break; case R.id.rb_shang: rb_shang.setBackgroundResource(R.drawable.icon_shangselected1105); rb_xia.setBackgroundResource(R.drawable.icon_xianormal1105); break; case R.id.rb_xia: rb_shang.setBackgroundResource(R.drawable.icon_shangnormal1105); rb_xia.setBackgroundResource(R.drawable.icon_xiaselected1105); break; case R.id.ib_location: aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(llposition)); isTouch = false; initOverlay(); // if (!isFirstLoc) { //// isFirstLoc = true; // aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false // // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种 // aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); //// aMap.moveCamera(); // aMap.moveCamera(CameraUpdateFactory.zoomTo(14)); // mlocationClient.startLocation(); // } break; case R.id.zoomin1: aMap.moveCamera(CameraUpdateFactory.zoomIn()); controlZoomShow(); break; case R.id.zoomout1: aMap.moveCamera(CameraUpdateFactory.zoomOut()); controlZoomShow(); break; case R.id.tv_notice: tv_notice.setVisibility(View.GONE); break; case R.id.tv_costtype: startActivity(new Intent(ClaimSurveyTwoActivity.this, ChargeCostWayActivity.class)); // LayoutInflater inflater1 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); // popupWindowView = inflater1.inflate(R.layout.popupwindow_cost, null); // popupWindow = new PopupWindow(popupWindowView, // ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, // true); // popupWindow.setBackgroundDrawable(new BitmapDrawable()); // // 设置PopupWindow的弹出和消失效果 // popupWindow.setAnimationStyle(R.style.popupAnimation); //// confirmButton = (Button) popupWindowView //// .findViewById(R.id.confirmButton); //// confirmButton.setOnClickListener(new OnClickListener() { //// @Override //// public void onClick(View view) { //// popupWindow.dismiss(); //// } //// }); // cancleButton = (Button) popupWindowView // .findViewById(R.id.cancleButton); // cancleButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // popupWindow.dismiss(); // } // }); // TextView tvO1 = (TextView) popupWindowView.findViewById(R.id.tvOne); // tvO1.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("国网电卡"); // popupWindow.dismiss(); // } // }); // TextView tvT2 = (TextView) popupWindowView.findViewById(R.id.tvTwo); // tvT2.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("普天电卡"); // popupWindow.dismiss(); // } // }); // TextView tvTh3 = (TextView) popupWindowView.findViewById(R.id.tvThree); // tvTh3.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("特来电APP"); // popupWindow.dismiss(); // } // }); // TextView tvF4 = (TextView) popupWindowView.findViewById(R.id.tvFour); // tvF4.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("现金"); // popupWindow.dismiss(); // } // }); // tvFi = (TextView) popupWindowView.findViewById(R.id.tvFive); // tvFi.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("其他"); // popupWindow.dismiss(); // } // }); // TextView tvF6 = (TextView) popupWindowView.findViewById(R.id.tvSix); // tvF6.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("4S店电卡"); // popupWindow.dismiss(); // } // }); // TextView tvF7 = (TextView) popupWindowView.findViewById(R.id.tvSeven); // tvF7.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("小易充电"); // popupWindow.dismiss(); // } // }); // TextView tvF8 = (TextView) popupWindowView.findViewById(R.id.tvEight); // tvF8.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("国网高速公路专用卡"); // popupWindow.dismiss(); // } // }); // // TextView tvXingXing = (TextView) popupWindowView.findViewById(R.id.tvXingXing); // tvXingXing.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Log.e("!!!","点击"); // costWay.setText("星星充电APP"); // popupWindow.dismiss(); // // } // }); // // // TextView tvJuDian = (TextView) popupWindowView.findViewById(R.id.tvJuDian); // tvJuDian.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Log.e("!!!","点击"); // costWay.setText("聚电桩APP"); // popupWindow.dismiss(); // } // }); // TextView tvEv = (TextView) popupWindowView.findViewById(R.id.tvev); // tvEv.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("EVCARD电卡"); // popupWindow.dismiss(); // // } // }); // // TextView tvyi = (TextView) popupWindowView.findViewById(R.id.tvYiChong); // tvyi.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // costWay.setText("易充卡"); // popupWindow.dismiss(); // // } // }); // popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); break; // case R.id.iv_back: // finish(); // break; case R.id.share_next: if (et_share_address.getText().toString().equals("")) { Toast.makeText(this, "请在地图上选择地址", Toast.LENGTH_SHORT).show(); } else if (zhanName.getText().toString().equals("")) { Toast.makeText(this, "请填写站点名称", Toast.LENGTH_SHORT).show(); } else if (fastNum.getText().toString().equals("") && slowNum.getText().toString().equals("")) { Toast.makeText(this, "请填写桩数量", Toast.LENGTH_SHORT).show(); } else if (chargeCost.getText().toString().equals("")) { Toast.makeText(this, "请填写充电费", Toast.LENGTH_SHORT).show(); } else if (et_serviceCost.getText().toString().equals("")) { Toast.makeText(this, "请填写服务费", Toast.LENGTH_SHORT).show(); } else if (parkCost.getText().toString().equals("")) { Toast.makeText(this, "请填写停车费", Toast.LENGTH_SHORT).show(); } else if (costWay.getText().toString().equals("请选择支付方式")) { Toast.makeText(this, "请选择支付方式", Toast.LENGTH_SHORT).show(); } else if (Bimp.tempSelectBitmap.size() == 0) { Toast.makeText(this, "请上传图片", Toast.LENGTH_SHORT).show(); } else { if (fastNum.getText().toString().equals("") && !slowNum.getText().toString().equals("")) { fastNum.setText("0"); } if (!fastNum.getText().toString().equals("") && slowNum.getText().toString().equals("")) { slowNum.setText("0"); } if (open_time.getText().toString().equals("")) { open_time.setText("00:00"); } if (close_time.getText().toString().equals("")) { close_time.setText("24:00"); } createDialog(); new Thread(new Runnable() { @Override public void run() { // submitShareTwo(); try { shite(""); } catch (Exception e) { e.printStackTrace(); } // uploadFile(); } }).start(); } // if (!zhanName.getText().toString().equals("") && !fastNum.getText().toString().equals("") && !slowNum.getText().toString().equals("") // && !chargeCost.getText().toString().equals("") && !costWay.getText().toString().equals("请选择支付方式") // && !parkCost.getText().toString().equals("") && !et_share_address.getText().toString().equals("") // &&!et_serviceCost.getText().toString().equals("")&& Bimp.tempSelectBitmap.size() != 0) { // createDialog(); // new Thread(new Runnable() { // @Override // public void run() { //// submitShareTwo(); // // try { // // shite(""); // // // } catch (Exception e) { // e.printStackTrace(); // } // //// uploadFile(); // } // }).start(); // }else if (Bimp.tempSelectBitmap.size() == 0){ // Toast.makeText(getApplication(),"请提交站点照片",Toast.LENGTH_SHORT).show(); // } else{ // Toast.makeText(ClaimSurveyTwoActivity.this,"请确认必填项是否全部填写",Toast.LENGTH_SHORT).show(); // } break; // case R.id.rl_open_object: // LayoutInflater inflater1 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); // popupWindowView = inflater1.inflate(R.layout.popupwindow_open, null); // popupWindow = new PopupWindow(popupWindowView, // ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, // true); // popupWindow.setBackgroundDrawable(new BitmapDrawable()); // // 设置PopupWindow的弹出和消失效果 // popupWindow.setAnimationStyle(R.style.popupAnimation); //// confirmButton = (Button) popupWindowView //// .findViewById(R.id.confirmButton); //// confirmButton.setOnClickListener(new View.OnClickListener() { //// @Override //// public void onClick(View view) { //// Toast.makeText(ShareTwoActivity.this, "YES", Toast.LENGTH_SHORT).show(); //// popupWindow.dismiss(); //// } //// }); // cancleButton = (Button) popupWindowView // .findViewById(R.id.cancleButton); // cancleButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { //// Toast.makeText(ShareTwoActivity.this, "NO", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // TextView tvOne1 = (TextView) popupWindowView.findViewById(R.id.tvOne); // tvOne1.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_open_object.setText("开放"); // popupWindow.dismiss(); // } // }); // TextView tvTwo1 = (TextView) popupWindowView.findViewById(R.id.tvTwo); // tvTwo1.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_open_object.setText("对内开放"); // popupWindow.dismiss(); // } // }); // popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); // break; // case R.id.rl_charge_cost_style: // LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); // popupWindowView = inflater.inflate(R.layout.popupwindow_cost, null); // popupWindow = new PopupWindow(popupWindowView, // ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, // true); // popupWindow.setBackgroundDrawable(new BitmapDrawable()); // // 设置PopupWindow的弹出和消失效果 // popupWindow.setAnimationStyle(R.style.popupAnimation); //// confirmButton = (Button) popupWindowView // .findViewById(R.id.confirmButton); // confirmButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Toast.makeText(ShareTwoActivity.this, "YES", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // cancleButton = (Button) popupWindowView // .findViewById(R.id.cancleButton); // cancleButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { //// Toast.makeText(ShareTwoActivity.this, "NO", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne); // tvOne.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setText("北京国家电网充电卡"); // popupWindow.dismiss(); // } // }); // tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo); // tvTwo.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setText("北京富电科技充电卡"); // popupWindow.dismiss(); // } // }); // tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree); // tvThree.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setText("北京普天新能源充电卡"); // popupWindow.dismiss(); // } // }); // tvFour = (TextView) popupWindowView.findViewById(R.id.tvFour); // tvFour.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setText("上海国家电网充电卡"); // popupWindow.dismiss(); // } // }); // tvFive = (TextView) popupWindowView.findViewById(R.id.tvFive); // tvFive.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setText("上海普天新能源充电卡"); // popupWindow.dismiss(); // } // }); // tvSix = (TextView) popupWindowView.findViewById(R.id.tvSix); // tvSix.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // et_style.setFocusableInTouchMode(true); // popupWindow.dismiss(); // } // }); // popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); // break; // case R.id.ll_add_photo: // CharSequence[] items = { "手机相册","拍照" }; // // CharSequence[] items = { "手机相册", "手机拍照" }; // imageChooseItem(items); // // // break; // case R.id.tv_holiday_start_time: // if (tpd_holiday_open == null) { // TimePickerDialog.OnTimeSetListener otsl = new TimePickerDialog.OnTimeSetListener() { // public void onTimeSet(TimePicker view, int hourOfDay, int minute) { // holiday_open.setText(((hourOfDay < 10 ? 0 + "" + hourOfDay : hourOfDay) + ":" + (minute < 10 ? 0 + "" + minute : minute)).toString()); // //close_time.setText(((hourOfDay < 10 ? 0 +""+ hourOfDay : hourOfDay)+":"+(minute<10?0+""+minute:minute)).toString()); // tpd_holiday_open.dismiss(); // } // }; // Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); // int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); // int minute = calendar.get(Calendar.MINUTE); // tpd_holiday_open = new TimePickerDialog(this, otsl, hourOfDay, minute, true); // } // tpd_holiday_open.show(); // break; // // case R.id.tv_holiday_stop_time: // if (tpd_holiday_close == null) { // TimePickerDialog.OnTimeSetListener otsl = new TimePickerDialog.OnTimeSetListener() { // public void onTimeSet(TimePicker view, int hourOfDay, int minute) { // holiday_close.setText(((hourOfDay < 10 ? 0 + "" + hourOfDay : hourOfDay) + ":" + (minute < 10 ? 0 + "" + minute : minute)).toString()); // //close_time.setText(((hourOfDay < 10 ? 0 +""+ hourOfDay : hourOfDay)+":"+(minute<10?0+""+minute:minute)).toString()); // tpd_holiday_close.dismiss(); // } // }; // Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); // int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); // int minute = calendar.get(Calendar.MINUTE); // tpd_holiday_close = new TimePickerDialog(this, otsl, hourOfDay, minute, true); // } // tpd_holiday_close.show(); // break; case R.id.tv_prefect_start_time: if (tpd_open == null) { TimePickerDialog.OnTimeSetListener otsl = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { open_time.setText(((hourOfDay < 10 ? 0 + "" + hourOfDay : hourOfDay) + ":" + (minute < 10 ? 0 + "" + minute : minute)).toString()); //close_time.setText(((hourOfDay < 10 ? 0 +""+ hourOfDay : hourOfDay)+":"+(minute<10?0+""+minute:minute)).toString()); tpd_open.dismiss(); } }; Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); tpd_open = new TimePickerDialog(this, otsl, hourOfDay, minute, true); } tpd_open.show(); break; case R.id.tv_ferfect_time: if (tpd_close == null) { TimePickerDialog.OnTimeSetListener otsl = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { //open_time.setText(((hourOfDay < 10 ? 0 +""+ hourOfDay : hourOfDay)+":"+(minute<10?0+""+minute:minute)).toString()); close_time.setText(((hourOfDay < 10 ? 0 + "" + hourOfDay : hourOfDay) + ":" + (minute < 10 ? 0 + "" + minute : minute)).toString()); tpd_close.dismiss(); } }; Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); tpd_close = new TimePickerDialog(this, otsl, hourOfDay, minute, true); } tpd_close.show(); break; // case R.id.tv_next: // Intent intent = new Intent(getApplication(), ShareThreeActivity.class); // intent.putExtra("location", share_address); // intent.putExtra("POI_jing", poi_jing); // intent.putExtra("POI_wei", poi_wei); // intent.putExtra("fast_num", et_fast_num.getText().toString()); // intent.putExtra("slow_num", et_slow_num.getText().toString()); // intent.putExtra("suit_car", tv_suit_car.getText().toString()); // intent.putExtra("belong_attribute", tv_belong_type.getText().toString()); // intent.putExtra("telephone", et_phone.getText().toString()); // intent.putExtra("Person_name", et_belong.getText().toString()); // intent.putExtra("company_name", et_belong.getText().toString()); // intent.putExtra("open_time", open_time.getText().toString()); // intent.putExtra("zhan_name", et_name.getText().toString()); // intent.putExtra("close_time", close_time.getText().toString()); // intent.putExtra("holiday_open", holiday_open.getText().toString()); // intent.putExtra("holiday_close", holiday_close.getText().toString()); // intent.putExtra("open_object", et_open_object.getText().toString()); // intent.putExtra("run_state", tv_run_state.getText().toString()); // intent.putExtra("pic", srcPath); // intent.putExtra("city", city); // if (checkText()) { // startActivity(intent); // } // break; case R.id.iv_back: finish(); // startActivity(new Intent(getApplication(),ShareListActivity.class)); SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); sharedPreferencesUtil.setFileName("shareInfo"); sharedPreferencesUtil.clearData(); break; // case R.id.iv_run_state: // final String[] operationSelect = {"正常", "故障", "废弃", "调试"}; // new AlertDialog.Builder(ShareTwoActivity.this) // .setTitle("请选择") // .setItems(operationSelect, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // switch (which) { // case 0: // tv_run_state.setText(operationSelect[0]); // break; // case 1: // tv_run_state.setText(operationSelect[1]); // break; // case 2: // tv_run_state.setText(operationSelect[2]); // break; // case 3: // tv_run_state.setText(operationSelect[3]); // default: // break; // } // } // }) // .setNegativeButton("取消", new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.cancel(); // } // }).show(); // break; // case R.id.iv_prefect_change_suit: // // String[] changeSelect = {"国标充电", "特斯拉", "德系"}; // new AlertDialog.Builder(ShareTwoActivity.this) // .setTitle("请选择") // .setItems(changeSelect, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // switch (which) { // case 0: // tv_suit_car.setText("国标充电"); // break; // case 1: // tv_suit_car.setText("特斯拉"); // break; // case 2: // tv_suit_car.setText("德系"); // break; // default: // break; // } // } // }) // .setNegativeButton("取消", new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.cancel(); // } // }).show(); // break; // case R.id.rl_perfect_belong: // final String[] belongSelect = {"企业", "私人"}; // new AlertDialog.Builder(ShareTwoActivity.this) // .setTitle("请选择") // .setItems(belongSelect, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // switch (which) { // case 0: // tv_belong_type.setText(belongSelect[0]); // break; // case 1: // tv_belong_type.setText(belongSelect[1]); //// tv_belong_style.setText("联系人"); //// et_belong.setText("王先生"); // break; // default: // break; // } // } // }) // .setNegativeButton("取消", new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.cancel(); // } // }).show(); // LayoutInflater inflater2 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); // popupWindowView = inflater2.inflate(R.layout.popupwindow_belong, null); // popupWindow = new PopupWindow(popupWindowView, // ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, // true); // popupWindow.setBackgroundDrawable(new BitmapDrawable()); // // 设置PopupWindow的弹出和消失效果 // popupWindow.setAnimationStyle(R.style.popupAnimation); // confirmButton = (Button) popupWindowView // .findViewById(R.id.confirmButton); // confirmButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // Toast.makeText(ShareTwoActivity.this, "YES", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // cancleButton = (Button) popupWindowView // .findViewById(R.id.cancleButton); // cancleButton.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { //// Toast.makeText(ShareTwoActivity.this, "NO", Toast.LENGTH_SHORT).show(); // popupWindow.dismiss(); // } // }); // TextView tvOne2 = (TextView) popupWindowView.findViewById(R.id.tvOne); // tvOne2.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // tv_belong_type.setText("企业"); // popupWindow.dismiss(); // } // }); // TextView tvTwo2 = (TextView) popupWindowView.findViewById(R.id.tvTwo); // tvTwo2.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // tv_belong_type.setText("私人"); // popupWindow.dismiss(); // } // }); // popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); // break; // case R.id.tv_submit: // if (!et_serviceCost.getText().toString().equals("")&& Bimp.tempSelectBitmap.size() != 0) { // createDialog(); // new Thread(new Runnable() { // @Override // public void run() { //// submitShareTwo(); // // try { // // shite(""); // // // } catch (Exception e) { // e.printStackTrace(); // } // //// uploadFile(); // } // }).start(); // }else if (Bimp.tempSelectBitmap.size() == 0){ // Toast.makeText(getApplication(),"请提交站点照片",Toast.LENGTH_SHORT).show(); // } else{ // Toast.makeText(ClaimSurveyTwoActivity.this,"请确认必填项是否全部填写",Toast.LENGTH_SHORT).show(); // } // break; } // mapStatus = mBaiduMap.getMapStatus(); } private Bitmap compressBmpFromBmp(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int options = 100; image.compress(Bitmap.CompressFormat.JPEG, 100, baos); while (baos.toByteArray().length / 1024 > 200) { baos.reset(); options -= 10; image.compress(Bitmap.CompressFormat.JPEG, options, baos); } ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null); return bitmap; } private String bitmapToBase64(Bitmap bitmap) { String result = null; ByteArrayOutputStream baos = null; try { if (bitmap != null) { baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); baos.flush(); baos.close(); byte[] bitmapBytes = baos.toByteArray(); result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (baos != null) { baos.flush(); baos.close(); } } catch (IOException e) { e.printStackTrace(); } } return result; } public static String roundByScale(double v, int scale) { if (scale < 0) { throw new IllegalArgumentException( "The scale must be a positive integer or zero"); } if (scale == 0) { return new DecimalFormat("0").format(v); } String formatStr = "0."; for (int i = 0; i < scale; i++) { formatStr = formatStr + "0"; } return new DecimalFormat(formatStr).format(v); } public void shite(String s) throws Exception { Map<String, String> par = new HashMap<String, String>(); String file; long appTime1 = System.currentTimeMillis() / 1000; Log.i("appTime(long)---", appTime1 + ""); long updatetime = appTime1 - MainMapActivity.cha; Log.i("updatetime(long)---", updatetime + ""); Log.i("cha---", MainMapActivity.cha + ""); String token = String.valueOf(updatetime); Log.i("token---", token); for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) { try { bm = imageZoom(Bimp.tempSelectBitmap.get(i).getBitmap()); file = bitmapToBase64(bm); par.put("file" + (i + 1), file); Log.i("file--------" + (i + 1), file); par.put("filename" + (i + 1), "androidapp.jpg"); } catch (Exception e) { e.printStackTrace(); } } par.put("zhan_name", zhanName.getText().toString()); par.put("zhan_id", zhan_id); par.put("user_id", MainApplication.userId); par.put("zhan_address", zhan_address); String jing = roundByScale(llposition.longitude, 16); String wei = roundByScale(llposition.latitude, 16); par.put("poi_jing", jing); par.put("poi_wei", wei); par.put("total_num", ""); par.put("fast_num", fastNum.getText().toString()); par.put("slow_num", slowNum.getText().toString()); par.put("open_object", ""); par.put("charges", ""); par.put("stop_cost", parkCost.getText().toString()); par.put("stop_cost_way", ""); par.put("charge_cost", chargeCost.getText().toString()); par.put("charge_cost_way", costWay.getText().toString()); par.put("other_cost", et_serviceCost.getText().toString()); par.put("telephone", ""); par.put("zhuang_produce", ""); par.put("remarks", et_remark.getText().toString()); Log.e("remarks", et_remark.getText().toString()); par.put("city", ""); par.put("supplier", ""); par.put("facilities_classify", ""); par.put("belong_attribute", ""); par.put("operation_state", ""); par.put("work_open", open_time.getText().toString()); par.put("work_close", close_time.getText().toString()); par.put("holiday_open", ""); par.put("holiday_close", ""); par.put("company_name", ""); par.put("person_name", ""); par.put("zhuang_num", ""); par.put("zy_num", ""); par.put("suit_car", suit_car2); par.put("park_location", park); par.put("token", DES3.encode(token)); try { String u = UploadUtil.post( // "http://123.57.6.131/zhannew/basic/web/index.php/zhanlist/add", MainApplication.url + "/zhannew/basic/web/index.php/investigateresults/add", par, null); System.err.println(u); // submit(u); Message msg = new Message(); msg.obj = u; msg.what = 2; handler.sendMessage(msg); } catch (IOException e) { e.printStackTrace(); } } @Override public View getInfoWindow(Marker marker) { tv = new TextView(this); tv.setBackgroundResource(R.drawable.bg_myinfowindow2_0); tv.setPadding(4, 0, 4, 16); tv.setGravity(Gravity.CENTER); if (mMarker != null) { tv.setText(zhan_name); et_share_address.setText(zhan_address); } // if (mMarker1 != null){ // tv.setText(location); // et_share_address.setText(location); // } // tv.setGravity(View.TEXT_ALIGNMENT_CENTER); tv.setTextColor(getResources().getColor(R.color.hintColor)); tv.setTextSize(15); return tv; } @Override public View getInfoContents(Marker marker) { return null; } @Override public void onTouch(MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { scrollView.requestDisallowInterceptTouchEvent(false); } else { scrollView.requestDisallowInterceptTouchEvent(true); } } /** * ATTENTION: This was auto-generated to implement the App Indexing API. * See https://g.co/AppIndexing/AndroidStudio for more information. */ public Action getIndexApiAction() { Thing object = new Thing.Builder() .setName("ClaimSurveyTwo Page") // TODO: Define a title for the content shown. // TODO: Make sure this auto-generated URL is correct. .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]")) .build(); return new Action.Builder(Action.TYPE_VIEW) .setObject(object) .setActionStatus(Action.STATUS_TYPE_COMPLETED) .build(); } @Override public void onStart() { super.onStart(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client.connect(); AppIndex.AppIndexApi.start(client, getIndexApiAction()); } @Override public void onStop() { super.onStop(); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. AppIndex.AppIndexApi.end(client, getIndexApiAction()); client.disconnect(); } @SuppressLint("HandlerLeak") public class GridAdapter extends BaseAdapter { private LayoutInflater inflater; private int selectedPosition = -1; private boolean shape; public boolean isShape() { return shape; } public void setShape(boolean shape) { this.shape = shape; } public GridAdapter(Context context) { inflater = LayoutInflater.from(context); } public void update() { loading(); } public int getCount() { if (Bimp.tempSelectBitmap.size() == 3) { return 3; } return (Bimp.tempSelectBitmap.size() + 1); } public Object getItem(int arg0) { return null; } public long getItemId(int arg0) { return 0; } public void setSelectedPosition(int position) { selectedPosition = position; } public int getSelectedPosition() { return selectedPosition; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.item_published_grida, parent, false); holder = new ViewHolder(); holder.image = (ImageView) convertView .findViewById(R.id.item_grida_image); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if (position == Bimp.tempSelectBitmap.size()) { holder.image.setImageBitmap(BitmapFactory.decodeResource( getResources(), R.drawable.icon_defaultadd1105)); if (position == 3) { holder.image.setVisibility(View.GONE); } } else { holder.image.setImageBitmap(Bimp.tempSelectBitmap.get(position).getBitmap()); } return convertView; } public class ViewHolder { public ImageView image; } Handler handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case 1: adapter.notifyDataSetChanged(); break; } super.handleMessage(msg); } }; public void loading() { new Thread(new Runnable() { public void run() { while (true) { if (Bimp.max == Bimp.tempSelectBitmap.size()) { Message message = new Message(); message.what = 1; handler.sendMessage(message); break; } else { Bimp.max += 1; Message message = new Message(); message.what = 1; handler.sendMessage(message); } } } }).start(); } } public String getString(String s) { String path = null; if (s == null) return ""; for (int i = s.length() - 1; i > 0; i++) { s.charAt(i); } return path; } protected void onRestart() { adapter.update(); super.onRestart(); } private static final int TAKE_PICTURE = 0x000001; public void photo() { PictureSelector.create(this) .openCamera(PictureMimeType.ofImage()) .selectionMode(PictureConfig.SINGLE) .isSingleDirectReturn(true) .isCompress(true)//是否压缩 .isPreviewEggs(true)//预览图片时是否增强左右滑动图片体验 .isGif(false)//是否显示gif .isAndroidQTransform(true) .imageEngine(GlideEngine.createGlideEngine()) .isWeChatStyle(false)// 是否开启微信图片选择风格 .isUseCustomCamera(false)// 是否使用自定义相机 .isPageStrategy(true)// 是否开启分页策略 & 每页多少条;默认开启 .setPictureStyle(Util.getWhiteStyle(this))// 动态自定义相册主题 .setRecyclerAnimationMode(AnimationType.SLIDE_IN_BOTTOM_ANIMATION)// 列表动画效果 .isMaxSelectEnabledMask(true)// 选择数到了最大阀值列表是否启用蒙层效果 .imageSpanCount(4)// 每行显示个数 .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回 .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部 .isEnableCrop(true) .rotateEnabled(false)//裁剪是否可旋转图片 .freeStyleCropEnabled(true)// 裁剪框拖动模式 //.isCropDragSmoothToCenter(true)// 裁剪框拖动时图片自动跟随居中 .circleDimmedLayer(false)// 是否开启圆形裁剪 .isDragFrame(true)//是否可拖动裁剪框(固定) .showCropFrame(true)// 是否显示裁剪矩形边框 圆形裁剪时建议设为false .showCropGrid(true)//是否显示裁剪矩形网格 圆形裁剪时建议设为false .forResult(PHOTO_REQUEST_CAMERA); } private void openPhotoAlbum() { PictureSelector.create(this) .openGallery(PictureMimeType.ofImage()) .isCamera(false)//列表是否显示拍照按钮 .selectionMode(PictureConfig.SINGLE) .isSingleDirectReturn(true)//PictureConfig.SINGLE模式下是否直接返回 .isCompress(true)//是否压缩 .isPreviewEggs(true)//预览图片时是否增强左右滑动图片体验 .isGif(false)//是否显示gif .isAndroidQTransform(true) .imageEngine(GlideEngine.createGlideEngine()) .isWeChatStyle(false)// 是否开启微信图片选择风格 .isUseCustomCamera(false)// 是否使用自定义相机 .isPageStrategy(true)// 是否开启分页策略 & 每页多少条;默认开启 .setPictureStyle(Util.getWhiteStyle(this))// 动态自定义相册主题 .setRecyclerAnimationMode(AnimationType.SLIDE_IN_BOTTOM_ANIMATION)// 列表动画效果 .isMaxSelectEnabledMask(true)// 选择数到了最大阀值列表是否启用蒙层效果 .imageSpanCount(4)// 每行显示个数 .isReturnEmpty(false)// 未选择数据时点击按钮是否可以返回 .isAutomaticTitleRecyclerTop(true)//图片列表超过一屏连续点击顶部标题栏快速回滚至顶部 .rotateEnabled(false)//裁剪是否可旋转图片 .isEnableCrop(true) .rotateEnabled(false)//裁剪是否可旋转图片 .setCircleStrokeWidth(8)//设置圆形裁剪边框粗细 .freeStyleCropEnabled(true)// 裁剪框拖动模式 // .isCropDragSmoothToCenter(true)// 裁剪框拖动时图片自动跟随居中 .circleDimmedLayer(true)// 是否开启圆形裁剪 .isDragFrame(true)//是否可拖动裁剪框(固定) .showCropFrame(false)// 是否显示裁剪矩形边框 圆形裁剪时建议设为false .showCropGrid(false)//是否显示裁剪矩形网格 圆形裁剪时建议设为false .forResult(PHOTO_REQUEST_GALLERY); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Log.e("isTouch===",isTouch+""); if (isTouch == true) { MarkerOptions oobd = new MarkerOptions().position(llposition) .icon(bdLocation1).zIndex(9).draggable(true).title(zhan_address).period(30); mMarker = (Marker) (aMap.addMarker(oobd)); mMarker.showInfoWindow(); } else { MarkerOptions oobd1 = new MarkerOptions().position(llposition) .icon(bdLocation).zIndex(9).draggable(true); mMarker1 = (Marker) (aMap.addMarker(oobd1)); } System.out.println("--------data------->" + data); //���ѡȡ if (resultCode == Activity.RESULT_OK){ if (requestCode == PHOTO_REQUEST_CAMERA || requestCode == PHOTO_REQUEST_GALLERY) { List<LocalMedia> medias = PictureSelector.obtainMultipleResult(data); if (medias != null && medias.size() > 0) { String path = ""; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { path = medias.get(0).getAndroidQToPath(); } else { path = medias.get(0).getPath(); } Bitmap bitmap = BitmapFactory.decodeFile(path); ImageItem takePhoto = new ImageItem(); takePhoto.setBitmap(bitmap); takePhoto.setImagePath(path); Bimp.tempSelectBitmap.add(takePhoto); } } } super.onActivityResult(requestCode, resultCode, data); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { for (int i = 0; i < PublicWay.activityList.size(); i++) { if (null != PublicWay.activityList.get(i)) { PublicWay.activityList.get(i).finish(); } } System.exit(0); } return true; } // private void sendRequest(Map<String, Object> params) { // RequestTask.task("http://app.ulinkmedia.cn/AppHanlder.aspx?callMethod=NewsListPage",params, handler); // } Handler handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case 2: try { JSONObject jsonObject = new JSONObject(msg.obj.toString()); String rtnCode = jsonObject.getString("rtnCode"); String rtnMsg = jsonObject.getString("rtnMsg"); if (rtnCode.equals("01")) { dismissDialog(); new com.electric.chargingpile.view.AlertDialog(ClaimSurveyTwoActivity.this).builder() .setMsg("勘察信息提交成功") .setNegativeButton("确定", new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(ClaimSurveyTwoActivity.this, ClaimListActivity.class)); SharedPreferences sharedPreferences = getSharedPreferences("userClaimInfo", Activity.MODE_PRIVATE); sharedPreferences.edit().clear().commit(); // Bimp.tempSelectBitmap.clear(); // PublicWay.activityList.get(i).finish(); // startActivity(new Intent(getApplication(),ShareListActivity.class)); SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); sharedPreferencesUtil.setFileName("shareInfo"); sharedPreferencesUtil.clearData(); finish(); } }).show(); // Toast.makeText(ShareTwoActivity.this, rtnMsg, Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { e.printStackTrace(); } break; case StatusConstants.REQUEST_WHAT_SUCCESS: break; } super.handleMessage(msg); } }; @Override protected void onPause() { // aMap.getUiSettings().setAllGesturesEnabled(false); mapView.onPause(); super.onPause(); MobclickAgent.onPause(this); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } @Override protected void onResume() { // aMap.getUiSettings().setAllGesturesEnabled(true); mapView.onResume(); super.onResume(); SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); sharedPreferencesUtil.setFileName("shareInfo"); // String address =sharedPreferencesUtil.getString("address", ""); String costway = sharedPreferencesUtil.getString("costWay", ""); // jing =sharedPreferencesUtil.getString("poi_jing", ""); // wei =sharedPreferencesUtil.getString("poi_wei", ""); // String tel =sharedPreferencesUtil.getString("tel", ""); //// String car =sharedPreferencesUtil.getString("car", ""); // String alipay =sharedPreferencesUtil.getString("alipay", ""); // carType.setText(car); // et_share_address.setText(address); costWay.setText(costway); // if (location == null || mMapView == null) // return; // MyLocationData locData = new MyLocationData.Builder() // .accuracy(location.getRadius()) // .direction(100).latitude(Double.parseDouble(poi_wei)) // .longitude(Double.parseDouble(poi_jing)).build(); // mBaiduMap.setMyLocationData(locData); // if (isFirstLoc) { // isFirstLoc = false; // mLocClient.stop(); // mBaiduMap.setMyLocationEnabled(false); // LatLng ll = new LatLng(Double.parseDouble(poi_wei), Double.parseDouble(poi_jing)); //// LatLng lll = new LatLng() // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); // llposition = ll; // city = location.getCity(); // district = location.getDistrict(); // initOverlay(); // } // if (isFirstLoc) { // isFirstLoc = false; // mLocClient.stop(); // mBaiduMap.setMyLocationEnabled(false); // LatLng ll = new LatLng(Double.parseDouble(poi_wei),Double.parseDouble(poi_jing)); //// LatLng lll = new LatLng() // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); // llposition = ll; // city = location.getCity(); // district = location.getDistrict(); // initOverlay(); // } MobclickAgent.onResume(this); } @Override protected void onDestroy() { Bimp.tempSelectBitmap.clear(); Bimp.max = 0; mapView.onDestroy(); // mMapView = null; super.onDestroy(); // bdLocation.recycle(); } private static String getPath(String path) { File f = new File(path); if (!f.exists()) { f.mkdirs(); } return f.getAbsolutePath(); } private File getFile(String path) { File f = new File(path); if (!f.exists()) { try { f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return f; } public Bitmap decodeUriAsBitmap(Uri uri) { Bitmap bitmap = null; try { bitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } return bitmap; } private Bitmap imageZoom(Bitmap bm) { // 图片允许最大空间 单位:KB double maxSize = 200.00; // 将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大) ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b = baos.toByteArray(); // 将字节换成KB double mid = b.length / 1024; // 判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩 if (mid > maxSize) { // 获取bitmap大小 是允许最大大小的多少倍 double i = mid / maxSize; // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍 // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小) bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight() / Math.sqrt(i)); } return bm; } public Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) { // 获取这个图片的宽和高 float width = bgimage.getWidth(); float height = bgimage.getHeight(); // 创建操作图片用的matrix对象 Matrix matrix = new Matrix(); // 计算宽高缩放率 float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // 缩放图片动作 matrix.postScale(scaleWidth, scaleHeight); Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, (int) height, matrix, true); // iv_2.setImageBitmap(bitmap); // tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + ""); return bitmap; } //地图缩放方法 private void controlZoomShow() { float zoom = aMap.getCameraPosition().zoom; try { if (zoom >= maxZoomLevel) { inBtn.setImageResource(R.drawable.icon_nojia2_0); inBtn.setEnabled(false); // Toast.makeText(getApplication(), "已放大到最大级别", Toast.LENGTH_SHORT) // .show(); return; } else { inBtn.setImageResource(R.drawable.icon_jia2_0); inBtn.setEnabled(true); } if (zoom <= minZoomLevel) { outBtn.setImageResource(R.drawable.icon_nojian2_0); outBtn.setEnabled(false); // Toast.makeText(getApplication(), "已缩小到最小级别", Toast.LENGTH_SHORT) // .show(); return; } else { outBtn.setImageResource(R.drawable.icon_jian2_0); outBtn.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); } } private void initMap() { if (aMap == null) { aMap = mapView.getMap(); Util.setMapCustomStyleFile(aMap, getApplicationContext()); // View v = mapView.getChildAt(0); // v.setOnTouchListener(new View.OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // if(event.getAction() == MotionEvent.ACTION_SCROLL){ // scrollView.requestDisallowInterceptTouchEvent(false); // }else{ // scrollView.requestDisallowInterceptTouchEvent(true); // } // return false; // } // }); MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationIcon(BitmapDescriptorFactory .fromResource(R.drawable.point_icon));// 设置小蓝点的图标 aMap.setMyLocationStyle(myLocationStyle); mUiSettings = aMap.getUiSettings(); //获得地图的最大和最小缩放级别 maxZoomLevel = aMap.getMaxZoomLevel(); minZoomLevel = aMap.getMinZoomLevel(); try { geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); setUpMap(); } catch (AMapException e) { e.printStackTrace(); } } } private void setUpMap() { aMap.setOnCameraChangeListener(this); aMap.setLocationSource(this);// 设置定位监听 aMap.setOnMapLoadedListener(this); aMap.setInfoWindowAdapter(this); aMap.setOnMapClickListener(this); aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示 aMap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示 aMap.getUiSettings().setScaleControlsEnabled(true);// 设置比例尺是否显示 aMap.getUiSettings().setRotateGesturesEnabled(false);// 设置地图是否旋转 aMap.setOnMapTouchListener(this); } @Override public void onCameraChange(CameraPosition cameraPosition) { } @Override public void onCameraChangeFinish(CameraPosition cameraPosition) { } @Override public void activate(OnLocationChangedListener onLocationChangedListener) { mListener = onLocationChangedListener; if (mlocationClient == null) { try { mlocationClient = new AMapLocationClient(this); mLocationOption = new AMapLocationClientOption(); //设置定位监听 mlocationClient.setLocationListener(this); //设置为高精度定位模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //设置定位参数 mlocationClient.setLocationOption(mLocationOption); // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗, // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求 // 在定位结束后,在合适的生命周期调用onDestroy()方法 // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除 // 设置是否只定位一次,默认为false mLocationOption.setOnceLocation(true); //设置是否强制刷新WIFI,默认为强制刷新 mLocationOption.setWifiActiveScan(false); mlocationClient.startLocation(); } catch (Exception e) { e.printStackTrace(); } } } @Override public void deactivate() { mListener = null; if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient = null; } private void getGaode(Double jing, Double wei) { // Log.e("jing", jing + ""); // Log.e("wei", wei + ""); double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double gg_lon; double gg_lat; double x = jing - 0.0065, y = wei - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); gg_lon = z * Math.cos(theta); gd_jing = String.valueOf(gg_lon); // Log.e("gg_lon", gg_lon + ""); gg_lat = z * Math.sin(theta); gd_wei = String.valueOf(gg_lat); // Log.e("gg_lat", gg_lat + ""); } @Override public void onMapLoaded() { aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种 aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); // aMap.moveCamera(); aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); getGaode(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei)); LatLng ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); // LatLng lll = new LatLng() // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); llposition = ll; //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(llposition)); initOverlay(); } @Override public void onRegeocodeSearched(RegeocodeResult result, int i) { if (i == 1000) { if (result != null && result.getRegeocodeAddress() != null && result.getRegeocodeAddress().getFormatAddress() != null) { et_share_address.setText(result.getRegeocodeAddress().getFormatAddress()); // tv_submit.setBackgroundColor(getResources().getColor(R.color.lvse)); } } } @Override public void onGeocodeSearched(GeocodeResult geocodeResult, int i) { } @Override public void onMapClick(LatLng latLng) { isTouch = true; llposition = latLng; Log.e("jing", llposition.longitude + ""); Log.e("wei", llposition.latitude + ""); // initOverlay1(); // getAddress(); } @Override public void onLocationChanged(AMapLocation amapLocation) { // if (mListener != null && amapLocation != null) { if (amapLocation != null && amapLocation.getErrorCode() == 0) { try { // tv_addressName.setText(amapLocation.getAddress()); // poi_jing = String.valueOf(amapLocation.getLongitude()); // poi_wei = String.valueOf(amapLocation.getLatitude()); } catch (NullPointerException e) { e.printStackTrace(); } // ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity); if (!isFirstLoc) { center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()); // Log.e("!@#$",amapLocation.getLatitude()+"```"+amapLocation.getLongitude()); //// Toast.makeText(this, amapLocation.getAddress(), Toast.LENGTH_SHORT).show(); //// Toast.makeText(this, amapLocation.getCity(), Toast.LENGTH_SHORT).show(); // ete("{\"fun\":\"timer\"}"); //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(center)); //点击定位按钮 能够将地图的中心移动到定位点 mListener.onLocationChanged(amapLocation); } isFirstLoc = false; } else { String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo(); Log.e("AmapErr", errText); // mLocationErrText.setVisibility(View.VISIBLE); Toast.makeText(this, errText, Toast.LENGTH_SHORT).show(); } } }