Skip to content

Commit 9acbe12

Browse files
author
lucas
committed
fix some bug
1 parent aa89bc2 commit 9acbe12

File tree

8 files changed

+158
-11
lines changed

8 files changed

+158
-11
lines changed

VideoOS/LuaViewSDK/src/com/taobao/luaview/util/JsonUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ public static Object toJSON(LuaTable table) {
9393
obj.put(key, value.optboolean(false));
9494
} else if (value.isint()) {
9595
obj.put(key, value.optint(0));
96+
}else if (value.isstring()) {
97+
obj.put(key, value.optstring(null));
9698
} else if (value.islong()) {
9799
obj.put(key, value.optlong(0L));
98-
} else if (value.isstring()) {
99-
obj.put(key, value.optstring(null));
100-
} else {
100+
} else {
101101
obj.put(key, value);
102102
}
103103
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoPlusController.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,21 @@ public void downError(Throwable t) {
606606
});
607607
model.startRequest();
608608
}
609+
610+
/**
611+
* 更新最近使用记录
612+
* @param appId
613+
*/
614+
public void refreshRecentHistory(String appId){
615+
if (!VenvyAPIUtil.isSupport(16)) {
616+
Log.e("VideoOS", "VideoOS 不支持Android4.0以下版本调用");
617+
return;
618+
}
619+
if (mVideoPlusAdapter == null) {
620+
VenvyLog.e("Video++ View 未设置adapter");
621+
return;
622+
}
623+
this.mPlatform = initPlatform(mVideoPlusAdapter);
624+
new VideoRecentlyModel(mPlatform,appId).startRequest();
625+
}
609626
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoPlusH5Controller.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,23 @@ public void startH5Program(final String appletId){
100100

101101

102102

103+
/**
104+
* 更新最近使用记录
105+
* @param appId
106+
*/
107+
public void refreshRecentHistory(String appId){
108+
if (!VenvyAPIUtil.isSupport(16)) {
109+
Log.e("VideoOS", "VideoOS 不支持Android4.0以下版本调用");
110+
return;
111+
}
112+
if (mVideoPlusAdapter == null) {
113+
VenvyLog.e("Video++ View 未设置adapter");
114+
return;
115+
}
116+
this.mPlatform = initPlatform(mVideoPlusAdapter);
117+
new VideoRecentlyModel(mPlatform,appId).startRequest();
118+
}
119+
120+
103121

104122
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoProgramToolBarView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public void start(String appletId, String data, int type) {
152152

153153
}
154154

155-
public void navigation(Uri uri, HashMap<String, String> params, IRouterCallback callback) {
156-
videoProgramView.navigation(uri, params, callback);
155+
public void refreshHistory(String appletId){
156+
videoProgramView.refreshRecentHistory(appletId);
157157
}
158158

159159
public void setVideoOSAdapter(@NonNull VideoPlusAdapter adapter) {

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoProgramTypeBView.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
import java.util.HashMap;
2020
import java.util.Map;
2121

22-
import cn.com.venvy.common.observer.ObservableManager;
2322
import cn.com.venvy.common.observer.VenvyObservable;
2423
import cn.com.venvy.common.observer.VenvyObservableTarget;
2524
import cn.com.venvy.common.observer.VenvyObserver;
2625
import cn.com.venvy.common.utils.VenvyLog;
2726
import cn.com.venvy.common.utils.VenvyUIUtil;
28-
import cn.com.videopls.pub.view.VideoOSLuaView;
2927

3028
/**
3129
* Created by Lucas on 2019/7/31.
@@ -152,7 +150,7 @@ public void start(@NonNull String appletId, String data, int orientationType, bo
152150
if (h5ProgramMap.containsKey(appletId)) {
153151
VenvyLog.d("h5 appletId is exists");
154152
VideoWebToolBarView h5View = h5ProgramMap.get(appletId);
155-
h5View.reload();
153+
h5View.reload(appletId);
156154
currentH5Program = h5View;
157155
return;
158156
}
@@ -173,6 +171,7 @@ public void start(@NonNull String appletId, String data, int orientationType, bo
173171
//notify lua script refresh
174172
existView.bringToFront();
175173
existView.notifyLua(data);
174+
existView.refreshHistory(appletId);
176175
currentProgram = existView;
177176
return;
178177
}
@@ -271,9 +270,9 @@ public void closeAllProgramByOrientation(int orientationType) {
271270
}
272271

273272

274-
public void showExceptionLogic(String msg, boolean needRetry,String data) {
273+
public void showExceptionLogic(String msg, boolean needRetry, String data) {
275274
if (currentProgram != null) {
276-
currentProgram.showExceptionLogic(msg,needRetry,data);
275+
currentProgram.showExceptionLogic(msg, needRetry, data);
277276
}
278277
}
279278

@@ -313,6 +312,7 @@ public void onAnimationEnd(Animator animation) {
313312

314313
/**
315314
* 暂时没有注册
315+
*
316316
* @param observable
317317
* @param tag
318318
* @param bundle

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoProgramView.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ public void stopService(ServiceType serviceType) {
125125
public void startVision(String appletId, String data, int type,boolean isH5Type,final IRouterCallback callback) {
126126
if (controller != null) {
127127
controller.startVisionProgram(appletId, data, type,isH5Type,callback);
128+
refreshRecentHistory(appletId);
128129
}
129130
}
130131

132+
public void refreshRecentHistory(String appletId){
133+
controller.refreshRecentHistory(appletId);
134+
}
135+
131136
/**
132137
* 筛出所有的luaview
133138
*
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package cn.com.videopls.pub;
2+
3+
import android.support.annotation.NonNull;
4+
import android.support.annotation.Nullable;
5+
6+
import org.json.JSONException;
7+
import org.json.JSONObject;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
import cn.com.venvy.AppSecret;
13+
import cn.com.venvy.Config;
14+
import cn.com.venvy.Platform;
15+
import cn.com.venvy.common.http.HttpRequest;
16+
import cn.com.venvy.common.http.base.IRequestHandler;
17+
import cn.com.venvy.common.http.base.IResponse;
18+
import cn.com.venvy.common.http.base.Request;
19+
import cn.com.venvy.common.utils.VenvyAesUtil;
20+
import cn.com.venvy.common.utils.VenvyLog;
21+
import cn.com.venvy.lua.plugin.LVCommonParamPlugin;
22+
23+
/**
24+
* Created by Lucas on 2019/9/9.
25+
*/
26+
public class VideoRecentlyModel extends VideoPlusBaseModel {
27+
28+
private static final String API = "/vision/addRecentMiniApp";
29+
30+
private String miniAppId;
31+
32+
public VideoRecentlyModel(@NonNull Platform platform, String miniAppId) {
33+
super(platform);
34+
this.miniAppId = miniAppId;
35+
}
36+
37+
38+
@Override
39+
public boolean needCheckResponseValid() {
40+
return false;
41+
}
42+
43+
@Override
44+
public Request createRequest() {
45+
return HttpRequest.post(Config.HOST_VIDEO_OS + API, createBody());
46+
}
47+
48+
private Map<String, String> createBody() {
49+
Map<String, String> paramBody = new HashMap<>();
50+
paramBody.put("miniAppId", miniAppId);
51+
paramBody.put("commonParam", LVCommonParamPlugin.getCommonParamJson());
52+
HashMap<String, String> data = new HashMap<>();
53+
data.put("data", VenvyAesUtil.encrypt(AppSecret.getAppSecret(getPlatform()), AppSecret.getAppSecret(getPlatform()), new JSONObject(paramBody).toString()));
54+
return data;
55+
}
56+
57+
@Override
58+
public IRequestHandler createRequestHandler() {
59+
return new IRequestHandler() {
60+
@Override
61+
public void requestFinish(Request request, IResponse response) {
62+
if (response.isSuccess()) {
63+
try {
64+
// 解密返回数据
65+
final JSONObject value = new JSONObject(response.getResult());
66+
String encryptData = value.optString("encryptData");
67+
final JSONObject decryptData = new JSONObject(VenvyAesUtil.decrypt(encryptData, AppSecret.getAppSecret(getPlatform()), AppSecret.getAppSecret(getPlatform())));
68+
String resCode = decryptData.optString("resCode"); // 应答码 00-成功 01-失败
69+
if(resCode.equals("00")){
70+
VenvyLog.d("refresh success");
71+
}else{
72+
String resMsg = decryptData.optString("resMsg");
73+
VenvyLog.d("refresh faile : "+resMsg);
74+
}
75+
} catch (JSONException e) {
76+
e.printStackTrace();
77+
}
78+
79+
} else {
80+
VenvyLog.d("refresh failed");
81+
}
82+
}
83+
84+
@Override
85+
public void requestError(Request request, @Nullable Exception e) {
86+
VenvyLog.e(VisionProgramConfigModel.class.getName(), "视联网小程序refresh failed " + (e != null ? e.getMessage() : ""));
87+
}
88+
89+
@Override
90+
public void startRequest(Request request) {
91+
92+
}
93+
94+
@Override
95+
public void requestProgress(Request request, int progress) {
96+
97+
}
98+
};
99+
}
100+
}

VideoOS/venvy_pub/src/main/java/cn/com/videopls/pub/VideoWebToolBarView.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,18 @@ public void fetchTargetUrl(String appletId, String data) {
233233
webView.setVisibility(GONE);
234234
startLoadingAnimation();
235235
controller.startH5Program(appletId);
236+
freshProgram(appletId);
236237

237238
JsBridge jsBridge = new JsBridge(getContext(), webView, controller.getPlatform());
238239
jsBridge.setJsData(data);
239240
webView.setJsBridge(jsBridge);
240241
}
241242

243+
244+
public void freshProgram(String appletId){
245+
controller.refreshRecentHistory(appletId);
246+
}
247+
242248
public void openLink(final String url) {
243249
VenvyLog.d("openLink : " + url);
244250
webView.setVisibility(VISIBLE);
@@ -247,8 +253,9 @@ public void openLink(final String url) {
247253
cancelLoadingAnimation();
248254
}
249255

250-
public void reload(){
256+
public void reload(String appletId){
251257
webView.reload();
258+
freshProgram(appletId);
252259
}
253260

254261

0 commit comments

Comments
 (0)