Showing
28 changed files
with
1302 additions
and
226 deletions
@@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
10 | { | 10 | { |
11 | "type": "SINGLE", | 11 | "type": "SINGLE", |
12 | "filters": [], | 12 | "filters": [], |
13 | - "versionCode": 204, | ||
14 | - "versionName": "2.0.4", | ||
15 | - "outputFile": "StudyMachine_v2.0.4_release_0901.apk" | 13 | + "versionCode": 205, |
14 | + "versionName": "2.0.5", | ||
15 | + "outputFile": "StudyMachine_v2.0.5_release_0908.apk" | ||
16 | } | 16 | } |
17 | ] | 17 | ] |
18 | } | 18 | } |
@@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
10 | 10 | ||
11 | <!-- 外部存储 --> | 11 | <!-- 外部存储 --> |
12 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | 12 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
13 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
13 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 14 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
14 | 15 | ||
15 | <!-- 拍照权限 --> | 16 | <!-- 拍照权限 --> |
@@ -146,6 +147,12 @@ | @@ -146,6 +147,12 @@ | ||
146 | android:launchMode="singleTask" | 147 | android:launchMode="singleTask" |
147 | android:screenOrientation="landscape" | 148 | android:screenOrientation="landscape" |
148 | android:windowSoftInputMode="adjustPan" /> | 149 | android:windowSoftInputMode="adjustPan" /> |
150 | + <!-- 首页 --> | ||
151 | + <activity | ||
152 | + android:name="com.studymachine.www.ui.activity.SwitchInfoActivity" | ||
153 | + android:launchMode="singleTask" | ||
154 | + android:screenOrientation="landscape" | ||
155 | + android:windowSoftInputMode="adjustPan" /> | ||
149 | 156 | ||
150 | <!-- 学情档案详情 --> | 157 | <!-- 学情档案详情 --> |
151 | <activity | 158 | <activity |
1 | package com.studymachine.www.app; | 1 | package com.studymachine.www.app; |
2 | 2 | ||
3 | +import android.content.Context; | ||
3 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | +import android.hardware.display.DisplayManager; | ||
6 | +import android.hardware.usb.UsbDevice; | ||
7 | +import android.os.Build; | ||
4 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | +import android.view.Display; | ||
5 | import android.view.View; | 10 | import android.view.View; |
6 | import android.view.WindowManager; | 11 | import android.view.WindowManager; |
12 | +import android.widget.Button; | ||
13 | +import android.widget.ImageView; | ||
7 | 14 | ||
8 | import androidx.annotation.NonNull; | 15 | import androidx.annotation.NonNull; |
9 | import androidx.annotation.Nullable; | 16 | import androidx.annotation.Nullable; |
10 | import androidx.annotation.StringRes; | 17 | import androidx.annotation.StringRes; |
18 | +import androidx.lifecycle.MutableLiveData; | ||
11 | 19 | ||
12 | import com.gyf.immersionbar.BarHide; | 20 | import com.gyf.immersionbar.BarHide; |
13 | import com.gyf.immersionbar.ImmersionBar; | 21 | import com.gyf.immersionbar.ImmersionBar; |
14 | import com.hjq.bar.TitleBar; | 22 | import com.hjq.bar.TitleBar; |
15 | import com.hjq.base.BaseActivity; | 23 | import com.hjq.base.BaseActivity; |
16 | import com.hjq.base.BaseDialog; | 24 | import com.hjq.base.BaseDialog; |
25 | +import com.rokid.axr.phone.glassdevice.RKGlassDevice; | ||
26 | +import com.rokid.axr.phone.glassdevice.callback.OnGlassDeviceConnectListener; | ||
27 | +import com.rokid.axr.phone.glassdevice.hw.GlassInfo; | ||
17 | import com.studymachine.www.R; | 28 | import com.studymachine.www.R; |
29 | +import com.studymachine.www.action.PresentationAction; | ||
18 | import com.studymachine.www.action.TitleBarAction; | 30 | import com.studymachine.www.action.TitleBarAction; |
19 | import com.studymachine.www.action.ToastAction; | 31 | import com.studymachine.www.action.ToastAction; |
20 | import com.studymachine.www.http.model.HttpData; | 32 | import com.studymachine.www.http.model.HttpData; |
@@ -23,6 +35,7 @@ import com.studymachine.www.other.Tool; | @@ -23,6 +35,7 @@ import com.studymachine.www.other.Tool; | ||
23 | import com.studymachine.www.ui.activity.HomeActivity; | 35 | import com.studymachine.www.ui.activity.HomeActivity; |
24 | import com.studymachine.www.ui.dialog.WaitDialog; | 36 | import com.studymachine.www.ui.dialog.WaitDialog; |
25 | import com.hjq.http.listener.OnHttpListener; | 37 | import com.hjq.http.listener.OnHttpListener; |
38 | +import com.studymachine.www.ui.presentation.WebPresentation; | ||
26 | 39 | ||
27 | import org.greenrobot.eventbus.EventBus; | 40 | import org.greenrobot.eventbus.EventBus; |
28 | 41 | ||
@@ -33,7 +46,7 @@ import okhttp3.Call; | @@ -33,7 +46,7 @@ import okhttp3.Call; | ||
33 | * desc : Activity 业务基类 | 46 | * desc : Activity 业务基类 |
34 | */ | 47 | */ |
35 | public abstract class AppActivity extends BaseActivity | 48 | public abstract class AppActivity extends BaseActivity |
36 | - implements ToastAction, TitleBarAction, OnHttpListener<Object> { | 49 | + implements ToastAction, TitleBarAction, OnHttpListener<Object>, PresentationAction { |
37 | 50 | ||
38 | /** | 51 | /** |
39 | * 标题栏对象 | 52 | * 标题栏对象 |
@@ -48,11 +61,21 @@ public abstract class AppActivity extends BaseActivity | @@ -48,11 +61,21 @@ public abstract class AppActivity extends BaseActivity | ||
48 | * 加载对话框 | 61 | * 加载对话框 |
49 | */ | 62 | */ |
50 | private BaseDialog mDialog; | 63 | private BaseDialog mDialog; |
64 | + public Button mControlBack; | ||
65 | + public Button mControlChange; | ||
66 | + public Button mControlMode; | ||
67 | + public ImageView mControlLine; | ||
51 | /** | 68 | /** |
52 | * 对话框数量 | 69 | * 对话框数量 |
53 | */ | 70 | */ |
54 | private int mDialogCount; | 71 | private int mDialogCount; |
55 | 72 | ||
73 | + public GlassInfo deviceInfo = RKGlassDevice.getInstance().getGlassInfo();; | ||
74 | + | ||
75 | + MutableLiveData<Boolean> connectStatus = new MutableLiveData(); | ||
76 | + | ||
77 | + public int mode = 0; | ||
78 | + | ||
56 | /** | 79 | /** |
57 | * 当前加载对话框是否在显示中 | 80 | * 当前加载对话框是否在显示中 |
58 | */ | 81 | */ |
@@ -84,6 +107,10 @@ public abstract class AppActivity extends BaseActivity | @@ -84,6 +107,10 @@ public abstract class AppActivity extends BaseActivity | ||
84 | }, 300); | 107 | }, 300); |
85 | } | 108 | } |
86 | 109 | ||
110 | + @Override | ||
111 | + public void openAppPresentation() { | ||
112 | + } | ||
113 | + | ||
87 | /** | 114 | /** |
88 | * 隐藏加载对话框 | 115 | * 隐藏加载对话框 |
89 | */ | 116 | */ |
@@ -105,8 +132,28 @@ public abstract class AppActivity extends BaseActivity | @@ -105,8 +132,28 @@ public abstract class AppActivity extends BaseActivity | ||
105 | 132 | ||
106 | @Override | 133 | @Override |
107 | protected void initLayout() { | 134 | protected void initLayout() { |
108 | - super.initLayout(); | 135 | + if(!RKGlassDevice.getInstance().requestUSBDevicePermission()){ |
136 | + toast("请到系统设置添加悬浮框权限"); | ||
137 | + finish(); | ||
138 | + } | ||
139 | + RKGlassDevice.getInstance().init(new OnGlassDeviceConnectListener() { | ||
140 | + @Override | ||
141 | + public void onGlassDeviceConnected(UsbDevice usbDevice) { | ||
142 | +// //Glass 设备连接成功 | ||
143 | +// addControllerView(); | ||
144 | + connectStatus.setValue(true); | ||
145 | + openAppPresentation(); | ||
146 | + } | ||
109 | 147 | ||
148 | + @Override | ||
149 | + public void onGlassDeviceDisconnected() { | ||
150 | + connectStatus.setValue(false); | ||
151 | +// mControllerBid.setVisibility(View.GONE); | ||
152 | + } | ||
153 | + }); | ||
154 | + | ||
155 | + deviceInfo = RKGlassDevice.getInstance().getGlassInfo(); | ||
156 | + super.initLayout(); | ||
110 | if (getTitleBar() != null) { | 157 | if (getTitleBar() != null) { |
111 | getTitleBar().setOnTitleBarListener(this); | 158 | getTitleBar().setOnTitleBarListener(this); |
112 | } | 159 | } |
@@ -160,6 +160,7 @@ public final class AppApplication extends Application { | @@ -160,6 +160,7 @@ public final class AppApplication extends Application { | ||
160 | 160 | ||
161 | @Override | 161 | @Override |
162 | public void onGlassDeviceDisconnected() { | 162 | public void onGlassDeviceDisconnected() { |
163 | + ActivityManager.getInstance().finishAllActivities(); | ||
163 | //Glass 设备断开连接 | 164 | //Glass 设备断开连接 |
164 | } | 165 | } |
165 | }); | 166 | }); |
@@ -5,6 +5,7 @@ import android.content.Context; | @@ -5,6 +5,7 @@ import android.content.Context; | ||
5 | import android.graphics.Rect; | 5 | import android.graphics.Rect; |
6 | import android.graphics.drawable.Drawable; | 6 | import android.graphics.drawable.Drawable; |
7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
8 | +import android.os.Handler; | ||
8 | import android.os.SystemClock; | 9 | import android.os.SystemClock; |
9 | import android.util.DisplayMetrics; | 10 | import android.util.DisplayMetrics; |
10 | import android.view.Display; | 11 | import android.view.Display; |
@@ -37,9 +38,12 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | @@ -37,9 +38,12 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | ||
37 | private FrameLayout mControllerFrame; | 38 | private FrameLayout mControllerFrame; |
38 | private ControllerView controllerView; | 39 | private ControllerView controllerView; |
39 | private FrameLayout mControllerBid; | 40 | private FrameLayout mControllerBid; |
40 | - private ImageView imageView; | 41 | + private ImageView mControllerPoint; |
42 | + private ImageView mControllerImage; | ||
41 | private StatusLayout mStatusLayout; | 43 | private StatusLayout mStatusLayout; |
42 | private ImageView mIvBack, mImgView; | 44 | private ImageView mIvBack, mImgView; |
45 | + public int mode = 1; | ||
46 | + | ||
43 | public AppPresentation(Context outerContext, Display display) { | 47 | public AppPresentation(Context outerContext, Display display) { |
44 | super(outerContext, display); | 48 | super(outerContext, display); |
45 | } | 49 | } |
@@ -48,29 +52,54 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | @@ -48,29 +52,54 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | ||
48 | super(outerContext, display, theme); | 52 | super(outerContext, display, theme); |
49 | } | 53 | } |
50 | 54 | ||
55 | + public void setMode(int mode) { | ||
56 | + this.mode = mode; | ||
57 | + if (mode == 1) { | ||
58 | + mControllerImage.setVisibility(View.VISIBLE); | ||
59 | + mControllerPoint.setVisibility(View.GONE); | ||
60 | + } else { | ||
61 | + mControllerImage.setVisibility(View.GONE); | ||
62 | + mControllerPoint.setVisibility(View.VISIBLE); | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
51 | @Override | 66 | @Override |
52 | protected void onCreate(Bundle savedInstanceState) { | 67 | protected void onCreate(Bundle savedInstanceState) { |
53 | super.onCreate(savedInstanceState); | 68 | super.onCreate(savedInstanceState); |
54 | setContentView(getLayout()); | 69 | setContentView(getLayout()); |
55 | addControllerView(); | 70 | addControllerView(); |
56 | initData(); | 71 | initData(); |
57 | - | ||
58 | - mIvBack.setOnClickListener(new View.OnClickListener() { | ||
59 | - @Override | ||
60 | - public void onClick(View v) { | ||
61 | - dismiss(); | ||
62 | - getOwnerActivity().finish(); | ||
63 | - } | ||
64 | - }); | 72 | + mIvBack = findViewById(R.id.iv_back); |
73 | + if (mIvBack != null) { | ||
74 | + mIvBack.setOnClickListener(new View.OnClickListener() { | ||
75 | + @Override | ||
76 | + public void onClick(View v) { | ||
77 | + getOwnerActivity().finish(); | ||
78 | + dismiss(); | ||
79 | + } | ||
80 | + }); | ||
81 | + } | ||
65 | EventBusManager.register(this); | 82 | EventBusManager.register(this); |
66 | } | 83 | } |
67 | 84 | ||
85 | + public void changeMode() { | ||
86 | + if (mode == 1){ | ||
87 | + setMode(0); | ||
88 | + } else { | ||
89 | + setMode(1); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
68 | private void addControllerView() { | 93 | private void addControllerView() { |
69 | controllerView = new ControllerView(getContext(), null); | 94 | controllerView = new ControllerView(getContext(), null); |
70 | ViewGroup root = (ViewGroup) getWindow().getDecorView(); | 95 | ViewGroup root = (ViewGroup) getWindow().getDecorView(); |
71 | root.addView(controllerView); | 96 | root.addView(controllerView); |
72 | controllerView.bringToFront(); | 97 | controllerView.bringToFront(); |
98 | + mControllerBid = findViewById(R.id.controller_bid); | ||
99 | + mControllerImage = findViewById(R.id.controller_image); | ||
100 | + mControllerPoint = findViewById(R.id.controller_point); | ||
73 | } | 101 | } |
102 | + | ||
74 | public abstract int getLayout(); | 103 | public abstract int getLayout(); |
75 | 104 | ||
76 | public abstract void initData(); | 105 | public abstract void initData(); |
@@ -259,52 +288,71 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | @@ -259,52 +288,71 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | ||
259 | float distanceY = event.getRawY() - lastY; | 288 | float distanceY = event.getRawY() - lastY; |
260 | lastX = event.getRawX(); | 289 | lastX = event.getRawX(); |
261 | lastY = event.getRawY(); | 290 | lastY = event.getRawY(); |
262 | - // 得到屏幕的宽 | ||
263 | - displayMetrics = getResources().getDisplayMetrics(); | ||
264 | - screenWidth = displayMetrics.widthPixels; | ||
265 | - // 得到标题栏和状态栏的高度 | ||
266 | - Rect rect = new Rect(); | ||
267 | - Window window = getWindow(); | ||
268 | - imageView.getWindowVisibleDisplayFrame(rect); | ||
269 | - int statusBarHeight = rect.top; | ||
270 | - int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); | ||
271 | - int titleBarHeight = contentViewTop - statusBarHeight; | ||
272 | - // 得到屏幕的高 | ||
273 | - screenHeight = displayMetrics.heightPixels - (statusBarHeight + titleBarHeight); | ||
274 | - // 更新界面 | ||
275 | - left = (int) (imageView.getLeft() + distanceX); | ||
276 | - top = (int) (imageView.getTop() + distanceY); | ||
277 | - right = (int) (imageView.getRight() + distanceX); | ||
278 | - bottom = (int) (imageView.getBottom() + distanceY); | ||
279 | - boolean move = false; | ||
280 | - | ||
281 | - //处理拖出屏幕的情况 | ||
282 | - if (left < 0) { | ||
283 | - move = true; | ||
284 | - scollX = left; | ||
285 | - left = 0; | ||
286 | - right = imageView.getWidth(); | ||
287 | - } | ||
288 | - if (right > screenWidth) { | ||
289 | - move = true; | ||
290 | - scollX = right - screenWidth; | ||
291 | - right = screenWidth; | ||
292 | - left = screenWidth - imageView.getWidth(); | ||
293 | - } | ||
294 | - if (top < 0) { | ||
295 | - move = true; | ||
296 | - scollY = top; | ||
297 | - top = 0; | ||
298 | - bottom = imageView.getHeight(); | ||
299 | - } | ||
300 | - if (bottom > screenHeight) { | ||
301 | - move = true; | ||
302 | - scollY = bottom - screenHeight; | ||
303 | - bottom = screenHeight; | ||
304 | - top = screenHeight - imageView.getHeight(); | 291 | + if (mode == 1) { |
292 | + // 得到屏幕的宽 | ||
293 | + displayMetrics = getResources().getDisplayMetrics(); | ||
294 | + screenWidth = displayMetrics.widthPixels; | ||
295 | + // 得到标题栏和状态栏的高度 | ||
296 | + Rect rect = new Rect(); | ||
297 | + Window window = getWindow(); | ||
298 | + mControllerImage.getWindowVisibleDisplayFrame(rect); | ||
299 | + int statusBarHeight = rect.top; | ||
300 | + int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop(); | ||
301 | + int titleBarHeight = contentViewTop - statusBarHeight; | ||
302 | + // 得到屏幕的高 | ||
303 | + screenHeight = displayMetrics.heightPixels - (statusBarHeight + titleBarHeight); | ||
304 | + // 更新界面 | ||
305 | + left = (int) (mControllerImage.getLeft() + distanceX); | ||
306 | + top = (int) (mControllerImage.getTop() + distanceY); | ||
307 | + right = (int) (mControllerImage.getRight() + distanceX); | ||
308 | + bottom = (int) (mControllerImage.getBottom() + distanceY); | ||
309 | + boolean move = false; | ||
310 | + | ||
311 | + //处理拖出屏幕的情况 | ||
312 | + if (left < 0) { | ||
313 | + move = true; | ||
314 | + scollX = left; | ||
315 | + left = 0; | ||
316 | + right = mControllerImage.getWidth(); | ||
317 | + } | ||
318 | + if (right > screenWidth) { | ||
319 | + move = true; | ||
320 | + scollX = right - screenWidth; | ||
321 | + right = screenWidth; | ||
322 | + left = screenWidth - mControllerImage.getWidth(); | ||
323 | + } | ||
324 | + if (top < 0) { | ||
325 | + move = true; | ||
326 | + scollY = top; | ||
327 | + top = 0; | ||
328 | + bottom = mControllerImage.getHeight(); | ||
329 | + } | ||
330 | + if (bottom > screenHeight) { | ||
331 | + move = true; | ||
332 | + scollY = bottom - screenHeight; | ||
333 | + bottom = screenHeight; | ||
334 | + top = screenHeight - mControllerImage.getHeight(); | ||
335 | + } | ||
336 | + //显示图片 | ||
337 | + mControllerImage.layout(left, top, right, bottom); | ||
338 | + if (move) { | ||
339 | + View view = getViewAtActivity(x, y); | ||
340 | + MotionEvent motionEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_DOWN, 0, 0, 0); | ||
341 | + view.dispatchTouchEvent(motionEvent); | ||
342 | + MotionEvent moveEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_MOVE, 0 - scollX, 0 - scollY, 0); | ||
343 | + view.dispatchTouchEvent(moveEvent); | ||
344 | + MotionEvent upEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_UP, 0, 0, 0); | ||
345 | + view.dispatchTouchEvent(upEvent); | ||
346 | + } | ||
347 | + } else { | ||
348 | + View view = getViewAtActivity(x, y); | ||
349 | + MotionEvent motionEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_DOWN, 0, 0, 0); | ||
350 | + view.dispatchTouchEvent(motionEvent); | ||
351 | + MotionEvent moveEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_MOVE, 0 - distanceX, 0 - distanceY, 0); | ||
352 | + view.dispatchTouchEvent(moveEvent); | ||
353 | + MotionEvent upEvent = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_UP, 0, 0, 0); | ||
354 | + view.dispatchTouchEvent(upEvent); | ||
305 | } | 355 | } |
306 | - //显示图片 | ||
307 | - imageView.layout(left, top, right, bottom); | ||
308 | break; | 356 | break; |
309 | //抬起 | 357 | //抬起 |
310 | case MotionEvent.ACTION_UP: | 358 | case MotionEvent.ACTION_UP: |
@@ -312,16 +360,33 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | @@ -312,16 +360,33 @@ public abstract class AppPresentation extends Presentation implements TitleBarAc | ||
312 | if (endTime - startTime < 200) { | 360 | if (endTime - startTime < 200) { |
313 | endTime = 0; | 361 | endTime = 0; |
314 | startTime = 0; | 362 | startTime = 0; |
315 | - x = imageView.getX(); | ||
316 | - y = imageView.getY(); | ||
317 | - View view = getViewAtActivity(x, y); | ||
318 | - if (null != view) { | ||
319 | - view.post(new Runnable() { | ||
320 | - @Override | ||
321 | - public void run() { | ||
322 | - simulateTouchEvent(view, x, y); | ||
323 | - } | ||
324 | - }); | 363 | + if (mode == 1) { |
364 | + x = mControllerImage.getX(); | ||
365 | + y = mControllerImage.getY(); | ||
366 | + View view = getViewAtActivity(x, y); | ||
367 | + if (null != view) { | ||
368 | + view.post(new Runnable() { | ||
369 | + @Override | ||
370 | + public void run() { | ||
371 | + simulateTouchEvent(view, x, y); | ||
372 | + } | ||
373 | + }); | ||
374 | + } | ||
375 | + } else { | ||
376 | + if (mControllerPoint == null) { | ||
377 | + break; | ||
378 | + } | ||
379 | + x = mControllerPoint.getX(); | ||
380 | + y = mControllerPoint.getY(); | ||
381 | + View view = getViewAtActivity(x, y); | ||
382 | + if (null != view) { | ||
383 | + view.post(new Runnable() { | ||
384 | + @Override | ||
385 | + public void run() { | ||
386 | + simulateTouchEvent(view, x, y); | ||
387 | + } | ||
388 | + }); | ||
389 | + } | ||
325 | } | 390 | } |
326 | } | 391 | } |
327 | 392 |
1 | +package com.studymachine.www.app; | ||
2 | + | ||
3 | +import android.app.Activity; | ||
4 | +import android.os.Handler; | ||
5 | +import android.os.Message; | ||
6 | +import android.view.View; | ||
7 | +import android.widget.ImageView; | ||
8 | + | ||
9 | +import androidx.annotation.NonNull; | ||
10 | + | ||
11 | +import com.studymachine.www.R; | ||
12 | +import com.studymachine.www.widget.X5WebView; | ||
13 | +import com.tencent.smtt.sdk.ValueCallback; | ||
14 | + | ||
15 | +import java.lang.ref.WeakReference; | ||
16 | +import java.util.logging.LogRecord; | ||
17 | + | ||
18 | +public class ModeHandler extends Handler { | ||
19 | + | ||
20 | + private AppPresentation presentation; | ||
21 | + private int mode; | ||
22 | + | ||
23 | + public ModeHandler(AppPresentation presentation) { | ||
24 | + this.presentation = presentation; | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public void handleMessage(@NonNull Message msg) { | ||
29 | + presentation.setMode(msg.what); | ||
30 | + super.handleMessage(msg); | ||
31 | + } | ||
32 | +} |
@@ -9,13 +9,11 @@ public final class LoginApi implements IRequestApi { | @@ -9,13 +9,11 @@ public final class LoginApi implements IRequestApi { | ||
9 | 9 | ||
10 | @Override | 10 | @Override |
11 | public String getApi() { | 11 | public String getApi() { |
12 | - return "auth/login"; | 12 | + return "auth/glasses/login"; |
13 | } | 13 | } |
14 | 14 | ||
15 | /** 手机号 */ | 15 | /** 手机号 */ |
16 | private String mobile; | 16 | private String mobile; |
17 | - /** 登录密码 */ | ||
18 | - private String password; | ||
19 | /** 场景 */ | 17 | /** 场景 */ |
20 | private String scene="password_login"; | 18 | private String scene="password_login"; |
21 | 19 | ||
@@ -24,11 +22,6 @@ public final class LoginApi implements IRequestApi { | @@ -24,11 +22,6 @@ public final class LoginApi implements IRequestApi { | ||
24 | return this; | 22 | return this; |
25 | } | 23 | } |
26 | 24 | ||
27 | - public LoginApi setPassword(String password) { | ||
28 | - this.password = password; | ||
29 | - return this; | ||
30 | - } | ||
31 | - | ||
32 | public final static class Bean { | 25 | public final static class Bean { |
33 | 26 | ||
34 | private String token; | 27 | private String token; |
@@ -9,7 +9,7 @@ public final class UpdateVersionApi implements IRequestApi { | @@ -9,7 +9,7 @@ public final class UpdateVersionApi implements IRequestApi { | ||
9 | 9 | ||
10 | @Override | 10 | @Override |
11 | public String getApi() { | 11 | public String getApi() { |
12 | - return "common/public/version"; | 12 | + return "common/public/version/glasses"; |
13 | } | 13 | } |
14 | 14 | ||
15 | public final static class Bean { | 15 | public final static class Bean { |
@@ -21,6 +21,8 @@ import com.hjq.http.listener.OnDownloadListener; | @@ -21,6 +21,8 @@ import com.hjq.http.listener.OnDownloadListener; | ||
21 | import com.hjq.http.model.HttpMethod; | 21 | import com.hjq.http.model.HttpMethod; |
22 | import com.hjq.toast.ToastUtils; | 22 | import com.hjq.toast.ToastUtils; |
23 | import com.studymachine.www.BuildConfig; | 23 | import com.studymachine.www.BuildConfig; |
24 | +import com.studymachine.www.app.AppPresentation; | ||
25 | +import com.studymachine.www.app.ModeHandler; | ||
24 | import com.studymachine.www.event.SwfEvent; | 26 | import com.studymachine.www.event.SwfEvent; |
25 | import com.studymachine.www.http.glide.GlideApp; | 27 | import com.studymachine.www.http.glide.GlideApp; |
26 | import com.studymachine.www.manager.GlobalParameterManager; | 28 | import com.studymachine.www.manager.GlobalParameterManager; |
@@ -29,6 +31,7 @@ import com.studymachine.www.other.AppConfig; | @@ -29,6 +31,7 @@ import com.studymachine.www.other.AppConfig; | ||
29 | import com.studymachine.www.other.Tool; | 31 | import com.studymachine.www.other.Tool; |
30 | import com.studymachine.www.other.WebUrlConfig; | 32 | import com.studymachine.www.other.WebUrlConfig; |
31 | import com.studymachine.www.ui.activity.AiDetailActivity; | 33 | import com.studymachine.www.ui.activity.AiDetailActivity; |
34 | +import com.studymachine.www.ui.activity.AiListActivity; | ||
32 | import com.studymachine.www.ui.activity.BrowserActivity; | 35 | import com.studymachine.www.ui.activity.BrowserActivity; |
33 | import com.studymachine.www.ui.activity.SwfActivity; | 36 | import com.studymachine.www.ui.activity.SwfActivity; |
34 | import com.studymachine.www.ui.dialog.WaitDialog; | 37 | import com.studymachine.www.ui.dialog.WaitDialog; |
@@ -50,6 +53,7 @@ public class MainJavaScriptInterface { | @@ -50,6 +53,7 @@ public class MainJavaScriptInterface { | ||
50 | private X5WebView mX5WebView; | 53 | private X5WebView mX5WebView; |
51 | private BaseDialog mDialog; | 54 | private BaseDialog mDialog; |
52 | private String singPageData; | 55 | private String singPageData; |
56 | + private ModeHandler handler; | ||
53 | private String time; | 57 | private String time; |
54 | private boolean isSwfPlay = false; | 58 | private boolean isSwfPlay = false; |
55 | private int mode; | 59 | private int mode; |
@@ -59,6 +63,12 @@ public class MainJavaScriptInterface { | @@ -59,6 +63,12 @@ public class MainJavaScriptInterface { | ||
59 | mX5WebView = x5WebView; | 63 | mX5WebView = x5WebView; |
60 | } | 64 | } |
61 | 65 | ||
66 | + public MainJavaScriptInterface(Activity context, X5WebView x5WebView, ModeHandler handler) { | ||
67 | + mContext = context; | ||
68 | + mX5WebView = x5WebView; | ||
69 | + this.handler = handler; | ||
70 | + } | ||
71 | + | ||
62 | /** | 72 | /** |
63 | * 记录ai的开始时间 | 73 | * 记录ai的开始时间 |
64 | * | 74 | * |
@@ -204,7 +214,7 @@ public class MainJavaScriptInterface { | @@ -204,7 +214,7 @@ public class MainJavaScriptInterface { | ||
204 | */ | 214 | */ |
205 | @JavascriptInterface | 215 | @JavascriptInterface |
206 | public void modeChange(int mode) { | 216 | public void modeChange(int mode) { |
207 | - this.mode = mode; | 217 | + handler.sendEmptyMessage(mode); |
208 | } | 218 | } |
209 | 219 | ||
210 | /** | 220 | /** |
@@ -222,6 +232,11 @@ public class MainJavaScriptInterface { | @@ -222,6 +232,11 @@ public class MainJavaScriptInterface { | ||
222 | */ | 232 | */ |
223 | @JavascriptInterface | 233 | @JavascriptInterface |
224 | public void gotoApp(String packageName) { | 234 | public void gotoApp(String packageName) { |
235 | + if (packageName.equals("studyMachine")) { | ||
236 | + AiListActivity.start(mContext); | ||
237 | + return; | ||
238 | + } | ||
239 | + | ||
225 | boolean hasApp = Tool.isApkInstalled(mContext, packageName); | 240 | boolean hasApp = Tool.isApkInstalled(mContext, packageName); |
226 | if (!hasApp) { | 241 | if (!hasApp) { |
227 | ToastUtils.show("app不存在"); | 242 | ToastUtils.show("app不存在"); |
@@ -29,6 +29,7 @@ import com.studymachine.www.action.StatusAction; | @@ -29,6 +29,7 @@ import com.studymachine.www.action.StatusAction; | ||
29 | import com.studymachine.www.aop.CheckNet; | 29 | import com.studymachine.www.aop.CheckNet; |
30 | import com.studymachine.www.aop.Log; | 30 | import com.studymachine.www.aop.Log; |
31 | import com.studymachine.www.app.AppActivity; | 31 | import com.studymachine.www.app.AppActivity; |
32 | +import com.studymachine.www.app.ModeHandler; | ||
32 | import com.studymachine.www.http.glide.GlideApp; | 33 | import com.studymachine.www.http.glide.GlideApp; |
33 | import com.studymachine.www.js.MainJavaScriptInterface; | 34 | import com.studymachine.www.js.MainJavaScriptInterface; |
34 | import com.studymachine.www.domain.AiDTO; | 35 | import com.studymachine.www.domain.AiDTO; |
@@ -41,6 +42,7 @@ import com.studymachine.www.ui.presentation.WebPresentation; | @@ -41,6 +42,7 @@ import com.studymachine.www.ui.presentation.WebPresentation; | ||
41 | import com.studymachine.www.ui.dialog.ConfirmDialog; | 42 | import com.studymachine.www.ui.dialog.ConfirmDialog; |
42 | import com.studymachine.www.widget.StatusLayout; | 43 | import com.studymachine.www.widget.StatusLayout; |
43 | import com.studymachine.www.widget.X5WebView; | 44 | import com.studymachine.www.widget.X5WebView; |
45 | +import com.tencent.smtt.sdk.ValueCallback; | ||
44 | import com.tencent.smtt.sdk.WebChromeClient; | 46 | import com.tencent.smtt.sdk.WebChromeClient; |
45 | import com.tencent.smtt.sdk.WebView; | 47 | import com.tencent.smtt.sdk.WebView; |
46 | import com.tencent.smtt.sdk.WebViewClient; | 48 | import com.tencent.smtt.sdk.WebViewClient; |
@@ -104,8 +106,40 @@ public final class AiDetailActivity extends AppActivity | @@ -104,8 +106,40 @@ public final class AiDetailActivity extends AppActivity | ||
104 | protected void initView() { | 106 | protected void initView() { |
105 | RKGlassDevice.getInstance().requestUSBDevicePermission(); | 107 | RKGlassDevice.getInstance().requestUSBDevicePermission(); |
106 | if (deviceInfo != null && deviceInfo.getSn() != null) { | 108 | if (deviceInfo != null && deviceInfo.getSn() != null) { |
107 | - mPointId = getString(INTENT_KEY_IN_POINT_ID); | ||
108 | - getPresentationDetail(); | 109 | + mControlBack = findViewById(R.id.control_back); |
110 | + mControlChange = findViewById(R.id.control_change); | ||
111 | + mControlMode = findViewById(R.id.control_mode); | ||
112 | + mControlBack.setVisibility(View.VISIBLE); | ||
113 | + mControlChange.setVisibility(View.VISIBLE); | ||
114 | + mControlMode.setVisibility(View.VISIBLE); | ||
115 | + mControlLine = findViewById(R.id.control_line); | ||
116 | + mControlBack.setOnClickListener(new View.OnClickListener() { | ||
117 | + @Override | ||
118 | + public void onClick(View v) { | ||
119 | + finish(); | ||
120 | + if (presentation != null) { | ||
121 | + presentation.dismiss(); | ||
122 | + } | ||
123 | + } | ||
124 | + }); | ||
125 | + mControlChange.setOnClickListener(new View.OnClickListener() { | ||
126 | + @Override | ||
127 | + public void onClick(View v) { | ||
128 | + SwitchInfoActivity.start(getContext()); | ||
129 | + finish(); | ||
130 | + if (presentation != null) { | ||
131 | + presentation.dismiss(); | ||
132 | + } | ||
133 | + } | ||
134 | + }); | ||
135 | + mControlMode.setOnClickListener(new View.OnClickListener() { | ||
136 | + @Override | ||
137 | + public void onClick(View v) { | ||
138 | + if (presentation != null) { | ||
139 | + presentation.changeMode(); | ||
140 | + } | ||
141 | + } | ||
142 | + }); | ||
109 | } else { | 143 | } else { |
110 | mImgView = findViewById(R.id.loadview); | 144 | mImgView = findViewById(R.id.loadview); |
111 | 145 | ||
@@ -140,6 +174,10 @@ public final class AiDetailActivity extends AppActivity | @@ -140,6 +174,10 @@ public final class AiDetailActivity extends AppActivity | ||
140 | 174 | ||
141 | @Override | 175 | @Override |
142 | public boolean dispatchTouchEvent(MotionEvent ev) { | 176 | public boolean dispatchTouchEvent(MotionEvent ev) { |
177 | + float y = mControlLine.getY(); | ||
178 | + if (ev.getY() < y){ | ||
179 | + return super.dispatchTouchEvent(ev); | ||
180 | + } | ||
143 | if (presentation != null) { | 181 | if (presentation != null) { |
144 | return presentation.onTouchEvent(ev); | 182 | return presentation.onTouchEvent(ev); |
145 | } | 183 | } |
@@ -148,24 +186,8 @@ public final class AiDetailActivity extends AppActivity | @@ -148,24 +186,8 @@ public final class AiDetailActivity extends AppActivity | ||
148 | 186 | ||
149 | private WebPresentation presentation; | 187 | private WebPresentation presentation; |
150 | 188 | ||
151 | - private void openAppPresentation() { | ||
152 | - if (null == presentation) { | ||
153 | - DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); | ||
154 | - Display[] displayList = mDisplayManage.getDisplays(); | ||
155 | - if (displayList.length > 1) { | ||
156 | - presentation = new WebPresentation(this, displayList[1],mPointId,mPointDetail); | ||
157 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
158 | - presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
159 | - } else { | ||
160 | - presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
161 | - } | ||
162 | - } | ||
163 | - } | ||
164 | - presentation.setOwnerActivity(this); | ||
165 | - presentation.show(); | ||
166 | - } | ||
167 | - | ||
168 | - private void getDetail() { | 189 | + public void openAppPresentation() { |
190 | + mPointId = getString(INTENT_KEY_IN_POINT_ID); | ||
169 | EasyHttp.get(this) | 191 | EasyHttp.get(this) |
170 | .api(new PointDetailApi() | 192 | .api(new PointDetailApi() |
171 | .setPointId(mPointId) | 193 | .setPointId(mPointId) |
@@ -174,8 +196,21 @@ public final class AiDetailActivity extends AppActivity | @@ -174,8 +196,21 @@ public final class AiDetailActivity extends AppActivity | ||
174 | @Override | 196 | @Override |
175 | public void onSucceed(HttpData<PointDetailApi.Bean<AiDTO>> result) { | 197 | public void onSucceed(HttpData<PointDetailApi.Bean<AiDTO>> result) { |
176 | mPointDetail = result.getData(); | 198 | mPointDetail = result.getData(); |
177 | - mX5WebView.loadUrl(result.getData().isFinish() ? mPointDetail.getScene().getArbitrarilyUrl() : mPointDetail.getScene().getSequenceUrl()); | ||
178 | - | 199 | + if (null == presentation) { |
200 | + DisplayManager mDisplayManage = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE); | ||
201 | + Display[] displayList = mDisplayManage.getDisplays(); | ||
202 | + if (displayList.length > 1) { | ||
203 | + presentation = new WebPresentation(getContext(), displayList[1], mPointId, mPointDetail); | ||
204 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
205 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
206 | + } else { | ||
207 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
208 | + } | ||
209 | + } | ||
210 | + } | ||
211 | + presentation.setOwnerActivity(getActivity()); | ||
212 | + presentation.show(); | ||
213 | + presentation.setMode(0); | ||
179 | // mX5WebView.loadUrl("http://192.168.1.26:8086/pages/ai/ai?aiIndex=0"); | 214 | // mX5WebView.loadUrl("http://192.168.1.26:8086/pages/ai/ai?aiIndex=0"); |
180 | } | 215 | } |
181 | 216 | ||
@@ -187,7 +222,7 @@ public final class AiDetailActivity extends AppActivity | @@ -187,7 +222,7 @@ public final class AiDetailActivity extends AppActivity | ||
187 | }); | 222 | }); |
188 | } | 223 | } |
189 | 224 | ||
190 | - private void getPresentationDetail() { | 225 | + private void getDetail() { |
191 | EasyHttp.get(this) | 226 | EasyHttp.get(this) |
192 | .api(new PointDetailApi() | 227 | .api(new PointDetailApi() |
193 | .setPointId(mPointId) | 228 | .setPointId(mPointId) |
@@ -196,7 +231,8 @@ public final class AiDetailActivity extends AppActivity | @@ -196,7 +231,8 @@ public final class AiDetailActivity extends AppActivity | ||
196 | @Override | 231 | @Override |
197 | public void onSucceed(HttpData<PointDetailApi.Bean<AiDTO>> result) { | 232 | public void onSucceed(HttpData<PointDetailApi.Bean<AiDTO>> result) { |
198 | mPointDetail = result.getData(); | 233 | mPointDetail = result.getData(); |
199 | - openAppPresentation(); | 234 | + mX5WebView.loadUrl(result.getData().isFinish() ? mPointDetail.getScene().getArbitrarilyUrl() : mPointDetail.getScene().getSequenceUrl()); |
235 | + | ||
200 | // mX5WebView.loadUrl("http://192.168.1.26:8086/pages/ai/ai?aiIndex=0"); | 236 | // mX5WebView.loadUrl("http://192.168.1.26:8086/pages/ai/ai?aiIndex=0"); |
201 | } | 237 | } |
202 | 238 | ||
@@ -278,7 +314,7 @@ public final class AiDetailActivity extends AppActivity | @@ -278,7 +314,7 @@ public final class AiDetailActivity extends AppActivity | ||
278 | @Override | 314 | @Override |
279 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 315 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
280 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 316 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
281 | - if (mX5WebView == null && presentation != null){ | 317 | + if (mX5WebView == null && presentation != null) { |
282 | presentation.dismiss(); | 318 | presentation.dismiss(); |
283 | return super.onKeyDown(keyCode, event); | 319 | return super.onKeyDown(keyCode, event); |
284 | } | 320 | } |
@@ -2,9 +2,14 @@ package com.studymachine.www.ui.activity; | @@ -2,9 +2,14 @@ package com.studymachine.www.ui.activity; | ||
2 | 2 | ||
3 | import android.content.Context; | 3 | import android.content.Context; |
4 | import android.content.Intent; | 4 | import android.content.Intent; |
5 | +import android.hardware.display.DisplayManager; | ||
5 | import android.media.MediaPlayer; | 6 | import android.media.MediaPlayer; |
7 | +import android.os.Build; | ||
6 | import android.util.Log; | 8 | import android.util.Log; |
9 | +import android.view.Display; | ||
10 | +import android.view.MotionEvent; | ||
7 | import android.view.View; | 11 | import android.view.View; |
12 | +import android.view.WindowManager; | ||
8 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
9 | 14 | ||
10 | import androidx.annotation.Nullable; | 15 | import androidx.annotation.Nullable; |
@@ -31,6 +36,8 @@ import com.studymachine.www.manager.GlobalParameterManager; | @@ -31,6 +36,8 @@ import com.studymachine.www.manager.GlobalParameterManager; | ||
31 | import com.studymachine.www.other.PermissionCallback; | 36 | import com.studymachine.www.other.PermissionCallback; |
32 | import com.studymachine.www.other.Tool; | 37 | import com.studymachine.www.other.Tool; |
33 | import com.studymachine.www.ui.adapter.AiListAdapter; | 38 | import com.studymachine.www.ui.adapter.AiListAdapter; |
39 | +import com.studymachine.www.ui.presentation.AiListPresentation; | ||
40 | +import com.studymachine.www.ui.presentation.BrowserPresentation; | ||
34 | 41 | ||
35 | import java.util.ArrayList; | 42 | import java.util.ArrayList; |
36 | import java.util.List; | 43 | import java.util.List; |
@@ -47,11 +54,16 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | @@ -47,11 +54,16 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | ||
47 | private List<GetAiListApi.Bean> mDataList = new ArrayList<>(); | 54 | private List<GetAiListApi.Bean> mDataList = new ArrayList<>(); |
48 | private AppCompatImageView mIvPerson; | 55 | private AppCompatImageView mIvPerson; |
49 | private MediaPlayer mMediaPlayer; | 56 | private MediaPlayer mMediaPlayer; |
57 | + private AiListPresentation presentation; | ||
50 | 58 | ||
51 | 59 | ||
52 | @Override | 60 | @Override |
53 | protected int getLayoutId() { | 61 | protected int getLayoutId() { |
54 | - return R.layout.ai_list_activity; | 62 | + if (deviceInfo != null && deviceInfo.getSn() != null) { |
63 | + return R.layout.control_cursor; | ||
64 | + } else { | ||
65 | + return R.layout.ai_list_activity; | ||
66 | + } | ||
55 | } | 67 | } |
56 | 68 | ||
57 | public static void start(Context context) { | 69 | public static void start(Context context) { |
@@ -61,6 +73,43 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | @@ -61,6 +73,43 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | ||
61 | 73 | ||
62 | @Override | 74 | @Override |
63 | protected void initView() { | 75 | protected void initView() { |
76 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
77 | + mControlBack = findViewById(R.id.control_back); | ||
78 | + mControlChange = findViewById(R.id.control_change); | ||
79 | + mControlMode = findViewById(R.id.control_mode); | ||
80 | + mControlBack.setVisibility(View.VISIBLE); | ||
81 | + mControlChange.setVisibility(View.GONE); | ||
82 | + mControlMode.setVisibility(View.GONE); | ||
83 | + mControlLine = findViewById(R.id.control_line); | ||
84 | + mControlBack.setOnClickListener(new View.OnClickListener() { | ||
85 | + @Override | ||
86 | + public void onClick(View v) { | ||
87 | + finish(); | ||
88 | + if (presentation != null) { | ||
89 | + presentation.dismiss(); | ||
90 | + } | ||
91 | + } | ||
92 | + }); | ||
93 | + mControlChange.setOnClickListener(new View.OnClickListener() { | ||
94 | + @Override | ||
95 | + public void onClick(View v) { | ||
96 | + SwitchInfoActivity.start(getContext()); | ||
97 | + finish(); | ||
98 | + if (presentation != null) { | ||
99 | + presentation.dismiss(); | ||
100 | + } | ||
101 | + } | ||
102 | + }); | ||
103 | + mControlMode.setOnClickListener(new View.OnClickListener() { | ||
104 | + @Override | ||
105 | + public void onClick(View v) { | ||
106 | + if (presentation != null) { | ||
107 | + presentation.changeMode(); | ||
108 | + } | ||
109 | + } | ||
110 | + }); | ||
111 | + return; | ||
112 | + } | ||
64 | mRecyclerView = findViewById(R.id.rv_list); | 113 | mRecyclerView = findViewById(R.id.rv_list); |
65 | mIvPerson = findViewById(R.id.iv_person); | 114 | mIvPerson = findViewById(R.id.iv_person); |
66 | 115 | ||
@@ -87,16 +136,17 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | @@ -87,16 +136,17 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | ||
87 | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) { | 136 | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) { |
88 | return false; | 137 | return false; |
89 | } | 138 | } |
139 | + | ||
90 | @Override | 140 | @Override |
91 | public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) { | 141 | public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) { |
92 | resource.setLoopCount(GifDrawable.LOOP_INTRINSIC); //设置次数 | 142 | resource.setLoopCount(GifDrawable.LOOP_INTRINSIC); //设置次数 |
93 | postDelayed(() -> { | 143 | postDelayed(() -> { |
94 | mMediaPlayer = Tool.playMediaPlayer(getContext(), R.raw.vr); | 144 | mMediaPlayer = Tool.playMediaPlayer(getContext(), R.raw.vr); |
95 | - mMediaPlayer.setOnErrorListener((mp,what,extra)->{ | 145 | + mMediaPlayer.setOnErrorListener((mp, what, extra) -> { |
96 | Tool.closeMediaPlayer(mMediaPlayer); | 146 | Tool.closeMediaPlayer(mMediaPlayer); |
97 | return true; | 147 | return true; |
98 | }); | 148 | }); |
99 | - mMediaPlayer.setOnCompletionListener((mp)->{ | 149 | + mMediaPlayer.setOnCompletionListener((mp) -> { |
100 | Tool.closeMediaPlayer(mMediaPlayer); | 150 | Tool.closeMediaPlayer(mMediaPlayer); |
101 | }); | 151 | }); |
102 | }, 0); | 152 | }, 0); |
@@ -108,13 +158,49 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | @@ -108,13 +158,49 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | ||
108 | } | 158 | } |
109 | 159 | ||
110 | @Override | 160 | @Override |
111 | - protected void initData() {} | 161 | + protected void initData() { |
162 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
163 | + return; | ||
164 | + } | ||
165 | + } | ||
166 | + | ||
167 | + | ||
168 | + @Override | ||
169 | + public boolean dispatchTouchEvent(MotionEvent ev) { | ||
170 | + float y = mControlLine.getY(); | ||
171 | + if (ev.getY() < y){ | ||
172 | + return super.dispatchTouchEvent(ev); | ||
173 | + } | ||
174 | + | ||
175 | + if (presentation != null) { | ||
176 | + return presentation.onTouchEvent(ev); | ||
177 | + } | ||
178 | + return super.dispatchTouchEvent(ev); | ||
179 | + } | ||
180 | + | ||
181 | + | ||
182 | + public void openAppPresentation() { | ||
183 | + if (null == presentation) { | ||
184 | + DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); | ||
185 | + Display[] displayList = mDisplayManage.getDisplays(); | ||
186 | + if (displayList.length > 1) { | ||
187 | + presentation = new AiListPresentation(this, displayList[1]); | ||
188 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
189 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
190 | + } else { | ||
191 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
192 | + } | ||
193 | + } | ||
194 | + } | ||
195 | + presentation.setOwnerActivity(this); | ||
196 | + presentation.show(); | ||
197 | + } | ||
112 | 198 | ||
113 | @Override | 199 | @Override |
114 | protected void onResume() { | 200 | protected void onResume() { |
115 | super.onResume(); | 201 | super.onResume(); |
116 | - getList(); | ||
117 | - GlobalParameterManager.getInstance().getData(); | 202 | +// getList(); |
203 | +// GlobalParameterManager.getInstance().getData(); | ||
118 | } | 204 | } |
119 | 205 | ||
120 | private void getList() { | 206 | private void getList() { |
@@ -156,6 +242,6 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | @@ -156,6 +242,6 @@ public final class AiListActivity extends AppActivity implements BaseAdapter.OnI | ||
156 | if (mMediaPlayer != null) { | 242 | if (mMediaPlayer != null) { |
157 | Tool.closeMediaPlayer(mMediaPlayer); | 243 | Tool.closeMediaPlayer(mMediaPlayer); |
158 | } | 244 | } |
159 | - | 245 | + presentation.dismiss(); |
160 | } | 246 | } |
161 | } | 247 | } |
@@ -5,10 +5,15 @@ import android.content.Context; | @@ -5,10 +5,15 @@ import android.content.Context; | ||
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.drawable.BitmapDrawable; | 7 | import android.graphics.drawable.BitmapDrawable; |
8 | +import android.hardware.display.DisplayManager; | ||
9 | +import android.os.Build; | ||
8 | import android.os.Message; | 10 | import android.os.Message; |
9 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
12 | +import android.view.Display; | ||
10 | import android.view.KeyEvent; | 13 | import android.view.KeyEvent; |
14 | +import android.view.MotionEvent; | ||
11 | import android.view.View; | 15 | import android.view.View; |
16 | +import android.view.WindowManager; | ||
12 | import android.widget.ImageView; | 17 | import android.widget.ImageView; |
13 | import android.widget.ProgressBar; | 18 | import android.widget.ProgressBar; |
14 | 19 | ||
@@ -20,15 +25,24 @@ import com.bumptech.glide.load.engine.GlideException; | @@ -20,15 +25,24 @@ import com.bumptech.glide.load.engine.GlideException; | ||
20 | import com.bumptech.glide.load.resource.gif.GifDrawable; | 25 | import com.bumptech.glide.load.resource.gif.GifDrawable; |
21 | import com.bumptech.glide.request.RequestListener; | 26 | import com.bumptech.glide.request.RequestListener; |
22 | import com.bumptech.glide.request.target.Target; | 27 | import com.bumptech.glide.request.target.Target; |
28 | +import com.rokid.axr.phone.glassdevice.RKGlassDevice; | ||
23 | import com.studymachine.www.R; | 29 | import com.studymachine.www.R; |
24 | import com.studymachine.www.action.StatusAction; | 30 | import com.studymachine.www.action.StatusAction; |
25 | import com.studymachine.www.aop.CheckNet; | 31 | import com.studymachine.www.aop.CheckNet; |
26 | import com.studymachine.www.aop.Log; | 32 | import com.studymachine.www.aop.Log; |
27 | import com.studymachine.www.app.AppActivity; | 33 | import com.studymachine.www.app.AppActivity; |
34 | +import com.studymachine.www.app.ModeHandler; | ||
28 | import com.studymachine.www.http.glide.GlideApp; | 35 | import com.studymachine.www.http.glide.GlideApp; |
29 | import com.studymachine.www.js.MainJavaScriptInterface; | 36 | import com.studymachine.www.js.MainJavaScriptInterface; |
37 | +import com.studymachine.www.manager.ActivityManager; | ||
38 | +import com.studymachine.www.other.DoubleClickHelper; | ||
39 | +import com.studymachine.www.other.Tool; | ||
40 | +import com.studymachine.www.ui.presentation.BrowserPresentation; | ||
41 | +import com.studymachine.www.ui.presentation.SplashPresentation; | ||
30 | import com.studymachine.www.widget.StatusLayout; | 42 | import com.studymachine.www.widget.StatusLayout; |
31 | import com.studymachine.www.widget.X5WebView; | 43 | import com.studymachine.www.widget.X5WebView; |
44 | +import com.tencent.smtt.export.external.interfaces.JsResult; | ||
45 | +import com.tencent.smtt.sdk.ValueCallback; | ||
32 | import com.tencent.smtt.sdk.WebChromeClient; | 46 | import com.tencent.smtt.sdk.WebChromeClient; |
33 | import com.tencent.smtt.sdk.WebView; | 47 | import com.tencent.smtt.sdk.WebView; |
34 | import com.tencent.smtt.sdk.WebViewClient; | 48 | import com.tencent.smtt.sdk.WebViewClient; |
@@ -36,13 +50,13 @@ import com.tencent.smtt.sdk.WebViewClient; | @@ -36,13 +50,13 @@ import com.tencent.smtt.sdk.WebViewClient; | ||
36 | import timber.log.Timber; | 50 | import timber.log.Timber; |
37 | 51 | ||
38 | /** | 52 | /** |
39 | - * desc : 内部使用的浏览器界面注入了特殊js | 53 | + * desc : 内部使用的浏览器界面注入了特殊js |
40 | */ | 54 | */ |
41 | public final class BrowserActivity extends AppActivity | 55 | public final class BrowserActivity extends AppActivity |
42 | implements StatusAction { | 56 | implements StatusAction { |
43 | 57 | ||
44 | private static final String INTENT_KEY_IN_URL = "url"; | 58 | private static final String INTENT_KEY_IN_URL = "url"; |
45 | - | 59 | + private BrowserPresentation presentation; |
46 | 60 | ||
47 | @CheckNet | 61 | @CheckNet |
48 | @Log | 62 | @Log |
@@ -65,16 +79,26 @@ public final class BrowserActivity extends AppActivity | @@ -65,16 +79,26 @@ public final class BrowserActivity extends AppActivity | ||
65 | 79 | ||
66 | @Override | 80 | @Override |
67 | protected int getLayoutId() { | 81 | protected int getLayoutId() { |
68 | - return R.layout.browser_activity; | 82 | + deviceInfo = RKGlassDevice.getInstance().getGlassInfo(); |
83 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
84 | + return R.layout.control_cursor; | ||
85 | + } else { | ||
86 | + return R.layout.browser_activity; | ||
87 | + } | ||
69 | } | 88 | } |
70 | 89 | ||
71 | @Override | 90 | @Override |
72 | protected void initView() { | 91 | protected void initView() { |
92 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
93 | + Tool.updateVersion(BrowserActivity.this.getContext()); | ||
94 | + return; | ||
95 | + } | ||
96 | + | ||
73 | mStatusLayout = findViewById(R.id.hl_browser_hint); | 97 | mStatusLayout = findViewById(R.id.hl_browser_hint); |
74 | mProgressBar = findViewById(R.id.pb_browser_progress); | 98 | mProgressBar = findViewById(R.id.pb_browser_progress); |
75 | mX5WebView = findViewById(R.id.wv_browser_view); | 99 | mX5WebView = findViewById(R.id.wv_browser_view); |
76 | - mImgView=findViewById(R.id.loadview); | ||
77 | - mX5WebView.addJavascriptInterface(new MainJavaScriptInterface(getActivity(),mX5WebView),"studyMachine"); | 100 | + mImgView = findViewById(R.id.loadview); |
101 | + mX5WebView.addJavascriptInterface(new MainJavaScriptInterface(getActivity(), mX5WebView), "studyMachine"); | ||
78 | 102 | ||
79 | GlideApp.with(this) | 103 | GlideApp.with(this) |
80 | .asGif() | 104 | .asGif() |
@@ -85,7 +109,42 @@ public final class BrowserActivity extends AppActivity | @@ -85,7 +109,42 @@ public final class BrowserActivity extends AppActivity | ||
85 | 109 | ||
86 | @Override | 110 | @Override |
87 | protected void initData() { | 111 | protected void initData() { |
88 | - | 112 | + if (deviceInfo != null && deviceInfo.getSn() != null) { |
113 | + mControlBack = findViewById(R.id.control_back); | ||
114 | + mControlChange = findViewById(R.id.control_change); | ||
115 | + mControlMode = findViewById(R.id.control_mode); | ||
116 | + mControlBack.setVisibility(View.VISIBLE); | ||
117 | + mControlChange.setVisibility(View.VISIBLE); | ||
118 | + mControlMode.setVisibility(View.VISIBLE); | ||
119 | + mControlLine = findViewById(R.id.control_line); | ||
120 | + mControlBack.setOnClickListener(new View.OnClickListener() { | ||
121 | + @Override | ||
122 | + public void onClick(View v) { | ||
123 | + finish(); | ||
124 | + if (presentation != null) { | ||
125 | + presentation.dismiss(); | ||
126 | + } | ||
127 | + } | ||
128 | + }); | ||
129 | + mControlChange.setOnClickListener(new View.OnClickListener() { | ||
130 | + @Override | ||
131 | + public void onClick(View v) { | ||
132 | + SwitchInfoActivity.start(getContext()); | ||
133 | + if (presentation != null) { | ||
134 | + presentation.dismiss(); | ||
135 | + } | ||
136 | + } | ||
137 | + }); | ||
138 | + mControlMode.setOnClickListener(new View.OnClickListener() { | ||
139 | + @Override | ||
140 | + public void onClick(View v) { | ||
141 | + if (presentation != null) { | ||
142 | + presentation.changeMode(); | ||
143 | + } | ||
144 | + } | ||
145 | + }); | ||
146 | + return; | ||
147 | + } | ||
89 | mX5WebView.setWebViewClient(new AppBrowserViewClient()); | 148 | mX5WebView.setWebViewClient(new AppBrowserViewClient()); |
90 | mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); | 149 | mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); |
91 | mX5WebView.loadUrl(getString(INTENT_KEY_IN_URL)); | 150 | mX5WebView.loadUrl(getString(INTENT_KEY_IN_URL)); |
@@ -103,6 +162,7 @@ public final class BrowserActivity extends AppActivity | @@ -103,6 +162,7 @@ public final class BrowserActivity extends AppActivity | ||
103 | 162 | ||
104 | @Override | 163 | @Override |
105 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 164 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
165 | + mX5WebView = presentation.getmX5WebView(); | ||
106 | if (keyCode == KeyEvent.KEYCODE_BACK && mX5WebView.canGoBack()) { | 166 | if (keyCode == KeyEvent.KEYCODE_BACK && mX5WebView.canGoBack()) { |
107 | // 后退网页并且拦截该事件 | 167 | // 后退网页并且拦截该事件 |
108 | mX5WebView.goBack(); | 168 | mX5WebView.goBack(); |
@@ -111,6 +171,53 @@ public final class BrowserActivity extends AppActivity | @@ -111,6 +171,53 @@ public final class BrowserActivity extends AppActivity | ||
111 | return super.onKeyDown(keyCode, event); | 171 | return super.onKeyDown(keyCode, event); |
112 | } | 172 | } |
113 | 173 | ||
174 | + @Override | ||
175 | + public void onBackPressed() { | ||
176 | + if (!DoubleClickHelper.isOnDoubleClick()) { | ||
177 | + toast(R.string.home_exit_hint); | ||
178 | + return; | ||
179 | + } | ||
180 | + // 移动到上一个任务栈,避免侧滑引起的不良反应 | ||
181 | + moveTaskToBack(false); | ||
182 | + postDelayed(() -> { | ||
183 | + // 进行内存优化,销毁掉所有的界面 | ||
184 | + ActivityManager.getInstance().finishAllActivities(); | ||
185 | + // 销毁进程(注意:调用此 API 可能导致当前 Activity onDestroy 方法无法正常回调) | ||
186 | + // System.exit(0); | ||
187 | + }, 300); | ||
188 | + } | ||
189 | + | ||
190 | + @Override | ||
191 | + public boolean dispatchTouchEvent(MotionEvent ev) { | ||
192 | + float y = mControlLine.getY(); | ||
193 | + if (ev.getY() < y){ | ||
194 | + return super.dispatchTouchEvent(ev); | ||
195 | + } | ||
196 | + if (presentation != null) { | ||
197 | + return presentation.onTouchEvent(ev); | ||
198 | + } | ||
199 | + return super.dispatchTouchEvent(ev); | ||
200 | + } | ||
201 | + | ||
202 | + | ||
203 | + public void openAppPresentation() { | ||
204 | + if (null == presentation) { | ||
205 | + DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); | ||
206 | + Display[] displayList = mDisplayManage.getDisplays(); | ||
207 | + if (displayList.length > 1) { | ||
208 | + presentation = new BrowserPresentation(this, displayList[1], getString(INTENT_KEY_IN_URL)); | ||
209 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
210 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
211 | + } else { | ||
212 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
213 | + } | ||
214 | + } | ||
215 | + } | ||
216 | + presentation.setOwnerActivity(this); | ||
217 | + presentation.show(); | ||
218 | + presentation.setMode(0); | ||
219 | + } | ||
220 | + | ||
114 | /** | 221 | /** |
115 | * 重新加载当前页 | 222 | * 重新加载当前页 |
116 | */ | 223 | */ |
@@ -123,6 +230,7 @@ public final class BrowserActivity extends AppActivity | @@ -123,6 +230,7 @@ public final class BrowserActivity extends AppActivity | ||
123 | @Override | 230 | @Override |
124 | protected void onDestroy() { | 231 | protected void onDestroy() { |
125 | super.onDestroy(); | 232 | super.onDestroy(); |
233 | + presentation.dismiss(); | ||
126 | } | 234 | } |
127 | 235 | ||
128 | private class AppBrowserViewClient extends WebViewClient { | 236 | private class AppBrowserViewClient extends WebViewClient { |
@@ -131,6 +239,7 @@ public final class BrowserActivity extends AppActivity | @@ -131,6 +239,7 @@ public final class BrowserActivity extends AppActivity | ||
131 | Timber.tag("网页UrlLoading").d(url); | 239 | Timber.tag("网页UrlLoading").d(url); |
132 | return super.shouldOverrideUrlLoading(webView, url); | 240 | return super.shouldOverrideUrlLoading(webView, url); |
133 | } | 241 | } |
242 | + | ||
134 | /** | 243 | /** |
135 | * 网页加载错误时回调,这个方法会在 onPageFinished 之前调用 | 244 | * 网页加载错误时回调,这个方法会在 onPageFinished 之前调用 |
136 | */ | 245 | */ |
@@ -139,11 +248,13 @@ public final class BrowserActivity extends AppActivity | @@ -139,11 +248,13 @@ public final class BrowserActivity extends AppActivity | ||
139 | // 这里为什么要用延迟呢?因为加载出错之后会先调用 onReceivedError 再调用 onPageFinished | 248 | // 这里为什么要用延迟呢?因为加载出错之后会先调用 onReceivedError 再调用 onPageFinished |
140 | post(() -> showError(listener -> reload())); | 249 | post(() -> showError(listener -> reload())); |
141 | } | 250 | } |
251 | + | ||
142 | /** | 252 | /** |
143 | * 开始加载网页 | 253 | * 开始加载网页 |
144 | */ | 254 | */ |
145 | @Override | 255 | @Override |
146 | - public void onPageStarted(WebView view, String url, Bitmap favicon) {} | 256 | + public void onPageStarted(WebView view, String url, Bitmap favicon) { |
257 | + } | ||
147 | 258 | ||
148 | /** | 259 | /** |
149 | * 完成加载网页 | 260 | * 完成加载网页 |
@@ -190,4 +301,13 @@ public final class BrowserActivity extends AppActivity | @@ -190,4 +301,13 @@ public final class BrowserActivity extends AppActivity | ||
190 | mProgressBar.setProgress(newProgress); | 301 | mProgressBar.setProgress(newProgress); |
191 | } | 302 | } |
192 | } | 303 | } |
304 | + | ||
305 | + @Override | ||
306 | + protected void onResume() { | ||
307 | + Tool.updateVersion(BrowserActivity.this.getContext()); | ||
308 | + if (presentation != null) { | ||
309 | + presentation.show(); | ||
310 | + } | ||
311 | + super.onResume(); | ||
312 | + } | ||
193 | } | 313 | } |
@@ -115,7 +115,6 @@ public final class LoginActivity extends AppActivity | @@ -115,7 +115,6 @@ public final class LoginActivity extends AppActivity | ||
115 | 115 | ||
116 | EasyHttp.post(this) | 116 | EasyHttp.post(this) |
117 | .api(new LoginApi() | 117 | .api(new LoginApi() |
118 | - .setPassword(password) | ||
119 | .setMobile(phone)) | 118 | .setMobile(phone)) |
120 | .request(new HttpCallback<HttpData<LoginApi.Bean>>(this) { | 119 | .request(new HttpCallback<HttpData<LoginApi.Bean>>(this) { |
121 | @Override | 120 | @Override |
1 | package com.studymachine.www.ui.activity; | 1 | package com.studymachine.www.ui.activity; |
2 | 2 | ||
3 | +import static com.umeng.socialize.utils.DeviceConfigInternal.context; | ||
4 | + | ||
5 | +import android.Manifest; | ||
3 | import android.animation.Animator; | 6 | import android.animation.Animator; |
4 | import android.animation.AnimatorListenerAdapter; | 7 | import android.animation.AnimatorListenerAdapter; |
8 | +import android.content.Context; | ||
5 | import android.content.Intent; | 9 | import android.content.Intent; |
10 | +import android.content.pm.PackageManager; | ||
11 | +import android.hardware.display.DisplayManager; | ||
12 | +import android.os.Build; | ||
13 | +import android.provider.Settings; | ||
14 | +import android.telecom.TelecomManager; | ||
15 | +import android.telephony.TelephonyManager; | ||
6 | import android.text.TextUtils; | 16 | import android.text.TextUtils; |
7 | import android.util.DisplayMetrics; | 17 | import android.util.DisplayMetrics; |
8 | import android.util.Log; | 18 | import android.util.Log; |
19 | +import android.view.Display; | ||
20 | +import android.view.MotionEvent; | ||
9 | import android.view.View; | 21 | import android.view.View; |
10 | import android.view.WindowManager; | 22 | import android.view.WindowManager; |
11 | 23 | ||
12 | import androidx.annotation.NonNull; | 24 | import androidx.annotation.NonNull; |
25 | +import androidx.core.app.ActivityCompat; | ||
13 | 26 | ||
14 | import com.airbnb.lottie.LottieAnimationView; | 27 | import com.airbnb.lottie.LottieAnimationView; |
15 | import com.gyf.immersionbar.BarHide; | 28 | import com.gyf.immersionbar.BarHide; |
16 | import com.gyf.immersionbar.ImmersionBar; | 29 | import com.gyf.immersionbar.ImmersionBar; |
17 | import com.hjq.http.listener.OnHttpListener; | 30 | import com.hjq.http.listener.OnHttpListener; |
31 | +import com.rokid.axr.phone.glassdevice.RKGlassDevice; | ||
18 | import com.studymachine.www.BuildConfig; | 32 | import com.studymachine.www.BuildConfig; |
19 | import com.studymachine.www.R; | 33 | import com.studymachine.www.R; |
20 | import com.studymachine.www.aop.CheckNet; | 34 | import com.studymachine.www.aop.CheckNet; |
@@ -22,9 +36,12 @@ import com.studymachine.www.app.AppActivity; | @@ -22,9 +36,12 @@ import com.studymachine.www.app.AppActivity; | ||
22 | import com.studymachine.www.event.DictionariesEvent; | 36 | import com.studymachine.www.event.DictionariesEvent; |
23 | import com.studymachine.www.event.NetworkEvent; | 37 | import com.studymachine.www.event.NetworkEvent; |
24 | import com.studymachine.www.http.api.HostApi; | 38 | import com.studymachine.www.http.api.HostApi; |
39 | +import com.studymachine.www.http.api.LoginApi; | ||
25 | import com.studymachine.www.http.api.UpdateVersionApi; | 40 | import com.studymachine.www.http.api.UpdateVersionApi; |
26 | import com.studymachine.www.http.api.UserInfoApi; | 41 | import com.studymachine.www.http.api.UserInfoApi; |
27 | import com.studymachine.www.http.model.HttpData; | 42 | import com.studymachine.www.http.model.HttpData; |
43 | +import com.studymachine.www.manager.AccountManager; | ||
44 | +import com.studymachine.www.manager.ActivityManager; | ||
28 | import com.studymachine.www.manager.DictionariesManager; | 45 | import com.studymachine.www.manager.DictionariesManager; |
29 | import com.studymachine.www.manager.GlobalParameterManager; | 46 | import com.studymachine.www.manager.GlobalParameterManager; |
30 | import com.studymachine.www.manager.UserManager; | 47 | import com.studymachine.www.manager.UserManager; |
@@ -33,8 +50,11 @@ import com.hjq.http.EasyHttp; | @@ -33,8 +50,11 @@ import com.hjq.http.EasyHttp; | ||
33 | import com.hjq.http.listener.HttpCallback; | 50 | import com.hjq.http.listener.HttpCallback; |
34 | import com.hjq.widget.view.SlantedTextView; | 51 | import com.hjq.widget.view.SlantedTextView; |
35 | import com.studymachine.www.other.ScreenUtils; | 52 | import com.studymachine.www.other.ScreenUtils; |
53 | +import com.studymachine.www.other.Tool; | ||
36 | import com.studymachine.www.other.WebUrlConfig; | 54 | import com.studymachine.www.other.WebUrlConfig; |
37 | import com.studymachine.www.ui.dialog.UpdateDialog; | 55 | import com.studymachine.www.ui.dialog.UpdateDialog; |
56 | +import com.studymachine.www.ui.presentation.SplashPresentation; | ||
57 | +import com.studymachine.www.ui.presentation.WebPresentation; | ||
38 | import com.tencent.mmkv.MMKV; | 58 | import com.tencent.mmkv.MMKV; |
39 | 59 | ||
40 | import org.greenrobot.eventbus.Subscribe; | 60 | import org.greenrobot.eventbus.Subscribe; |
@@ -49,12 +69,17 @@ public final class SplashActivity extends AppActivity { | @@ -49,12 +69,17 @@ public final class SplashActivity extends AppActivity { | ||
49 | 69 | ||
50 | @Override | 70 | @Override |
51 | protected int getLayoutId() { | 71 | protected int getLayoutId() { |
52 | - return R.layout.splash_activity; | 72 | + deviceInfo = RKGlassDevice.getInstance().getGlassInfo(); |
73 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
74 | + return R.layout.control_cursor; | ||
75 | + } else { | ||
76 | + return R.layout.splash_activity; | ||
77 | + } | ||
53 | } | 78 | } |
54 | 79 | ||
55 | @Override | 80 | @Override |
56 | protected void initView() { | 81 | protected void initView() { |
57 | - | 82 | + openAppPresentation(); |
58 | } | 83 | } |
59 | 84 | ||
60 | /** | 85 | /** |
@@ -68,17 +93,18 @@ public final class SplashActivity extends AppActivity { | @@ -68,17 +93,18 @@ public final class SplashActivity extends AppActivity { | ||
68 | @Override | 93 | @Override |
69 | public void onSucceed(HttpData<HostApi.Bean> result) { | 94 | public void onSucceed(HttpData<HostApi.Bean> result) { |
70 | if (result.getData() != null) { | 95 | if (result.getData() != null) { |
71 | - if (AppConfig.isDebug()) { | ||
72 | - AppConfig.setHostUrl("http://192.168.1.23:8100/"); | ||
73 | - AppConfig.setWebHostUrl("http://192.168.1.26:8086/"); | ||
74 | - } else { | ||
75 | - AppConfig.setHostUrl(result.getData().getApi()); | ||
76 | - AppConfig.setWebHostUrl(result.getData().getH5Url()); | ||
77 | - } | ||
78 | - AppConfig.setHostUrl(result.getData().getApi()); | ||
79 | - AppConfig.setWebHostUrl(result.getData().getH5Url()); | ||
80 | -// AppConfig.setHostUrl("http://192.168.1.23:8100/"); | ||
81 | -// AppConfig.setWebHostUrl("http://192.168.1.26:8086/"); | 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 | +// } | ||
103 | +// AppConfig.setHostUrl(result.getData().getApi()); | ||
104 | +// AppConfig.setWebHostUrl(result.getData().getH5Url()); | ||
105 | + AppConfig.setHostUrl("https://api.veln.cn/"); | ||
106 | + AppConfig.setWebHostUrl("https://h5.veln.cn/"); | ||
107 | +// Tool.updateVersion(getContext()); | ||
82 | initConfig(); | 108 | initConfig(); |
83 | } | 109 | } |
84 | } | 110 | } |
@@ -89,6 +115,7 @@ public final class SplashActivity extends AppActivity { | @@ -89,6 +115,7 @@ public final class SplashActivity extends AppActivity { | ||
89 | NoNetworkActivity.start(getContext()); | 115 | NoNetworkActivity.start(getContext()); |
90 | } | 116 | } |
91 | }); | 117 | }); |
118 | + | ||
92 | } | 119 | } |
93 | 120 | ||
94 | @Subscribe(threadMode = ThreadMode.MAIN) | 121 | @Subscribe(threadMode = ThreadMode.MAIN) |
@@ -104,24 +131,68 @@ public final class SplashActivity extends AppActivity { | @@ -104,24 +131,68 @@ public final class SplashActivity extends AppActivity { | ||
104 | private void initConfig() { | 131 | private void initConfig() { |
105 | DictionariesManager.getInstance(); | 132 | DictionariesManager.getInstance(); |
106 | GlobalParameterManager.getInstance().getData(); | 133 | GlobalParameterManager.getInstance().getData(); |
134 | + if (TextUtils.isEmpty(UserManager.getInstance().getToken())) { | ||
135 | + String phone = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID); | ||
136 | + EasyHttp.post(this) | ||
137 | + .api((new LoginApi()) | ||
138 | + .setMobile(phone)) | ||
139 | + .request(new HttpCallback<HttpData<LoginApi.Bean>>(this) { | ||
140 | + @Override | ||
141 | + public void onSucceed(HttpData<LoginApi.Bean> result) { | ||
142 | + UserManager.getInstance().setToken(result.getData().getToken()); | ||
143 | + UserManager.getInstance().getUserInfo(new UserManager.OnHttpUserInfo() { | ||
144 | + @Override | ||
145 | + public void onSucceed() { | ||
146 | + AccountManager.getInstance().addAccountMap(phone, "000000"); | ||
147 | + postDelayed(() -> { | ||
148 | + SwitchInfoActivity.start(getContext()); | ||
149 | + // 销毁除了首页之外的 Activity | ||
150 | + ActivityManager.getInstance().finishAllActivities(SwitchInfoActivity.class); | ||
151 | + finish(); | ||
152 | + presentation.dismiss(); | ||
153 | + }, 1000); | ||
154 | + } | ||
155 | + | ||
156 | + @Override | ||
157 | + public void onFail() { | ||
158 | + | ||
159 | + } | ||
160 | + }); | ||
161 | + } | ||
107 | 162 | ||
108 | - MMKV mmkv = MMKV.defaultMMKV(); | ||
109 | - String isFirstRun = mmkv.decodeString("isFirstRun"); | ||
110 | - if (TextUtils.isEmpty(isFirstRun)) { | ||
111 | - RegisterActivity.start(getContext()); | ||
112 | - mmkv.encode("isFirstRun", "true"); | 163 | + @Override |
164 | + public void onFail(Exception e) { | ||
165 | + super.onFail(e); | ||
166 | + } | ||
167 | + }); | ||
113 | } else { | 168 | } else { |
114 | - if (TextUtils.isEmpty(UserManager.getInstance().getToken())) { | ||
115 | - LoginActivity.start(getContext()); | 169 | + UserManager.getInstance().getUserInfo(); |
170 | + // 刷新用户信息 | ||
171 | + 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(); | ||
116 | } else { | 178 | } else { |
117 | - // 刷新用户信息 | ||
118 | - UserManager.getInstance().getUserInfo(); | ||
119 | - HomeActivity.start(getContext()); | 179 | + BrowserActivity.start(getContext(),"https://preview.inibiru.com/creator/custom/index.html?id=12242"); |
180 | + ActivityManager.getInstance().finishAllActivities(BrowserActivity.class); | ||
181 | + finish(); | ||
182 | + presentation.dismiss(); | ||
120 | } | 183 | } |
121 | } | 184 | } |
122 | - finish(); | ||
123 | } | 185 | } |
124 | 186 | ||
187 | + @Override | ||
188 | + public boolean dispatchTouchEvent(MotionEvent ev) { | ||
189 | + if (presentation != null) { | ||
190 | + return presentation.onTouchEvent(ev); | ||
191 | + } | ||
192 | + return super.dispatchTouchEvent(ev); | ||
193 | + } | ||
194 | + | ||
195 | + private SplashPresentation presentation; | ||
125 | 196 | ||
126 | @NonNull | 197 | @NonNull |
127 | @Override | 198 | @Override |
@@ -137,6 +208,23 @@ public final class SplashActivity extends AppActivity { | @@ -137,6 +208,23 @@ public final class SplashActivity extends AppActivity { | ||
137 | //super.onBackPressed(); | 208 | //super.onBackPressed(); |
138 | } | 209 | } |
139 | 210 | ||
211 | + public void openAppPresentation() { | ||
212 | + if (null == presentation) { | ||
213 | + DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); | ||
214 | + Display[] displayList = mDisplayManage.getDisplays(); | ||
215 | + if (displayList.length > 1) { | ||
216 | + presentation = new SplashPresentation(this, displayList[1]); | ||
217 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
218 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
219 | + } else { | ||
220 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
221 | + } | ||
222 | + } | ||
223 | + } | ||
224 | + presentation.setOwnerActivity(this); | ||
225 | + presentation.show(); | ||
226 | + } | ||
227 | + | ||
140 | @Override | 228 | @Override |
141 | protected void initActivity() { | 229 | protected void initActivity() { |
142 | // 问题及方案:https://www.cnblogs.com/net168/p/5722752.html | 230 | // 问题及方案:https://www.cnblogs.com/net168/p/5722752.html |
@@ -160,5 +248,6 @@ public final class SplashActivity extends AppActivity { | @@ -160,5 +248,6 @@ public final class SplashActivity extends AppActivity { | ||
160 | // 因为修复了一个启动页被重复启动的问题,所以有可能 Activity 还没有初始化完成就已经销毁了 | 248 | // 因为修复了一个启动页被重复启动的问题,所以有可能 Activity 还没有初始化完成就已经销毁了 |
161 | // 所以如果需要在此处释放对象资源需要先对这个对象进行判空,否则可能会导致空指针异常 | 249 | // 所以如果需要在此处释放对象资源需要先对这个对象进行判空,否则可能会导致空指针异常 |
162 | super.onDestroy(); | 250 | super.onDestroy(); |
251 | + presentation.dismiss(); | ||
163 | } | 252 | } |
164 | } | 253 | } |
1 | +package com.studymachine.www.ui.activity; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.content.Intent; | ||
5 | +import android.hardware.display.DisplayManager; | ||
6 | +import android.os.Build; | ||
7 | +import android.text.TextUtils; | ||
8 | +import android.view.Display; | ||
9 | +import android.view.MotionEvent; | ||
10 | +import android.view.View; | ||
11 | +import android.view.WindowManager; | ||
12 | +import android.widget.Button; | ||
13 | + | ||
14 | +import androidx.recyclerview.widget.RecyclerView; | ||
15 | + | ||
16 | +import com.hjq.http.EasyHttp; | ||
17 | +import com.hjq.http.listener.HttpCallback; | ||
18 | +import com.studymachine.www.R; | ||
19 | +import com.studymachine.www.app.AppActivity; | ||
20 | +import com.studymachine.www.enumtype.DictionariesEnum; | ||
21 | +import com.studymachine.www.event.DictionariesEvent; | ||
22 | +import com.studymachine.www.event.UserInfoEvent; | ||
23 | +import com.studymachine.www.http.api.EditUserInfoApi; | ||
24 | +import com.studymachine.www.http.api.GetDictionariesApi; | ||
25 | +import com.studymachine.www.http.model.HttpData; | ||
26 | +import com.studymachine.www.manager.ActivityManager; | ||
27 | +import com.studymachine.www.manager.DictionariesManager; | ||
28 | +import com.studymachine.www.manager.UserManager; | ||
29 | +import com.studymachine.www.other.AppConfig; | ||
30 | +import com.studymachine.www.ui.adapter.RadioAdapter; | ||
31 | +import com.studymachine.www.ui.fragment.HomeFragment; | ||
32 | +import com.studymachine.www.ui.fragment.SwitchInfoFragment; | ||
33 | +import com.studymachine.www.ui.presentation.SplashPresentation; | ||
34 | +import com.studymachine.www.ui.presentation.SwitchInfoPresentation; | ||
35 | + | ||
36 | +import org.greenrobot.eventbus.Subscribe; | ||
37 | +import org.greenrobot.eventbus.ThreadMode; | ||
38 | + | ||
39 | +import java.util.ArrayList; | ||
40 | +import java.util.List; | ||
41 | + | ||
42 | +public class SwitchInfoActivity extends AppActivity implements RadioAdapter.OnRadioListener{ | ||
43 | + | ||
44 | + private RadioAdapter mGradeAdapter, mTextbookAdapter; | ||
45 | + private RecyclerView mRvGrade, mTextbook; | ||
46 | + private Button mCommitBtn; | ||
47 | + private GetDictionariesApi.Bean mSelectGrade, mSelectTextbook; | ||
48 | + private List<GetDictionariesApi.Bean> mGradeDataList = new ArrayList<>(); | ||
49 | + private List<GetDictionariesApi.Bean> mTextbookDataList = new ArrayList<>(); | ||
50 | + private SwitchInfoPresentation presentation; | ||
51 | + | ||
52 | + public static void start(Context context) { | ||
53 | + Intent intent = new Intent(context, SwitchInfoActivity.class); | ||
54 | + context.startActivity(intent); | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + protected int getLayoutId() { | ||
59 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
60 | + return R.layout.control_cursor; | ||
61 | + } else { | ||
62 | + return R.layout.switch_info_fragment; | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + protected void initView() { | ||
68 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
69 | + return; | ||
70 | + } | ||
71 | + mCommitBtn = findViewById(R.id.btn_commit); | ||
72 | + mRvGrade = findViewById(R.id.rv_grade); | ||
73 | + mTextbook = findViewById(R.id.rv_textbook); | ||
74 | + setOnClickListener(mCommitBtn); | ||
75 | + } | ||
76 | + | ||
77 | + | ||
78 | + @Override | ||
79 | + protected void initData() { | ||
80 | + if (deviceInfo != null && deviceInfo.getSn() != null) { | ||
81 | + mControlBack = findViewById(R.id.control_back); | ||
82 | + mControlChange = findViewById(R.id.control_change); | ||
83 | + mControlMode = findViewById(R.id.control_mode); | ||
84 | + mControlBack.setVisibility(View.VISIBLE); | ||
85 | + mControlChange.setVisibility(View.GONE); | ||
86 | + mControlMode.setVisibility(View.GONE); | ||
87 | + mControlLine = findViewById(R.id.control_line); | ||
88 | + mControlBack.setOnClickListener(new View.OnClickListener() { | ||
89 | + @Override | ||
90 | + public void onClick(View v) { | ||
91 | + finish(); | ||
92 | + if (presentation != null) { | ||
93 | + presentation.dismiss(); | ||
94 | + } | ||
95 | + } | ||
96 | + }); | ||
97 | + mControlChange.setOnClickListener(new View.OnClickListener() { | ||
98 | + @Override | ||
99 | + public void onClick(View v) { | ||
100 | + SwitchInfoActivity.start(getContext()); | ||
101 | + finish(); | ||
102 | + if (presentation != null) { | ||
103 | + presentation.dismiss(); | ||
104 | + } | ||
105 | + } | ||
106 | + }); | ||
107 | + mControlMode.setOnClickListener(new View.OnClickListener() { | ||
108 | + @Override | ||
109 | + public void onClick(View v) { | ||
110 | + if (presentation != null) { | ||
111 | + presentation.changeMode(); | ||
112 | + } | ||
113 | + } | ||
114 | + }); | ||
115 | + return; | ||
116 | + } | ||
117 | + initGrade(); | ||
118 | + initTextbook(); | ||
119 | + DictionariesManager.getInstance().getHttpData(); | ||
120 | + } | ||
121 | + | ||
122 | + private void initTextbook() { | ||
123 | + mTextbookDataList = DictionariesManager.getInstance().getDictionItem(DictionariesEnum.CATEGORY_KEY); | ||
124 | + List<GetDictionariesApi.Bean> beanList = new ArrayList<>(); | ||
125 | + String category = UserManager.getInstance().getUserBean().getCategory(); | ||
126 | + if (!TextUtils.isEmpty(category)) { | ||
127 | + for (int i = 0; i < mTextbookDataList.size(); i++) { | ||
128 | + if (mTextbookDataList.get(i).getValue().equals(category)) { | ||
129 | + beanList.add(mTextbookDataList.get(i)); | ||
130 | + mSelectTextbook = mTextbookDataList.get(i); | ||
131 | + break; | ||
132 | + } | ||
133 | + } | ||
134 | + } | ||
135 | + mTextbookAdapter = new RadioAdapter(this, beanList); | ||
136 | + mTextbookAdapter.setListener(this); | ||
137 | + mTextbook.setAdapter(mTextbookAdapter); | ||
138 | + mTextbookAdapter.setData(mTextbookDataList); | ||
139 | + | ||
140 | + } | ||
141 | + | ||
142 | + private void initGrade() { | ||
143 | + mGradeDataList = DictionariesManager.getInstance().getDictionItem(DictionariesEnum.GRADE_KEY); | ||
144 | + List<GetDictionariesApi.Bean> beanList = new ArrayList<>(); | ||
145 | + String grade = UserManager.getInstance().getUserBean().getGrade(); | ||
146 | + if (!TextUtils.isEmpty(grade)) { | ||
147 | + for (int i = 0; i < mGradeDataList.size(); i++) { | ||
148 | + if (mGradeDataList.get(i).getValue().equals(grade)) { | ||
149 | + beanList.add(mGradeDataList.get(i)); | ||
150 | + mSelectGrade = mGradeDataList.get(i); | ||
151 | + break; | ||
152 | + } | ||
153 | + } | ||
154 | + } | ||
155 | + mGradeAdapter = new RadioAdapter(this, beanList); | ||
156 | + mGradeAdapter.setListener(this); | ||
157 | + mRvGrade.setAdapter(mGradeAdapter); | ||
158 | + mGradeAdapter.setData(mGradeDataList); | ||
159 | + } | ||
160 | + | ||
161 | + | ||
162 | + @Override | ||
163 | + public void onClick(View view) { | ||
164 | + if (view == mCommitBtn) { | ||
165 | + EasyHttp.post(this) | ||
166 | + .api(new EditUserInfoApi() | ||
167 | + .setCategory(mSelectTextbook.getValue()) | ||
168 | + .setGrade(mSelectGrade.getValue())) | ||
169 | + .request(new HttpCallback<HttpData>(this) { | ||
170 | + @Override | ||
171 | + public void onSucceed(HttpData result) { | ||
172 | + UserManager.getInstance().getUserInfo(); | ||
173 | + BrowserActivity.start(getContext(), "https://preview.inibiru.com/creator/custom/index.html?id=12242"); | ||
174 | + presentation.dismiss(); | ||
175 | + finish(); | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public void onFail(Exception e) { | ||
180 | + super.onFail(e); | ||
181 | + } | ||
182 | + }); | ||
183 | + } | ||
184 | + } | ||
185 | + | ||
186 | + @Override | ||
187 | + public boolean dispatchTouchEvent(MotionEvent ev) { | ||
188 | + float y = mControlLine.getY(); | ||
189 | + if (ev.getY() < y){ | ||
190 | + return super.dispatchTouchEvent(ev); | ||
191 | + } | ||
192 | + if (presentation != null) { | ||
193 | + return presentation.onTouchEvent(ev); | ||
194 | + } | ||
195 | + return super.dispatchTouchEvent(ev); | ||
196 | + } | ||
197 | + | ||
198 | + public void openAppPresentation() { | ||
199 | + if (null == presentation) { | ||
200 | + DisplayManager mDisplayManage = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE); | ||
201 | + Display[] displayList = mDisplayManage.getDisplays(); | ||
202 | + if (displayList.length > 1) { | ||
203 | + presentation = new SwitchInfoPresentation(this, displayList[1]); | ||
204 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0 | ||
205 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY); | ||
206 | + } else { | ||
207 | + presentation.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); | ||
208 | + } | ||
209 | + } | ||
210 | + } | ||
211 | + presentation.setOwnerActivity(this); | ||
212 | + presentation.show(); | ||
213 | + } | ||
214 | + | ||
215 | + @Override | ||
216 | + public void onItemClick(RecyclerView recyclerView, int position, List<GetDictionariesApi.Bean> mSelectList) { | ||
217 | + if (recyclerView == mRvGrade) { | ||
218 | + mSelectGrade = mSelectList.get(0); | ||
219 | + } else if (recyclerView == mTextbook) { | ||
220 | + mSelectTextbook = mSelectList.get(0); | ||
221 | + } | ||
222 | + } | ||
223 | + | ||
224 | + @Subscribe(threadMode = ThreadMode.MAIN) | ||
225 | + public void onEventBus(UserInfoEvent userInfoEvent) { | ||
226 | + } | ||
227 | + | ||
228 | + @Subscribe(threadMode = ThreadMode.MAIN) | ||
229 | + public void onEventBus(DictionariesEvent dictionariesEvent) { | ||
230 | + initGrade(); | ||
231 | + initTextbook(); | ||
232 | + } | ||
233 | + | ||
234 | + @Override | ||
235 | + protected void onDestroy() { | ||
236 | + super.onDestroy(); | ||
237 | + presentation.dismiss(); | ||
238 | + } | ||
239 | +} |
@@ -66,7 +66,7 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | @@ -66,7 +66,7 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | ||
66 | mAiListAdapter.setOnItemClickListener(this); | 66 | mAiListAdapter.setOnItemClickListener(this); |
67 | mRecyclerView.setAdapter(mAiListAdapter); | 67 | mRecyclerView.setAdapter(mAiListAdapter); |
68 | getList(); | 68 | getList(); |
69 | - XXPermissions.with(getContext()) | 69 | + XXPermissions.with(getOwnerActivity()) |
70 | .permission(Permission.READ_EXTERNAL_STORAGE) | 70 | .permission(Permission.READ_EXTERNAL_STORAGE) |
71 | .permission(Permission.WRITE_EXTERNAL_STORAGE) | 71 | .permission(Permission.WRITE_EXTERNAL_STORAGE) |
72 | .request(new PermissionCallback() { | 72 | .request(new PermissionCallback() { |
@@ -76,7 +76,7 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | @@ -76,7 +76,7 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | ||
76 | } | 76 | } |
77 | }); | 77 | }); |
78 | 78 | ||
79 | - GlideApp.with(getContext()) | 79 | + GlideApp.with(getOwnerActivity()) |
80 | .asGif() | 80 | .asGif() |
81 | .load(R.drawable.ai_person) | 81 | .load(R.drawable.ai_person) |
82 | .listener(new RequestListener<GifDrawable>() { | 82 | .listener(new RequestListener<GifDrawable>() { |
@@ -105,10 +105,11 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | @@ -105,10 +105,11 @@ public class AiListPresentation extends AppPresentation implements BaseAdapter.O | ||
105 | .into(mIvPerson); | 105 | .into(mIvPerson); |
106 | } | 106 | } |
107 | 107 | ||
108 | + | ||
108 | @Override | 109 | @Override |
109 | public void onItemClick(RecyclerView recyclerView, View itemView, int position) { | 110 | public void onItemClick(RecyclerView recyclerView, View itemView, int position) { |
110 | if (mDataList.get(position).getQuestionNum() > 0) { | 111 | if (mDataList.get(position).getQuestionNum() > 0) { |
111 | - AiDetailActivity.start(getContext(), String.valueOf(mDataList.get(position).getId())); | 112 | + AiDetailActivity.start(getOwnerActivity(), String.valueOf(mDataList.get(position).getId())); |
112 | } | 113 | } |
113 | } | 114 | } |
114 | 115 |
1 | +package com.studymachine.www.ui.presentation; | ||
2 | + | ||
3 | +import static com.hjq.http.EasyUtils.post; | ||
4 | + | ||
5 | +import android.content.Context; | ||
6 | +import android.graphics.Bitmap; | ||
7 | +import android.graphics.drawable.BitmapDrawable; | ||
8 | +import android.os.Message; | ||
9 | +import android.view.Display; | ||
10 | +import android.view.View; | ||
11 | +import android.widget.ImageView; | ||
12 | +import android.widget.ProgressBar; | ||
13 | + | ||
14 | +import com.studymachine.www.R; | ||
15 | +import com.studymachine.www.action.StatusAction; | ||
16 | +import com.studymachine.www.aop.CheckNet; | ||
17 | +import com.studymachine.www.app.AppPresentation; | ||
18 | +import com.studymachine.www.app.ModeHandler; | ||
19 | +import com.studymachine.www.http.glide.GlideApp; | ||
20 | +import com.studymachine.www.js.MainJavaScriptInterface; | ||
21 | +import com.studymachine.www.ui.activity.BrowserActivity; | ||
22 | +import com.studymachine.www.widget.StatusLayout; | ||
23 | +import com.studymachine.www.widget.X5WebView; | ||
24 | +import com.tencent.smtt.sdk.ValueCallback; | ||
25 | +import com.tencent.smtt.sdk.WebChromeClient; | ||
26 | +import com.tencent.smtt.sdk.WebView; | ||
27 | +import com.tencent.smtt.sdk.WebViewClient; | ||
28 | + | ||
29 | +import java.util.TimerTask; | ||
30 | + | ||
31 | +import timber.log.Timber; | ||
32 | + | ||
33 | +public class BrowserPresentation extends AppPresentation implements StatusAction { | ||
34 | + private String url; | ||
35 | + private StatusLayout mStatusLayout; | ||
36 | + private ProgressBar mProgressBar; | ||
37 | + private X5WebView mX5WebView; | ||
38 | + private ImageView mImgView; | ||
39 | + | ||
40 | + public BrowserPresentation(Context outerContext, Display display) { | ||
41 | + super(outerContext, display); | ||
42 | + } | ||
43 | + | ||
44 | + public BrowserPresentation(Context outerContext, Display display, String url) { | ||
45 | + super(outerContext, display); | ||
46 | + this.url = url; | ||
47 | + } | ||
48 | + | ||
49 | + public X5WebView getmX5WebView() { | ||
50 | + return this.mX5WebView; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public int getLayout() { | ||
55 | + return R.layout.browser_activity; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public void initData() { | ||
60 | + final ModeHandler handler = new ModeHandler(this); | ||
61 | + mStatusLayout = findViewById(R.id.hl_browser_hint); | ||
62 | + mProgressBar = findViewById(R.id.pb_browser_progress); | ||
63 | + mX5WebView = findViewById(R.id.wv_browser_view); | ||
64 | + mImgView = findViewById(R.id.loadview); | ||
65 | + mX5WebView.addJavascriptInterface(new MainJavaScriptInterface(getOwnerActivity(), mX5WebView, handler), "studyMachine"); | ||
66 | + | ||
67 | + GlideApp.with(getOwnerActivity()) | ||
68 | + .asGif() | ||
69 | + .load(R.drawable.common_load) | ||
70 | + .into(mImgView); | ||
71 | + mX5WebView.setWebViewClient(new AppBrowserViewClient()); | ||
72 | + mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); | ||
73 | + mX5WebView.loadUrl(url); | ||
74 | +// handler.sendEmptyMessage(0); | ||
75 | +// Runnable task = new Runnable() { | ||
76 | +// 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 | +// } | ||
85 | +// | ||
86 | +// } | ||
87 | +// }); | ||
88 | +// | ||
89 | +// handler.sendEmptyMessage(0);//设置循环时间,此处是5秒 | ||
90 | +// handler.postDelayed(this, 100); | ||
91 | +// //需要执行的代码 | ||
92 | +// } | ||
93 | +// }; | ||
94 | +// | ||
95 | +// handler.post(task); | ||
96 | + } | ||
97 | + | ||
98 | + | ||
99 | + private class AppBrowserViewClient extends WebViewClient { | ||
100 | + @Override | ||
101 | + public boolean shouldOverrideUrlLoading(com.tencent.smtt.sdk.WebView webView, String url) { | ||
102 | + Timber.tag("网页UrlLoading").d(url); | ||
103 | + return super.shouldOverrideUrlLoading(webView, url); | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * 网页加载错误时回调,这个方法会在 onPageFinished 之前调用 | ||
108 | + */ | ||
109 | + @Override | ||
110 | + public void onReceivedError(WebView webView, int i, String s, String s1) { | ||
111 | + // 这里为什么要用延迟呢?因为加载出错之后会先调用 onReceivedError 再调用 onPageFinished | ||
112 | + post(() -> showError(listener -> reload())); | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * 开始加载网页 | ||
117 | + */ | ||
118 | + @Override | ||
119 | + public void onPageStarted(WebView view, String url, Bitmap favicon) { | ||
120 | + } | ||
121 | + | ||
122 | + /** | ||
123 | + * 完成加载网页 | ||
124 | + */ | ||
125 | + @Override | ||
126 | + public void onPageFinished(WebView view, String url) { | ||
127 | +// showComplete(); | ||
128 | + mImgView.setVisibility(View.GONE); | ||
129 | + } | ||
130 | + } | ||
131 | + | ||
132 | + private class AppBrowserChromeClient extends WebChromeClient { | ||
133 | + | ||
134 | + @Override | ||
135 | + public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) { | ||
136 | + Timber.tag("网页").d("look"); | ||
137 | + return false; | ||
138 | + } | ||
139 | + | ||
140 | + /** | ||
141 | + * 收到网页标题 | ||
142 | + */ | ||
143 | + @Override | ||
144 | + public void onReceivedTitle(WebView view, String title) { | ||
145 | + if (title == null) { | ||
146 | + return; | ||
147 | + } | ||
148 | + setTitle(title); | ||
149 | + } | ||
150 | + | ||
151 | + @Override | ||
152 | + public void onReceivedIcon(WebView view, Bitmap icon) { | ||
153 | + if (icon == null) { | ||
154 | + return; | ||
155 | + } | ||
156 | + setRightIcon(new BitmapDrawable(getResources(), icon)); | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * 收到加载进度变化 | ||
161 | + */ | ||
162 | + @Override | ||
163 | + public void onProgressChanged(WebView view, int newProgress) { | ||
164 | + mProgressBar.setProgress(newProgress); | ||
165 | + } | ||
166 | + } | ||
167 | + | ||
168 | + /** | ||
169 | + * 重新加载当前页 | ||
170 | + */ | ||
171 | + @CheckNet | ||
172 | + private void reload() { | ||
173 | + mX5WebView.reload(); | ||
174 | + } | ||
175 | +} |
@@ -55,6 +55,7 @@ import com.studymachine.www.manager.EventBusManager; | @@ -55,6 +55,7 @@ import com.studymachine.www.manager.EventBusManager; | ||
55 | import com.studymachine.www.manager.GlobalParameterManager; | 55 | import com.studymachine.www.manager.GlobalParameterManager; |
56 | import com.studymachine.www.manager.UserManager; | 56 | import com.studymachine.www.manager.UserManager; |
57 | import com.studymachine.www.other.AppConfig; | 57 | import com.studymachine.www.other.AppConfig; |
58 | +import com.studymachine.www.other.Tool; | ||
58 | import com.studymachine.www.ui.activity.AiDetailActivity; | 59 | import com.studymachine.www.ui.activity.AiDetailActivity; |
59 | 60 | ||
60 | import org.greenrobot.eventbus.EventBus; | 61 | import org.greenrobot.eventbus.EventBus; |
@@ -97,65 +98,13 @@ public class SplashPresentation extends AppPresentation { | @@ -97,65 +98,13 @@ public class SplashPresentation extends AppPresentation { | ||
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | - /** | ||
101 | - * 获取动态域名 | ||
102 | - */ | ||
103 | - @CheckNet | ||
104 | - private void getHost() { | ||
105 | - EasyHttp.get((LifecycleOwner) getOwnerActivity()) | ||
106 | - .api(new HostApi()) | ||
107 | - .request(new HttpCallback<HttpData<HostApi.Bean>>(this) { | ||
108 | - @Override | ||
109 | - public void onSucceed(HttpData<HostApi.Bean> result) { | ||
110 | - if (result.getData() != null) { | ||
111 | - if (AppConfig.isDebug()) { | ||
112 | - AppConfig.setHostUrl("http://192.168.1.23:8100/"); | ||
113 | - AppConfig.setWebHostUrl("http://192.168.1.26:8086/"); | ||
114 | - } else { | ||
115 | - AppConfig.setHostUrl(result.getData().getApi()); | ||
116 | - AppConfig.setWebHostUrl(result.getData().getH5Url()); | ||
117 | - } | ||
118 | - AppConfig.setHostUrl(result.getData().getApi()); | ||
119 | - AppConfig.setWebHostUrl(result.getData().getH5Url()); | ||
120 | -// AppConfig.setHostUrl("http://192.168.1.23:8100/"); | ||
121 | -// AppConfig.setWebHostUrl("http://192.168.1.26:8086/"); | ||
122 | - initConfig(); | ||
123 | - } | ||
124 | - } | ||
125 | - | ||
126 | - @Override | ||
127 | - public void onFail(Exception e) { | ||
128 | - super.onFail(e); | ||
129 | - NoNetworkActivity.start(getContext()); | ||
130 | - } | ||
131 | - }); | ||
132 | - } | ||
133 | 101 | ||
134 | @Override | 102 | @Override |
135 | public void initData() { | 103 | public void initData() { |
136 | - getHost(); | 104 | +// Tool.updateVersion(getOwnerActivity()); |
105 | +// getHost(); | ||
137 | } | 106 | } |
138 | 107 | ||
139 | - private void initConfig() { | ||
140 | - DictionariesManager.getInstance(); | ||
141 | - GlobalParameterManager.getInstance().getData(); | ||
142 | - | ||
143 | - MMKV mmkv = MMKV.defaultMMKV(); | ||
144 | - String isFirstRun = mmkv.decodeString("isFirstRun"); | ||
145 | - if (TextUtils.isEmpty(isFirstRun)) { | ||
146 | - RegisterActivity.start(getContext()); | ||
147 | - mmkv.encode("isFirstRun", "true"); | ||
148 | - } else { | ||
149 | - if (TextUtils.isEmpty(UserManager.getInstance().getToken())) { | ||
150 | - LoginActivity.start(getContext()); | ||
151 | - } else { | ||
152 | - // 刷新用户信息 | ||
153 | - UserManager.getInstance().getUserInfo(); | ||
154 | - HomeActivity.start(getContext()); | ||
155 | - } | ||
156 | - } | ||
157 | - finish(); | ||
158 | - } | ||
159 | 108 | ||
160 | private void finish() { | 109 | private void finish() { |
161 | dismiss(); | 110 | dismiss(); |
1 | +package com.studymachine.www.ui.presentation; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | +import android.text.TextUtils; | ||
5 | +import android.view.Display; | ||
6 | +import android.view.View; | ||
7 | +import android.widget.Button; | ||
8 | + | ||
9 | +import androidx.lifecycle.LifecycleOwner; | ||
10 | +import androidx.recyclerview.widget.RecyclerView; | ||
11 | + | ||
12 | +import com.hjq.base.action.ClickAction; | ||
13 | +import com.hjq.http.EasyHttp; | ||
14 | +import com.hjq.http.listener.HttpCallback; | ||
15 | +import com.studymachine.www.R; | ||
16 | +import com.studymachine.www.app.AppPresentation; | ||
17 | +import com.studymachine.www.enumtype.DictionariesEnum; | ||
18 | +import com.studymachine.www.event.DictionariesEvent; | ||
19 | +import com.studymachine.www.event.UserInfoEvent; | ||
20 | +import com.studymachine.www.http.api.EditUserInfoApi; | ||
21 | +import com.studymachine.www.http.api.GetDictionariesApi; | ||
22 | +import com.studymachine.www.http.model.HttpData; | ||
23 | +import com.studymachine.www.manager.ActivityManager; | ||
24 | +import com.studymachine.www.manager.DictionariesManager; | ||
25 | +import com.studymachine.www.manager.UserManager; | ||
26 | +import com.studymachine.www.other.AppConfig; | ||
27 | +import com.studymachine.www.ui.activity.BrowserActivity; | ||
28 | +import com.studymachine.www.ui.activity.HomeActivity; | ||
29 | +import com.studymachine.www.ui.adapter.RadioAdapter; | ||
30 | +import com.studymachine.www.ui.fragment.HomeFragment; | ||
31 | + | ||
32 | +import org.greenrobot.eventbus.Subscribe; | ||
33 | +import org.greenrobot.eventbus.ThreadMode; | ||
34 | + | ||
35 | +import java.util.ArrayList; | ||
36 | +import java.util.List; | ||
37 | + | ||
38 | +public class SwitchInfoPresentation extends AppPresentation implements RadioAdapter.OnRadioListener, ClickAction { | ||
39 | + | ||
40 | + private RadioAdapter mGradeAdapter, mTextbookAdapter; | ||
41 | + private RecyclerView mRvGrade, mTextbook; | ||
42 | + private Button mCommitBtn; | ||
43 | + private GetDictionariesApi.Bean mSelectGrade, mSelectTextbook; | ||
44 | + private List<GetDictionariesApi.Bean> mGradeDataList = new ArrayList<>(); | ||
45 | + private List<GetDictionariesApi.Bean> mTextbookDataList = new ArrayList<>(); | ||
46 | + | ||
47 | + public SwitchInfoPresentation(Context outerContext, Display display) { | ||
48 | + super(outerContext, display); | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public int getLayout() { | ||
53 | + return R.layout.switch_info_fragment; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public void initData() { | ||
58 | + mCommitBtn = findViewById(R.id.btn_commit); | ||
59 | + mRvGrade = findViewById(R.id.rv_grade); | ||
60 | + mTextbook = findViewById(R.id.rv_textbook); | ||
61 | + setOnClickListener(mCommitBtn); | ||
62 | + initGrade(); | ||
63 | + initTextbook(); | ||
64 | + DictionariesManager.getInstance().getHttpData(); | ||
65 | + } | ||
66 | + | ||
67 | + private void initTextbook() { | ||
68 | + mTextbookDataList = DictionariesManager.getInstance().getDictionItem(DictionariesEnum.CATEGORY_KEY); | ||
69 | + List<GetDictionariesApi.Bean> beanList = new ArrayList<>(); | ||
70 | + String category = UserManager.getInstance().getUserBean().getCategory(); | ||
71 | + if (!TextUtils.isEmpty(category)) { | ||
72 | + for (int i = 0; i < mTextbookDataList.size(); i++) { | ||
73 | + if (mTextbookDataList.get(i).getValue().equals(category)) { | ||
74 | + beanList.add(mTextbookDataList.get(i)); | ||
75 | + mSelectTextbook = mTextbookDataList.get(i); | ||
76 | + break; | ||
77 | + } | ||
78 | + } | ||
79 | + } | ||
80 | + mTextbookAdapter = new RadioAdapter(getContext(), beanList); | ||
81 | + mTextbookAdapter.setListener(this); | ||
82 | + mTextbook.setAdapter(mTextbookAdapter); | ||
83 | + mTextbookAdapter.setData(mTextbookDataList); | ||
84 | + | ||
85 | + } | ||
86 | + | ||
87 | + private void initGrade() { | ||
88 | + mGradeDataList = DictionariesManager.getInstance().getDictionItem(DictionariesEnum.GRADE_KEY); | ||
89 | + List<GetDictionariesApi.Bean> beanList = new ArrayList<>(); | ||
90 | + String grade = UserManager.getInstance().getUserBean().getGrade(); | ||
91 | + if (!TextUtils.isEmpty(grade)) { | ||
92 | + for (int i = 0; i < mGradeDataList.size(); i++) { | ||
93 | + if (mGradeDataList.get(i).getValue().equals(grade)) { | ||
94 | + beanList.add(mGradeDataList.get(i)); | ||
95 | + mSelectGrade = mGradeDataList.get(i); | ||
96 | + break; | ||
97 | + } | ||
98 | + } | ||
99 | + } | ||
100 | + mGradeAdapter = new RadioAdapter(getContext(), beanList); | ||
101 | + mGradeAdapter.setListener(this); | ||
102 | + mRvGrade.setAdapter(mGradeAdapter); | ||
103 | + mGradeAdapter.setData(mGradeDataList); | ||
104 | + } | ||
105 | + | ||
106 | + | ||
107 | + @Override | ||
108 | + public void onClick(View view) { | ||
109 | + if (view == mCommitBtn) { | ||
110 | + EasyHttp.post((LifecycleOwner) getOwnerActivity()) | ||
111 | + .api(new EditUserInfoApi() | ||
112 | + .setCategory(mSelectTextbook.getValue()) | ||
113 | + .setGrade(mSelectGrade.getValue())) | ||
114 | + .request(new HttpCallback<HttpData>(this) { | ||
115 | + @Override | ||
116 | + public void onSucceed(HttpData result) { | ||
117 | + UserManager.getInstance().getUserInfo(); | ||
118 | + BrowserActivity.start(getContext(), "https://preview.inibiru.com/creator/custom/index.html?id=12242"); | ||
119 | + ActivityManager.getInstance().finishAllActivities(BrowserActivity.class); | ||
120 | + getOwnerActivity().finish(); | ||
121 | + dismiss(); | ||
122 | + } | ||
123 | + | ||
124 | + @Override | ||
125 | + public void onFail(Exception e) { | ||
126 | + super.onFail(e); | ||
127 | + } | ||
128 | + }); | ||
129 | + } | ||
130 | + } | ||
131 | + | ||
132 | + @Override | ||
133 | + public void onItemClick(RecyclerView recyclerView, int position, List<GetDictionariesApi.Bean> mSelectList) { | ||
134 | + if (recyclerView == mRvGrade) { | ||
135 | + mSelectGrade = mSelectList.get(0); | ||
136 | + } else if (recyclerView == mTextbook) { | ||
137 | + mSelectTextbook = mSelectList.get(0); | ||
138 | + } | ||
139 | + } | ||
140 | + | ||
141 | + @Subscribe(threadMode = ThreadMode.MAIN) | ||
142 | + public void onEventBus(UserInfoEvent userInfoEvent) { | ||
143 | + } | ||
144 | + | ||
145 | + @Subscribe(threadMode = ThreadMode.MAIN) | ||
146 | + public void onEventBus(DictionariesEvent dictionariesEvent) { | ||
147 | + initGrade(); | ||
148 | + initTextbook(); | ||
149 | + } | ||
150 | +} |
@@ -39,6 +39,7 @@ import com.studymachine.www.R; | @@ -39,6 +39,7 @@ import com.studymachine.www.R; | ||
39 | import com.studymachine.www.action.TitleBarAction; | 39 | import com.studymachine.www.action.TitleBarAction; |
40 | import com.studymachine.www.aop.CheckNet; | 40 | import com.studymachine.www.aop.CheckNet; |
41 | import com.studymachine.www.app.AppPresentation; | 41 | import com.studymachine.www.app.AppPresentation; |
42 | +import com.studymachine.www.app.ModeHandler; | ||
42 | import com.studymachine.www.domain.AiDTO; | 43 | import com.studymachine.www.domain.AiDTO; |
43 | import com.studymachine.www.enumtype.TopicEnum; | 44 | import com.studymachine.www.enumtype.TopicEnum; |
44 | import com.studymachine.www.event.SwfEvent; | 45 | import com.studymachine.www.event.SwfEvent; |
@@ -64,6 +65,7 @@ import com.studymachine.www.action.StatusAction; | @@ -64,6 +65,7 @@ import com.studymachine.www.action.StatusAction; | ||
64 | import com.studymachine.www.ui.dialog.ConfirmDialog; | 65 | import com.studymachine.www.ui.dialog.ConfirmDialog; |
65 | import com.studymachine.www.widget.StatusLayout; | 66 | import com.studymachine.www.widget.StatusLayout; |
66 | import com.studymachine.www.widget.X5WebView; | 67 | import com.studymachine.www.widget.X5WebView; |
68 | +import com.tencent.smtt.sdk.ValueCallback; | ||
67 | import com.tencent.smtt.sdk.WebChromeClient; | 69 | import com.tencent.smtt.sdk.WebChromeClient; |
68 | import com.tencent.smtt.sdk.WebView; | 70 | import com.tencent.smtt.sdk.WebView; |
69 | import com.tencent.smtt.sdk.WebViewClient; | 71 | import com.tencent.smtt.sdk.WebViewClient; |
@@ -92,32 +94,25 @@ public class WebPresentation extends AppPresentation implements StatusAction { | @@ -92,32 +94,25 @@ public class WebPresentation extends AppPresentation implements StatusAction { | ||
92 | this.mPointId = mPointId; | 94 | this.mPointId = mPointId; |
93 | this.mPointDetail = mPointDetail; | 95 | this.mPointDetail = mPointDetail; |
94 | } | 96 | } |
95 | - | 97 | + public X5WebView getmX5WebView(){ |
98 | + return this.mX5WebView; | ||
99 | + } | ||
96 | public WebPresentation(Context outerContext, Display display, int theme) { | 100 | public WebPresentation(Context outerContext, Display display, int theme) { |
97 | super(outerContext, display, theme); | 101 | super(outerContext, display, theme); |
98 | } | 102 | } |
99 | 103 | ||
100 | - private void addControllerView() { | ||
101 | - controllerView = new ControllerView(getContext(), null); | ||
102 | - ViewGroup root = (ViewGroup) getWindow().getDecorView(); | ||
103 | - root.addView(controllerView); | ||
104 | - controllerView.bringToFront(); | ||
105 | - } | ||
106 | - | ||
107 | @Override | 104 | @Override |
108 | public int getLayout() { | 105 | public int getLayout() { |
109 | return R.layout.ai_detail_activity; | 106 | return R.layout.ai_detail_activity; |
110 | } | 107 | } |
111 | 108 | ||
112 | public void initData() { | 109 | public void initData() { |
113 | - mControllerFrame = findViewById(R.id.controller_frame); | 110 | + final ModeHandler handler = new ModeHandler(this); |
114 | mImgView = findViewById(R.id.loadview); | 111 | mImgView = findViewById(R.id.loadview); |
115 | mStatusLayout = findViewById(R.id.hl_browser_hint); | 112 | mStatusLayout = findViewById(R.id.hl_browser_hint); |
116 | mIvBack = findViewById(R.id.iv_back); | 113 | mIvBack = findViewById(R.id.iv_back); |
117 | mX5WebView = findViewById(R.id.wv_browser_view); | 114 | mX5WebView = findViewById(R.id.wv_browser_view); |
118 | - mControllerBid = findViewById(R.id.controller_bid); | ||
119 | - imageView = findViewById(R.id.controller_image); | ||
120 | - MainJavaScriptInterface mainJavaScriptInterface = new MainJavaScriptInterface(getOwnerActivity(), mX5WebView); | 115 | + MainJavaScriptInterface mainJavaScriptInterface = new MainJavaScriptInterface(getOwnerActivity(), mX5WebView,handler); |
121 | mX5WebView.addJavascriptInterface(mainJavaScriptInterface, "studyMachine"); | 116 | mX5WebView.addJavascriptInterface(mainJavaScriptInterface, "studyMachine"); |
122 | String currentDateTimeString = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()); | 117 | String currentDateTimeString = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date()); |
123 | mainJavaScriptInterface.setTime(currentDateTimeString); | 118 | mainJavaScriptInterface.setTime(currentDateTimeString); |
@@ -129,7 +124,35 @@ public class WebPresentation extends AppPresentation implements StatusAction { | @@ -129,7 +124,35 @@ public class WebPresentation extends AppPresentation implements StatusAction { | ||
129 | mX5WebView.setWebViewClient(new AppBrowserViewClient()); | 124 | mX5WebView.setWebViewClient(new AppBrowserViewClient()); |
130 | mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); | 125 | mX5WebView.setWebChromeClient(new AppBrowserChromeClient()); |
131 | mX5WebView.loadUrl(mPointDetail.isFinish() ? mPointDetail.getScene().getArbitrarilyUrl() : mPointDetail.getScene().getSequenceUrl()); | 126 | mX5WebView.loadUrl(mPointDetail.isFinish() ? mPointDetail.getScene().getArbitrarilyUrl() : mPointDetail.getScene().getSequenceUrl()); |
132 | - | 127 | + mIvBack.setOnClickListener(new View.OnClickListener() { |
128 | + @Override | ||
129 | + public void onClick(View v) { | ||
130 | + dismiss(); | ||
131 | + getOwnerActivity().finish(); | ||
132 | + } | ||
133 | + }); | ||
134 | + handler.sendEmptyMessage(0); | ||
135 | +// Runnable task = new Runnable() { | ||
136 | +// public void run() { | ||
137 | +// mX5WebView.evaluateJavascript("javascript:answerExist()", new ValueCallback<String>() { | ||
138 | +// @Override | ||
139 | +// public void onReceiveValue(String s) { | ||
140 | +// try { | ||
141 | +// mode = Integer.valueOf(s); | ||
142 | +// } catch (Exception e) { | ||
143 | +// mode = 1; | ||
144 | +// } | ||
145 | +// | ||
146 | +// } | ||
147 | +// }); | ||
148 | +// | ||
149 | +// handler.sendEmptyMessage(mode);//设置循环时间,此处是5秒 | ||
150 | +// handler.postDelayed(this, 1000); | ||
151 | +// //需要执行的代码 | ||
152 | +// } | ||
153 | +// }; | ||
154 | +// | ||
155 | +// handler.post(task); | ||
133 | } | 156 | } |
134 | 157 | ||
135 | @Subscribe(threadMode = ThreadMode.MAIN) | 158 | @Subscribe(threadMode = ThreadMode.MAIN) |
app/src/main/res/drawable-xhdpi/point.png
0 → 100644
2.08 KB
@@ -8,15 +8,15 @@ | @@ -8,15 +8,15 @@ | ||
8 | tools:context="com.studymachine.www.ui.activity.AiListActivity"> | 8 | tools:context="com.studymachine.www.ui.activity.AiListActivity"> |
9 | 9 | ||
10 | <androidx.appcompat.widget.AppCompatImageView | 10 | <androidx.appcompat.widget.AppCompatImageView |
11 | - android:layout_width="match_parent" | ||
12 | - android:layout_height="match_parent" | 11 | + android:layout_width="wrap_content" |
12 | + android:layout_height="wrap_content" | ||
13 | android:src="@drawable/ai_person_bg" | 13 | android:src="@drawable/ai_person_bg" |
14 | android:translationZ="@dimen/dp_2" /> | 14 | android:translationZ="@dimen/dp_2" /> |
15 | 15 | ||
16 | 16 | ||
17 | <androidx.appcompat.widget.AppCompatImageView | 17 | <androidx.appcompat.widget.AppCompatImageView |
18 | android:id="@+id/iv_person" | 18 | android:id="@+id/iv_person" |
19 | - android:layout_width="@dimen/dp_500" | 19 | + android:layout_width="@dimen/dp_300" |
20 | android:layout_centerVertical="true" | 20 | android:layout_centerVertical="true" |
21 | android:layout_height="wrap_content" | 21 | android:layout_height="wrap_content" |
22 | android:src="@drawable/ai_person_to" | 22 | android:src="@drawable/ai_person_to" |
@@ -3,20 +3,51 @@ | @@ -3,20 +3,51 @@ | ||
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
4 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent"> | 5 | android:layout_height="match_parent"> |
6 | -<FrameLayout | 6 | +<RelativeLayout |
7 | android:id="@+id/controller_frame" | 7 | android:id="@+id/controller_frame" |
8 | android:layout_width="match_parent" | 8 | android:layout_width="match_parent" |
9 | android:layout_height="match_parent" | 9 | android:layout_height="match_parent" |
10 | android:background="@color/black" | 10 | android:background="@color/black" |
11 | > | 11 | > |
12 | - <TextView | 12 | + <Button |
13 | + android:id="@+id/control_back" | ||
13 | android:layout_width="wrap_content" | 14 | android:layout_width="wrap_content" |
14 | android:layout_height="wrap_content" | 15 | android:layout_height="wrap_content" |
15 | - android:gravity="center" | ||
16 | - android:layout_gravity="center" | ||
17 | - android:text="触控板\n请保持手机横屏" | ||
18 | - android:textSize="@dimen/sp_25" | ||
19 | - android:textColor="@color/white" | 16 | + android:layout_alignParentLeft="true" |
17 | + android:text="后退" | ||
18 | + android:textSize="@dimen/sp_16" | ||
19 | + android:visibility="gone" | ||
20 | + android:layout_marginLeft="@dimen/dp_15" | ||
21 | + android:textColor="@color/black" | ||
20 | /> | 22 | /> |
21 | -</FrameLayout> | 23 | + |
24 | + <Button | ||
25 | + android:id="@+id/control_change" | ||
26 | + android:layout_width="wrap_content" | ||
27 | + android:layout_height="wrap_content" | ||
28 | + android:layout_toRightOf="@id/control_back" | ||
29 | + android:layout_marginLeft="@dimen/dp_15" | ||
30 | + android:text="版本切换" | ||
31 | + android:visibility="gone" | ||
32 | + android:textColor="@color/black" | ||
33 | + android:textSize="@dimen/sp_16" /> | ||
34 | + | ||
35 | + <Button | ||
36 | + android:id="@+id/control_mode" | ||
37 | + android:layout_width="wrap_content" | ||
38 | + android:layout_height="wrap_content" | ||
39 | + android:layout_alignParentRight="true" | ||
40 | + android:text="操作切换" | ||
41 | + android:visibility="gone" | ||
42 | + android:layout_marginRight="@dimen/dp_15" | ||
43 | + android:textColor="@color/black" | ||
44 | + android:textSize="@dimen/sp_16" /> | ||
45 | + <ImageView | ||
46 | + android:id="@+id/control_line" | ||
47 | + android:layout_width="match_parent" | ||
48 | + android:layout_height="@dimen/dp_1_5" | ||
49 | + android:background="@color/white" | ||
50 | + android:layout_alignBottom="@id/control_back" | ||
51 | + /> | ||
52 | +</RelativeLayout> | ||
22 | </androidx.constraintlayout.widget.ConstraintLayout> | 53 | </androidx.constraintlayout.widget.ConstraintLayout> |
@@ -11,4 +11,11 @@ | @@ -11,4 +11,11 @@ | ||
11 | android:layout_gravity="center" | 11 | android:layout_gravity="center" |
12 | android:background="@drawable/ai_hand" | 12 | android:background="@drawable/ai_hand" |
13 | /> | 13 | /> |
14 | + <ImageView | ||
15 | + android:id="@+id/controller_point" | ||
16 | + android:layout_width="wrap_content" | ||
17 | + android:layout_height="wrap_content" | ||
18 | + android:src="@drawable/point" | ||
19 | + android:visibility="gone" | ||
20 | + android:layout_gravity="center"/> | ||
14 | </FrameLayout> | 21 | </FrameLayout> |
@@ -10,8 +10,8 @@ android { | @@ -10,8 +10,8 @@ android { | ||
10 | minSdkVersion 24 | 10 | minSdkVersion 24 |
11 | // 目标适配版本 | 11 | // 目标适配版本 |
12 | targetSdkVersion 28 | 12 | targetSdkVersion 28 |
13 | - versionName '2.0.4' | ||
14 | - versionCode 204 | 13 | + versionName '2.0.5' |
14 | + versionCode 205 | ||
15 | } | 15 | } |
16 | 16 | ||
17 | // 支持 Java JDK 8 | 17 | // 支持 Java JDK 8 |
@@ -46,6 +46,7 @@ public abstract class BaseActivity extends AppCompatActivity | @@ -46,6 +46,7 @@ public abstract class BaseActivity extends AppCompatActivity | ||
46 | } | 46 | } |
47 | 47 | ||
48 | protected void initActivity() { | 48 | protected void initActivity() { |
49 | + | ||
49 | initLayout(); | 50 | initLayout(); |
50 | initView(); | 51 | initView(); |
51 | initData(); | 52 | initData(); |