List of usage examples for android.content Intent getDoubleExtra
public double getDoubleExtra(String name, double defaultValue)
From source file:cn.yunluosoft.tonglou.activity.ChatActivity.java
/** * onActivityResult//from ww w. j a v a2 s . c o m */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 8226 && resultCode == RESULT_OK) { String s = data.getStringExtra("name"); if (!ToosUtils.isStringEmpty(s)) { messageInfo.receiverNickName = s; toChatUsername = messageInfo.receiverImUserName; // toChatUsername = getIntent().getStringExtra("userId"); ((TextView) findViewById(R.id.title_title)).setText(messageInfo.receiverNickName); } } if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1))); // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refreshSeekTo(data.getIntExtra("position", adapter.getCount()) - 1); break; // case RESULT_CODE_FORWARD: // ?? // EMMessage forwardMsg = (EMMessage) adapter.getItem(data // .getIntExtra("position", 0)); // Intent intent = new Intent(this, ForwardMessageActivity.class); // intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); // startActivity(intent); // // break; default: break; } } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ?? int duration = data.getIntExtra("dur", 0); String videoPath = data.getStringExtra("path"); File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis()); Bitmap bitmap = null; FileOutputStream fos = null; try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon); } fos = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } fos = null; } if (bitmap != null) { bitmap.recycle(); bitmap = null; } } sendVideo(videoPath, file.getAbsolutePath(), duration / 1000); } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? loading(); // if (data != null) { // Uri selectedImage = data.getData(); // if (selectedImage != null) { // sendPicByUri(selectedImage); // } // } } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ?? if (data != null) { Uri uri = data.getData(); if (uri != null) { sendFile(uri); } } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { toggleMore(more); sendLocationMsg(latitude, longitude, "", locationAddress); } else { String st = getResources().getString(R.string.unable_to_get_loaction); Toast.makeText(this, st, Toast.LENGTH_SHORT).show(); } // ??? } else if (requestCode == REQUEST_CODE_TEXT || requestCode == REQUEST_CODE_VOICE || requestCode == REQUEST_CODE_PICTURE || requestCode == REQUEST_CODE_LOCATION || requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ??? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); addUserToBlacklist(deleteMsg.getFrom()); } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { adapter.refresh(); } } }
From source file:com.gongpingjia.carplay.activity.chat.ChatActivity.java
/** * onActivityResult/* ww w .j ava 2 s. c o m*/ */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1))); // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refreshSeekTo(data.getIntExtra("position", adapter.getCount()) - 1); break; case RESULT_CODE_FORWARD: // ?? // EMMessage forwardMsg = (EMMessage) adapter.getItem(data // .getIntExtra("position", 0)); // Intent intent = new Intent(this, // ForwardMessageActivity.class); // intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); // startActivity(intent); break; default: break; } } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ?? int duration = data.getIntExtra("dur", 0); String videoPath = data.getStringExtra("path"); File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis()); Bitmap bitmap = null; FileOutputStream fos = null; try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon); } fos = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } fos = null; } if (bitmap != null) { bitmap.recycle(); bitmap = null; } } sendVideo(videoPath, file.getAbsolutePath(), duration / 1000); } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? if (data != null && data.getExtras() != null) { @SuppressWarnings("unchecked") List<PhotoModel> photos = (List<PhotoModel>) data.getExtras().getSerializable("photos"); if (photos == null || photos.isEmpty()) { showToast("!"); } else { for (int i = 0; i < photos.size(); i++) { PhotoModel photo = photos.get(i); sendPicByUri(Uri.parse(photo.getOriginalPath())); } } } // if (data != null) { // Uri selectedImage = data.getData(); // if (selectedImage != null) { // sendPicByUri(selectedImage); // } // } } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ?? if (data != null) { Uri uri = data.getData(); if (uri != null) { sendFile(uri); } } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { toggleMore(more); sendLocationMsg(latitude, longitude, "", locationAddress); } else { String st = getResources().getString(R.string.unable_to_get_loaction); Toast.makeText(this, st, 0).show(); } // ??? } else if (requestCode == REQUEST_CODE_TEXT || requestCode == REQUEST_CODE_VOICE || requestCode == REQUEST_CODE_PICTURE || requestCode == REQUEST_CODE_LOCATION || requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ??? // EMMessage deleteMsg = (EMMessage) adapter.getItem(data // .getIntExtra("position", -1)); // addUserToBlacklist(deleteMsg.getFrom()); } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { adapter.refresh(); } } }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * onActivityResult// www.j a v a2 s . com */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1))); // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refresh(); listView.setSelection(data.getIntExtra("position", adapter.getCount()) - 1); break; case RESULT_CODE_FORWARD: // ?? EMMessage forwardMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", 0)); Intent intent = new Intent(this, ForwardMessageActivity.class); intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); startActivity(intent); break; default: break; } } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ?? int duration = data.getIntExtra("dur", 0); String videoPath = data.getStringExtra("path"); File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis()); Bitmap bitmap = null; FileOutputStream fos = null; try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon); } fos = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } fos = null; } if (bitmap != null) { bitmap.recycle(); bitmap = null; } } sendVideo(videoPath, file.getAbsolutePath(), duration / 1000); } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) { sendPicByUri(selectedImage); } } } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ?? if (data != null) { Uri uri = data.getData(); if (uri != null) { sendFile(uri); } } } else if (requestCode == REQUEST_CODE_CREATE_GUESS) { if (data != null) { try { sendJingcai( match.getJSONObject("team1").getString("name") + "VS" + match.getJSONObject("team2").getString("name"), "isGuess", data.getStringExtra("id") + "," + data.getStringExtra("price")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // Toast.makeText(ChatActivity.this, // data.getStringExtra("id"), Toast.LENGTH_SHORT) // .show(); } } else if (requestCode == REQUEST_CODE_CREATE_BRAG) { if (data != null) { sendJingcai("??", "isBrag", data.getStringExtra("id")); } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { more(more); sendLocationMsg(latitude, longitude, "", locationAddress); } else { String st = getResources().getString(R.string.unable_to_get_loaction); Toast.makeText(this, st, 0).show(); } // ??? } else if (requestCode == REQUEST_CODE_TEXT || requestCode == REQUEST_CODE_VOICE || requestCode == REQUEST_CODE_PICTURE || requestCode == REQUEST_CODE_LOCATION || requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ??? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); addUserToBlacklist(deleteMsg.getFrom()); } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { adapter.refresh(); } } }
From source file:xj.property.activity.HXBaseActivity.ChatActivity.java
/** * onActivityResult/*from w w w . j a v a 2 s .co m*/ */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1))); // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refresh(); listView.setSelection(data.getIntExtra("position", adapter.getCount()) - 1); break; case RESULT_CODE_FORWARD: // ?? EMMessage forwardMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", 0)); Intent intent = new Intent(this, ForwardMessageActivity.class); intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); startActivity(intent); break; default: break; } } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); clearDB(); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ?? int duration = data.getIntExtra("dur", 0); String videoPath = data.getStringExtra("path"); File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis()); Bitmap bitmap = null; FileOutputStream fos = null; try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon); } fos = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } fos = null; } if (bitmap != null) { bitmap.recycle(); bitmap = null; } } sendVideo(videoPath, file.getAbsolutePath(), duration / 1000); } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? int bitmapChatSize = BitmapHelper.bitmapChatListStorage.size(); if (bitmapChatSize > 0) { for (int i = 0; i < bitmapChatSize; i++) { Uri selectedImage = Uri.parse(BitmapHelper.bitmapChatListStorage.get(i)); if (selectedImage != null) { sendPicByUri(selectedImage); } } BitmapHelper.bitmapChatListStorage.clear(); } // if (data != null) { // Uri selectedImage = data.getData(); // if (selectedImage != null) { // sendPicByUri(selectedImage); // } // } } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ?? if (data != null) { Uri uri = data.getData(); if (uri != null) { sendFile(uri); } } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { more(more); sendLocationMsg(latitude, longitude, "", locationAddress); } else { showToast("???"); } // ??? } else if (requestCode == REQUEST_CODE_TEXT || requestCode == REQUEST_CODE_VOICE || requestCode == REQUEST_CODE_PICTURE || requestCode == REQUEST_CODE_LOCATION || requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { if (TextUtils.equals(servantType, Config.SERVANT_TYPE_BANGBANG) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WEIXIUTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_SHOPTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WUYE)) { sendPictureServantOrComplain(pasteText.replace(COPY_IMAGE, "")); } else { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ??? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); addUserToBlacklist(deleteMsg.getFrom()); } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); //// ?, ???,? } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { if (data != null) { String destoryflag = data.getStringExtra(Config.EXPKey_GROUP_DESTORY); if (TextUtils.equals(destoryflag, Config.EXPKey_GROUP_DESTORY)) { if (conversation != null) { conversation.clear(); ////TODO ?? // EMChatManager.getInstance().deleteConversation(conversation); } showToast("?"); finish(); } group.setGroupName(data.getStringExtra(Config.EXPKey_GROUP)); } adapter.refresh(); } } }
From source file:com.haomee.chat.activity.ChatActivity.java
/** * onActivityResult/*from w w w .ja v a 2s . c o m*/ */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = ((EMMessage) adapter.getItem(data.getIntExtra("position", -1))); if (copyMsg.getType() == EMMessage.Type.IMAGE) { ImageMessageBody imageBody = (ImageMessageBody) copyMsg.getBody(); // ??? clipboard.setText(COPY_IMAGE + imageBody.getLocalUrl()); } else { // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); } break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refresh(); listView.setSelection(data.getIntExtra("position", adapter.getCount()) - 1); break; /* * case RESULT_CODE_FORWARD: // ?? EMMessage forwardMsg = * (EMMessage) adapter.getItem(data.getIntExtra("position", 0)); * Intent intent = new Intent(this, ForwardMessageActivity.class); * intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); * startActivity(intent); * * break; */ default: break; } } else if (requestCode == REQUEST_CODE_FROM_GAME) { LiuLianApplication.PUBLIC_GAME_ID = ""; } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { // ?? int duration = data.getIntExtra("dur", 0); String videoPath = data.getStringExtra("path"); File file = new File(PathUtil.getInstance().getImagePath(), "thvideo" + System.currentTimeMillis()); Bitmap bitmap = null; FileOutputStream fos = null; try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.app_panel_video_icon); } fos = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } fos = null; } if (bitmap != null) { bitmap.recycle(); bitmap = null; } } sendVideo(videoPath, file.getAbsolutePath(), duration / 1000); } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) { sendPicByUri(selectedImage); } } } else if (requestCode == REQUEST_CODE_SELECT_FILE) { // ?? if (data != null) { Uri uri = data.getData(); if (uri != null) { sendFile(uri); } } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { more(all_container); sendLocationMsg(latitude, longitude, "", locationAddress); } else { MyToast.makeText(this, "????", 0).show(); } // ??? } else if (requestCode == REQUEST_CODE_TEXT) { resendMessage(); } else if (requestCode == REQUEST_CODE_VOICE) { resendMessage(); } else if (requestCode == REQUEST_CODE_PICTURE) { resendMessage(); } else if (requestCode == REQUEST_CODE_LOCATION) { resendMessage(); } else if (requestCode == REQUEST_CODE_VIDEO || requestCode == REQUEST_CODE_FILE) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } else if (requestCode == REQUEST_CODE_ADD_TO_BLACKLIST) { // ??? EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); addUserToBlacklist(deleteMsg.getFrom()); } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { adapter.refresh(); } } }
From source file:com.runye.express.chat.activity.ChatActivity.java
/** * //from w ww.ja v a2 s. c om */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CODE_EXIT_GROUP) { setResult(RESULT_OK); finish(); return; } if (requestCode == REQUEST_CODE_CONTEXT_MENU) { switch (resultCode) { case RESULT_CODE_COPY: // ?? EMMessage copyMsg = (adapter.getItem(data.getIntExtra("position", -1))); if (copyMsg.getType() == EMMessage.Type.IMAGE) { ImageMessageBody imageBody = (ImageMessageBody) copyMsg.getBody(); // ??? clipboard.setText(COPY_IMAGE + imageBody.getLocalUrl()); } else { // clipboard.setText(SmileUtils.getSmiledText(ChatActivity.this, // ((TextMessageBody) copyMsg.getBody()).getMessage())); clipboard.setText(((TextMessageBody) copyMsg.getBody()).getMessage()); } break; case RESULT_CODE_DELETE: // ? EMMessage deleteMsg = adapter.getItem(data.getIntExtra("position", -1)); conversation.removeMessage(deleteMsg.getMsgId()); adapter.refresh(); listView.setSelection(data.getIntExtra("position", adapter.getCount()) - 1); break; case RESULT_CODE_FORWARD: // ?? EMMessage forwardMsg = adapter.getItem(data.getIntExtra("position", 0)); Intent intent = new Intent(this, ForwardMessageActivity.class); intent.putExtra("forward_msg_id", forwardMsg.getMsgId()); startActivity(intent); break; default: break; } } if (resultCode == RESULT_OK) { // ? if (requestCode == REQUEST_CODE_EMPTY_HISTORY) { // ? EMChatManager.getInstance().clearConversation(toChatUsername); adapter.refresh(); } else if (requestCode == REQUEST_CODE_CAMERA) { // ?? if (cameraFile != null && cameraFile.exists()) sendPicture(cameraFile.getAbsolutePath()); } else if (requestCode == REQUEST_CODE_SELECT_VIDEO) { Uri videoUri = data.getData(); String[] proj = { MediaStore.Images.Media.DATA, MediaStore.Video.Media.DURATION }; try { Cursor cursor = getContentResolver().query(videoUri, proj, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); int duration = cursor .getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION)); String videoPath = cursor.getString(index); Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(videoPath, 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.chat_app_panel_video_icon); } File videoFile = new File(videoPath); System.out.println("length:" + videoFile.length()); // ???5M if (videoFile.length() > 1024 * 1024 * 5) { Toast.makeText(this, "??5M?", Toast.LENGTH_SHORT).show(); return; } // get the thumb image file File file = new File(PathUtil.getInstance().getVideoPath(), "th" + videoFile.getName()); try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap.compress(CompressFormat.JPEG, 100, new FileOutputStream(file)); } catch (Exception e) { e.printStackTrace(); } sendVideo(videoPath, file.getAbsolutePath(), duration); } } else { File videoFile = new File(videoUri.getPath()); Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(videoFile.getAbsolutePath(), 3); if (bitmap == null) { EMLog.d("chatactivity", "problem load video thumbnail bitmap,use default icon"); bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.chat_app_panel_video_icon); } System.out.println("length:" + videoFile.length()); // ???5M if (videoFile.length() > 1024 * 1024 * 5) { Toast.makeText(this, "??5M?", Toast.LENGTH_SHORT).show(); return; } // get the thumb image file File file = new File(PathUtil.getInstance().getVideoPath(), "th" + videoFile.getName()); try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } bitmap.compress(CompressFormat.JPEG, 100, new FileOutputStream(file)); } catch (Exception e) { e.printStackTrace(); } sendVideo(videoFile.getAbsolutePath(), file.getAbsolutePath(), 0); } } catch (Exception e) { System.out.println("exception:" + e.getMessage()); } } else if (requestCode == REQUEST_CODE_CAMERA_VIDEO) { if (videoFile != null && videoFile.exists()) { // ? String thumbPath = com.easemob.util.ImageUtils.saveVideoThumb(videoFile, 120, 120, Thumbnails.MINI_KIND); sendVideo(videoFile.getAbsolutePath(), thumbPath, 1); } } else if (requestCode == REQUEST_CODE_LOCAL) { // ?? if (data != null) { Uri selectedImage = data.getData(); if (selectedImage != null) sendPicByUri(selectedImage); } } else if (requestCode == REQUEST_CODE_MAP) { // double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); String locationAddress = data.getStringExtra("address"); if (locationAddress != null && !locationAddress.equals("")) { more(more); sendLocationMsg(latitude, longitude, "", locationAddress); } else { Toast.makeText(this, "????", 0).show(); } // ??? } else if (requestCode == REQUEST_CODE_TEXT) { resendMessage(); } else if (requestCode == REQUEST_CODE_VOICE) { resendMessage(); } else if (requestCode == REQUEST_CODE_PICTURE) { resendMessage(); } else if (requestCode == REQUEST_CODE_LOCATION) { resendMessage(); } else if (requestCode == REQUEST_CODE_VIDEO) { resendMessage(); } else if (requestCode == REQUEST_CODE_COPY_AND_PASTE) { // if (!TextUtils.isEmpty(clipboard.getText())) { String pasteText = clipboard.getText().toString(); if (pasteText.startsWith(COPY_IMAGE)) { // ??path sendPicture(pasteText.replace(COPY_IMAGE, "")); } } } else if (conversation.getMsgCount() > 0) { adapter.refresh(); setResult(RESULT_OK); } else if (requestCode == REQUEST_CODE_GROUP_DETAIL) { EMChatManager.getInstance().getConversation(toChatUsername); adapter.refresh(); } } }
From source file:com.zoffcc.applications.zanavi.Navit.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.e("Navit", "onActivityResult"); switch (requestCode) { case Navit.ZANaviIntro_id: try {//from ww w. j av a2 s .com PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(PREF_KEY_FIRST_START, false) .commit(); } catch (Exception e) { e.printStackTrace(); } case Navit.NavitGPXConvChooser_id: try { Log.e("Navit", "onActivityResult 001"); if (resultCode == AppCompatActivity.RESULT_OK) { String in_ = data.getStringExtra(FileDialog.RESULT_PATH); convert_gpx_file_real(in_); } } catch (Exception e77) { e77.printStackTrace(); } break; case NavitReplayFileConvChooser_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { final String in_ = data.getStringExtra(FileDialog.RESULT_PATH); final Thread replay_gpx_file_001 = new Thread() { @Override public void run() { try { Thread.sleep(2000); // wait 2 seconds before we start String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN) .format(new Date()); ZANaviDebugReceiver.DR_replay_gps_file(in_, date); } catch (Exception e) { } } }; replay_gpx_file_001.start(); } } catch (Exception e77) { e77.printStackTrace(); } break; case Navit.NavitDeleteSecSelectMap_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { if (!data.getStringExtra("selected_id") .equalsIgnoreCase(NavitDeleteSelectMapActivity.CANCELED_ID)) { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! // remove all sdcard maps Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 19); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { Thread.sleep(100); } catch (InterruptedException e) { } Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id"))); String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer .parseInt(data.getStringExtra("selected_id"))]; Log.d("Navit", "delete map full line=" + map_full_line); String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0]; System.out.println("del map file :" + del_map_name); // remove from cat file NavitMapDownloader.remove_from_cat_file(map_full_line); // remove from disk File del_map_name_file = new File(del_map_name); del_map_name_file.delete(); for (int jkl = 1; jkl < 51; jkl++) { File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl)); del_map_name_fileSplit.delete(); } // also remove index file File del_map_name_file_idx = new File(del_map_name + ".idx"); del_map_name_file_idx.delete(); // remove also any MD5 files for this map that may be on disk try { String tmp = map_full_line.split(":", 2)[1]; if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN)) { tmp = tmp.replace("*", ""); tmp = tmp.replace("/", ""); tmp = tmp.replace("\\", ""); tmp = tmp.replace(" ", ""); tmp = tmp.replace(">", ""); tmp = tmp.replace("<", ""); System.out .println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5"); File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5"); md5_final_filename.delete(); } } catch (Exception e) { e.printStackTrace(); } // remove map, and zoom out // ***** onStop(); // ***** onCreate(getIntent().getExtras()); try { Thread.sleep(100); } catch (InterruptedException e) { } // add all sdcard maps msg = new Message(); b = new Bundle(); b.putInt("Callback", 20); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); final Thread zoom_to_route_004 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_004.start(); System.out.println("Global_Location_update_not_allowed = 0"); Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now! } } } catch (Exception e) { Log.d("Navit", "error on onActivityResult 3"); e.printStackTrace(); } break; case Navit.NavitDownloaderPriSelectMap_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { try { // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // set map id to download Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer .parseInt(data.getStringExtra("selected_id"))]; // show the map download progressbar, and download the map if (Navit.download_map_id > -1) { // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app // new method in service Message msg = progress_handler.obtainMessage(); // Bundle b = new Bundle(); msg.what = 22; progress_handler.sendMessage(msg); // show license for OSM maps //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT).show(); // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } } else { // user pressed back key } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } break; case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!! break; case ZANaviVoiceInput_id: if (resultCode == AppCompatActivity.RESULT_OK) { try { String addr = data.getStringExtra("address_string"); double lat = data.getDoubleExtra("lat", 0); double lon = data.getDoubleExtra("lon", 0); String hn = ""; // save last address entry string p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); Boolean partial_match = true; Navit.use_index_search = false; Navit_last_address_partial_match = partial_match; Navit_last_address_search_string = addr; Navit_last_address_hn_string = hn; Navit_last_address_full_file_search = false; // clear results Navit.NavitAddressResultList_foundItems.clear(); Navit.Navit_Address_Result_double_index.clear(); Navit.NavitSearchresultBarIndex = -1; Navit.NavitSearchresultBar_title = ""; Navit.NavitSearchresultBar_text = ""; Navit.search_results_towns = 0; Navit.search_results_streets = 0; Navit.search_results_streets_hn = 0; Navit.search_results_poi = 0; if (addr.equals("")) { // empty search string entered Toast.makeText(getApplicationContext(), Navit.get_text("No search string"), Toast.LENGTH_LONG).show(); //TRANS } else { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! // --> this still does the search // google_online_search_and_set_destination(addr); result_set_destination(lat, lon, addr); System.out.println("Global_Location_update_not_allowed = 0"); Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now! } } catch (Exception e) { } } break; case NavitAddressSearch_id_online: case NavitAddressSearch_id_offline: Log.e("Navit", "NavitAddressSearch_id_:001"); try { if (resultCode == AppCompatActivity.RESULT_OK) { try { String addr = data.getStringExtra("address_string"); String hn = ""; try { // only from offline mask! hn = data.getStringExtra("hn_string"); } catch (Exception e) { hn = ""; } // save last address entry string p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); Boolean partial_match = false; try { // only from offline mask! partial_match = data.getStringExtra("partial_match").equals("1"); } catch (Exception e) { } Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putInt("Callback", 44); msg2.setData(b2); NavitGraphics.callback_handler.sendMessage(msg2); if (requestCode == NavitAddressSearch_id_offline) { search_hide_duplicates = false; try { Boolean hide_dup = data.getStringExtra("hide_dup").equals("1"); if (hide_dup) { search_hide_duplicates = true; Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 45); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } } catch (Exception e) { } if (Navit.CIDEBUG == 0) { Navit.use_index_search = Navit.allow_use_index_search(); } } else { Navit.use_index_search = false; } Navit_last_address_partial_match = partial_match; Navit_last_address_search_string = addr; Navit_last_address_hn_string = hn; try { // only from offline mask! Navit_last_address_full_file_search = data.getStringExtra("full_file_search") .equals("1"); } catch (Exception e) { Navit_last_address_full_file_search = false; } try { // only from offline mask! Navit_last_address_search_country_iso2_string = data .getStringExtra("address_country_iso2"); Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3); // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags); Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL* p.PREF_search_country = Navit_last_address_search_country_id; setPrefs_search_country(); } catch (Exception e) { } // clear results Navit.NavitAddressResultList_foundItems.clear(); Navit.Navit_Address_Result_double_index.clear(); Navit.NavitSearchresultBarIndex = -1; Navit.NavitSearchresultBar_title = ""; Navit.NavitSearchresultBar_text = ""; Navit.search_results_towns = 0; Navit.search_results_streets = 0; Navit.search_results_streets_hn = 0; Navit.search_results_poi = 0; if (addr.equals("")) { // empty search string entered Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS } else { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! if (requestCode == NavitAddressSearch_id_online) { // online googlemaps search try { Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG); } catch (Exception e) { e.printStackTrace(); } System.out.println("dialog -- 11:003"); System.out.println("online googlemaps search"); Message msg = progress_handler.obtainMessage(); Bundle b = new Bundle(); msg.what = 11; b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG); msg.setData(b); progress_handler.sendMessage(msg); } else if (requestCode == NavitAddressSearch_id_offline) { // offline binfile search if (!Navit.use_index_search) { try { Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE); } catch (Exception e) { e.printStackTrace(); } // show dialog, and start search for the results // make it indirect, to give our activity a chance to startup // (remember we come straight from another activity and ours is still paused!) System.out.println("dialog -- 11:004"); Message msg = progress_handler.obtainMessage(); Bundle b = new Bundle(); msg.what = 11; b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE); msg.setData(b); progress_handler.sendMessage(msg); } } } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } } else { // user pressed back key Log.e("Navit", "NavitAddressSearch_id_:900"); } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } Log.e("Navit", "NavitAddressSearch_id_:999"); break; case Navit.NavitAddressResultList_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { try { if (data.getStringExtra("what").equals("view")) { // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); // save last address entry string String addr = data.getStringExtra("address_string"); p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } System.out.println("XSOM:009"); if (Navit.use_index_search) { show_geo_on_screen_with_zoom_and_delay( (float) Navit.transform_to_geo_lat( Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon( Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); } else { show_geo_on_screen_with_zoom_and_delay( Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); } } else if (data.getStringExtra("what").equals("set")) { Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // save last address entry string String addr = data.getStringExtra("address_string"); p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); String _addr = ""; double _lat = 0; double _lon = 0; // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon) // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat) // ok now set target try { if (Navit.use_index_search) { _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr; _lat = Navit.transform_to_geo_lat( Navit.NavitAddressResultList_foundItems.get(destination_id).lat); _lon = Navit.transform_to_geo_lon( Navit.NavitAddressResultList_foundItems.get(destination_id).lon); //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); } else { _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr; _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat; _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon; //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); } // save points //write_map_points(); } catch (Exception e) { e.printStackTrace(); } route_wrapper(_addr, 0, 0, false, _lat, _lon, true); final Thread zoom_to_route_005 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_005.start(); // zoom_to_route(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } // if (Navit.use_index_search) // { // show_geo_on_screen((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); // } // else // { // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); // } } else { // -- nothing -- } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } catch (Exception e) { } } else { // user pressed back key } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } break; case NavitAddressSearch_id_gmaps: try { if (resultCode == AppCompatActivity.RESULT_OK) { } } catch (Exception e) { e.printStackTrace(); } break; case NavitAddressSearch_id_sharedest: try { if (resultCode == AppCompatActivity.RESULT_OK) { } Log.d("Navit", "sharedest: finished"); } catch (Exception e) { e.printStackTrace(); } break; case NavitGeoCoordEnter_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { // lat lon enter activitiy result try { if (data.getStringExtra("what").equals("view")) { // get the coords for the destination float lat = Float.parseFloat(data.getStringExtra("lat")); float lon = Float.parseFloat(data.getStringExtra("lon")); // Log.d("Navit", "coord picker: " + lat); // Log.d("Navit", "coord picker: " + lon); // set nice zoomlevel before we show destination // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL; // // // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 33); // b.putString("s", Integer.toString(zoom_want)); // msg.setData(b); // try // { // N_NavitGraphics.callback_handler.sendMessage(msg); // Navit.GlobalScaleLevel = zoom_want; // } // catch (Exception e) // { // e.printStackTrace(); // } // if (PREF_save_zoomlevel) // { // setPrefs_zoomlevel(); // } // set nice zoomlevel before we show destination try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } show_geo_on_screen(lat, lon); } else { // get the coords for the destination float lat = Float.parseFloat(data.getStringExtra("lat")); float lon = Float.parseFloat(data.getStringExtra("lat")); String dest_name = "manual coordinates"; // ok now set target try { dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon); if ((dest_name.equals(" ")) || (dest_name == null)) { dest_name = "manual coordinates"; } // Navit.remember_destination(dest_name, lat, lon); // // save points // write_map_points(); } catch (Exception e) { e.printStackTrace(); } // // DEBUG: clear route rectangle list // NavitGraphics.route_rects.clear(); // // if (NavitGraphics.navit_route_status == 0) // { // Navit.destination_set(); // // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 3); // b.putString("lat", String.valueOf(lat)); // b.putString("lon", String.valueOf(lon)); // b.putString("q", dest_name); // msg.setData(b); // NavitGraphics.callback_handler.sendMessage(msg); // } // else // { // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 48); // b.putString("lat", String.valueOf(lat)); // b.putString("lon", String.valueOf(lon)); // b.putString("q", dest_name); // msg.setData(b); // NavitGraphics.callback_handler.sendMessage(msg); // } // route_wrapper(dest_name, 0, 0, false, lat, lon, true); final Thread zoom_to_route_006 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_006.start(); // zoom_to_route(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } // show_geo_on_screen(lat, lon); } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } catch (Exception e) { } } } catch (Exception e) { e.printStackTrace(); } break; case NavitRecentDest_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); if (data.getStringExtra("what").equals("view")) { try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } float lat = Navit.map_points.get(destination_id).lat; float lon = Navit.map_points.get(destination_id).lon; show_geo_on_screen_with_zoom_and_delay(lat, lon, 150); } else { // ok now set target String dest_name = Navit.map_points.get(destination_id).point_name; float lat = Navit.map_points.get(destination_id).lat; float lon = Navit.map_points.get(destination_id).lon; // System.out.println("XXXXXX:" + lat + " " + lon); route_wrapper(dest_name, 0, 0, false, lat, lon, true); final Thread zoom_to_route_007 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_007.start(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); } break; case NavitSendFeedback_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { String feedback_text = data.getStringExtra("feedback_text"); String subject_d_version = ""; if (Navit_DonateVersion_Installed) { subject_d_version = subject_d_version + "D,"; } if (Navit_Largemap_DonateVersion_Installed) { subject_d_version = subject_d_version + "L,"; } try { int rl = get_reglevel(); if (rl > 0) { subject_d_version = "U" + rl + ","; } } catch (Exception e) { e.printStackTrace(); } String FD_addon = ""; if (FDBL) { FD_addon = ",FD"; } sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"), Toast.LENGTH_SHORT).show(); //TRANS } break; default: Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode); try { // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data); // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- } catch (Exception e) { e.printStackTrace(); } break; } Log.e("Navit", "onActivityResult finished"); }