@Override public void onOtherButtonClick(ActionSheet actionSheet, int index) { if (msgData == null) return; String picURL = ""; if (!TextUtils.isEmpty(msgData.getPic())) { picURL = Pub_HttpUtils.BASE_URL + msgData.getPic(); } if (index == 0) { // 海航圈 doShare( picURL, msgData.getTitle(), msgData.getId(), text.getText().toString(), url, "点击这里查看详情", "海航公众平台"); } else if (index == 1) { // 海航好友 String customshareInfoString = ShareUtil.getShareLinkParameters( url, msgData.getTitle(), text.getText().toString(), picURL); ShareUtil.gotoShare_UserListActivity( this, customshareInfoString, text.getText().toString(), msgData.getTitle(), picURL, false); } else if (index == 2) { // 微信朋友圈 senWechatReq(1, url, text.getText().toString(), msgData.getTitle(), picURL); } else if (index == 3) { // 微信好友 senWechatReq(0, url, text.getText().toString(), msgData.getTitle(), picURL); } }
@SuppressLint("SetJavaScriptEnabled") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.publics_webview); setVolumeControlStream(AudioManager.STREAM_MUSIC); try { if (getIntent().hasExtra("internal")) { isInternal = getIntent().getStringExtra("internal").equals("1"); } } catch (Exception e) { isInternal = false; } // 微信注册 api = WXAPIFactory.createWXAPI(this, appId, false); api.registerApp(appId); url = this.getIntent().getStringExtra("url"); String title = ""; if (getIntent().hasExtra("from")) { title = "历史消息"; if (getIntent().hasExtra("marker")) { title = getIntent().getStringExtra("marker"); // 来自工作圈跳转 // Social_WorkGroupListAdapter String id = getIntent().getStringExtra("id"); // 来自工作圈跳转 String pic = getIntent().getStringExtra("img"); String msgTitle = getIntent().getStringExtra("msgtitle"); String cnname = getIntent().getStringExtra("cnname"); if (pic.contains(Pub_HttpUtils.BASE_URL)) { pic = pic.replace(Pub_HttpUtils.BASE_URL, ""); } msgData = new Pub_MenuContent(); msgData.setId(id); msgData.setPic(pic); msgData.setTitle(msgTitle); msgData.setName(cnname); } } else { title = getIntent().getStringExtra("title"); if (getIntent().hasExtra("specialMsg")) { Pub_message msg = (Pub_message) getIntent().getSerializableExtra("specialMsg"); if (msg != null) { msgData = new Pub_MenuContent(); msgData.setId(msg.getId()); msgData.setPic(""); msgData.setTitle("网页链接"); msgData.setName(""); } } else if (getIntent().hasExtra("fromMenu")) { // 菜单跳转 msgData = new Pub_MenuContent(); msgData.setId("0x123"); msgData.setPic(""); msgData.setTitle("网页链接"); msgData.setName(""); } else { msgData = (Pub_MenuContent) getIntent().getSerializableExtra("msg"); } } text = (TextView) findViewById(R.id.textview_title); TextView share = (TextView) findViewById(R.id.shareBtn); text.setText(title); findViewById(R.id.button_left_1) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { IntentAnimUtil.backword(Pub_WebViewActivity.this); } }); if (title.equals("历史消息")) { share.setVisibility(View.GONE); } else { share.setVisibility(View.VISIBLE); share.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO 分享到工作圈 SharePopupWindow window = new SharePopupWindow(Pub_WebViewActivity.this); window.showAtLocation( findViewById(R.id.public_root_view), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); // ActionSheet.createBuilder(Pub_WebViewActivity.this, // getSupportFragmentManager()) // .setCancelButtonTitle("取 消") // .setOtherButtonTitles("分享到海航圈", "分享给好友" , "分享到微信朋友圈", // "分享给微信好友") // .setCancelableOnTouchOutside(true) // .setListener(Pub_WebViewActivity.this) // .show(); } }); } webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setBuiltInZoomControls(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setSupportZoom(true); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setDefaultTextEncodingName("UTF-8"); webview.setWebViewClient( new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { if (url.startsWith("hnairpublic")) { String user = url.substring(url.indexOf("=") + 1, url.length()); Intent intent = new Intent(Pub_WebViewActivity.this, Pub_OfficialAccountInfoActivity.class); intent.putExtra("user", user); IntentAnimUtil.startActivityWithSlideForward( Pub_WebViewActivity.this, intent, false); return true; } String fileClass = url.substring(url.lastIndexOf(".") + 1); if (fileClass.equalsIgnoreCase("apk")) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse(url); intent.setData(content_url); startActivity(intent); return true; } } catch (Exception e) { webview.loadUrl(url); return true; } webview.loadUrl(url); return true; } }); webview.loadUrl(url); }