优化汇总(20170106),礼包相关优化补充(20170104), 快速点击弹窗按钮可能会出现卡死

This commit is contained in:
khy
2017-01-09 17:51:38 +08:00
parent 40615976e1
commit ed71d3e348
40 changed files with 463 additions and 195 deletions

View File

@ -3,6 +3,7 @@ package com.gh.gamecenter;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.DownloadListener;
@ -15,6 +16,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.entity.CommentnumEntity;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -35,6 +37,7 @@ public class WebActivity extends BaseActivity {
@BindView(R.id.web_progressbar) ProgressBar progressBar;
@BindView(R.id.web_comment) TextView webComment;
@BindView(R.id.news_bottom) RelativeLayout newsBottom;
@BindView(R.id.actionbar_tv_title) TextView newsTitle;
private String newsId;
private int commentNum;
@ -47,12 +50,13 @@ public class WebActivity extends BaseActivity {
if (getIntent().getBundleExtra("data") != null) {
Bundle data = getIntent().getBundleExtra("data");
webUrl = data.getString("url");
webTitle = "推送网页";
webTitle = "";
} else {
webUrl = getIntent().getStringExtra("url");
webTitle = getIntent().getStringExtra("gameName");
newsId = getIntent().getStringExtra("newsId");
}
// webUrl = "http://tieba.baidu.com/f?kw=%E7%BD%91%E6%98%93%E9%98%B4%E9%98%B3%E5%B8%88&red_tag=3194925450";
View contentView = View.inflate(this, R.layout.activity_web, null);
init(contentView, webTitle);
@ -67,11 +71,11 @@ public class WebActivity extends BaseActivity {
//用webview打开url
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
// @Override
// public boolean shouldOverrideUrlLoading(WebView view, String url) {
// view.loadUrl(url);
// return true;
// }
// @Override
// public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
@ -95,10 +99,23 @@ public class WebActivity extends BaseActivity {
//设置加载进度条
webView.setWebChromeClient(new WebChromeClient(){
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
if (TextUtils.isEmpty(newsId)) {
newsTitle.setEllipsize(TextUtils.TruncateAt.END);
newsTitle.setPadding(DisplayUtils.dip2px(getApplication(), 30), 0,DisplayUtils.dip2px(getApplication(), 30), 0);
newsTitle.setSingleLine();
newsTitle.setText(title);
}
}
@Override
public void onProgressChanged(WebView view, int newProgress) {
progressBar.setProgress(newProgress);
if (newProgress == 100){
if (newProgress == 100 && newsId != null){
progressBar.setVisibility(View.GONE);
if (newsBottom.getVisibility() == View.GONE) {
newsBottom.setVisibility(View.VISIBLE);
@ -136,7 +153,7 @@ public class WebActivity extends BaseActivity {
super.onNext(response);
if (response.size() > 0 && response.get(0).getNum() > 0) {
commentNum = response.get(0).getNum();
webComment.setText("查看评论(" + response.get(0).getNum() + ")");
webComment.setText("查看评论 " + response.get(0).getNum() + "");
}
}
});
@ -156,7 +173,7 @@ public class WebActivity extends BaseActivity {
super.onActivityResult(requestCode, resultCode, data);
// 刷新评论数
if (resultCode == 1001 && progressBar.getVisibility() == View.VISIBLE && newsId != null) {
webComment.setText("查看评论(" + data.getExtras().getInt("commentNum") + ")");
webComment.setText("查看评论 " + data.getExtras().getInt("commentNum") + "");
}
}