1687 lines
54 KiB
Java
1687 lines
54 KiB
Java
package cn.shangyu.gdxzExpert.umeng;
|
||
|
||
import static cn.shangyu.gdxzExpert.utils.Url.newsDetail;
|
||
|
||
import android.Manifest;
|
||
import android.app.Dialog;
|
||
import android.content.Context;
|
||
import android.content.DialogInterface;
|
||
import android.content.Intent;
|
||
import android.graphics.Bitmap;
|
||
import android.graphics.BitmapFactory;
|
||
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.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.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.ImageView;
|
||
import android.widget.LinearLayout;
|
||
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 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.URL;
|
||
import java.net.URLDecoder;
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
import java.util.concurrent.locks.ReentrantLock;
|
||
|
||
import cn.shangyu.gdxzExpert.R;
|
||
import cn.shangyu.gdxzExpert.activity.AddProclamationActivity;
|
||
import cn.shangyu.gdxzExpert.activity.GroupChatSelectPatientActivity;
|
||
import cn.shangyu.gdxzExpert.activity.GroupSelectParentActivity;
|
||
import cn.shangyu.gdxzExpert.activity.KeyWordActivity;
|
||
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.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 PushNewsDetailActivity 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 PushNewsDetailActivity 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;
|
||
|
||
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())
|
||
{
|
||
|
||
mWebView.goBack();
|
||
}
|
||
else
|
||
{
|
||
finish();
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if ("WelcomeUI".equals(from)){
|
||
startActivity(new Intent(PushNewsDetailActivity.this, WelcomeUI.class));
|
||
}
|
||
finish();
|
||
}
|
||
|
||
}
|
||
});
|
||
/**
|
||
* flag == 3 bookUuid,agreenum,readnum,collpath等到请求了接口后调用
|
||
*
|
||
*/
|
||
// String flags =getIntent().getData().getQueryParameter("flag");
|
||
// if(StringUtil.isEmpty(flags))
|
||
// {
|
||
flag = getIntent().getIntExtra("flag", 3);
|
||
// }
|
||
// else
|
||
// {
|
||
// flag = Integer.valueOf(flags);
|
||
// }
|
||
if (flag == 1) {//含分享
|
||
top_right.setVisibility(View.VISIBLE);
|
||
top_right.setImageResource(R.drawable.share_icon);
|
||
top_right.setOnClickListener(this);
|
||
} 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");
|
||
|
||
} 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");
|
||
// if(StringUtil.isEmpty(bookUuid))
|
||
// {
|
||
// bookUuid=getIntent().getData().getQueryParameter("uuid");
|
||
// }
|
||
// agreenum = intent.getStringExtra("newsagreenum");
|
||
// readnum = intent.getStringExtra("newsreadnum");
|
||
// collpath = intent.getStringExtra("imageUrl");
|
||
} 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");
|
||
}
|
||
/**
|
||
* mTv_agree,mTv_readNum等到请求了接口后调用
|
||
*
|
||
*/
|
||
// 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() {
|
||
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);//
|
||
|
||
|
||
ll_agree.setOnClickListener(this);
|
||
setitle1();
|
||
requestIsAgree();
|
||
showLoadingView();
|
||
/**
|
||
* 这三个方法等到请求了接口后调用
|
||
*
|
||
*/
|
||
|
||
// initData();
|
||
pushDetail();
|
||
AddNewsDetail();
|
||
return view;
|
||
}
|
||
|
||
//能否解决部分手机WebView崩溃
|
||
// @Override
|
||
// public AssetManager getAssets() {
|
||
// return getResources().getAssets();
|
||
// }
|
||
private void pushDetail()
|
||
{
|
||
Map<String,String> map = new HashMap<>();
|
||
map.put("uuid",bookUuid);
|
||
sendJsonPostParamtoNetSignMD5(newsDetail,map,105,this);
|
||
}
|
||
|
||
private void AddNewsDetail() {
|
||
|
||
|
||
// // 提取专家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);
|
||
String url = null;
|
||
if (flag == 2){
|
||
url = Url.getKePuCollection;
|
||
}else if (flag == 10){
|
||
url = Url.caseDetial;
|
||
}else {
|
||
url = Url.newsDetial;
|
||
}
|
||
|
||
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);
|
||
}
|
||
|
||
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 (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);
|
||
}
|
||
|
||
} 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 =Url.urlHtml+isCollectionPath;
|
||
title = getIntent().getStringExtra("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.VISIBLE);
|
||
top_right_text.setText("推荐");
|
||
top_right_text.setOnClickListener(this);
|
||
}
|
||
|
||
// inside_share.setVisibility(View.VISIBLE);
|
||
// inside_share.setOnClickListener(this);
|
||
}
|
||
// newsTitle = getIntent().getStringExtra("newsTitle");// 新闻的标题
|
||
// summary = getIntent().getStringExtra("summary");// 新闻的摘要
|
||
if (type == 1 && StringUtil.isEmpty(summary)) {
|
||
summary = "新鲜资讯,一触即达";
|
||
}
|
||
// imageUrl = getIntent().getStringExtra("imageUrl");// 新闻的图的地址
|
||
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() {
|
||
|
||
|
||
|
||
// mWebView.setInitialScale(25);
|
||
if(title.equals("专题e站")){
|
||
|
||
settings = mWebView.getSettings();
|
||
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 + ";GdxzAndroidPatientApp");
|
||
// 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
|
||
{
|
||
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(PushNewsDetailActivity.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;
|
||
}
|
||
});
|
||
// 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(
|
||
PushNewsDetailActivity.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文件夹内
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||
if (PermissionsUtil.hasPermission(PushNewsDetailActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||
new DownLoadUrlImage(imgurl, ctx);
|
||
Toast.makeText(getBaseContext(), "图片保存",
|
||
Toast.LENGTH_SHORT).show();
|
||
}
|
||
else
|
||
{
|
||
EasyWindow.with(PushNewsDetailActivity.this).setGravity(Gravity.TOP).setYOffset(200).setWidth(1000)
|
||
|
||
.setContentView(R.layout.float_top_dialog_download).show();
|
||
PermissionsUtil.requestPermission(PushNewsDetailActivity.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;
|
||
}
|
||
});
|
||
loadurl(mWebView, url);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@Override
|
||
protected void onResume() {
|
||
super.onResume();
|
||
|
||
// 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) {
|
||
switch (v.getId()) {
|
||
case R.id.top_right_text:
|
||
//分享功能换成分享到容联
|
||
delVisit();
|
||
break;
|
||
// case R.id.inside_share:
|
||
// //分享功能换成分享到容联
|
||
// delVisit();
|
||
// break;
|
||
case 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(PushNewsDetailActivity.this, WelcomeUI.class));
|
||
}
|
||
finish();
|
||
|
||
|
||
break;
|
||
|
||
case R.id.top_right:
|
||
if (flag == 8) {
|
||
Intent intent = new Intent(ctx, AddProclamationActivity.class);
|
||
intent.putExtra("hospital_uuid", hospital_uuid);
|
||
ctx.startActivity(intent);
|
||
} else {
|
||
share();// 调用分享
|
||
}
|
||
|
||
break;
|
||
case 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);
|
||
}
|
||
}
|
||
break;
|
||
case R.id.ll_agree:
|
||
if (isAgree != null) {
|
||
LogUtil.i("isAgree = "+isAgree);
|
||
if (!isAgree.equals("1")) {
|
||
// 点赞
|
||
requestToAgree();
|
||
} else {
|
||
// 取消点赞
|
||
requestDissAgree();
|
||
}
|
||
}
|
||
break;
|
||
case R.id.ll_share:
|
||
share();
|
||
|
||
// list = PatientSqlManager.getPatientInfoList(Constant.typePatient);
|
||
// new ParseHtmlTask(UIUtils.getContext()).execute();
|
||
break;
|
||
}
|
||
}
|
||
|
||
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) {
|
||
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 + "");
|
||
|
||
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 105:
|
||
try {
|
||
summary = jsonObject.getJSONObject("data").optString("summary");
|
||
imageUrl = Url.urlHtml +jsonObject.getJSONObject("data").optString("headImg");
|
||
isCollectionPath = jsonObject.getJSONObject("data").optString("path");
|
||
agreenum=jsonObject.getJSONObject("data").optString("agreenum");
|
||
readnum=jsonObject.getJSONObject("data").optString("readnum");
|
||
newsTitle=jsonObject.getJSONObject("data").optString("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");
|
||
}
|
||
initData();
|
||
|
||
} 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(PushNewsDetailActivity.this, "callnewsUuid",
|
||
bookUuid);
|
||
SharePrefUtil.saveString(PushNewsDetailActivity.this, "callnewsagree",
|
||
mTv_agree.getText().toString());
|
||
SharePrefUtil.saveString(PushNewsDetailActivity.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(PushNewsDetailActivity.this, "callnewsUuid",
|
||
bookUuid);
|
||
SharePrefUtil.saveString(PushNewsDetailActivity.this, "callnewsagree",
|
||
mTv_agree.getText().toString());
|
||
SharePrefUtil.saveString(PushNewsDetailActivity.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;
|
||
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);
|
||
// 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(PushNewsDetailActivity.this, "请稍候");
|
||
}
|
||
pd.show();
|
||
new ParseHtmlTask(UIUtils.getContext()).execute();
|
||
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setTitle() {
|
||
// TODO Auto-generated method stub
|
||
|
||
}
|
||
|
||
@Override
|
||
protected void onDestroy() {
|
||
// TODO Auto-generated method stub
|
||
|
||
super.onDestroy();
|
||
UMShareAPI.get(this).release();
|
||
Constant.isShareGetPoint = false;
|
||
//释放资源
|
||
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(PushNewsDetailActivity.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) {
|
||
// TODO Auto-generated method stub
|
||
// IMChattingHelper.getInstance().handleSendRichTextMessage(bean, mRecipients,"2,1,2,0", PushNewsDetailActivity.this);
|
||
addGroupSendMsg("3",bookUuid,"");
|
||
}
|
||
|
||
@Override
|
||
public void onLoadingComplete(String imageUri, View view,
|
||
Bitmap loadedImage) {
|
||
// TODO Auto-generated method stub
|
||
BitmapUtil.saveBitmapToLocalSDCard(loadedImage,bean.getPicUrl(), PushNewsDetailActivity.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", PushNewsDetailActivity.this);
|
||
if(pd!=null)
|
||
pd.dismiss();
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
private final ReentrantLock lock = new ReentrantLock();
|
||
private void addGroupSendMsg(String msg_type, String msg_content, final String mFilePath1) {
|
||
|
||
// 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(PushNewsDetailActivity.this, "uuid", ""));
|
||
map.put("client_type", "A");
|
||
map.put("version", UpdateVersionUtils.getVersionName() );
|
||
LogUtils.e("user_uuid+version = "+SharePrefUtil.getString(PushNewsDetailActivity.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;
|
||
|
||
}
|
||
}
|