2142 lines
69 KiB
Java
2142 lines
69 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
|
|
|
import static cn.shangyu.gdxzExpert.utils.Url.getNewWa;
|
|
|
|
import android.Manifest;
|
|
import android.app.Dialog;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.pm.ActivityInfo;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.graphics.Color;
|
|
import android.os.Build;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.GestureDetector;
|
|
import android.view.Gravity;
|
|
import android.view.KeyEvent;
|
|
import android.view.LayoutInflater;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.View.OnClickListener;
|
|
import android.view.View.OnLongClickListener;
|
|
import android.view.View.OnTouchListener;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup.LayoutParams;
|
|
import android.view.WindowManager;
|
|
import android.webkit.CookieManager;
|
|
import android.webkit.CookieSyncManager;
|
|
import android.webkit.JsResult;
|
|
import android.webkit.ValueCallback;
|
|
import android.webkit.WebChromeClient;
|
|
import android.webkit.WebSettings;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.Button;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.PopupWindow;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import com.github.dfqin.grantor.PermissionListener;
|
|
import com.github.dfqin.grantor.PermissionsUtil;
|
|
import com.google.gson.Gson;
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
import com.hjq.window.EasyWindow;
|
|
import com.lidroid.xutils.exception.HttpException;
|
|
import com.lidroid.xutils.http.RequestParams;
|
|
import com.lidroid.xutils.http.ResponseInfo;
|
|
import com.lidroid.xutils.http.callback.RequestCallBack;
|
|
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
|
|
import com.lidroid.xutils.util.LogUtils;
|
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
import com.nostra13.universalimageloader.core.assist.FailReason;
|
|
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
|
import com.umeng.socialize.UMShareAPI;
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.io.FileInputStream;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
import java.net.URLDecoder;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
import cn.shangyu.gdxzExpert.R;
|
|
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
|
import cn.shangyu.gdxzExpert.bean.TimestampBean;
|
|
import cn.shangyu.gdxzExpert.ecdemo.ECAsyncTask;
|
|
import cn.shangyu.gdxzExpert.ecdemo.RichTextBean;
|
|
import cn.shangyu.gdxzExpert.ecdemo.common.CCPAppManager;
|
|
import cn.shangyu.gdxzExpert.ecdemo.common.utils.BitmapUtil;
|
|
import cn.shangyu.gdxzExpert.ecdemo.ui.chatting.IMChattingHelper;
|
|
import cn.shangyu.gdxzExpert.ecdemo.ui.chatting.ViewImageInfo;
|
|
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
|
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
|
import cn.shangyu.gdxzExpert.report.CommUtil;
|
|
import cn.shangyu.gdxzExpert.report.reportBean;
|
|
import cn.shangyu.gdxzExpert.splash.WelcomeUI;
|
|
import cn.shangyu.gdxzExpert.ui.CustomProgressDialog;
|
|
import cn.shangyu.gdxzExpert.utils.Base64Util;
|
|
import cn.shangyu.gdxzExpert.utils.Constant;
|
|
import cn.shangyu.gdxzExpert.utils.DownLoadUrlImage;
|
|
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
|
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
|
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
|
import cn.shangyu.gdxzExpert.utils.ShareUtils;
|
|
import cn.shangyu.gdxzExpert.utils.SignUtil;
|
|
import cn.shangyu.gdxzExpert.utils.StreamTool;
|
|
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
|
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
|
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
|
import cn.shangyu.gdxzExpert.utils.UpdateVersionUtils;
|
|
import cn.shangyu.gdxzExpert.utils.Url;
|
|
import cn.shangyu.gdxzExpert.view.ItemLongClickedPopWindow;
|
|
import cn.shangyu.gdxzExpert.view.X5WebView;
|
|
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
|
import cn.shangyu.gdxzExpert.widget.ECListDialog;
|
|
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
|
|
|
|
|
/**
|
|
* 功能说明:
|
|
*
|
|
* @author 详细新闻页面 NewsDetailActivity
|
|
*/
|
|
|
|
public class NewsDetailActivity extends BaseActivity implements
|
|
OnTouchListener, OnClickListener, OnCallBackFromNet {
|
|
// private static final long serialVersionUID = 5952689219411916553L;
|
|
private String url;
|
|
private String title;
|
|
private X5WebView mWebView;
|
|
private TextView mTv_agree;
|
|
private TextView mTv_readNum;
|
|
private LinearLayout ll_agree;
|
|
private LinearLayout ll_share;
|
|
private WebSettings settings;
|
|
private String newsTitle = "";
|
|
private String summary = "";
|
|
private String imageUrl = "";
|
|
private ImageView mIv_agree;
|
|
private String isAgree;// 0未点赞1点赞
|
|
private int type = 0;// 新闻传值1,科普文章传值2
|
|
private String expertUuid;
|
|
private String bookUuid = "";
|
|
private String agreenum = "";
|
|
private String readnum = "";
|
|
private String booktitle = "";
|
|
private NewsDetailActivity ctx;
|
|
private View view;
|
|
private LinearLayout mLl_bottom;
|
|
private int noagree = 0;
|
|
private int agree = 0;
|
|
private Intent intent;
|
|
private LinearLayout ll_collect;
|
|
private String isCollection; // 是否收藏1收藏过 0为收藏
|
|
private String collpath = "";
|
|
private ImageView iv_collect;
|
|
private TextView tv_collect;
|
|
private GestureDetector gestureDetector;
|
|
private int downX, downY;
|
|
int flag =0;
|
|
private String hospital_uuid;
|
|
private String shareurl;
|
|
private String sharetitl;
|
|
private boolean isCollt = false;
|
|
private String isCollectiontitle;
|
|
private String isCollectionPath;
|
|
private int detailisAgree;
|
|
private String from;
|
|
private boolean need_back=false;
|
|
private FrameLayout video_fullView;// 全屏时视频加载view
|
|
private View xCustomView;
|
|
private WebChromeClient.CustomViewCallback xCustomViewCallback;
|
|
public void setitle1() {
|
|
// TODO Auto-generated method stub
|
|
intent = getIntent();
|
|
top_back_layout.setVisibility(View.VISIBLE);
|
|
top_right_text.setVisibility(View.GONE);
|
|
top_back_layout.setOnClickListener(new OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
|
|
if("专题e站".equals(title)||need_back)
|
|
{
|
|
if(mWebView!=null&&mWebView.canGoBack())
|
|
{
|
|
|
|
// finish();
|
|
mWebView.goBack();
|
|
}
|
|
else
|
|
{
|
|
finish();
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if ("WelcomeUI".equals(from)){
|
|
startActivity(new Intent(NewsDetailActivity.this, WelcomeUI.class));
|
|
}
|
|
finish();
|
|
}
|
|
|
|
}
|
|
});
|
|
flag = getIntent().getIntExtra("flag", 0);
|
|
// if(flag==0&&getIntent().getData()!=null)
|
|
// {
|
|
// try {
|
|
// int flags = Integer.valueOf(getIntent().getData().getQueryParameter("types"));
|
|
// switch (flags)
|
|
// {
|
|
// case 3:
|
|
// flag=3;
|
|
// break;
|
|
// case 4:
|
|
// flag=1;
|
|
// break;
|
|
// case 6:
|
|
// flag=10;
|
|
// break;
|
|
// case 8:
|
|
// flag=2;
|
|
// break;
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
//
|
|
// }
|
|
// }
|
|
if (flag == 1) {//含分享
|
|
top_right.setVisibility(View.VISIBLE);
|
|
top_right.setImageResource(R.drawable.share_icon);
|
|
top_right.setOnClickListener(this);
|
|
bookUuid = intent.getStringExtra("newsuuid");//首页新闻点击上报需要uuid,其他地方不需要,但是没做改动,不知道后续有没有影响
|
|
} else if (flag == 2) {// 科普
|
|
Constant.isShareGetPoint = true;
|
|
type = 2;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("kepuuuid");
|
|
agreenum = intent.getStringExtra("kepuagreenum");
|
|
readnum = intent.getStringExtra("kepureadnum");
|
|
// if(StringUtil.isEmpty(bookUuid)&&StringUtil.isEmpty(agreenum)&&StringUtil.isEmpty(readnum)&&getIntent().getData()!=null)
|
|
// {
|
|
// bookUuid=getIntent().getData().getQueryParameter("uuid");
|
|
// agreenum=getIntent().getData().getQueryParameter("agreenum");
|
|
// readnum=getIntent().getData().getQueryParameter("readnum");
|
|
// }
|
|
} else if (flag == 3) {// 新闻
|
|
Constant.isShareGetPoint = true;
|
|
type = 1;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("newsuuid");
|
|
agreenum = intent.getStringExtra("newsagreenum");
|
|
readnum = intent.getStringExtra("newsreadnum");
|
|
collpath = intent.getStringExtra("imageUrl");
|
|
// if(StringUtil.isEmpty(bookUuid)&&StringUtil.isEmpty(agreenum)&&StringUtil.isEmpty(readnum)&&StringUtil.isEmpty(collpath)&&getIntent().getData()!=null)
|
|
// {
|
|
// bookUuid=getIntent().getData().getQueryParameter("uuid");
|
|
// agreenum=getIntent().getData().getQueryParameter("agreenum");
|
|
// readnum=getIntent().getData().getQueryParameter("readnum");
|
|
// collpath=Url.urlHtml+getIntent().getData().getQueryParameter("headImg");
|
|
// }
|
|
} else if (flag == 4) {// 新闻轮播图
|
|
type = 1;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("newssuuuid");
|
|
agreenum = intent.getStringExtra("newssagreenum");
|
|
readnum = intent.getStringExtra("newssreadnum");
|
|
collpath = intent.getStringExtra("imageUrl");
|
|
} else if (flag == 5) {// 首页轮播图
|
|
type = 1;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("newsfsuuuid");
|
|
agreenum = intent.getStringExtra("newsfagreenum");
|
|
readnum = intent.getStringExtra("newsfreadnum");
|
|
} else if (flag == 6) {// 经典病例列表
|
|
type = 3;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("nfsuuuid");
|
|
agreenum = intent.getStringExtra("nfagreenum");
|
|
readnum = intent.getStringExtra("nfreadnum");
|
|
collpath = intent.getStringExtra("npath");
|
|
booktitle = intent.getStringExtra("collect");
|
|
} else if (flag == 7) {// 病历收藏跳过来的
|
|
type = 3;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("other_uuid");
|
|
agreenum = intent.getStringExtra("agreenum");
|
|
readnum = intent.getStringExtra("readnum");
|
|
collpath = intent.getStringExtra("path");
|
|
booktitle = intent.getStringExtra("collection");
|
|
} else if (flag == 8) {
|
|
int isExpert = intent.getIntExtra("isExpert", 0);
|
|
if (isExpert == 1) {
|
|
top_right.setVisibility(View.VISIBLE);
|
|
top_right.setImageResource(R.drawable.icon_contributing);
|
|
top_right.setOnClickListener(this);
|
|
hospital_uuid = intent.getStringExtra("hospital_uuid");
|
|
}
|
|
}else if (flag == 9) {//更多动态
|
|
mLl_bottom.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}else if (flag == 10){//病例荟萃ShareCaseFragment
|
|
type = 7;
|
|
mLl_bottom.setVisibility(View.VISIBLE);
|
|
ll_collect.setVisibility(View.VISIBLE);
|
|
tv_collect.setVisibility(View.VISIBLE);
|
|
bookUuid = intent.getStringExtra("nfsuuuid");
|
|
agreenum = intent.getStringExtra("nfagreenum");
|
|
readnum = intent.getStringExtra("nfreadnum");
|
|
collpath = intent.getStringExtra("npath");
|
|
booktitle = intent.getStringExtra("collect");
|
|
// if(StringUtil.isEmpty(bookUuid)&&StringUtil.isEmpty(agreenum)&&StringUtil.isEmpty(readnum)&&
|
|
// StringUtil.isEmpty(collpath)&&StringUtil.isEmpty(booktitle)&&getIntent().getData()!=null)
|
|
// {
|
|
// bookUuid=getIntent().getData().getQueryParameter("uuid");
|
|
// agreenum=getIntent().getData().getQueryParameter("agreeNum");
|
|
// readnum=getIntent().getData().getQueryParameter("readNum");
|
|
// collpath=getIntent().getData().getQueryParameter("path");
|
|
// booktitle = getIntent().getData().getQueryParameter("title");
|
|
// }
|
|
}
|
|
if (!"".equals(agreenum)) {
|
|
mTv_agree.setText(agreenum);
|
|
} else {
|
|
mTv_agree.setText("0");
|
|
}
|
|
if (!"".equals(readnum)) {
|
|
mTv_readNum.setText(readnum);
|
|
} else {
|
|
mTv_readNum.setText("1");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public View onCreateSuccessedView() {
|
|
// if (!UIUtils.isLogined())
|
|
// {
|
|
// Intent intent = new Intent();
|
|
// intent.setClass(this, LoginNewActivity.class);
|
|
// startActivity(intent);
|
|
// finish();
|
|
// return null;
|
|
// }
|
|
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
|
view = UIUtils.inflate(R.layout.activity_news_detail);
|
|
X5WebView.initHardwareAccelerate(this);
|
|
mWebView = view.findViewById(R.id.news_detail_wv);
|
|
ctx = this;
|
|
expertUuid = SharePrefUtil.getString(ct, "uuid", "");
|
|
|
|
mLl_bottom = (LinearLayout) view.findViewById(R.id.ll_bottom);
|
|
ll_collect = (LinearLayout) view.findViewById(R.id.ll_collect);
|
|
ll_collect.setOnClickListener(this);
|
|
ll_agree = (LinearLayout) view.findViewById(R.id.ll_agree);// 点赞
|
|
ll_share = (LinearLayout) view.findViewById(R.id.ll_share);// 分享
|
|
ll_agree.setOnClickListener(this);
|
|
ll_share.setOnClickListener(this);
|
|
loadingView = view.findViewById(R.id.loading_view);
|
|
loadfailView = (LinearLayout) view.findViewById(R.id.ll_load_fail);
|
|
mTv_agree = (TextView) view.findViewById(R.id.tv_agree);// 点赞
|
|
mTv_readNum = (TextView) view.findViewById(R.id.tv_readNum);// 显示 阅读量
|
|
mIv_agree = (ImageView) view.findViewById(R.id.iv_agree);// 显示 阅读量
|
|
iv_collect = (ImageView) view.findViewById(R.id.iv_collect);//
|
|
tv_collect = (TextView) view.findViewById(R.id.tv_collect);//
|
|
video_fullView = view.findViewById(R.id.f_move);
|
|
// video_fullView.setKeepScreenOn(true); //确保屏幕长亮
|
|
|
|
ll_agree.setOnClickListener(this);
|
|
setitle1();
|
|
requestIsAgree();
|
|
showLoadingView();
|
|
initData();
|
|
if(flag==6)
|
|
{
|
|
AddNewsDetails();
|
|
}
|
|
else
|
|
{
|
|
AddNewsDetail();
|
|
}
|
|
|
|
return view;
|
|
}
|
|
|
|
//能否解决部分手机WebView崩溃
|
|
// @Override
|
|
// public AssetManager getAssets() {
|
|
// return getResources().getAssets();
|
|
// }
|
|
String finalUrl ="";
|
|
private void AddNewsDetail() {
|
|
String url = null;
|
|
if (flag == 2){
|
|
url = Url.getKePuCollection;
|
|
}else if (flag == 10){
|
|
url = Url.caseDetial;
|
|
}else {
|
|
if(!StringUtil.isEmpty(getIntent().getStringExtra("kepuuuid")))
|
|
{
|
|
url = Url.getKePuCollection;
|
|
bookUuid=getIntent().getStringExtra("kepuuuid");//从聊天页面进入科普,然后上报画像系统
|
|
}
|
|
else
|
|
{
|
|
url = Url.newsDetial;
|
|
}
|
|
|
|
}
|
|
// 提取专家uuid
|
|
RequestParams params = new RequestParams();// 封装参数
|
|
params.addBodyParameter("user_uuid", expertUuid);// 传专家uuid
|
|
params.addBodyParameter("uuid", bookUuid);
|
|
// params.addBodyParameter("type", String.valueOf(1));
|
|
LogUtil.i("user_uuid = "+expertUuid);
|
|
LogUtil.i("uuid = "+bookUuid);
|
|
|
|
|
|
|
|
|
|
finalUrl = url;
|
|
HttpHelper.loadData(HttpMethod.POST,url, params,
|
|
new RequestCallBack<String>() {
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
processData(info.result);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
LogUtil.i("数据请求失败了: " + arg1);
|
|
// onLoaded();
|
|
// ptrLv.setEmptyView(load_empty);
|
|
}
|
|
});
|
|
// Map<String, String> param = new HashMap<String, String>();
|
|
// param.put("user_uuid", expertUuid);
|
|
// param.put("uuid", bookUuid);
|
|
// sendParamtoNet(Url.newsDetial, param, NEWS_DETAIL, ctx, false);
|
|
}
|
|
private void AddNewsDetails() {
|
|
Map<String, String> param = new HashMap<String, String>();
|
|
param.put("uuid", bookUuid);
|
|
sendJsonPostParamtoNetSignMD5(Url.medicalRecordShareDetail, param, 101, this
|
|
);
|
|
}
|
|
private String gettag="";
|
|
public void processData(String result) {
|
|
LogUtil.i("新闻详情msg = "+result);
|
|
// String code = null;
|
|
// String message = null;
|
|
// "isAgree": 0,
|
|
// "code": "1",
|
|
// "isCollection": 0,
|
|
// String isAgree=null;
|
|
int isCollection = 0;
|
|
JSONObject jsonObject = null;
|
|
JSONArray jsonArray = null;
|
|
try {
|
|
|
|
jsonObject = new JSONObject(result);
|
|
// code = jsonObject.getString("code");
|
|
// message = jsonObject.getString("message");
|
|
isCollection = jsonObject.optInt("isCollection");
|
|
isCollectionPath = jsonObject.optString("path");
|
|
isCollectiontitle = jsonObject.optString("title");
|
|
detailisAgree = jsonObject.optInt("isAgree",2);
|
|
int agreenum = jsonObject.optInt("agreenum");
|
|
mTv_agree.setText(agreenum+"");
|
|
if(flag==3||flag==2||flag==10||flag==6)
|
|
{
|
|
readnum=jsonObject.optString("readnum");
|
|
mTv_readNum.setText(readnum);
|
|
}
|
|
|
|
if (StringUtil.isEmpty(isCollectionPath)){
|
|
isCollectionPath = url.replace(Url.urlHtml,"");
|
|
isCollectiontitle = newsTitle;
|
|
collpath = imageUrl;
|
|
}
|
|
if (detailisAgree==0){
|
|
isAgree = "0";
|
|
mIv_agree.setImageResource(R.drawable.argee_no);
|
|
noagree = agreenum;
|
|
agree = noagree + 1;
|
|
|
|
}else if (detailisAgree==1){
|
|
isAgree = "1";
|
|
agree = agreenum;
|
|
noagree = agree - 1;
|
|
mIv_agree.setImageResource(R.drawable.argee_sure);
|
|
|
|
}
|
|
if (isCollection==1) {
|
|
LogUtil.i("新闻详情isCollection = "+isCollection);
|
|
isCollt = true;
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_sel);
|
|
} else {
|
|
isCollt = false;
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_nor);
|
|
}
|
|
if(url.contains("outpatient_details")||url.contains("wxPatient/index.htm#/outPatient")||url.contains(getNewWa)
|
|
|| "动态详情".equals(top_title.getText()))
|
|
{
|
|
//门诊不用上报画像系统
|
|
}
|
|
else if(Url.getKePuCollection.equals(finalUrl))
|
|
{
|
|
gettag=jsonObject.optString("tags");
|
|
needreportDetail("患教文库",gettag ,isCollectiontitle);
|
|
}
|
|
else if(Url.newsDetial.equals(finalUrl))
|
|
{
|
|
gettag=jsonObject.optString("tags");
|
|
needreportDetail("肝胆新闻",gettag,isCollectiontitle);
|
|
}
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
// public void getimageUrl(){
|
|
// Resources r =
|
|
// NewsDetailActivity.this.getApplicationContext().getResources();
|
|
// Uri uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
|
|
// + r.getResourcePackageName(R.drawable.default_news_iv) + "/"
|
|
// + r.getResourceTypeName(R.drawable.default_news_iv) + "/"
|
|
// + r.getResourceEntryName(R.drawable.default_news_iv));
|
|
// String headLineString =
|
|
// getAbsoluteImagePath(NewsDetailActivity.this.getApplicationContext()
|
|
// ,uri);
|
|
// }
|
|
@Override
|
|
public ResultState onLoad() {
|
|
return ResultState.STATE_SUCCESSED;
|
|
}
|
|
|
|
private void initData() {
|
|
url = getIntent().getStringExtra("url");
|
|
title = getIntent().getStringExtra("title");
|
|
// if(StringUtil.isEmpty(url)&&StringUtil.isEmpty(title)&&getIntent().getData()!=null)
|
|
// {
|
|
// url = Url.urlHtml+getIntent().getData().getQueryParameter("path");
|
|
// switch (flag)
|
|
// {
|
|
// case 3:
|
|
// title="新闻详情";
|
|
// break;
|
|
// case 1:
|
|
// title="科研详情";
|
|
// break;
|
|
// case 10:
|
|
// title="病例详情";
|
|
// break;
|
|
// case 2:
|
|
// title="患教详情";
|
|
// break;
|
|
// }
|
|
//// title = getIntent().getData().getQueryParameter("title");
|
|
// }
|
|
from = getIntent().getStringExtra("from");
|
|
need_back=getIntent().getBooleanExtra("need_back",false);
|
|
if(StringUtil.isEmpty(title))
|
|
title="";
|
|
LogUtil.e("url = "+url);
|
|
// url = "http://www.hep-druginteractions.org/checker";
|
|
if(title.equals("患教详情")){
|
|
String need_inside_share=getIntent().getStringExtra("need_inside_share");
|
|
if(StringUtil.isEmpty(need_inside_share))
|
|
{
|
|
top_right_text.setVisibility(View.GONE);
|
|
top_right_text.setText("推荐");
|
|
top_right_text.setOnClickListener(this);
|
|
}
|
|
|
|
// inside_share.setVisibility(View.VISIBLE);
|
|
// inside_share.setOnClickListener(this);
|
|
}
|
|
newsTitle = getIntent().getStringExtra("newsTitle");// 新闻的标题
|
|
// if(StringUtil.isEmpty(newsTitle)&&getIntent().getData()!=null)
|
|
// {
|
|
// if(flag==1)
|
|
// {
|
|
// newsTitle = getIntent().getData().getQueryParameter("projectName");
|
|
// }
|
|
// else if(flag==2)
|
|
// {
|
|
// newsTitle = getIntent().getData().getQueryParameter("topic");
|
|
// }
|
|
// else
|
|
// {
|
|
// newsTitle = getIntent().getData().getQueryParameter("title");
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
summary = getIntent().getStringExtra("summary");// 新闻的摘要
|
|
// if(StringUtil.isEmpty(summary)&&getIntent().getData()!=null)
|
|
// {
|
|
// if(flag==1)
|
|
// {
|
|
// summary = getIntent().getData().getQueryParameter("content");
|
|
// }
|
|
// else
|
|
// {
|
|
// summary = getIntent().getData().getQueryParameter("summary");
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
if (type == 1 && StringUtil.isEmpty(summary)) {
|
|
summary = "新鲜资讯,一触即达";
|
|
}
|
|
imageUrl = getIntent().getStringExtra("imageUrl");// 新闻的图的地址
|
|
// if(StringUtil.isEmpty(imageUrl)&&getIntent().getData()!=null)
|
|
// {
|
|
// if(flag==1)
|
|
// {
|
|
// imageUrl = Url.urlHtml+getIntent().getData().getQueryParameter("imgs");
|
|
// }
|
|
// else if(flag==2)
|
|
// {
|
|
// imageUrl = Url.urlHtml+getIntent().getData().getQueryParameter("imgPath");
|
|
// }
|
|
// else
|
|
// {
|
|
// imageUrl = Url.urlHtml+getIntent().getData().getQueryParameter("headImg");
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
// if(StringUtil.isEmpty(url)&&StringUtil.isEmpty(title)&&getIntent().getData()!=null)
|
|
// {
|
|
// url = Url.urlHtml+getIntent().getData().getQueryParameter("path");
|
|
// title = getIntent().getData().getQueryParameter("title");
|
|
// }
|
|
if (!TextUtils.isEmpty(title)) {
|
|
if (title.length() > 13) {
|
|
String concat = title.substring(0, 13).concat("...");
|
|
top_title.setText(concat);
|
|
} else {
|
|
top_title.setText(title);
|
|
}
|
|
} else {
|
|
top_title.setText("新闻详情");
|
|
}
|
|
// mWebView.setOnTouchListener(this);
|
|
gestureDetector = new GestureDetector(this,
|
|
new GestureDetector.SimpleOnGestureListener() {
|
|
@Override
|
|
public void onLongPress(MotionEvent e) {
|
|
downX = (int) e.getX();
|
|
downY = (int) e.getY();
|
|
}
|
|
});
|
|
dealNewsDetail();
|
|
}
|
|
|
|
public void loadurl(final WebView view, final String url) {
|
|
LogUtil.i("真实url = "+url);
|
|
view.loadUrl(url);
|
|
}
|
|
|
|
|
|
private void dealNewsDetail() {
|
|
|
|
|
|
settings = mWebView.getSettings();
|
|
// mWebView.setInitialScale(25);
|
|
if(title.equals("专题e站")){
|
|
settings.setBuiltInZoomControls(true);
|
|
settings.setDisplayZoomControls(false);
|
|
|
|
}
|
|
|
|
// // 设置 缓存模式
|
|
// settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
|
// // settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
// // 开启 DOM storage API 功能
|
|
// settings.setDomStorageEnabled(true);
|
|
// // 开启 database storage API 功能
|
|
// settings.setDatabaseEnabled(true);
|
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
// settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
// }
|
|
|
|
// settings.setJavaScriptEnabled(true);// 启用javascript脚本
|
|
// settings.setJavaScriptCanOpenWindowsAutomatically(true);// 支持通过JS打开新窗口
|
|
String ua = settings.getUserAgentString();
|
|
settings.setUserAgentString(ua + ";GdxzAndroidExpertApp");
|
|
if(url.contains(Url.getNewWa))
|
|
{
|
|
settings.setUserAgentString(ua + "gdxz-expert");
|
|
}
|
|
// settings.setLoadWithOverviewMode(true);
|
|
// settings.setUseWideViewPort(true);
|
|
// settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
|
|
// settings.setSupportZoom(true);
|
|
// settings.setBuiltInZoomControls(true);
|
|
|
|
if (!StringUtil.isEmpty(getIntent().getStringExtra("homemodal")))
|
|
{
|
|
mWebView.getSettings().setBlockNetworkImage(false);
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
|
|
mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
mWebView.getSettings().setBlockNetworkImage(true);
|
|
}
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
mWebView.getSettings().setMixedContentMode(
|
|
WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
|
}
|
|
|
|
mWebView.setWebViewClient(new WebViewClient() {
|
|
|
|
|
|
@Override
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
if("专题e站".equals(title)||need_back)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
loadurl(view, url);
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
LogUtil.i("onPageStarted", "onPageStarted" + url);
|
|
loadingView.setVisibility(View.VISIBLE);
|
|
super.onPageStarted(view, url, favicon);
|
|
}
|
|
|
|
@Override
|
|
public void onPageFinished(final WebView view, String url) {
|
|
// TODO Auto-generated method stub
|
|
dismissLoadingView();
|
|
|
|
|
|
// mWebView.loadUrl("javascript:accessSource('" + "app" + "')");
|
|
// mWebView.post(new Runnable() {
|
|
// @Override
|
|
// public void run() {
|
|
|
|
if (!StringUtil.isEmpty(getIntent().getStringExtra("homemodal")))
|
|
{
|
|
//
|
|
mWebView.evaluateJavascript("accessSource('" + "app" + "')", new ValueCallback<String>() {
|
|
@Override
|
|
public void onReceiveValue(String value) {
|
|
|
|
}
|
|
});
|
|
// view.loadUrl("javascript:(function() { " +
|
|
// "var videos = document.getElementsByTagName('audio');" +
|
|
// " for(var i=0;i<videos.length;i++){videos[i].play();}})()");
|
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
//
|
|
// mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
|
//
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
// if(flag==3||flag==1||flag==10||flag==2) {
|
|
// mWebView.evaluateJavascript("accessSource('" + "app" + "')", new ValueCallback<String>() {
|
|
// @Override
|
|
// public void onReceiveValue(String value) {
|
|
//
|
|
// }
|
|
// });
|
|
// }
|
|
|
|
mWebView.getSettings().setBlockNetworkImage(false);
|
|
}
|
|
// }
|
|
// });
|
|
|
|
|
|
|
|
if (url.contains("#") && type != 3 && url.contains(Url.urlHtml)) {
|
|
String keyWord = url.substring(url.indexOf("#") + 1);
|
|
try {
|
|
String output = URLDecoder.decode(keyWord, "UTF-8");
|
|
Intent intent = new Intent(ctx, KeyWordActivity.class);
|
|
intent.putExtra("keyword", output);
|
|
intent.setType(type + "");
|
|
startActivity(intent);
|
|
} catch (UnsupportedEncodingException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
String urlEnd = url;
|
|
if (url.contains(Url.urlHtml)) {
|
|
urlEnd = url.split(Url.urlHtml)[1];
|
|
}
|
|
if (url.isEmpty() || url.length() <= Url.urlHtml.length()
|
|
|| StringUtil.isEmpty(urlEnd)) {
|
|
if(!url.equals("http://www.igandan.com/")&&!url.equals("http://www.igandan.com"))
|
|
loadurl(view, "file:///android_asset/error/error.html");
|
|
}
|
|
// if ("乙路前行".equals(top_title.getText())||"谈丙话肝".equals(top_title.getText())||"常见问题".equals(top_title.getText())) {
|
|
// shareurl = url;
|
|
// sharetitl = view.getTitle();
|
|
// }
|
|
if ("乙路前行".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = "乙路前行—一路有你 一起前行";
|
|
}else if ("谈丙话肝".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = "谈丙话肝";
|
|
}else if ("常见问题".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = "肝病常见问题权威答";
|
|
}else if("病例大赛".equals(top_title.getText())){
|
|
shareurl = url;
|
|
sharetitl = "第三届利肝中国行病例大赛";
|
|
}else if ("知识大赛".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = "全国青年医师肝病知识大赛";
|
|
}else if ("肝胆医院".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = view.getTitle();
|
|
}else if ("动态详情".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = view.getTitle();
|
|
}else if ("肝愿为你".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = view.getTitle();
|
|
}else if ("080中国研究".equals(top_title.getText())) {
|
|
shareurl = url;
|
|
sharetitl = view.getTitle();
|
|
}
|
|
else if("专题e站".equals(top_title.getText()))
|
|
{
|
|
shareurl = url;
|
|
sharetitl = view.getTitle();
|
|
}
|
|
super.onPageFinished(view, url);
|
|
}
|
|
|
|
|
|
@Override
|
|
public void onReceivedError(WebView view, int errorCode,
|
|
String description, String failingUrl) {
|
|
dismissLoadingView();
|
|
LogUtil.i("onReceivedError", "onReceivedError" + failingUrl
|
|
+ errorCode + description);
|
|
loadurl(view, "file:///android_asset/error/error.html");
|
|
super.onReceivedError(view, errorCode, description, failingUrl);
|
|
}
|
|
});
|
|
mWebView.setWebChromeClient(new WebChromeClient(){
|
|
@Override
|
|
public void onReceivedTitle(WebView view, String title1) {
|
|
super.onReceivedTitle(view, title1);
|
|
if (!StringUtil.isEmpty(getIntent().getStringExtra("homemodal")))
|
|
title =title1;
|
|
top_title.setText(title);
|
|
|
|
}
|
|
|
|
@Override
|
|
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
|
|
ECAlertDialog buildAlert = ECAlertDialog.buildAlert(NewsDetailActivity.this, message, "取消",
|
|
"确定", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog,
|
|
int which) {
|
|
// TODO Auto-generated method stub
|
|
result.cancel();
|
|
|
|
}
|
|
}, new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog,
|
|
int which) {
|
|
result.confirm();
|
|
}
|
|
});
|
|
buildAlert.setTitle("温馨提示");
|
|
buildAlert.setTitleColor(getResources().getColor(
|
|
R.color.top_title));
|
|
buildAlert.show();
|
|
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void onShowCustomView(View view, CustomViewCallback callback) {
|
|
// super.onShowCustomView(view, callback);
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
mWebView.setVisibility(View.GONE);
|
|
layout_top.setVisibility(View.GONE);
|
|
mToolbar.setBackgroundColor(Color.BLACK);
|
|
|
|
// 如果一个视图已经存在,那么立刻终止并新建一个
|
|
if (xCustomView != null) {
|
|
callback.onCustomViewHidden();
|
|
return;
|
|
}
|
|
xCustomView = view;
|
|
xCustomViewCallback = callback;
|
|
video_fullView.addView(view);
|
|
|
|
video_fullView.setVisibility(View.VISIBLE);
|
|
|
|
setFullScreen();
|
|
}
|
|
|
|
@Override
|
|
public void onHideCustomView() {
|
|
// super.onHideCustomView();
|
|
mToolbar.setBackgroundColor(getResources().getColor(R.color.top_bg));
|
|
layout_top.setVisibility(View.VISIBLE);
|
|
if (xCustomView == null)// 不是全屏播放状态
|
|
return;
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
xCustomView.setVisibility(View.GONE);
|
|
video_fullView.removeView(xCustomView);
|
|
xCustomView = null;
|
|
video_fullView.setVisibility(View.GONE);
|
|
xCustomViewCallback.onCustomViewHidden();
|
|
mWebView.setVisibility(View.VISIBLE);
|
|
quitFullScreen();
|
|
}
|
|
});
|
|
// intent = getIntent();
|
|
// content = intent.getStringExtra("content");
|
|
// mWebView.loadUrl(Url.urlHtml+content);
|
|
// mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
|
|
|
mWebView.setOnLongClickListener(new OnLongClickListener() {
|
|
|
|
@Override
|
|
public boolean onLongClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
WebView.HitTestResult result = ((WebView) v).getHitTestResult();
|
|
|
|
if (null == result)
|
|
return false;
|
|
int type = result.getType();
|
|
final String imgurl = result.getExtra();
|
|
final ItemLongClickedPopWindow itemLongClickedPopWindow = new ItemLongClickedPopWindow(
|
|
NewsDetailActivity.this,
|
|
ItemLongClickedPopWindow.IMAGE_VIEW_POPUPWINDOW,
|
|
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
|
if (type == 0) {
|
|
return false;
|
|
}
|
|
switch (type) {
|
|
case WebView.HitTestResult.PHONE_TYPE: // 处理拨号
|
|
break;
|
|
case WebView.HitTestResult.EMAIL_TYPE: // 处理Email
|
|
break;
|
|
case WebView.HitTestResult.GEO_TYPE: // TODO
|
|
break;
|
|
case WebView.HitTestResult.SRC_ANCHOR_TYPE: // 超链接
|
|
// Log.d(DEG_TAG, "超链接");
|
|
break;
|
|
case WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE:
|
|
break;
|
|
case WebView.HitTestResult.IMAGE_TYPE: // 处理长按图片的菜单项
|
|
// 通过GestureDetector获取按下的位置,来定位PopWindow显示的位置
|
|
itemLongClickedPopWindow.showAtLocation(
|
|
findViewById(R.id.ll_bottom), Gravity.BOTTOM
|
|
| Gravity.CENTER_HORIZONTAL, 0, 0);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
itemLongClickedPopWindow.getView(
|
|
R.id.item_longclicked_lookImage).setOnClickListener(
|
|
new OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// 取消
|
|
itemLongClickedPopWindow.dismiss();
|
|
ArrayList<ViewImageInfo> urls = new ArrayList<ViewImageInfo>();
|
|
urls.add(new ViewImageInfo(0, imgurl, imgurl));
|
|
CCPAppManager.startChattingImageViewAction(ct,
|
|
0, urls, true);
|
|
}
|
|
});
|
|
itemLongClickedPopWindow.getView(
|
|
R.id.item_longclicked_viewImage).setOnClickListener(
|
|
new OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// 取消
|
|
itemLongClickedPopWindow.dismiss();
|
|
}
|
|
});
|
|
itemLongClickedPopWindow.getView(
|
|
R.id.item_longclicked_saveImage).setOnClickListener(
|
|
new OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// 下载
|
|
itemLongClickedPopWindow.dismiss();
|
|
// 点击图片后将图片保存到SD卡跟目录下的Test文件夹内
|
|
// DownLoadUrlImage 使用应用私有目录,Android 13+ 不需要存储权限
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
boolean needsPermission = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU;
|
|
boolean hasPermission = true;
|
|
|
|
if (needsPermission) {
|
|
// Android 12及以下需要存储权限(用于保存到 MediaStore)
|
|
hasPermission = PermissionsUtil.hasPermission(NewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
}
|
|
// Android 13+ 保存到应用私有目录不需要权限
|
|
|
|
if (hasPermission) {
|
|
new DownLoadUrlImage(imgurl, ctx);
|
|
Toast.makeText(getBaseContext(), "图片保存",
|
|
Toast.LENGTH_SHORT).show();
|
|
}
|
|
else
|
|
{
|
|
EasyWindow.with(NewsDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
|
|
|
.setContentView(R.layout.float_top_dialog_download).show();
|
|
PermissionsUtil.requestPermission(NewsDetailActivity.this, new PermissionListener() {
|
|
@Override
|
|
public void permissionGranted(@NonNull String[] permissions) {
|
|
EasyWindow.cancelAll();
|
|
new DownLoadUrlImage(imgurl, ctx);
|
|
Toast.makeText(getBaseContext(), "图片保存",
|
|
Toast.LENGTH_SHORT).show();
|
|
}
|
|
@Override
|
|
public void permissionDenied(@NonNull String[] permissions) {
|
|
EasyWindow.cancelAll();
|
|
//用户拒绝了访问读写的申请
|
|
//
|
|
}
|
|
|
|
}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE});
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
new DownLoadUrlImage(imgurl, ctx);
|
|
Toast.makeText(getBaseContext(), "图片保存",
|
|
Toast.LENGTH_SHORT).show();
|
|
}
|
|
|
|
}
|
|
});
|
|
return true;
|
|
}
|
|
});
|
|
if(url.contains(Url.modernHepatology+"/modernHepatology")||url.contains("modernHepatology"))
|
|
{
|
|
setCookie();
|
|
// CommonUtil.setCookie(url);
|
|
}
|
|
loadurl(mWebView, url);
|
|
}
|
|
|
|
|
|
/**
|
|
* 退出全屏
|
|
*/
|
|
private void quitFullScreen() {
|
|
// 声明当前屏幕状态的参数并获取
|
|
final WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
|
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
getWindow().setAttributes(attrs);
|
|
getWindow()
|
|
.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
|
}
|
|
/**
|
|
* 设置全屏
|
|
*/
|
|
private void setFullScreen() {
|
|
// 设置全屏的相关属性,获取当前的屏幕状态,然后设置全屏
|
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
// 全屏下的状态码:1098974464
|
|
// 窗口下的状态吗:1098973440
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void onResume() {
|
|
super.onResume();
|
|
// if("专题e站".equals(getIntent().getStringExtra("title")))
|
|
// {
|
|
// needreportPage("专题e站");
|
|
// }
|
|
// webView.resumeTimers();
|
|
try {
|
|
if (mWebView != null) {
|
|
mWebView.getClass().getMethod("onResume")
|
|
.invoke(mWebView, (Object[]) null);
|
|
mWebView.onResume();
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onPause() {
|
|
super.onPause();
|
|
|
|
// webView.pauseTimers();
|
|
try {
|
|
if (mWebView != null) {
|
|
mWebView.onPause();
|
|
mWebView.getClass().getMethod("onPause")
|
|
.invoke(mWebView, (Object[]) null);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
protected void processClick(View v) {
|
|
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
|
int id = v.getId();
|
|
if (id == R.id.top_right_text) {
|
|
//分享功能换成分享到容联
|
|
delVisit();
|
|
// case R.id.inside_share:
|
|
// //分享功能换成分享到容联
|
|
// delVisit();
|
|
// break;
|
|
} else if (id == R.id.top_back_layout) {
|
|
// Intent intentCollection = new Intent();
|
|
// intentCollection.putExtra("uuid", bookUuid);
|
|
// intentCollection.putExtra("isCollection", isCollt);
|
|
// setResult(112, intentCollection);
|
|
if ("WelcomeUI".equals(from)){
|
|
startActivity(new Intent(NewsDetailActivity.this, WelcomeUI.class));
|
|
}
|
|
finish();
|
|
} else if (id == R.id.top_right) {
|
|
if (flag == 8) {
|
|
Intent intent = new Intent(ctx, AddProclamationActivity.class);
|
|
intent.putExtra("hospital_uuid", hospital_uuid);
|
|
ctx.startActivity(intent);
|
|
} else {
|
|
if(title.equals("患教详情"))
|
|
{
|
|
showSharePopupWindow(view);// 调用分享
|
|
}else
|
|
{
|
|
share();// 调用分享
|
|
}
|
|
|
|
|
|
}
|
|
} else if (id == R.id.ll_collect) {
|
|
// 调用收藏
|
|
if (isCollection != null) {
|
|
if (flag==3||flag==4){//新闻
|
|
if (!isCollt){
|
|
//收藏
|
|
AddCollection(1);
|
|
}else {
|
|
DisCollection(1);
|
|
//取消收藏
|
|
}
|
|
}else if (flag==2){
|
|
if (!isCollt){
|
|
//收藏
|
|
AddCollection(2);
|
|
}else {
|
|
DisCollection(2);
|
|
//取消收藏
|
|
}
|
|
}else if (flag==10){//病例荟萃
|
|
if (!isCollt){
|
|
//收藏
|
|
AddCollection(7);
|
|
}else {
|
|
DisCollection(7);
|
|
//取消收藏
|
|
}
|
|
}else if (!isCollection.equals("1")) {
|
|
CollectListSure(3);
|
|
// 收藏
|
|
} else {
|
|
// 取消收藏
|
|
CollectListDis(3);
|
|
}
|
|
}
|
|
} else if (id == R.id.ll_agree) {
|
|
if (isAgree != null) {
|
|
LogUtil.i("isAgree = "+isAgree);
|
|
if (!isAgree.equals("1")) {
|
|
// 点赞
|
|
requestToAgree();
|
|
if(title.equals("患教详情")||title.equals("新闻详情"))
|
|
{
|
|
if(title.equals("患教详情"))
|
|
{
|
|
needreportSome("like",newsTitle,gettag+"","患教文库");
|
|
}
|
|
else
|
|
{
|
|
needreportSome("like",newsTitle,gettag+"","肝胆新闻");
|
|
}
|
|
|
|
}
|
|
} else {
|
|
// 取消点赞
|
|
requestDissAgree();
|
|
}
|
|
}
|
|
} else if (id == R.id.ll_share) {
|
|
if(title.equals("患教详情"))
|
|
{
|
|
showSharePopupWindow(view);// 调用分享
|
|
}else
|
|
{
|
|
share();// 调用分享
|
|
}
|
|
if(title.equals("患教详情")||title.equals("新闻详情"))
|
|
{
|
|
if(title.equals("患教详情"))
|
|
{
|
|
needreportSome("share",newsTitle,gettag+"","患教文库");
|
|
}
|
|
else
|
|
{
|
|
needreportSome("share",newsTitle,gettag+"","肝胆新闻");
|
|
}
|
|
|
|
}
|
|
// share();
|
|
// showSharePopupWindow(view);
|
|
|
|
// list = PatientSqlManager.getPatientInfoList(Constant.typePatient);
|
|
// new ParseHtmlTask(UIUtils.getContext()).execute();
|
|
}
|
|
}
|
|
private void showSharePopupWindow(View view) {
|
|
|
|
// 一个自定义的布局,作为显示的内容
|
|
View contentView = LayoutInflater.from(this)
|
|
.inflate(R.layout.popu_share_video, null);
|
|
LinearLayout ll_huan = contentView.findViewById(R.id.ll_huan);
|
|
LinearLayout ll_weixin = contentView.findViewById(R.id.ll_weixin);
|
|
LinearLayout ll_weixincircle = contentView.findViewById(R.id.ll_weixincircle);
|
|
LinearLayout ll_sina = contentView.findViewById(R.id.ll_sina);
|
|
Button btn_quxiao = contentView.findViewById(R.id.btn_quxiao);
|
|
|
|
final PopupWindow popupWindow = new PopupWindow(contentView,
|
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
|
|
btn_quxiao.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
popupWindow.dismiss();
|
|
}
|
|
});
|
|
ll_huan.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
popupWindow.dismiss();
|
|
delVisit();
|
|
}
|
|
});
|
|
ll_weixin.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
share(SHARE_MEDIA.WEIXIN);
|
|
popupWindow.dismiss();
|
|
}
|
|
});
|
|
ll_weixincircle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
share(SHARE_MEDIA.WEIXIN_CIRCLE);
|
|
popupWindow.dismiss();
|
|
}
|
|
});
|
|
ll_sina.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
share(SHARE_MEDIA.SINA);
|
|
popupWindow.dismiss();
|
|
}
|
|
});
|
|
popupWindow.setTouchable(true);
|
|
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
|
|
|
|
@Override
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
});
|
|
|
|
popupWindow.showAtLocation(view, 0, 0, 0);
|
|
|
|
}
|
|
private void share(SHARE_MEDIA share_media) {
|
|
String shareTitle = newsTitle;
|
|
String shareUrl = url;
|
|
// if(flag==3)
|
|
// {
|
|
// shareUrl+="?fromtype=doctor";
|
|
// }
|
|
String msgSinaContent = "分享一篇来自\"肝胆相照\"的文章:" + shareTitle + shareUrl;
|
|
// ShareUtils.shareMsg(ct, shareTitle, "分享给你一个好看的文章," + shareTitle +
|
|
// " 详情:" + shareUrl, null);
|
|
if (TextUtils.isEmpty(shareTitle)) {
|
|
shareTitle = getIntent().getStringExtra("title");
|
|
}
|
|
if (TextUtils.isEmpty(shareUrl)) {
|
|
shareUrl = "";
|
|
}
|
|
if (TextUtils.isEmpty(summary)) {
|
|
summary = newsTitle;
|
|
}
|
|
if (TextUtils.isEmpty(imageUrl)) {
|
|
imageUrl = "";
|
|
}
|
|
if ("专题e站".equals(top_title.getText())||"动态详情".equals(top_title.getText())||"肝胆医院".equals(top_title.getText())||"乙路前行".equals(top_title.getText())||"谈丙话肝".equals(top_title.getText())||"常见问题".equals(top_title.getText())||"病例大赛".equals(top_title.getText())||"知识大赛".equals(top_title.getText())||"肝愿为你".equals(top_title.getText())||"080中国研究".equals(top_title.getText())){
|
|
if (!StringUtil.isEmpty(sharetitl)) {
|
|
shareTitle = sharetitl;
|
|
shareUrl = shareurl;
|
|
}
|
|
}
|
|
// if ("分享肝胆相照APP".equals(title)) {
|
|
// shareTitle = "肝胆相照专家端APP";
|
|
// }
|
|
Bitmap bitmap = ImageLoader.getInstance().loadImageSync(imageUrl);
|
|
ShareUtils.shareUmeng(ct, shareTitle, summary, msgSinaContent,
|
|
imageUrl, shareUrl, bitmap,share_media);
|
|
// ShareUtils.mController.openShare(NewsDetailActivity.this, false);
|
|
}
|
|
public void delVisit() {
|
|
final ECListDialog dialog = new ECListDialog(ct, new String[] { "单独选择",
|
|
"分组选择" });
|
|
dialog.setOnDialogItemClickListener(new ECListDialog.OnDialogItemClickListener() {
|
|
@Override
|
|
public void onDialogItemClick(Dialog d, int position) {
|
|
// canclePatient(CanclePatientUrl, patientUuid, uuid, p);
|
|
if (position == 0) {
|
|
|
|
Intent intent = new Intent(ct,GroupChatSelectPatientActivity.class);
|
|
intent.putExtra("sendgroup",50);
|
|
startActivityForResult(intent, 69);
|
|
dialog.dismiss();
|
|
} else {
|
|
|
|
Intent intent = new Intent(ct,GroupSelectParentActivity.class);
|
|
intent.putExtra("sendgroup",50);
|
|
startActivityForResult(intent, 69);
|
|
dialog.dismiss();
|
|
|
|
}
|
|
}
|
|
});
|
|
dialog.setTitle("温馨提示");
|
|
dialog.setTitleColor(ct.getResources().getColor(R.color.top_title));
|
|
dialog.show();
|
|
}
|
|
private void AddCollection(int i) {
|
|
if(title.equals("患教详情")||title.equals("新闻详情"))
|
|
{
|
|
if(title.equals("患教详情"))
|
|
{
|
|
needreportSome("collect",newsTitle,gettag+"","患教文库");
|
|
}
|
|
else
|
|
{
|
|
needreportSome("collect",newsTitle,gettag+"","肝胆新闻");
|
|
}
|
|
}
|
|
RequestParams params = new RequestParams();// 封装参数
|
|
params.addBodyParameter("user_uuid", expertUuid);// 传专家uuid
|
|
params.addBodyParameter("other_uuid", bookUuid);
|
|
params.addBodyParameter("title", isCollectiontitle);
|
|
params.addBodyParameter("path", isCollectionPath);
|
|
params.addBodyParameter("readnum", readnum);
|
|
params.addBodyParameter("imgpath", collpath);
|
|
params.addBodyParameter("public_name", isCollectiontitle);
|
|
params.addBodyParameter("type", String.valueOf(i));
|
|
LogUtil.i("user_uuid = "+expertUuid);
|
|
LogUtil.i("other_uuid = "+bookUuid);
|
|
LogUtil.i("title = "+isCollectiontitle);
|
|
LogUtil.i("path = "+isCollectionPath);
|
|
LogUtil.i("readnum = "+readnum);
|
|
LogUtil.i("imgpath = "+collpath);
|
|
LogUtil.i("public_name = "+isCollectiontitle);
|
|
LogUtil.i("type = "+i);
|
|
HttpHelper.loadData(HttpMethod.POST, Url.getcollection, params,
|
|
new RequestCallBack<String>() {
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
closeProgressDialog();
|
|
processDataColl(info.result);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
LogUtil.i("数据请求失败了: " + arg1);
|
|
closeProgressDialog();
|
|
// onLoaded();
|
|
// ptrLv.setEmptyView(load_empty);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void DisCollection(int i) {
|
|
RequestParams params = new RequestParams();// 封装参数
|
|
params.addBodyParameter("user_uuid", expertUuid);// 传专家uuid
|
|
params.addBodyParameter("other_uuid", bookUuid);
|
|
params.addBodyParameter("type", String.valueOf(i));
|
|
HttpHelper.loadData(HttpMethod.POST, Url.getdiscollection, params,
|
|
new RequestCallBack<String>() {
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
closeProgressDialog();
|
|
processDataColl(info.result);
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
LogUtil.i("数据请求失败了: " + arg1);
|
|
closeProgressDialog();
|
|
// onLoaded();
|
|
// ptrLv.setEmptyView(load_empty);
|
|
}
|
|
});
|
|
}
|
|
public void processDataColl(String result) {
|
|
LogUtil.i("收藏结果 = "+result);
|
|
String code = null;
|
|
String message = null;
|
|
JSONArray jsonArray = null;
|
|
JSONObject jsonObject = null;
|
|
try {
|
|
jsonObject = new JSONObject(result);
|
|
code = jsonObject.getString("code");
|
|
message = jsonObject.getString("message");
|
|
if (code.equals("1")) {
|
|
if (isCollt) {
|
|
isCollt = false;
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_nor);
|
|
ToastUtil.showMessage("取消收藏成功");
|
|
} else {
|
|
isCollt = true;
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_sel);
|
|
ToastUtil.showMessage("收藏成功");
|
|
}
|
|
|
|
} else {
|
|
ToastUtil.showMessage(message);
|
|
}
|
|
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
private void CollectListSure(int i) {
|
|
// TODO Auto-generated method stub
|
|
RequestParams params = new RequestParams();// 封装参数
|
|
params.addBodyParameter("user_uuid", expertUuid);
|
|
params.addBodyParameter("type", String.valueOf(i));
|
|
params.addBodyParameter("other_uuid", bookUuid);
|
|
params.addBodyParameter("title", booktitle);
|
|
params.addBodyParameter("path", collpath);
|
|
|
|
HttpHelper.loadData(HttpMethod.POST, Url.getcollection, params,
|
|
new RequestCallBack<String>() {
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
SharePrefUtil.saveString(ct, Url.getcollection,info.result);
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_sel);
|
|
ToastUtil.showMessage("收藏成功");
|
|
isCollection = "1";
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
LogUtil.i("数据请求失败了: " + arg1);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void CollectListDis(int type) {
|
|
// TODO Auto-generated method stub
|
|
RequestParams params = new RequestParams();// 封装参数
|
|
params.addBodyParameter("user_uuid", expertUuid);// 传专家uuid
|
|
params.addBodyParameter("type", String.valueOf(type));
|
|
params.addBodyParameter("other_uuid", bookUuid);
|
|
params.addBodyParameter("title", booktitle);
|
|
params.addBodyParameter("path", collpath);
|
|
HttpHelper.loadData(HttpMethod.POST, Url.getdiscollection, params,
|
|
new RequestCallBack<String>() {
|
|
@Override
|
|
public void onSuccess(ResponseInfo<String> info) {
|
|
SharePrefUtil.saveString(ct, Url.getdiscollection,
|
|
info.result);
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_nor);
|
|
ToastUtil.showMessage("取消收藏成功");
|
|
isCollection = "0";
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(HttpException arg0, String arg1) {
|
|
LogUtil.i("数据请求失败了: " + arg1);
|
|
}
|
|
});
|
|
}
|
|
|
|
public static final int GET_ISAGREE_FROM_NET = 101; // 是否点赞
|
|
public static final int GET_TOAGREE_FROM_NET = 102; // 点赞
|
|
public static final int GET_DISSAGREE_FROM_NET = 103; // 取消点赞
|
|
public static final int NEWS_DETAIL = 104; // 取消点赞
|
|
|
|
private void requestIsAgree() {
|
|
Map<String, String> param = new HashMap<String, String>();
|
|
param.put("user_uuid", expertUuid);
|
|
param.put("news_article_uuid", bookUuid);
|
|
param.put("type", type + "");
|
|
sendParamtoNet(Url.getRead, param, GET_ISAGREE_FROM_NET, ctx, false);
|
|
}
|
|
|
|
private void requestToAgree() {
|
|
Map<String, String> param = new HashMap<String, String>();
|
|
param.put("user_uuid", expertUuid);
|
|
param.put("news_article_uuid", bookUuid);
|
|
param.put("type", type + "");
|
|
sendParamtoNet(Url.getAgree, param, GET_TOAGREE_FROM_NET, ctx, false);
|
|
}
|
|
|
|
private void requestDissAgree() {
|
|
Map<String, String> param = new HashMap<String, String>();
|
|
param.put("user_uuid", expertUuid);
|
|
param.put("news_article_uuid", bookUuid);
|
|
param.put("type", type + "");
|
|
sendParamtoNet(Url.getDisAgree, param, GET_DISSAGREE_FROM_NET, ctx,
|
|
false);
|
|
}
|
|
|
|
public void onCallbackFromThread(String resultJson) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onCallBackFromThread(String resultJson, int resultCode) {
|
|
// TODO Auto-generated method stub
|
|
if(resultJson==null)
|
|
return;
|
|
String code = null;
|
|
JSONObject jsonObject = null;
|
|
String message = null;
|
|
try {
|
|
jsonObject = new JSONObject(resultJson);
|
|
code = jsonObject.getString("code");
|
|
message = jsonObject.getString("message");
|
|
} catch (JSONException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
if(jsonObject==null||code==null||message==null)
|
|
{
|
|
return;
|
|
}
|
|
if (code.equals("1")) {
|
|
switch (resultCode) {
|
|
case GET_ISAGREE_FROM_NET:
|
|
try {
|
|
isCollection = jsonObject.getString("isCollection");
|
|
int intagree = 0;
|
|
if (!TextUtils.isEmpty(agreenum)) {
|
|
intagree = Integer.parseInt(agreenum);
|
|
}
|
|
if (flag!=10){
|
|
isAgree = jsonObject.getString("isAgree");
|
|
if (isAgree.equals("1")) {
|
|
agree = intagree;
|
|
noagree = agree - 1;
|
|
mIv_agree.setImageResource(R.drawable.argee_sure);
|
|
} else {
|
|
noagree = intagree;
|
|
agree = noagree + 1;
|
|
mIv_agree.setImageResource(R.drawable.argee_no);
|
|
}
|
|
}
|
|
|
|
if (flag!=3&&flag!=4&&flag!=2&&flag!=10){
|
|
LogUtil.i("ISAGREE+isCollection = "+isCollection);
|
|
if (isCollection!=null&&isCollection.equals("1")) {
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_sel);
|
|
} else {
|
|
iv_collect.setImageResource(R.drawable.icon_book_collect_nor);
|
|
}
|
|
}
|
|
|
|
} catch (JSONException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
break;
|
|
case GET_TOAGREE_FROM_NET:
|
|
isAgree = "1";
|
|
mIv_agree.setImageResource(R.drawable.argee_sure);
|
|
ToastUtil.showMessage("点赞成功");
|
|
|
|
mTv_agree.setText(agree + "");
|
|
// private TextView mTv_readNum, mTv_agree;
|
|
break;
|
|
case GET_DISSAGREE_FROM_NET:
|
|
isAgree = "0";
|
|
mIv_agree.setImageResource(R.drawable.argee_no);
|
|
mTv_agree.setText(noagree + "");
|
|
ToastUtil.showMessage("取消点赞成功");
|
|
break;
|
|
case NEWS_DETAIL://新闻详情
|
|
processData(resultJson);
|
|
break;
|
|
}
|
|
} else if(code.equals("200"))
|
|
{
|
|
switch (resultCode)
|
|
{
|
|
case 101:
|
|
try {
|
|
JSONObject object = new JSONObject(resultJson);
|
|
processData(object.optJSONObject("data").toString());
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
else {
|
|
ToastUtil.showMessage(message);
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
public void finish() {
|
|
ViewGroup view = (ViewGroup) getWindow().getDecorView();
|
|
view.removeAllViews();
|
|
int flag = getIntent().getIntExtra("flag", 0);
|
|
if (flag == 2) {// 科普
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsUuid",
|
|
bookUuid);
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsagree",
|
|
mTv_agree.getText().toString());
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsread",
|
|
(Integer.parseInt(mTv_readNum.getText().toString()) + 1)
|
|
+ "");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("uuid", bookUuid);
|
|
intent.putExtra("agreenum", mTv_agree.getText().toString());
|
|
intent.putExtra("readnum",(Integer.parseInt(mTv_readNum.getText().toString()) + 1)+ "");
|
|
intent.putExtra("isCollection", isCollt);
|
|
setResult(112, intent);
|
|
} else if (flag == 3 || flag == 4 || flag == 5) {// 新闻
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsUuid",
|
|
bookUuid);
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsagree",
|
|
mTv_agree.getText().toString());
|
|
SharePrefUtil.saveString(NewsDetailActivity.this, "callnewsread",
|
|
(Integer.parseInt(mTv_readNum.getText().toString()) + 1)+ "");
|
|
Intent intent = new Intent();
|
|
intent.putExtra("isCollection", isCollt);
|
|
intent.putExtra("uuid", bookUuid);
|
|
setResult(114, intent);
|
|
} else if (flag == 6 || flag == 7|| flag == 10) {// 经典病例,病理荟萃 列表 和收藏
|
|
Intent intent = new Intent();
|
|
intent.putExtra("uuid", bookUuid);
|
|
intent.putExtra("agreenum", mTv_agree.getText().toString());
|
|
intent.putExtra("readnum",
|
|
(Integer.parseInt(mTv_readNum.getText().toString()) + 1)
|
|
+ "");
|
|
setResult(113, intent);
|
|
}
|
|
|
|
super.finish();
|
|
}
|
|
|
|
|
|
/**
|
|
* 调用分享功能
|
|
*/
|
|
private void share() {
|
|
String shareTitle = newsTitle;
|
|
String shareUrl = url;
|
|
// if(flag==3)
|
|
// {
|
|
// shareUrl+="?fromtype=doctor";
|
|
// }
|
|
String msgSinaContent = "分享一篇来自\"肝胆相照\"的文章:" + shareTitle + shareUrl;
|
|
// ShareUtils.shareMsg(ct, shareTitle, "分享给你一个好看的文章," + shareTitle +
|
|
// " 详情:" + shareUrl, null);
|
|
if (TextUtils.isEmpty(shareTitle)) {
|
|
shareTitle = getIntent().getStringExtra("title");
|
|
}
|
|
if (TextUtils.isEmpty(shareUrl)) {
|
|
shareUrl = "";
|
|
}
|
|
if (TextUtils.isEmpty(summary)) {
|
|
summary = newsTitle;
|
|
}
|
|
if (TextUtils.isEmpty(imageUrl)) {
|
|
imageUrl = "";
|
|
}
|
|
if ("专题e站".equals(top_title.getText())||"动态详情".equals(top_title.getText())||"肝胆医院".equals(top_title.getText())||"乙路前行".equals(top_title.getText())||"谈丙话肝".equals(top_title.getText())||"常见问题".equals(top_title.getText())||"病例大赛".equals(top_title.getText())||"知识大赛".equals(top_title.getText())||"肝愿为你".equals(top_title.getText())||"080中国研究".equals(top_title.getText())){
|
|
if (!StringUtil.isEmpty(sharetitl)) {
|
|
shareTitle = sharetitl;
|
|
shareUrl = shareurl;
|
|
}
|
|
}
|
|
if(url.contains(Url.getNewWa))
|
|
{
|
|
shareUrl = "https://wx.igandan.com/patientpay/index?module=shop&expert_uuid="+SharePrefUtil.getString(ct, "uuid", "");
|
|
summary="肝胆相照®肝胆病在线公共服务平台";
|
|
}
|
|
if(url.contains(Url.modernHepatology+"/modernHepatology")||url.contains("modernHepatology"))
|
|
{
|
|
shareUrl = Url.modernHepatology+"/modernHepatology/index.htm#/liver-tools";
|
|
}
|
|
// if ("分享肝胆相照APP".equals(title)) {
|
|
// shareTitle = "肝胆相照专家端APP";
|
|
// }
|
|
Bitmap bitmap = ImageLoader.getInstance().loadImageSync(imageUrl);
|
|
ShareUtils.shareUmeng(ct, shareTitle, summary, msgSinaContent,
|
|
imageUrl, shareUrl, bitmap);
|
|
// ShareUtils.mController.openShare(NewsDetailActivity.this, false);
|
|
}
|
|
|
|
@Override
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
/** 使用SSO授权必须添加如下代码 */
|
|
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
|
|
if (requestCode == 69
|
|
&& resultCode == GroupChatSelectPatientActivity.RESULTCODE_OK) {
|
|
if (data == null) {
|
|
return;
|
|
}
|
|
mRecipients = data.getStringExtra("uuid");
|
|
if (pd==null){
|
|
pd = new CustomProgressDialog(NewsDetailActivity.this, "请稍候");
|
|
}
|
|
pd.show();
|
|
new ParseHtmlTask(UIUtils.getContext()).execute();
|
|
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setTitle() {
|
|
// TODO Auto-generated method stub
|
|
top_title.setMaxLines(12);
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
// TODO Auto-generated method stub
|
|
|
|
super.onDestroy();
|
|
if ("WelcomeUI".equals(from))
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
UMShareAPI.get(this).release();
|
|
}
|
|
|
|
Constant.isShareGetPoint = false;
|
|
if (video_fullView != null)
|
|
video_fullView.removeAllViews();
|
|
//释放资源
|
|
if (mWebView != null)
|
|
mWebView.destroy();
|
|
}
|
|
|
|
@Override
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
// TODO Auto-generated method stub
|
|
return gestureDetector.onTouchEvent(event);
|
|
}
|
|
|
|
@Override
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
if (keyCode == KeyEvent.KEYCODE_BACK&& event.getRepeatCount() == 0) {
|
|
if ("WelcomeUI".equals(from)){
|
|
LogUtil.i("开始启动");
|
|
startActivity(new Intent(NewsDetailActivity.this, WelcomeUI.class));
|
|
|
|
}
|
|
finish();
|
|
return true;
|
|
}
|
|
return super.onKeyDown(keyCode, event);
|
|
}
|
|
|
|
|
|
RichTextBean richTextBean;
|
|
public String imagUrl;
|
|
//public String urlShare;
|
|
public String content;
|
|
// private ArrayList<PatientModel> list;
|
|
private String mRecipients = "";
|
|
CustomProgressDialog pd;
|
|
public class ParseHtmlTask extends ECAsyncTask {
|
|
|
|
public ParseHtmlTask(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
@Override
|
|
protected Object doInBackground(Object[] params) {
|
|
|
|
// url = "http://wx.igandan.com/expert/outpatient_details?expert_uuid=" + SharePrefUtil.getString(UIUtils.getContext(), "uuid", "") + "&expert_name=" + SharePrefUtil.getString(UIUtils.getContext(), "realName", "");
|
|
// urlShare = Url.urlOutpatient+ SharePrefUtil.getString(UIUtils.getContext(), "uuid", "") + "&expert_name=" + SharePrefUtil.getString(UIUtils.getContext(), "realName", "");
|
|
content = "肝胆相照®肝胆病在线公共服务平台";
|
|
imagUrl = "http://tdoc.igandan.org/app/book/pdf/2019/20190613152617.png";
|
|
// 从患者数据库里取出患者列表
|
|
|
|
// for (int i = 0;i<list.size();i++){
|
|
// String uuid = list.get(i).getUuid();
|
|
// LogUtil.i("uuid = "+uuid);
|
|
// // 要过滤出真正的uuid
|
|
// if (!StringUtil.isEmpty(uuid)&&uuid.contains("#")) {
|
|
// uuid = uuid.split("#")[1];
|
|
// mRecipients += uuid + ",";
|
|
// }
|
|
//
|
|
// }
|
|
// mRecipients="q8RuKHrtHNYBLdjixwy,";
|
|
LogUtil.i("mRecipients = "+mRecipients);
|
|
try {
|
|
richTextBean = new RichTextBean();
|
|
richTextBean.setUrl(url);
|
|
richTextBean.setPicUrl(imagUrl);
|
|
richTextBean.setTitle(newsTitle);
|
|
richTextBean.setDesc(content);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return richTextBean;
|
|
}
|
|
|
|
@Override
|
|
protected void onPostExecute(Object o) {
|
|
|
|
if (o != null && o instanceof RichTextBean) {
|
|
RichTextBean bean = (RichTextBean) o;
|
|
handleSendMessage(bean);
|
|
}
|
|
}
|
|
}
|
|
private void handleSendMessage(final RichTextBean bean) {
|
|
ImageLoader.getInstance().loadImage(bean.getPicUrl(),
|
|
new ImageLoadingListener() {
|
|
@Override
|
|
public void onLoadingStarted(String s, View view) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onLoadingCancelled(String s, View view) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onLoadingFailed(String imageUri, View view,
|
|
FailReason failReason) {
|
|
addGroupSendMsg("3",bookUuid,"");
|
|
// TODO Auto-generated method stub
|
|
// IMChattingHelper.getInstance().handleSendRichTextMessage(bean, mRecipients,"2,1,2,0",NewsDetailActivity.this);
|
|
}
|
|
|
|
@Override
|
|
public void onLoadingComplete(String imageUri, View view,
|
|
Bitmap loadedImage) {
|
|
// TODO Auto-generated method stub
|
|
BitmapUtil.saveBitmapToLocalSDCard(loadedImage,bean.getPicUrl(),NewsDetailActivity.this);
|
|
if (mRecipients.contains(",")) {
|
|
// List<String> list = new ArrayList<>();
|
|
// String[] split = mRecipients.split(",");
|
|
// for (int j = 0; j < split.length; j++) {
|
|
// if (!StringUtil.isEmpty(split[j])&&!list.contains(split[j])) {
|
|
// list.add(split[j]);
|
|
// IMChattingHelper.getInstance().handleSendRichTextMessage(bean, Constant.Patient_AppKey+split[j], "2,1,2,0",NewsDetailActivity.this);
|
|
// }
|
|
// }
|
|
//添加群发记录富文本
|
|
addGroupSendMsg("3",bookUuid,"");
|
|
|
|
}else {
|
|
IMChattingHelper.getInstance().handleSendRichTextMessage(bean, mRecipients, "2,1,2,0", NewsDetailActivity.this);
|
|
if(pd!=null)
|
|
pd.dismiss();
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
private final ReentrantLock lock = new ReentrantLock();
|
|
private void addGroupSendMsg(String msg_type, String msg_content, final String mFilePath1) {
|
|
needreport(mRecipients.split(",").length+"","患教图文");
|
|
// if (pd==null){
|
|
// pd = new CustomProgressDialog(NewsDetailActivity.this, "请稍候");
|
|
// }
|
|
// pd.show();
|
|
final Map<String,String> map = new HashMap<>();
|
|
map.put("msg_type",msg_type);
|
|
if (StringUtil.isEmpty(mFilePath1)){
|
|
map.put("msg_content",msg_content);
|
|
}
|
|
map.put("patient_user_uuid",mRecipients);
|
|
map.put("user_uuid", SharePrefUtil.getString(NewsDetailActivity.this, "uuid", ""));
|
|
map.put("client_type", "A");
|
|
map.put("version", UpdateVersionUtils.getVersionName() );
|
|
LogUtils.e("user_uuid+version = "+SharePrefUtil.getString(NewsDetailActivity.this, "uuid", "")+","+UpdateVersionUtils.getVersionName());
|
|
new Thread(new Runnable() {
|
|
private HttpHelper.HttpResult httpResult;
|
|
private String result1;
|
|
|
|
@Override
|
|
public void run() {
|
|
// TODO Auto-generated method stub
|
|
lock.lock();
|
|
|
|
try {
|
|
if(!StringUtil.isEmpty(mFilePath1)){
|
|
FileInputStream fileInputStream = new FileInputStream(mFilePath1);
|
|
BitmapFactory.Options opts = new BitmapFactory.Options();
|
|
// opts.inJustDecodeBounds = true;
|
|
opts.inTempStorage = new byte[100 * 1024];
|
|
opts.inPreferredConfig = Bitmap.Config.RGB_565;
|
|
opts.inPurgeable = true;
|
|
BitmapFactory.decodeFile(mFilePath1,opts);
|
|
opts.inSampleSize = calculateInSampleSize(opts,
|
|
720, 1280);
|
|
opts.inInputShareable = true;
|
|
Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream,
|
|
null, opts);
|
|
String s = Base64Util.BitmaptoBase64(bitmap);
|
|
map.put("msg_content",s);
|
|
}
|
|
|
|
|
|
|
|
httpResult = HttpHelper.post(Url.getTimestamp, null);
|
|
if (httpResult != null) {
|
|
result1 = httpResult.getString();
|
|
// LogUtils.e(result);
|
|
TimestampBean bean = GsonTools.fromGsonToBean(result1, TimestampBean.class);
|
|
map.put("timestamp", bean.getTimestamp());
|
|
LogUtils.e("timestamp = "+ bean.getTimestamp());
|
|
|
|
String encoding = "UTF-8";
|
|
Gson gson = new Gson();
|
|
String params = gson.toJson(map);
|
|
Log.d("gdxzinside","params = "+params.toString());
|
|
byte[] data;
|
|
String sign = SignUtil.getSign(map);
|
|
data = params.getBytes(encoding);
|
|
URL url = new URL(Url.addGroupSendMsg);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("POST");
|
|
conn.setDoOutput(true);
|
|
conn.setRequestProperty("Content-Type","application/json");
|
|
conn.setRequestProperty("sign",sign);
|
|
conn.setRequestProperty("Content-Length",String.valueOf(data.length));
|
|
conn.setConnectTimeout(5 * 1000);
|
|
OutputStream outStream = conn.getOutputStream();
|
|
outStream.write(data);
|
|
outStream.flush();
|
|
outStream.close();
|
|
if (conn.getResponseCode() == 200) {
|
|
InputStream inStream = conn.getInputStream();
|
|
String result = new String(StreamTool.readInputStream(inStream), "UTF-8");
|
|
LogUtil.i("result = "+result);
|
|
JSONObject jsonObject = new JSONObject(result);
|
|
String code = jsonObject.optString("code");
|
|
|
|
if ("200".equals(code)){
|
|
if(pd!=null)
|
|
pd.dismiss();
|
|
ToastUtil.showMessage("推荐成功");
|
|
}
|
|
else
|
|
{
|
|
if(pd!=null)
|
|
pd.dismiss();
|
|
ToastUtil.showMessage("提交失败,请重试");
|
|
}
|
|
} else {
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
// ToastUtil.showMessage("提交失败,请重试");
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} finally {
|
|
lock.unlock();
|
|
}
|
|
|
|
}
|
|
}).start();
|
|
|
|
}
|
|
public static int calculateInSampleSize(BitmapFactory.Options options,
|
|
int reqWidth, int reqHeight) {
|
|
|
|
final int height = options.outHeight;
|
|
|
|
final int width = options.outWidth;
|
|
|
|
int inSampleSize = 1;
|
|
|
|
if (height > reqHeight || width > reqWidth) {
|
|
|
|
final int heightRatio = Math.round((float) height
|
|
/ (float) reqHeight);
|
|
|
|
final int widthRatio = Math.round((float) width / (float) reqWidth);
|
|
|
|
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
|
|
|
|
}
|
|
|
|
return inSampleSize;
|
|
|
|
}
|
|
private void needreport(String number,String belogn)
|
|
{
|
|
List<reportBean> reportBeans=new ArrayList<>();
|
|
reportBean rbens=new reportBean();
|
|
rbens.setUser_id(Constant.Report_userId);
|
|
rbens.setApp_key(Constant.Repotr_app_key);
|
|
rbens.setOs(CommUtil.Repotr_os);
|
|
rbens.setDevice(CommUtil.getDeviceName());
|
|
rbens.setDevice_type(CommUtil.getDeviceType());
|
|
rbens.setApp_version(CommUtil.getVersionName());
|
|
rbens.setNetwork_carrier(CommUtil.getCarrierName);
|
|
rbens.setNetwork_type(CommUtil.getCurrentNetworkType(UIUtils.getContext()));
|
|
rbens.setEvent_nickname("group_message");
|
|
rbens.setNumber(number);
|
|
rbens.setBelong(belogn);
|
|
rbens.setCreate_date(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
reportBeans.add(rbens);
|
|
startReport(reportBeans);
|
|
}
|
|
|
|
|
|
private void setCookie() {
|
|
|
|
CookieManager cookieManager = CookieManager.getInstance();
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
cookieManager.removeSessionCookies(null);
|
|
cookieManager.flush();
|
|
} else {
|
|
cookieManager.removeSessionCookie();
|
|
CookieSyncManager.getInstance().sync();
|
|
}
|
|
cookieManager.setAcceptCookie(true);
|
|
URL url1 = null;
|
|
try {
|
|
url1 = new URL(url);
|
|
|
|
} catch (MalformedURLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
String host1 = "https://"+url1.getHost();
|
|
cookieManager.setCookie(host1, "hcp_from=expert_app"+";path=/;domain=.igandan.com");
|
|
cookieManager.setCookie(host1, "hcp_token="+SharePrefUtil.getString(NewsDetailActivity.this,"hcp_token","")+";path=/;domain=.igandan.com");
|
|
// cookieManager.setCookie(Url.modernHepatology, "session_token="+SharePrefUtil.getString(NewsDetailActivity.this,"hcp_token",""));
|
|
// cookieManager.setCookie(Url.modernHepatology, "domain="+".igandan.com");
|
|
// cookieManager.setCookie(Url.modernHepatology, "path=/");
|
|
//
|
|
// Log.d("gdxzfile","qqqq "+SharePrefUtil.getString(CourseUrlDetailActivity.this,"hcp_token",""));
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
cookieManager.flush();
|
|
} else {
|
|
|
|
CookieSyncManager.getInstance().sync();
|
|
}
|
|
}
|
|
}
|