1.1.4发布
parent
5178ce0f04
commit
980756f307
@ -0,0 +1,242 @@
|
|||||||
|
package com.rehome.dywoa.ui.activity;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.just.agentweb.AgentWeb;
|
||||||
|
import com.just.agentweb.DefaultWebClient;
|
||||||
|
import com.just.agentweb.WebChromeClient;
|
||||||
|
import com.just.agentweb.WebViewClient;
|
||||||
|
import com.rehome.dywoa.App;
|
||||||
|
import com.rehome.dywoa.BuildConfig;
|
||||||
|
import com.rehome.dywoa.Contans;
|
||||||
|
import com.rehome.dywoa.R;
|
||||||
|
import com.rehome.dywoa.base.BaseAgentWebActivity;
|
||||||
|
import com.rehome.dywoa.bean.FwSingleLoginResult;
|
||||||
|
import com.rehome.dywoa.bean.SisTokenBeanData;
|
||||||
|
import com.rehome.dywoa.utils.GsonUtils;
|
||||||
|
import com.rehome.dywoa.utils.HttpListener;
|
||||||
|
import com.rehome.dywoa.utils.NoProgresshttpUtils;
|
||||||
|
import com.rehome.dywoa.utils.NohttpUtils;
|
||||||
|
import com.rehome.dywoa.utils.RSAUtils;
|
||||||
|
import com.rehome.dywoa.utils.UiUtlis;
|
||||||
|
import com.rehome.dywoa.weiget.WebLayout;
|
||||||
|
import com.yolanda.nohttp.NoHttp;
|
||||||
|
import com.yolanda.nohttp.RequestMethod;
|
||||||
|
import com.yolanda.nohttp.rest.Request;
|
||||||
|
import com.yolanda.nohttp.rest.Response;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
|
||||||
|
public class BiShowActivity extends BaseAgentWebActivity {
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
private TextView mTitleTextView;
|
||||||
|
//private String urlToken = "webroot/decision/url/mobile#/directory";
|
||||||
|
private String urlToken = "webroot/decision";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String type;
|
||||||
|
String urlLog;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_wait_for_to_do);
|
||||||
|
|
||||||
|
|
||||||
|
type = getIntent().getStringExtra("type");
|
||||||
|
urlLog = getIntent().getStringExtra("urlLog");
|
||||||
|
if(TextUtils.isEmpty(type)){
|
||||||
|
type = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
mToolbar = this.findViewById(R.id.toolbar);
|
||||||
|
mToolbar.setTitleTextColor(Color.WHITE);
|
||||||
|
mToolbar.setTitle("");
|
||||||
|
mToolbar.setNavigationIcon(R.drawable.ac_back_icon);
|
||||||
|
mTitleTextView = this.findViewById(R.id.toolbar_title);
|
||||||
|
mTitleTextView.setText(type);
|
||||||
|
this.setSupportActionBar(mToolbar);
|
||||||
|
if (getSupportActionBar() != null) {
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
}
|
||||||
|
mToolbar.setNavigationOnClickListener(v -> BiShowActivity.this.finish());
|
||||||
|
|
||||||
|
|
||||||
|
//支持缩放
|
||||||
|
mAgentWeb.getWebCreator().getWebView().getSettings().setBuiltInZoomControls(true);
|
||||||
|
mAgentWeb.getWebCreator().getWebView().getSettings().setDisplayZoomControls(false);
|
||||||
|
mAgentWeb.getWebCreator().getWebView().getSettings().setSupportZoom(true);
|
||||||
|
mAgentWeb.getWebCreator().getWebView().getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||||
|
|
||||||
|
checkServerConnectStatus();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//检查服务器连接状态
|
||||||
|
private void checkServerConnectStatus() {
|
||||||
|
Map<String,String> param = new HashMap<>();
|
||||||
|
param.put("login","dywoa");
|
||||||
|
String json = GsonUtils.GsonString(param);
|
||||||
|
String url = Contans.IP + Contans.check_server_connect;
|
||||||
|
showLog(url);
|
||||||
|
showLog(json);
|
||||||
|
Request<String> request = NoHttp.createStringRequest(
|
||||||
|
url,
|
||||||
|
RequestMethod.POST
|
||||||
|
);
|
||||||
|
request.setDefineRequestBodyForJson(json);
|
||||||
|
NoProgresshttpUtils.getInstance().add(this, 0, request, new HttpListener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSucceed(int what, Response<String> response) {
|
||||||
|
String result = response.get();
|
||||||
|
showLog("-----onSucceed----");
|
||||||
|
showLog(result);
|
||||||
|
if(result.equals("1")){
|
||||||
|
showLog("connect server success");
|
||||||
|
//可以连接到服务器,请求数据
|
||||||
|
getSingleLoginToken();
|
||||||
|
}else{
|
||||||
|
showToast("无法连接到服务器,请检查网络环境");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailed(int what, Response<String> response) {
|
||||||
|
showLog("connect server onFailed");
|
||||||
|
showToast("无法连接到服务器,请检查网络环境");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void getSingleLoginToken() {
|
||||||
|
//1724740210123
|
||||||
|
//1640832102097
|
||||||
|
long nowTime = System.currentTimeMillis();
|
||||||
|
showLog(String.valueOf(nowTime));
|
||||||
|
HashMap<String,String> param = new HashMap<>();
|
||||||
|
param.put("username",App.getInstance().getUserInfo().getManid());
|
||||||
|
param.put("issueTime",String.valueOf(nowTime));
|
||||||
|
String jsonParam = GsonUtils.GsonString(param);
|
||||||
|
String usernameEncrypt = RSAUtils.encryptBASE64BIStr(jsonParam);
|
||||||
|
String usernameEncode = "";
|
||||||
|
try {
|
||||||
|
usernameEncode = URLEncoder.encode(usernameEncrypt, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = Contans.BI_TOKEN_IP + urlToken + "?ssoToken=" + usernameEncode;
|
||||||
|
loadSisPage(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSisPage(String biUrl) {
|
||||||
|
showLog(biUrl);
|
||||||
|
this.mAgentWeb.getUrlLoader().loadUrl(biUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
protected ViewGroup getAgentWebParent() {
|
||||||
|
return (ViewGroup) this.findViewById(R.id.container);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getIndicatorColor() {
|
||||||
|
return Color.parseColor("#ff0000");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setTitle(WebView view, String title) {
|
||||||
|
super.setTitle(view, title);
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
if (mTitleTextView != null) {
|
||||||
|
mTitleTextView.setText(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getIndicatorHeight() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
protected String getUrl() {
|
||||||
|
return null;
|
||||||
|
//return "https://www.baidu.com/";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void showLog(String logText) {
|
||||||
|
if (BuildConfig.LOG_ERROR) {
|
||||||
|
if (TextUtils.isEmpty(logText)) {
|
||||||
|
Log.i("app", "logText is null");
|
||||||
|
} else {
|
||||||
|
Log.i("app", logText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToast(String msg) {
|
||||||
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToast(int strId) {
|
||||||
|
Toast.makeText(this, strId, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#ffffff"
|
||||||
|
tools:context=".ui.activity.BiShowActivity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:titleTextColor="@android:color/white"
|
||||||
|
app:theme="@style/Widget.AppCompat.Toolbar"
|
||||||
|
app:titleTextColor="@android:color/white">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toolbar_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="20sp"/>
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
Loading…
Reference in New Issue