package com.electric.chargingpile.activity; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ProgressDialog; import android.app.TimePickerDialog; import android.content.Context; import android.content.Intent; 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.Bundle; import android.os.Environment; 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.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; 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.electric.chargingpile.R; import com.electric.chargingpile.application.MainApplication; import com.electric.chargingpile.data.Pic; import com.electric.chargingpile.data.PrivateZhuang; import com.electric.chargingpile.data.Zhan; import com.electric.chargingpile.util.BarColorUtil; import com.electric.chargingpile.util.Bimp; import com.electric.chargingpile.util.CheckMobileNum; import com.electric.chargingpile.util.ImageItem; import com.electric.chargingpile.util.ImageUtils; import com.electric.chargingpile.util.JsonUtils; import com.electric.chargingpile.util.OkHttpUtil; import com.electric.chargingpile.util.PublicWay; import com.electric.chargingpile.util.Res; import com.electric.chargingpile.util.ScreenUtils; import com.electric.chargingpile.util.ToastUtil; import com.electric.chargingpile.util.UploadUtil; import com.electric.chargingpile.view.CustomProgressDialog; import com.squareup.okhttp.Request; import com.squareup.okhttp.Response; 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.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; 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; import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.ObservableOnSubscribe; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import me.iwf.photopicker.PhotoPicker; import pub.devrel.easypermissions.AfterPermissionGranted; import pub.devrel.easypermissions.EasyPermissions; public class PrivateZhuangInfoActivity extends Activity implements View.OnClickListener, EasyPermissions.PermissionCallbacks { private static final String TAG = "PrivateZhuangInfoActivi"; private static final int PIC_NUM = 3; private ImageView ivBack, ivType; Bitmap bm = null; private TextView shareList, tvO, tvT, tvTh, tvF, tvFi, zhuangType, costWay, shareNext; // public MyLocationListenner myListener = new MyLocationListenner(); // BaiduMapOptions mapOptions; private TimePickerDialog tpd_open = null; private TimePickerDialog tpd_close = null; private String camePath;//拍照路径 private static final String PHOTO_FILE_NAME = "android.jpg"; private static final String PHOTO_FILE_PATH = getPath(Environment.getExternalStorageDirectory() + "/" + "cdz"); private File tempFile; private static final int PHOTO_REQUEST_CAMERA = 1; private static final int PHOTO_REQUEST_GALLERY = 2; private static final int PHOTO_REQUEST_CUT = 3; private ImageView inBtn, outBtn; private String jing, wei; private PrivateZhuang privateZhuang; // private LocationMode mCurrentMode; public static final int REQUSET = 11; public static boolean isFirstLoc = true; 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 list = new ArrayList(); private Zhan zhan; ToggleButton carType; private String suit_car2 = "国标"; // BitmapDescriptor mCurrentMarker; private static boolean isGetData = false; private static String location; private static String city; private static String district; private EditText et_telephone; private TextView et_share_address; private Button confirmButton; private Button cancleButton; private PopupWindow popupWindow; private View popupWindowView; private Bitmap bitmap; Context mContext; TextView tv; private Toast toast = null; 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 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, share_list; private RelativeLayout rl_address; private String tag, id, zhan_name, zhan_address, poi_jing, poi_wei, fast_num, slow_num, stop_cost, charge_cost, charge_cost_way, other_cost, telephone, remarks, park_location, work_open, work_close, suit_car, pic_counts, pic; private ProgressDialog insertDialog; private static final int RC_ALBUM_PERM = 123; private Handler handler = new Handler() { // 主线程通过这个方法处理消息 @Override public void handleMessage(final Message msg) { switch (msg.what) { case 1: // new Handler().postDelayed(new Runnable() { // //// // @Override // public void run() { // // Bundle bundle = msg.getData(); String id = bundle.getString("id"); Bitmap bitmap = (Bitmap) msg.obj; Log.e("bitmap", bitmap + ""); Log.e("bitmap_id", id + ""); ImageItem mImageItem = new ImageItem(); mImageItem.setBitmap(bitmap); try { Bimp.tempSelectBitmap.add(Integer.parseInt(id), mImageItem); } catch (Exception e) { e.printStackTrace(); } adapter.update(); // } // }, 1000); break; case 2: Toast.makeText(PrivateZhuangInfoActivity.this, "提交信息成功,感谢您的分享", Toast.LENGTH_SHORT).show(); dismissDialog(); // for(int i=0;i< PublicWay.activityList.size();i++){ // if (null != PublicWay.activityList.get(i)) { // Bimp.tempSelectBitmap.clear(); //// PublicWay.activityList.get(i).finish(); // } // } // startActivity(new Intent(getApplication(),ShareListActivity.class)); // SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); // sharedPreferencesUtil.setFileName("shareInfo"); // sharedPreferencesUtil.clearData(); startActivity(new Intent(getApplicationContext(), PrivateZhaungListActivity.class)); finish(); break; case 3: dismissDialog(); Toast.makeText(PrivateZhuangInfoActivity.this, "服务器处理错误", Toast.LENGTH_SHORT).show(); break; case 5: // try { //// Log.e("!!!",msg.obj.toString()); // JSONObject jsonObj = new JSONObject(msg.obj.toString()); // String data = jsonObj.getString("data"); // String time = jsonObj.getString("time"); //// String pic = jsonObj.getString("pic"); // Log.i("data-----",data); //// Log.i("pic------",pic); // String zhan_data = DES3.decode(data); // Log.i("zhan_data-----",zhan_data); // // // try { // Gson g = new Gson(); // List l = g.fromJson(zhan_data, new TypeToken>() { // }.getType()); // // // list.clear(); //// mBaiduMap.clear(); // if (l != null && l.size() > 0) { //// List ll = DES3.encode(l); // list.addAll(l); //// initOverlay(list); // if (center != null) { // for (int i = 0; i < list.size(); i++) { // double dwei = Double.parseDouble(list.get(i) // .getPoi_wei()); // double djing = Double.parseDouble(list.get(i) // .getPoi_jing()); // LatLng ll = new LatLng(dwei, djing); // double d = DistanceUtil.getDistance(center, ll); // list.get(i).setDistance(Util.getDistance(d)); // } // // } // // } else { //// Toast.makeText(getApplication(), "没有合适的充电桩", Toast.LENGTH_SHORT) //// .show(); // showTextToast("没有合适的充电桩"); //// if (center != null) { //// BitmapDescriptor point = BitmapDescriptorFactory //// .fromResource(R.drawable.point_icon); //// oo = new MarkerOptions().position(center) //// .anchor(0.5f, 0.5f).zIndex(7).icon(point) //// .draggable(true); //// mBaiduMap.addOverlay(oo); //// } // } //// if (list.size() > 0) { //// list = Util.getSortList(list); //// } // }catch (Exception e){ //// BitmapDescriptor point = BitmapDescriptorFactory //// .fromResource(R.drawable.point_icon); //// oo = new MarkerOptions().position(center). //// anchor(0.5f, 0.5f).zIndex(7) //// .draggable(true).icon(point); //// mBaiduMap.addOverlay(oo); //// Toast.makeText(getApplication(),"该范围内没有充电桩",Toast.LENGTH_SHORT).show(); // } // // } catch (Exception e) { // e.printStackTrace(); // } break; case 6: try { Log.e("!!!", msg.toString()); JSONObject jsonObject = new JSONObject(msg.obj.toString()); Log.e("!!!!!!", msg.obj.toString()); String rtnCode = jsonObject.getString("rtnCode"); String rtnMsg = jsonObject.getString("rtnMsg"); if (rtnCode.equals("01")) { dismissDialog(); String s = "“雷锋同志”您提交的信息已成功"; String s1 = "非常感谢您的支持,我们将尽快审核添加到APP中"; new com.electric.chargingpile.view.AlertDialog(PrivateZhuangInfoActivity.this).builder() .setMsg(s + "\n" + s1) .setNegativeButton("确认关闭", new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(PrivateZhuangInfoActivity.this, PrivateZhaungListActivity.class)); // for(int i=0;i(); mContext = this; // map = new HashMap<>(); Init(); initView(); // try { // new Thread(new Runnable() { // // @Override // public void run() { // try { // bitmap = Bimp.revitionImageSize("http://cdz.d1ev.com/zhannew/uploadfile/2016/311471336239androidapp.jpg",300); // } catch (IOException e) { // e.printStackTrace(); // } // } // }).start(); // // } catch (Exception e) { // e.printStackTrace(); // } // // // new Handler().postDelayed(new Runnable() { // // @Override // public void run() { // ImageItem mImageItem=new ImageItem(); // Log.e("bitmap", bitmap+""); // mImageItem.setBitmap(bitmap); // //// mImageItem.setImagePath("http://cdz.d1ev.com/zhannew/uploadfile/2016/311471336239androidapp.jpg"); //// mImageItem.setImagePath("/storage/emulated/0/DCIM/Camera/aaaa.jpg"); // Bimp.tempSelectBitmap.add(0, mImageItem); // adapter.update(); // } // }, 1000); // // firstSelect(); } private void showTextToast(String msg) { if (toast == null) { toast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT); } else { toast.setText(msg); } toast.show(); } // 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(); // // } // // // } 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(PrivateZhuangInfoActivity.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); Button bt1 = (Button) view .findViewById(R.id.item_popupwindows_camera); 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) { pop.dismiss(); ll_popup.clearAnimation(); if (MainScanActivity.isCameraUseable()) { photo(); } else { ToastUtil.showToast(getApplicationContext(), "您当前关闭了调用摄像头权限", Toast.LENGTH_SHORT); // new AlertDialogTwo(PrivateZhuangInfoActivity.this).builder() // .setMsg("您当前关闭了调用摄像头权限,是否去打开?") // .setPositiveButton("去打开", new View.OnClickListener() { // @Override // public void onClick(View v) { // Intent intent = new Intent(Settings.ACTION_SETTINGS); // startActivity(intent); // } // }).setNegativeButton("忽略", new View.OnClickListener() { // @Override // public void onClick(View v) { // // } // }).show(); } } }); bt2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(PrivateZhuangInfoActivity.this, AlbumActivity.class); startActivity(intent); overridePendingTransition(R.anim.activity_translate_in, R.anim.activity_translate_out); // startActivityForResult(intent, 1); 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); // new Thread(new Runnable() { // @Override // public void run() { //// Bitmap bitmap = getHttpBitmap("http://cdz.d1ev.com/zhannew/uploadfile/2016/311471336239androidapp.jpg");//从网络获取图片 //// savePicture(bitmap); // ImageItem mImageItem=new ImageItem(); // Log.e("bitmap", bitmap+""); // mImageItem.setBitmap(bitmap); // // mImageItem.setImagePath("http://cdz.d1ev.com/zhannew/uploadfile/2016/311471336239androidapp.jpg"); //// mImageItem.setImagePath("/storage/emulated/0/DCIM/Camera/aaaa.jpg"); // Bimp.tempSelectBitmap.add(0, mImageItem); //// ImageItem mImageItem=new ImageItem(); //// mImageItem.setImagePath("/storage/emulated/0/DCIM/Camera/IMG_20160816_180805.jpg"); //// Bimp.tempSelectBitmap.add(0, mImageItem); //// takePhoto.setImagePath(FileUtils.SDPATH + fileName + ".JPEG"); //// Bimp.tempSelectBitmap.add(takePhoto); // } // }).start(); 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(PrivateZhuangInfoActivity.this,R.anim.activity_translate_in)); // pop.showAtLocation(parent, Gravity.CENTER, 0, 0); permissionTask(); } else { Intent intent = new Intent(PrivateZhuangInfoActivity.this, GalleryPrivateActivity.class); intent.putExtra("position", "1"); intent.putExtra("ID", arg2); startActivity(intent); } } }); } /** * 调用图库选择 */ private void callGallery() { Log.e(TAG, "callGallery: " + (Bimp.max - Bimp.tempSelectBitmap.size())); //调用第三方图库选择 PhotoPicker.builder() .setPhotoCount(PIC_NUM - Bimp.tempSelectBitmap.size())//可选择图片数量 .setShowCamera(true)//是否显示拍照按钮 .setShowGif(true)//是否显示动态图 .setPreviewEnabled(true)//是否可以预览 .start(this, PhotoPicker.REQUEST_CODE); } @Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (data != null) { if (requestCode == 1) { //处理调用系统图库 } else if (requestCode == PhotoPicker.REQUEST_CODE) { //异步方式插入图片 insertImagesSync(data); } else if (requestCode == REQUSET) { poi_jing = data.getStringExtra("poi_jing"); Log.e("返回==poi_jing", poi_jing); poi_wei = data.getStringExtra("poi_wei"); Log.e("返回==poi_wei", poi_wei); et_share_address.setText(data.getStringExtra("address")); } } } } /** * 异步方式插入图片 * * @param data */ private void insertImagesSync(final Intent data) { insertDialog.show(); Observable.create(new ObservableOnSubscribe() { @Override public void subscribe(ObservableEmitter subscriber) { try { ArrayList photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS); //可以同时插入多张图片 for (String imagePath : photos) { Log.e(TAG, "call: imagePath " + imagePath); Bitmap bitmap = BitmapFactory.decodeFile(imagePath);//压缩图片 if (ImageUtils.readPictureDegree(imagePath) != 0) { bitmap = imageZoom(ImageUtils.toturn(bitmap)); } else { bitmap = imageZoom(bitmap); } ImageItem takePhoto = new ImageItem(); takePhoto.setBitmap(bitmap); takePhoto.setImagePath(imagePath); Bimp.tempSelectBitmap.add(takePhoto); // // Log.e(TAG, "call: "+imagePath ); subscriber.onNext(imagePath); } subscriber.onComplete(); } catch (Exception e) { e.printStackTrace(); subscriber.onError(e); } } }) .subscribeOn(Schedulers.io())//生产事件在io .observeOn(AndroidSchedulers.mainThread())//消费事件在UI线程 .subscribe(new Observer() { @Override public void onComplete() { Log.e(TAG, "onCompleted: -------------"); insertDialog.dismiss(); adapter.update(); } @Override public void onError(Throwable e) { insertDialog.dismiss(); Log.e(TAG, "onError: " + "图片插入失败:" + e.getMessage()); ToastUtil.showToast(getApplicationContext(), "图片插入失败", Toast.LENGTH_SHORT); } @Override public void onSubscribe(Disposable d) { } @Override public void onNext(String imagePath) { } }); } private void initView() { insertDialog = new ProgressDialog(this); insertDialog.setMessage("正在插入图片..."); insertDialog.setCanceledOnTouchOutside(false); et_telephone = (EditText) findViewById(R.id.et_telephone); et_serviceCost = (EditText) findViewById(R.id.et_serviceCost); inBtn = (ImageView) findViewById(R.id.zoomin1); outBtn = (ImageView) findViewById(R.id.zoomout1); inBtn.setOnClickListener(this); outBtn.setOnClickListener(this); rl_address = (RelativeLayout) findViewById(R.id.ll_address); rl_address.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); // share_list = (TextView) findViewById(R.id.tv_share_list); // share_list.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); 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); et_serviceCost = (EditText) findViewById(R.id.et_serviceCost); 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); 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); // mMapView = (MapView) findViewById(R.id.mapView_share); et_share_address = (TextView) 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); if (tag.equals("edit")) { // imageView.setImageBitmap(bitmap); // savePicture(bitmap);//保存图片到SD卡 fastNum.setText(fast_num); slowNum.setText(slow_num); et_telephone.setText(telephone); zhanName.setText(zhan_name); et_share_address.setText(zhan_address); et_remark.setText(remarks); open_time.setText(work_open); close_time.setText(work_close); chargeCost.setText(charge_cost); parkCost.setText(stop_cost); et_serviceCost.setText(other_cost); if (suit_car.equals("国标")) { rb_guo.setBackgroundResource(R.drawable.icon_guoselected1105); rb_te.setBackgroundResource(R.drawable.icon_tenormal1105); } else { rb_guo.setBackgroundResource(R.drawable.icon_guonormal1105); rb_te.setBackgroundResource(R.drawable.icon_teselected1105); } suit_car2 = suit_car; costWay.setText(charge_cost_way); if (park_location.equals("1")) { rb_shang.setBackgroundResource(R.drawable.icon_shangselected1105); rb_xia.setBackgroundResource(R.drawable.icon_xianormal1105); } else { rb_shang.setBackgroundResource(R.drawable.icon_shangnormal1105); rb_xia.setBackgroundResource(R.drawable.icon_xiaselected1105); } park = park_location; new Thread(new Runnable() { @Override public void run() { List listPic = JsonUtils.parseToObjectList(pic, Pic.class); Log.e("pic===size", listPic.size() + ""); for (int i = 0; i < listPic.size(); i++) { try { bitmap = Bimp.revitionImageSize(MainApplication.url + "/zhannew/uploadfile/" + listPic.get(i).getUrl(), 300); // showPic(bitmap,finalI); // Log.d("dddddmsg", msg + ""); if (bitmap != null) { Message mes = new Message(); mes.obj = bitmap; Log.e("bitmap===", bitmap + ""); mes.what = 1; Bundle bundle = new Bundle(); bundle.putString("id", String.valueOf(i)); mes.setData(bundle); handler.sendMessage(mes); } } catch (IOException e) { e.printStackTrace(); } } } }).start(); } } // private void showPic(final Bitmap bitmap, final int i){ // new Handler().postDelayed(new Runnable() { //// // @Override // public void run() { // ImageItem mImageItem=new ImageItem(); // Log.e("bitmap", bitmap+""); // mImageItem.setBitmap(bitmap); // Bimp.tempSelectBitmap.add(i, mImageItem); // adapter.update(); // } // }, 1000); // } private void initDate() { tag = getIntent().getStringExtra("tag"); if (tag.equals("edit")) { fast_num = getIntent().getStringExtra("fast_num"); slow_num = getIntent().getStringExtra("slow_num"); telephone = getIntent().getStringExtra("telephone"); zhan_name = getIntent().getStringExtra("zhan_name"); zhan_address = getIntent().getStringExtra("zhan_address"); remarks = getIntent().getStringExtra("remarks"); work_open = getIntent().getStringExtra("work_open"); work_close = getIntent().getStringExtra("work_close"); charge_cost = getIntent().getStringExtra("charge_cost"); stop_cost = getIntent().getStringExtra("stop_cost"); other_cost = getIntent().getStringExtra("other_cost"); suit_car = getIntent().getStringExtra("suit_car"); charge_cost_way = getIntent().getStringExtra("charge_cost_way"); park_location = getIntent().getStringExtra("park_location"); id = getIntent().getStringExtra("id"); poi_jing = getIntent().getStringExtra("poi_jing"); poi_wei = getIntent().getStringExtra("poi_wei"); pic = getIntent().getStringExtra("pic"); } } // public void initOverlay(List l) { // for (int i = 0; i < l.size(); i++) { // double dwei = Double.parseDouble(l.get(i).getPoi_wei()); // double djing = Double.parseDouble(l.get(i).getPoi_jing()); // LatLng ll = new LatLng(dwei, djing); //// if (l.get(i).getSuit_car2().equals("国标")&&l.get(i).getStatus().equals("99")) { //// if (l.get(i).getStatus().equals("1")) { //// oono = new MarkerOptions().position(ll).icon(bdno) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(oono); //// ooyes = new MarkerOptions().position(ll).icon(bdyes) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(ooyes); //// } // if(l.get(i).getStatus().equals("4")){ // ooyes = new MarkerOptions().position(ll).icon(bdyes) // .anchor(0.5f, 1.0f).zIndex(8); // mBaiduMap.addOverlay(ooyes); // }else if(l.get(i).getStatus().equals("3")){ // oono = new MarkerOptions().position(ll).icon(bdno) // .anchor(0.5f, 1.0f).zIndex(8); // mBaiduMap.addOverlay(oono); // } // // //// if(l.get(i).getAuthentication().equals("0")){ //// oono = new MarkerOptions().position(ll).icon(bdno) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(oono); //// } //// else{ //// oono = new MarkerOptions().position(ll).icon(bdno) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(oono); //// } //// if (l.get(i).getStatus().equals("99")) { //// ooyes = new MarkerOptions().position(ll).icon(bdyes) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(ooyes); //// } //// }else if (l.get(i).getSuit_car2().equals("特斯拉")&&l.get(i).getStatus().equals("99")) { // //// //// if(l.get(i).getSuit_car2().equals("特斯拉") && l.get(i).getAuthentication().equals("1")){ //// ooyes = new MarkerOptions().position(ll).icon(bdyes) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(ooyes); //// } else{ //// oono = new MarkerOptions().position(ll).icon(bdno) //// .anchor(0.5f, 1.0f).zIndex(8).draggable(true); //// mBaiduMap.addOverlay(oono); //// } //// //// //// //// // } //// if (center != null) { //// BitmapDescriptor point = BitmapDescriptorFactory //// .fromResource(R.drawable.point_icon); //// oo = new MarkerOptions().position(center).anchor(0.5f, 0.5f).zIndex(7).draggable(false).icon(point); //// mBaiduMap.addOverlay(oo); //// } //// mBaiduMap.clear(); // // } // // private void getAddress() { // mSearch = GeoCoder.newInstance(); // mSearch.setOnGetGeoCodeResultListener(this); // mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(llposition)); // } // 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); // // } @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.ll_address: Intent intent = new Intent(PrivateZhuangInfoActivity.this, PrivateZhuangMapActivity.class); if (tag.equals("edit")) { intent.putExtra("tag", "edit"); intent.putExtra("poi_jing", poi_jing); Log.e("poi_jing===", poi_jing); intent.putExtra("poi_wei", poi_wei); Log.e("poi_wei===", poi_wei); intent.putExtra("zhan_address", zhan_address); } else { intent.putExtra("tag", "add"); } intent.putExtra("zhan_address", zhan_address); startActivityForResult(intent, REQUSET); 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: // if (!isFirstLoc) { // isFirstLoc = true; // // Toast.makeText(this,"正在定位当前位置...",Toast.LENGTH_LONG); // 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(); // } // break; case R.id.tv_notice: tv_notice.setVisibility(View.GONE); break; case R.id.tv_costtype: // startActivity(new Intent(PrivateZhuangInfoActivity.this,ChargeCostWayActivity.class)); LayoutInflater inflater1 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); popupWindowView = inflater1.inflate(R.layout.popupwindow_privatecostway, 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("现金"); 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 (et_telephone.getText().toString().equals("")) { Toast.makeText(this, "请填写联系方式", Toast.LENGTH_SHORT).show(); } else if (CheckMobileNum.isMobileNum(et_telephone.getText().toString()) == false) { Toast.makeText(this, "请填写正确的联系方式", Toast.LENGTH_SHORT).show(); } else if (chargeCost.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 (et_serviceCost.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("")) { // createDialog(); // new Thread(new Runnable() { // @Override // public void run() { //// submitShareTwo(); // // try { // // shite(""); // // // } catch (Exception e) { // e.printStackTrace(); // } // //// uploadFile(); // } // }).start(); // }else{ // Toast.makeText(ShareTwoActivity.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: // SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); // sharedPreferencesUtil.setFileName("shareInfo"); // sharedPreferencesUtil.clearData(); finish(); 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; // case R.id.zoomin1: // mBaiduMap.setMapStatus(MapStatusUpdateFactory // .zoomTo(mapStatus.zoom + 1)); // controlZoomShow(); // break; // case R.id.zoomout1: // mBaiduMap.setMapStatus(MapStatusUpdateFactory // .zoomTo(mapStatus.zoom - 1)); // controlZoomShow(); // break; } // mapStatus = mBaiduMap.getMapStatus(); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); // sharedPreferencesUtil.setFileName("shareInfo"); // sharedPreferencesUtil.clearData(); finish(); } return false; } //地图缩放方法 // private void controlZoomShow() { // float zoom = mBaiduMap.getMapStatus().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(); // } // // } // public void getPoint() { // if (!isGetData) { // isGetData = true; // new Handler().postDelayed(new Runnable() { // // @Override // public void run() { // MyLocationData locCenter = mBaiduMap.getLocationData(); // if (locCenter != null) { // center = new LatLng(locCenter.latitude, // locCenter.longitude); // //// mBaiduMap.addOverlay(new MarkerOptions().position(center).icon( //// BitmapDescriptorFactory //// .fromResource(R.drawable.position_icon))); // } else { // return; // } //// Point p1 = new Point(0, 0); //// LatLng locLeftTop = mBaiduMap.getProjection() //// .fromScreenLocation(p1); //// Point p2 = new Point(MainApplication.mScreenWidth, mMapView //// .getHeight()); //// LatLng llRightBottom = mBaiduMap.getProjection() //// .fromScreenLocation(p2); //// MainMap(); // } // }, 500); // } // } // private void MainMap() { // new Thread(new Runnable() { // Point p1 = new Point(0,0); // LatLng locLeftTop = mBaiduMap.getProjection() // .fromScreenLocation(p1); // Point p2 = new Point(MainApplication.mScreenWidth, mMapView // .getHeight()); // LatLng llRightBottom = mBaiduMap.getProjection() // .fromScreenLocation(p2); // // // // GeoPoint centerPoint = mapview.getMapCenter();// 地图中心坐标 //// int tbSpan = mapview.getLatitudeSpan();// 当前纬线的跨度(从地图的上边缘到下边缘) //// int lrSpan = mapview.getLongitudeSpan();// 当前经度的跨度(从地图的左边缘到地图的右边缘) //// GeoPoint ltPoint = new GeoPoint(centerPoint.getLatitudeE6() - tbSpan / 2, centerPoint.getLongitudeE6() - lrSpan //// / 2);// 左上角坐标 //// GeoPoint rbPoint = new GeoPoint(centerPoint.getLatitudeE6()// 右下角坐标 //// + tbSpan / 2, centerPoint.getLongitudeE6() + lrSpan / 2); // @Override // public void run() { // String url=MainApplication.url+"/zhannew/basic/web/index.php/zhanlist/getlist?poi_lux="+ locLeftTop.longitude+""+"&poi_luy="+ locLeftTop.latitude+"" +"&poi_rdx="+ llRightBottom.longitude+""+"&poi_rdy="+ llRightBottom.latitude+ ""+"&suit_car2="+MainApplication.userTpye; // submitShowMap(url); // } // }).start(); // // } private void submitShowMap(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 = 5; 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); } } 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 par = new HashMap(); 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(); } } // String fast = fastNum par.put("zhan_name", zhanName.getText().toString()); par.put("zhan_address", et_share_address.getText().toString()); String jing = roundByScale(Double.parseDouble(poi_jing), 16); ; String wei = roundByScale(Double.parseDouble(poi_wei), 16); par.put("poi_jing", jing); par.put("poi_wei", wei); // Log.e("poi_jing",jing); // Log.e("poi_wei",wei); par.put("suit_car", suit_car2); par.put("charge_cost", chargeCost.getText().toString()); par.put("charge_cost_way", costWay.getText().toString()); par.put("stop_cost", parkCost.getText().toString()); par.put("telephone", et_telephone.getText().toString()); par.put("other_cost", et_serviceCost.getText().toString()); par.put("park_location", park); par.put("work_open", open_time.getText().toString()); par.put("work_close", close_time.getText().toString()); par.put("user_id", MainApplication.userId); par.put("remarks", et_remark.getText().toString()); par.put("fast_num", fastNum.getText().toString()); par.put("slow_num", slowNum.getText().toString()); if (tag.equals("edit")) { par.put("where", id); // JSONObject jsonObject = new JSONObject(); // JSONArray jsonArray = new JSONArray(); // jsonArray.put(0,"a"); // jsonObject.put("jsonArray",jsonArray); par.put("picid", "a"); } // if () // par.put("where", zhan_id); // par.put("zhan_id", zhan_id); // par.put("total_num", ""); // // par.put("open_object", ""); // par.put("charges", ""); // // par.put("stop_cost_way", ""); // // // par.put("other_cost", et_serviceCost.getText().toString()); // // par.put("zhuang_produce", ""); // // par.put("city", ""); // par.put("supplier", ""); // par.put("facilities_classify", ""); // par.put("belong_attribute", ""); // par.put("operation_state", ""); // // 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("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/applist/createpile", 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 void onPermissionsGranted(int requestCode, List perms) { } @Override public void onPermissionsDenied(int requestCode, List perms) { } @AfterPermissionGranted(RC_ALBUM_PERM) public void permissionTask() { if (isPermissionOK()) { callGallery(); // Have permission, do the thing! // Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show(); // ifTimeout(); } else { // Ask for one permission EasyPermissions.requestPermissions( this, "充电桩想要获取您的图片读取权限,是否允许?", RC_ALBUM_PERM, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE); } } private boolean isPermissionOK() { return EasyPermissions.hasPermissions(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE ); } // @Override // public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) { // // } // // @Override // public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) { // if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) { // Toast.makeText(ShareTwoActivity.this, "抱歉,未能找到结果", // Toast.LENGTH_LONG).show(); // return; // } //// TextView tv = new TextView(this); //// tv.setBackgroundResource(R.color.bkg_button_green); //// tv.setPadding(7, 7, 7, 7); //// tv.setText(result.getAddress()); //// tv.setTextColor(Color.WHITE); //// mInfoWindow = new InfoWindow(tv, llposition, -60); //// mBaiduMap.showInfoWindow(mInfoWindow); // location = result.getAddress(); // city = Util.getCityName(result.getAddress()); // et_share_address.setText(location); // } @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() { // Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // startActivityForResult(openCameraIntent, TAKE_PICTURE); // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/myimage/", String.valueOf(System // .currentTimeMillis()) + ".jpg"); // camePath = file.getPath(); // Uri imageUri = Uri.fromFile(file); // intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // startActivityForResult(intent, TAKE_PICTURE); if (hasSdcard()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//��������� intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); // intent.putExtra(MediaStore.EXTRA_OUTPUT, cutImgUri); startActivityForResult(intent, PHOTO_REQUEST_CAMERA); } // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File( // Environment.getExternalStorageDirectory(), "androidapp.jpg"))); // ((Activity) mContext).startActivityForResult(intent, 2); } // public void photo() { // Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // startActivityForResult(openCameraIntent, TAKE_PICTURE); //// Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //// File file = new File(Environment.getExternalStorageDirectory() + "/myimage/", String.valueOf(System //// .currentTimeMillis()) + ".jpg"); //// camePath = file.getPath(); //// Uri imageUri = Uri.fromFile(file); //// intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); //// startActivityForResult(intent, TAKE_PICTURE); // } // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // System.out.println("--------data------->"+data); // //���ѡȡ // if(requestCode == PHOTO_REQUEST_CAMERA && resultCode == Activity.RESULT_OK ){ // //��������ͼƬ�ͽ�ȡ���ͼƬ�ļ���д����ͬһ���ļ���photo.jpg // crop(Uri.fromFile(tempFile),Uri.fromFile(tempFile)); // } // //���ؽ�ȡ��ͼƬ // else if(requestCode == PHOTO_REQUEST_CUT ){ // //���д�ͼʹ��Uri // Bitmap bitmap = decodeUriAsBitmap(Uri.fromFile(tempFile));//decode bitmap //// mFace.setImageBitmap(bitmap); // String fileName = String.valueOf(System.currentTimeMillis()); // ImageItem takePhoto = new ImageItem(); // takePhoto.setBitmap(bitmap); // takePhoto.setImagePath(FileUtils.SDPATH + fileName + ".JPEG"); // Bimp.tempSelectBitmap.add(takePhoto); // }else { //// Toast.makeText(getApplicationContext(), "��ȡͼƬʧ��", Toast.LENGTH_SHORT).show(); // } // super.onActivityResult(requestCode, resultCode, data); // if (resultCode != Activity.RESULT_OK) { // return; // } // switch (requestCode) { // // 如果是直接从相册获取 // case REQUSET: // poi_jing = data.getStringExtra("poi_jing"); // Log.e("返回==poi_jing",poi_jing); // poi_wei = data.getStringExtra("poi_wei"); // Log.e("返回==poi_wei",poi_wei); // et_share_address.setText(data.getStringExtra("address")); // default: // break; // } // } // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // switch (requestCode) { // case TAKE_PICTURE: // if (Bimp.tempSelectBitmap.size() < 3 && resultCode == RESULT_OK) { // //// String fileName = String.valueOf(System.currentTimeMillis()); //// Bundle bundle = data.getExtras("data"); //// Bitmap bm = (Bitmap) data.getExtras().get("data"); //// FileUtils.saveBitmap(bm, fileName); //// //// ImageItem takePhoto = new ImageItem(); //// takePhoto.setBitmap(bm); //// takePhoto.setImagePath(FileUtils.SDPATH + fileName + ".JPEG"); //// Bimp.tempSelectBitmap.add(takePhoto); // //// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS"); // // Bitmap bitmap = BitmapFactory.decodeFile(camePath); // File file = new File(String.valueOf(Environment.getDataDirectory())); // file.mkdirs(); // String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myimage/" + System.currentTimeMillis() // + ".jpg"; // try { // FileOutputStream b = new FileOutputStream(fileName); // bitmap.compress(Bitmap.CompressFormat.JPEG, 50, b); // b.flush(); // b.close(); // bitmap = Bimp.revitionImageSize(fileName); // FileUtils.saveBitmap(bitmap, // "" + fileName.substring(fileName.lastIndexOf("/") + 1, fileName.lastIndexOf("."))); // ImageItem takePhoto = new ImageItem(); // takePhoto.setBitmap(bitmap); // takePhoto.setImagePath(fileName); // Bimp.tempSelectBitmap.add(takePhoto); // if (null != adapter) { // adapter.notifyDataSetChanged(); // } // File refile = new File(camePath); // if (refile.exists()) { // refile.delete(); // } // } catch (Exception e) { // e.printStackTrace(); // } // // //// Bitmap bitmap = BitmapFactory.decodeFile(camePath); //// File file = new File(Environment.getExternalStorageDirectory() + "/myImage/"); //// file.mkdirs(); //// String fileName = Environment.getExternalStorageDirectory() + "/myImage/" + System.currentTimeMillis() //// + ".jpg"; //// try { //// FileOutputStream b = new FileOutputStream(fileName); //// bitmap.compress(Bitmap.CompressFormat.JPEG, 50, b); //// b.flush(); //// b.close(); //// bitmap = Bimp.revitionImageSize(fileName); //// FileUtils.saveBitmap(bitmap, //// "" + fileName.substring(fileName.lastIndexOf("/") + 1, fileName.lastIndexOf("."))); //// ImageItem takePhoto = new ImageItem(); //// takePhoto.setBitmap(bitmap); //// takePhoto.setImagePath(fileName); //// Bimp.tempSelectBitmap.add(takePhoto); //// if (null != adapter) { //// adapter.notifyDataSetChanged(); //// } //// File refile = new File(camePath); //// if (refile.exists()) { //// refile.delete(); //// } //// } catch (Exception e) { //// e.printStackTrace(); //// } // } // // break; //// case 1: //// if (data != null) { //// startPhotoZoom(data.getData()); //// Toast.makeText(mContext, "拖动正方形角可调整剪切大小", //// android.widget.Toast.LENGTH_SHORT).show(); //// } //// break; //// // 如果是调用相机拍照时 //// case 2: //// File temp = new File(Environment.getExternalStorageDirectory() //// + "/androidapp.jpg"); //// startPhotoZoom(Uri.fromFile(temp)); //// break; // } // } // private void cameraCamera(Intent data) { // SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS"); // String name = formatter.format(System.currentTimeMillis()) + ".jpg"; // Log.i("zhiwei.zhao", "image name:" + name); // Toast.makeText(this, name, Toast.LENGTH_LONG).show(); // Bundle bundle = data.getExtras(); // /* 获取相机返回的数据,并转换为Bitmap图片格式 */ // Bitmap bitmap = (Bitmap) bundle.get("data"); // FileOutputStream b = null; // // String path = Environment.getExternalStorageDirectory().getPath(); // File file = new File(path + "/myImage/"); // /** 检测文件夹是否存在,不存在则创建文件夹 **/ // if (!file.exists() && !file.isDirectory()) // file.mkdirs(); // String fileName = file.getPath() + "/" + name; // Log.i("zhiwei.zhao", "camera file path:" + fileName); // try { // b = new FileOutputStream(fileName); // /* 把数据写入文件 */ // bitmap.compress(Bitmap.CompressFormat.JPEG, 100, b); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } finally { // try { // if (b == null) // return; // b.flush(); // b.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // showImgs(bitmap, true); // } // public class MyLocationListenner implements BDLocationListener { // // // @Override // public void onReceiveLocation(BDLocation location) { // if (location == null || mMapView == null) // return; // MyLocationData locData = new MyLocationData.Builder() // .accuracy(location.getRadius()).direction(1000) // .latitude(location.getLatitude()) // .longitude(location.getLongitude()).build(); // mBaiduMap.setMyLocationData(locData); // if (isFirstLoc) { // isFirstLoc = false; // mLocClient.stop(); // mBaiduMap.setMyLocationEnabled(true); // LatLng ll = new LatLng(location.getLatitude(), // location.getLongitude()); // if (TextUtils.isEmpty(location.getCity())) { //// mSearch.reverseGeoCode(new ReverseGeoCodeOption() //// .location(ll)); // } else { // city = location.getCity(); // } // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); // getPoint(); // } // } // // public void onReceivePoi(BDLocation poiLocation) { // } // } @Override protected void onDestroy() { Bimp.tempSelectBitmap.clear(); Bimp.max = 0; super.onDestroy(); } private Bitmap compressBmpFromBmp(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int options = 100; image.compress(Bitmap.CompressFormat.JPEG, 60, 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 void crop(Uri uri, Uri cutImgUri) { // �ü�ͼƬ��ͼ Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); // �ü���ı�����1��1 // intent.putExtra("aspectX", 4); // intent.putExtra("aspectY", 3); // �ü������ͼƬ�ijߴ��С // intent.putExtra("outputX", 400); // intent.putExtra("outputY", 300); // ͼƬ��ʽ intent.putExtra("outputFormat", "JPEG"); intent.putExtra("noFaceDetection", true);// ȡ������ʶ�� intent.putExtra("return-data", false);// true:������uri��false������uri intent.putExtra(MediaStore.EXTRA_OUTPUT, cutImgUri);//д���ȡ��ͼƬ startActivityForResult(intent, PHOTO_REQUEST_CUT); } private boolean hasSdcard() { if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { return true; } else { return false; } } 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 comp(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 30, baos); if (baos.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出 baos.reset();//重置baos即清空baos image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中 } ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); BitmapFactory.Options newOpts = new BitmapFactory.Options(); //开始读入图片,此时把options.inJustDecodeBounds 设回true了 newOpts.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts); newOpts.inJustDecodeBounds = false; int w = newOpts.outWidth; int h = newOpts.outHeight; //现在主流手机比较多是800*480分辨率,所以高和宽我们设置为 float hh = 800f;//这里设置高度为800f float ww = 480f;//这里设置宽度为480f //缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可 int be = 1;//be=1表示不缩放 if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放 be = (int) (newOpts.outWidth / ww); } else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放 be = (int) (newOpts.outHeight / hh); } if (be <= 0) be = 1; newOpts.inSampleSize = be;//设置缩放比例 newOpts.inPreferredConfig = Bitmap.Config.RGB_565;//降低图片从ARGB888到RGB565 //重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了 isBm = new ByteArrayInputStream(baos.toByteArray()); bitmap = BitmapFactory.decodeStream(isBm, null, newOpts); return compressImage(bitmap);//压缩好比例大小后再进行质量压缩 } private Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 80, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 int options = 70; while (baos.toByteArray().length / 1024 > 300) { //循环判断如果压缩后图片是否大于100kb,大于继续压缩 baos.reset();//重置baos即清空baos options -= 10;//每次都减少10 image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中 } ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中 Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片 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; } @Override protected void 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); } public Bitmap getHttpBitmap(String url) { Bitmap bitmap = null; try { URL pictureUrl = new URL(url); InputStream in = pictureUrl.openStream(); bitmap = BitmapFactory.decodeStream(in); in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return bitmap; } public void savePicture(Bitmap bitmap) { String pictureName = "/storage/emulated/0/DCIM/Camera/aaaa.jpg"; File file = new File(pictureName); FileOutputStream out; try { out = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem item = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, "Exit"); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { System.exit(0); return true; } }); return true; } }