Commit a9b298916232dd74ab5a7db0b80ca940c6bb283f

Authored by 简柏林
1 parent a6c2e714

代码提交

@@ -33,10 +33,13 @@ import com.studymachine.www.BuildConfig; @@ -33,10 +33,13 @@ import com.studymachine.www.BuildConfig;
33 import com.studymachine.www.R; 33 import com.studymachine.www.R;
34 import com.studymachine.www.aop.CheckNet; 34 import com.studymachine.www.aop.CheckNet;
35 import com.studymachine.www.app.AppActivity; 35 import com.studymachine.www.app.AppActivity;
  36 +import com.studymachine.www.app.AppPresentation;
  37 +import com.studymachine.www.domain.AiDTO;
36 import com.studymachine.www.event.DictionariesEvent; 38 import com.studymachine.www.event.DictionariesEvent;
37 import com.studymachine.www.event.NetworkEvent; 39 import com.studymachine.www.event.NetworkEvent;
38 import com.studymachine.www.http.api.HostApi; 40 import com.studymachine.www.http.api.HostApi;
39 import com.studymachine.www.http.api.LoginApi; 41 import com.studymachine.www.http.api.LoginApi;
  42 +import com.studymachine.www.http.api.PointDetailApi;
40 import com.studymachine.www.http.api.UpdateVersionApi; 43 import com.studymachine.www.http.api.UpdateVersionApi;
41 import com.studymachine.www.http.api.UserInfoApi; 44 import com.studymachine.www.http.api.UserInfoApi;
42 import com.studymachine.www.http.model.HttpData; 45 import com.studymachine.www.http.model.HttpData;
@@ -53,7 +56,10 @@ import com.studymachine.www.other.ScreenUtils; @@ -53,7 +56,10 @@ import com.studymachine.www.other.ScreenUtils;
53 import com.studymachine.www.other.Tool; 56 import com.studymachine.www.other.Tool;
54 import com.studymachine.www.other.WebUrlConfig; 57 import com.studymachine.www.other.WebUrlConfig;
55 import com.studymachine.www.ui.dialog.UpdateDialog; 58 import com.studymachine.www.ui.dialog.UpdateDialog;
  59 +import com.studymachine.www.ui.presentation.AiListPresentation;
  60 +import com.studymachine.www.ui.presentation.BrowserPresentation;
56 import com.studymachine.www.ui.presentation.SplashPresentation; 61 import com.studymachine.www.ui.presentation.SplashPresentation;
  62 +import com.studymachine.www.ui.presentation.SwitchInfoPresentation;
57 import com.studymachine.www.ui.presentation.WebPresentation; 63 import com.studymachine.www.ui.presentation.WebPresentation;
58 import com.tencent.mmkv.MMKV; 64 import com.tencent.mmkv.MMKV;
59 65
@@ -66,6 +72,13 @@ import timber.log.Timber; @@ -66,6 +72,13 @@ import timber.log.Timber;
66 * desc : 闪屏界面 72 * desc : 闪屏界面
67 */ 73 */
68 public final class SplashActivity extends AppActivity { 74 public final class SplashActivity extends AppActivity {
  75 + private SplashPresentation splashPresentation;
  76 + private AiListPresentation aiListPresentation;
  77 + private BrowserPresentation browserPresentation;
  78 + private SwitchInfoPresentation switchInfoPresentation;
  79 + private WebPresentation webPresentation;
  80 + private String mPointId;
  81 + public PointDetailApi.Bean<AiDTO> mPointDetail;
69 82
70 @Override 83 @Override
71 protected int getLayoutId() { 84 protected int getLayoutId() {
@@ -93,18 +106,17 @@ public final class SplashActivity extends AppActivity { @@ -93,18 +106,17 @@ public final class SplashActivity extends AppActivity {
93 @Override 106 @Override
94 public void onSucceed(HttpData<HostApi.Bean> result) { 107 public void onSucceed(HttpData<HostApi.Bean> result) {
95 if (result.getData() != null) { 108 if (result.getData() != null) {
96 -// if (AppConfig.isDebug()) {  
97 -// AppConfig.setHostUrl("http://192.168.1.23:8100/");  
98 -// AppConfig.setWebHostUrl("http://192.168.1.26:8086/");  
99 -// } else {  
100 -// AppConfig.setHostUrl(result.getData().getApi());  
101 -// AppConfig.setWebHostUrl(result.getData().getH5Url());  
102 -// } 109 + if (AppConfig.isDebug()) {
  110 + AppConfig.setHostUrl("https://api.veln.cn/");
  111 + AppConfig.setWebHostUrl("https://h5.veln.cn/");
  112 + } else {
  113 + AppConfig.setHostUrl(result.getData().getApi());
  114 + AppConfig.setWebHostUrl(result.getData().getH5Url());
  115 + }
103 // AppConfig.setHostUrl(result.getData().getApi()); 116 // AppConfig.setHostUrl(result.getData().getApi());
104 // AppConfig.setWebHostUrl(result.getData().getH5Url()); 117 // AppConfig.setWebHostUrl(result.getData().getH5Url());
105 - AppConfig.setHostUrl("https://api.veln.cn/");  
106 - AppConfig.setWebHostUrl("https://h5.veln.cn/");  
107 -// Tool.updateVersion(getContext()); 118 +
  119 + Tool.updateVersion(getContext());
108 initConfig(); 120 initConfig();
109 } 121 }
110 } 122 }
@@ -125,6 +137,42 @@ public final class SplashActivity extends AppActivity { @@ -125,6 +137,42 @@ public final class SplashActivity extends AppActivity {
125 137
126 @Override 138 @Override
127 protected void initData() { 139 protected void initData() {
  140 + if (deviceInfo != null && deviceInfo.getSn() != null) {
  141 + mControlBack = findViewById(R.id.control_back);
  142 + mControlChange = findViewById(R.id.control_change);
  143 + mControlMode = findViewById(R.id.control_mode);
  144 + mControlBack.setVisibility(View.VISIBLE);
  145 + mControlChange.setVisibility(View.VISIBLE);
  146 + mControlMode.setVisibility(View.VISIBLE);
  147 + mControlLine = findViewById(R.id.control_line);
  148 +// mControlBack.setOnClickListener(new View.OnClickListener() {
  149 +// @Override
  150 +// public void onClick(View v) {
  151 +// finish();
  152 +// if (presentation != null) {
  153 +// presentation.dismiss();
  154 +// }
  155 +// }
  156 +// });
  157 +// mControlChange.setOnClickListener(new View.OnClickListener() {
  158 +// @Override
  159 +// public void onClick(View v) {
  160 +// SwitchInfoActivity.start(getContext());
  161 +// if (presentation != null) {
  162 +// presentation.dismiss();
  163 +// }
  164 +// }
  165 +// });
  166 +// mControlMode.setOnClickListener(new View.OnClickListener() {
  167 +// @Override
  168 +// public void onClick(View v) {
  169 +// if (presentation != null) {
  170 +// presentation.changeMode();
  171 +// }
  172 +// }
  173 +// });
  174 +// return;
  175 +// }
128 getHost(); 176 getHost();
129 } 177 }
130 178
@@ -145,11 +193,8 @@ public final class SplashActivity extends AppActivity { @@ -145,11 +193,8 @@ public final class SplashActivity extends AppActivity {
145 public void onSucceed() { 193 public void onSucceed() {
146 AccountManager.getInstance().addAccountMap(phone, "000000"); 194 AccountManager.getInstance().addAccountMap(phone, "000000");
147 postDelayed(() -> { 195 postDelayed(() -> {
148 - SwitchInfoActivity.start(getContext());  
149 - // 销毁除了首页之外的 Activity  
150 - ActivityManager.getInstance().finishAllActivities(SwitchInfoActivity.class);  
151 - finish();  
152 - presentation.dismiss(); 196 + splashPresentation.dismiss();
  197 + openPresentation(browserPresentation);
153 }, 1000); 198 }, 1000);
154 } 199 }
155 200
@@ -169,31 +214,30 @@ public final class SplashActivity extends AppActivity { @@ -169,31 +214,30 @@ public final class SplashActivity extends AppActivity {
169 UserManager.getInstance().getUserInfo(); 214 UserManager.getInstance().getUserInfo();
170 // 刷新用户信息 215 // 刷新用户信息
171 String grade = UserManager.getInstance().getUserBean().getGrade(); 216 String grade = UserManager.getInstance().getUserBean().getGrade();
172 - if ( TextUtils.isEmpty(grade)) {  
173 - SwitchInfoActivity.start(this);  
174 - // 销毁除了首页之外的 Activity  
175 - ActivityManager.getInstance().finishAllActivities(SwitchInfoActivity.class);  
176 - finish();  
177 - presentation.dismiss(); 217 + if (TextUtils.isEmpty(grade)) {
  218 + splashPresentation.dismiss();
178 } else { 219 } else {
179 - BrowserActivity.start(getContext(),"https://preview.inibiru.com/creator/custom/index.html?id=12242"); 220 + BrowserActivity.start(getContext(), "https://preview.inibiru.com/creator/custom/index.html?id=12242");
180 ActivityManager.getInstance().finishAllActivities(BrowserActivity.class); 221 ActivityManager.getInstance().finishAllActivities(BrowserActivity.class);
181 finish(); 222 finish();
182 - presentation.dismiss(); 223 + splashPresentation.dismiss();
183 } 224 }
184 } 225 }
185 } 226 }
186 227
187 @Override 228 @Override
188 public boolean dispatchTouchEvent(MotionEvent ev) { 229 public boolean dispatchTouchEvent(MotionEvent ev) {
189 - if (presentation != null) {  
190 - return presentation.onTouchEvent(ev); 230 + float y = mControlLine.getY();
  231 + if (ev.getY() < y){
  232 + return super.dispatchTouchEvent(ev);
  233 + }
  234 +
  235 + if (splashPresentation != null) {
  236 + return splashPresentation.onTouchEvent(ev);
191 } 237 }
192 return super.dispatchTouchEvent(ev); 238 return super.dispatchTouchEvent(ev);
193 } 239 }
194 240
195 - private SplashPresentation presentation;  
196 -  
197 @NonNull 241 @NonNull
198 @Override 242 @Override
199 protected ImmersionBar createStatusBarConfig() { 243 protected ImmersionBar createStatusBarConfig() {
@@ -209,11 +253,38 @@ public final class SplashActivity extends AppActivity { @@ -209,11 +253,38 @@ public final class SplashActivity extends AppActivity {
209 } 253 }
210 254
211 public void openAppPresentation() { 255 public void openAppPresentation() {
  256 + if (null == splashPresentation) {
  257 + DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
  258 + Display[] displayList = mDisplayManage.getDisplays();
  259 + if (displayList.length > 1) {
  260 + splashPresentation = new SplashPresentation(this, displayList[1]);
  261 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0
  262 + splashPresentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
  263 + } else {
  264 + splashPresentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
  265 + }
  266 + }
  267 + }
  268 + splashPresentation.setOwnerActivity(this);
  269 + splashPresentation.show();
  270 + }
  271 +
  272 + public void openPresentation(AppPresentation presentation) {
212 if (null == presentation) { 273 if (null == presentation) {
213 DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); 274 DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
214 Display[] displayList = mDisplayManage.getDisplays(); 275 Display[] displayList = mDisplayManage.getDisplays();
215 if (displayList.length > 1) { 276 if (displayList.length > 1) {
216 - presentation = new SplashPresentation(this, displayList[1]); 277 + if (presentation instanceof SplashPresentation) {
  278 + presentation = new SplashPresentation(this, displayList[1]);
  279 + } else if (presentation instanceof BrowserPresentation) {
  280 + presentation = new BrowserPresentation(this, displayList[1], "https://preview.inibiru.com/creator/custom/index.html?id=12242");
  281 + } else if (presentation instanceof AiListPresentation) {
  282 + presentation = new AiListPresentation(this, displayList[1]);
  283 + } else if (presentation instanceof SwitchInfoPresentation) {
  284 + presentation = new SwitchInfoPresentation(this, displayList[1]);
  285 + } else if (presentation instanceof WebPresentation) {
  286 + presentation = new WebPresentation(getContext(), displayList[1], mPointId, mPointDetail);
  287 + }
217 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 288 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0
218 presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); 289 presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
219 } else { 290 } else {
@@ -248,6 +319,6 @@ public final class SplashActivity extends AppActivity { @@ -248,6 +319,6 @@ public final class SplashActivity extends AppActivity {
248 // 因为修复了一个启动页被重复启动的问题,所以有可能 Activity 还没有初始化完成就已经销毁了 319 // 因为修复了一个启动页被重复启动的问题,所以有可能 Activity 还没有初始化完成就已经销毁了
249 // 所以如果需要在此处释放对象资源需要先对这个对象进行判空,否则可能会导致空指针异常 320 // 所以如果需要在此处释放对象资源需要先对这个对象进行判空,否则可能会导致空指针异常
250 super.onDestroy(); 321 super.onDestroy();
251 - presentation.dismiss(); 322 + splashPresentation.dismiss();
252 } 323 }
253 } 324 }
@@ -21,6 +21,7 @@ import com.studymachine.www.js.MainJavaScriptInterface; @@ -21,6 +21,7 @@ import com.studymachine.www.js.MainJavaScriptInterface;
21 import com.studymachine.www.ui.activity.BrowserActivity; 21 import com.studymachine.www.ui.activity.BrowserActivity;
22 import com.studymachine.www.widget.StatusLayout; 22 import com.studymachine.www.widget.StatusLayout;
23 import com.studymachine.www.widget.X5WebView; 23 import com.studymachine.www.widget.X5WebView;
  24 +import com.tencent.smtt.export.external.interfaces.JsResult;
24 import com.tencent.smtt.sdk.ValueCallback; 25 import com.tencent.smtt.sdk.ValueCallback;
25 import com.tencent.smtt.sdk.WebChromeClient; 26 import com.tencent.smtt.sdk.WebChromeClient;
26 import com.tencent.smtt.sdk.WebView; 27 import com.tencent.smtt.sdk.WebView;
@@ -36,6 +37,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction @@ -36,6 +37,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction
36 private ProgressBar mProgressBar; 37 private ProgressBar mProgressBar;
37 private X5WebView mX5WebView; 38 private X5WebView mX5WebView;
38 private ImageView mImgView; 39 private ImageView mImgView;
  40 + ModeHandler handler;
39 41
40 public BrowserPresentation(Context outerContext, Display display) { 42 public BrowserPresentation(Context outerContext, Display display) {
41 super(outerContext, display); 43 super(outerContext, display);
@@ -57,7 +59,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction @@ -57,7 +59,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction
57 59
58 @Override 60 @Override
59 public void initData() { 61 public void initData() {
60 - final ModeHandler handler = new ModeHandler(this); 62 + handler = new ModeHandler(this);
61 mStatusLayout = findViewById(R.id.hl_browser_hint); 63 mStatusLayout = findViewById(R.id.hl_browser_hint);
62 mProgressBar = findViewById(R.id.pb_browser_progress); 64 mProgressBar = findViewById(R.id.pb_browser_progress);
63 mX5WebView = findViewById(R.id.wv_browser_view); 65 mX5WebView = findViewById(R.id.wv_browser_view);
@@ -70,28 +72,34 @@ public class BrowserPresentation extends AppPresentation implements StatusAction @@ -70,28 +72,34 @@ public class BrowserPresentation extends AppPresentation implements StatusAction
70 .into(mImgView); 72 .into(mImgView);
71 mX5WebView.setWebViewClient(new AppBrowserViewClient()); 73 mX5WebView.setWebViewClient(new AppBrowserViewClient());
72 mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); 74 mX5WebView.setWebChromeClient(new AppBrowserChromeClient());
  75 + mX5WebView.getSettings().setJavaScriptEnabled(true);
73 mX5WebView.loadUrl(url); 76 mX5WebView.loadUrl(url);
74 // handler.sendEmptyMessage(0); 77 // handler.sendEmptyMessage(0);
75 // Runnable task = new Runnable() { 78 // Runnable task = new Runnable() {
76 // public void run() { 79 // public void run() {
77 -// mX5WebView.evaluateJavascript("javascript:answerExist()", new ValueCallback<String>() {  
78 -// @Override  
79 -// public void onReceiveValue(String s) {  
80 -// try {  
81 -// mode = Integer.valueOf(s);  
82 -// } catch (Exception e) {  
83 -// mode = 0;  
84 -// } 80 +// try {
  81 +// mX5WebView.loadUrl("javascript:alert(answerExist())");
  82 +// mX5WebView.evaluateJavascript("javascript:answerExist()", new ValueCallback<String>() {
  83 +// @Override
  84 +// public void onReceiveValue(String s) {
  85 +// try {
  86 +// mode = Integer.valueOf(s);
  87 +// } catch (Exception e) {
  88 +// mode = 1;
  89 +// }
85 // 90 //
86 -// }  
87 -// }); 91 +// }
  92 +// });
  93 +////
  94 +// handler.sendEmptyMessage(mode);//设置循环时间,此处是5秒
  95 +// }catch ( Exception e){
88 // 96 //
89 -// handler.sendEmptyMessage(0);//设置循环时间,此处是5秒  
90 -// handler.postDelayed(this, 100); 97 +// }
  98 +// handler.postDelayed(this, 5000);
91 // //需要执行的代码 99 // //需要执行的代码
92 // } 100 // }
93 // }; 101 // };
94 -// 102 +
95 // handler.post(task); 103 // handler.post(task);
96 } 104 }
97 105
@@ -124,6 +132,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction @@ -124,6 +132,7 @@ public class BrowserPresentation extends AppPresentation implements StatusAction
124 */ 132 */
125 @Override 133 @Override
126 public void onPageFinished(WebView view, String url) { 134 public void onPageFinished(WebView view, String url) {
  135 +
127 // showComplete(); 136 // showComplete();
128 mImgView.setVisibility(View.GONE); 137 mImgView.setVisibility(View.GONE);
129 } 138 }