正在查看: 自健身 v3.3.4 应用的 CoachDetailHtmlActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 CoachDetailHtmlActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
import butterknife.BindView;
import com.mu.gymtrain.Base.BaseActivity;
import com.mu.gymtrain.Http.HttpHelper;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.Utils.ViewUtils;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class CoachDetailHtmlActivity extends BaseActivity {
private String html;
private WebSettings webSettings;
@BindView(R.id.webView)
WebView webView;
public int getContentLayout() {
return R.layout.text_html_layout;
}
public void initView() {
((TextView) findViewById(R.id.title_middle)).setText("图文详情");
this.html = getIntent().getStringExtra("html");
initWebView();
if (!TextUtils.isEmpty(this.html)) {
this.html = this.html.replaceAll("/public/upload", "https://www.zijianshen.com//public/upload");
this.webSettings.setTextZoom(260);
this.webView.loadData(this.html, "text/html;charset=utf-8", "utf-8");
}
findViewById(R.id.title_left).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CoachDetailHtmlActivity.this.finish();
}
});
}
public void initData() {
String stringExtra = getIntent().getStringExtra("id");
if (TextUtils.isEmpty(stringExtra)) {
return;
}
ViewUtils.showLoading(this, "加载中...");
HttpHelper.getInstance().getRetrofitService(this).getCoachHTML(UrlConfig.Path.COACH_HTML + stringExtra, getToken()).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
ViewUtils.hideLoading();
try {
String string = ((ResponseBody) response.body()).string();
CoachDetailHtmlActivity.this.html = string.replaceAll("/public/upload", "https://www.zijianshen.com//public/upload");
CoachDetailHtmlActivity.this.webView.loadData(CoachDetailHtmlActivity.this.html, "text/html;charset=utf-8", "utf-8");
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
ViewUtils.hideLoading();
}
});
}
private void initWebView() {
WebSettings settings = this.webView.getSettings();
this.webSettings = settings;
settings.setAllowContentAccess(true);
this.webSettings.setAppCacheEnabled(false);
this.webSettings.setBuiltInZoomControls(false);
this.webSettings.setUseWideViewPort(true);
this.webSettings.setLoadWithOverviewMode(true);
this.webSettings.setAppCacheEnabled(true);
this.webSettings.setDomStorageEnabled(true);
this.webSettings.setDatabaseEnabled(true);
this.webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
this.webView.setSaveEnabled(true);
this.webView.setKeepScreenOn(true);
this.webSettings.setCacheMode(1);
this.webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(final WebView view, final String url) {
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onLoadResource(WebView webView, String s) {
super.onLoadResource(webView, s);
}
});
}
}