@Override public void onReceiveLocation(BDLocation location) { if (!Utils.isEmpty(location.getLatitude() + "") && !Utils.isEmpty(location.getLongitude() + "")) { mLocationClient.stop(); tv_address.setText(location.getCity()); } }
/** 显示label的popupwindow */ private void showLabel() { if (Utils.isEmpty(tags)) { queryLabel(); return; } else { // if(type.equals("0")){ // CircleTagVo tag1 = new CircleTagVo(); // tag1.setTitle("普通日记"); // tag1.setType("1"); // }else if(type.equals("1")){ // CircleTagVo tag3 = new CircleTagVo(); // tag3.setTitle("疾病记录"); // tag3.setType("3"); // } // CircleTagVo tag1 = new CircleTagVo(); // tag1.setTitle("普通日记"); // tag1.setType("1"); // CircleTagVo tag3 = new CircleTagVo(); // tag3.setTitle("疾病记录"); // tag3.setType("3"); // tags.add(tag1); // tags.add(tag3); } if (popupView == null) { popupView = makeView(R.layout.pupopwindow_selectlabel); Rect rect = new Rect(); this.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int statusBarHeight = rect.top; popupWindow = new PopupWindow( popupView, WindowManager.LayoutParams.MATCH_PARENT, AppUtils.getHeight(activity) - statusBarHeight); LinearLayout window = (LinearLayout) popupView.findViewById(R.id.ll_top); LinearLayout content = (LinearLayout) popupView.findViewById(R.id.ll_bottom); TextView tv_cancel = (TextView) popupView.findViewById(R.id.tv_cancel); TextView tv_submit = (TextView) popupView.findViewById(R.id.tv_submit); GridViewPage gridViewPage = (GridViewPage) popupView.findViewById(R.id.viewpage_label); // 载入数据到gridViewPage中 loadDataToGridViewPage(gridViewPage, tags); tv_cancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { popupWindow.dismiss(); } }); tv_submit.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { tv_label.setText(tags.get(selectLabelIndex).getTitle()); if (Utils.isEmpty(tags.get(selectLabelIndex).getId())) { tv_label.setTag(R.id.tag_first, tags.get(selectLabelIndex).getType()); } else { tv_label.setTag(R.id.tag_two, tags.get(selectLabelIndex).getId()); } popupWindow.dismiss(); } }); window.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { popupWindow.dismiss(); } }); content.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) {} }); } if (popupWindow.isShowing()) { popupWindow.dismiss(); } else { popupWindow.showAtLocation(ll_publish, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); } }
@OnClick(R.id.tv_publish) void publish(View view) { if (Utils.isEmpty(et_title.getText().toString())) { toast("请输入标题"); return; } if (Utils.isEmpty(et_content.getText().toString())) { toast("请输入内容"); return; } if (Utils.isEmpty(type)) { if (tv_label.getTag(R.id.tag_first) == null && tv_label.getTag(R.id.tag_two) == null) { toast("请选择标签"); return; } } if (!SimpleUtils.isLogin(activity)) { skip(LoginActivity.class); return; } PostParams params = new PostParams(); showDialog(); params.put("title", et_title.getText().toString()); params.put("content", et_content.getText().toString()); params.put("address", tv_address.getText().toString()); if (tv_label.getTag(R.id.tag_two) != null) { params.put("category_id", tv_label.getTag(R.id.tag_two).toString()); // 标签id } if (tv_label.getTag(R.id.tag_first) != null) { params.put("type", tv_label.getTag(R.id.tag_first).toString()); // 标签id params.put("category_id", "2"); // 标签id } if (tb_notify.isChecked()) { params.put("private", "0"); // 标签id } else { params.put("private", "1"); // 标签id } String pics = ""; Set keys = ids.keySet(); Iterator<String> it = keys.iterator(); while (it.hasNext()) { String key = it.next(); String id = ids.get(key); if (Utils.isEmpty(pics)) { pics = id; } else { pics = pics + "," + id; } } params.put("pictures", pics); HttpUtils.postJSONObject( activity, Const.PUBLIC_CIRCLE, SimpleUtils.buildUrl(activity, params), new RespJSONObjectListener(activity) { @Override public void getResp(JSONObject obj) { dismissDialog(); RespVo respVo = GsonTools.getVo(obj.toString(), RespVo.class); if (respVo.isSuccess()) { toast("动态已发布"); EventBus.getDefault().post(new DiseaseRecordActivity.RefreshEvent()); finish(); } else { toast(respVo.getMessage()); } } @Override public void doFailed() { dismissDialog(); } }); }
private void uploadImage(final String path) { showDialog(); final PostParams params = new PostParams(); InitUtil.createAdFolder(this, "tempFile"); params.put("file", Utils.saveBitmapFile(this, getSmallBitmap(path), "tempFile")); HttpUtils.postJSONObject( activity, Const.UPLOAD_IMAGE, params, new RespJSONObjectListener(activity) { @Override public void getResp(JSONObject jsonObject) { dismissDialog(); RespVo<UploadFileVo> resp = GsonTools.getVo(jsonObject.toString(), RespVo.class); if (resp.isSuccess()) { final UploadFileVo fileVo = resp.getData(activity, jsonObject, UploadFileVo.class); ids.put(fileVo.getId() + "", fileVo.getId() + ""); final int width = (AppUtils.getWidth(activity) - 80) / 3; final View view = makeView(R.layout.item_photo); ImageView iv_image = (ImageView) view.findViewById(R.id.iv_image); ImageView iv_delete = (ImageView) view.findViewById(R.id.iv_delete); iv_delete.setVisibility(View.VISIBLE); iv_delete.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { fl_pics.removeView(view); ids.remove(fileVo.getId() + ""); if (fl_pics.getChildCount() < 3) { View temp = makeView(R.layout.item_photo); ImageView iv_image = (ImageView) temp.findViewById(R.id.iv_image); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width); lp.leftMargin = 18; temp.setLayoutParams(lp); iv_image.setImageResource(R.drawable.icon_addzhaopian); temp.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { GalleryConfig.Builder builder = new GalleryConfig.Builder(activity); builder.imageloader(new GlideImageLoader()); builder.singleSelect(); builder.enableEdit(); builder.enableRotate(); builder.showCamera(); GalleryConfig config = builder.build(); GalleryFinal.open(config); } }); fl_pics.addView(temp); } } }); iv_image.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<CircleVo.ItemCircle.Cover> list = new ArrayList<CircleVo.ItemCircle.Cover>(); CircleVo.ItemCircle.Cover cover = new CircleVo.ItemCircle.Cover(); cover.setPath(path); list.add(cover); skip(PicScannerActivity.class, list); } }); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width); lp.leftMargin = 18; view.setLayoutParams(lp); view.setTag(path); iv_image.setImageBitmap(Utils.getSmallBitmap(path)); fl_pics.addView(view, 0); if (fl_pics.getChildCount() == 4) { fl_pics.removeViewAt(3); } } else { toast("获取图片失败,请重试"); } } @Override public void doFailed() { dismissDialog(); } }); }