History.js
29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
//日记(我的收藏)
//这里跳转地址是由返回数据指定,暂未实现
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var FocusInfo = require('FocusInfo');
var TVCanvas = require('TVCanvas');
var TVScrollParameter = require('TVScrollParameter');
var ListView = require('ListView');
var ListCell = require('ListCell');
cc.Class({
extends: TVCanvas,
properties: {
spriteCollect: cc.Sprite,
spriteEditor: cc.Sprite,
spriteClear: cc.Sprite,
spriteBackEditor: cc.Sprite,
spriteIndex: cc.Sprite,
_bPfbTypeCellInit: false,
_aTypeAppId: [],
_nodeTypeHeight: 0,
TYPE_LIST_CELL_SIZE: 4,
_bIsCategoryListDataInit: false,
// _iCurrentTypeIndex: 0,
_iDefaultCollectionId: 0,
_bEditorStatus: false,
_oType: null,
_aNavList: [], //存储跳转需要的参数,appId,url...
_strAppId: '',
},
onLoad: function () {
this._super();
//-----------上下文及参数相关处理------------
let oSceneParameter = this._cApplication.getTopSceneParameter();
if (oSceneParameter) {
this._strAppId = oSceneParameter.appId;//应用id
}
//恢复上下文
if (this._cApplication.getBackStatus()) {
this._oSceneContext = this._cApplication.popSceneContext();
this._cApplication.setBackStatus(false);
} else {
this._oSceneContext = {};
this._oSceneContext.requestedTypeId = null;
this._oSceneContext._iCurrentTypeIndex = 0;
this._oSceneContext.categoryRecordIndexOfFirstCell = 0;
this._oSceneContext.focusPath = "TypeListArea/TypeListWrapper/TypeList/TypeListCell0";
this._oSceneContext.typeListY = 0;
// this._oSceneContext.elderTypeId = oSceneParameter.elderTypeId || 37; //从上级拿过来的二级父Id
}
this._strAppId = this._strAppId || "tda7e47f868313d9f5"; //测试
//---------上下文及参数相关处理结束-----------
// this.spriteHistory.spriteFrame.setRect(cc.rect(0, 0, 176, 64));
this.spriteCollect.spriteFrame.setRect(cc.rect(0, 0, 176, 64));
this.spriteEditor.spriteFrame.setRect(cc.rect(0, 0, 137, 65));
this.spriteClear.spriteFrame.setRect(cc.rect(0, 0, 137, 65));
this.spriteBackEditor.spriteFrame.setRect(cc.rect(0, 0, 137, 65));
this.spriteIndex.spriteFrame.setRect(cc.rect(0, 0, 137, 65));
this.getPageBg(this, 'background');
this.getListBookmark(); //直接请求
this.getDefaultCollection(); //删除所有条目用的
},
/**
* 拿到列表需要的ids
*/
getListBookmark: function () {
let oTypeRequestParameters = {
"view": "json",
// "appId": this._aTypeAppId[this._oSceneContext._iCurrentTypeIndex],
"sortByCollection": 1,
"start": 0,
"limit": 9,
"sortField": "update_time",
"sortDirection": "desc",
"token": Common.TEST_API_TOKEN_EDU,
};
Network.ajax('GET', Common.TOPDRAW_API_SERVER_EDU + "User/ListBookmark", null, oTypeRequestParameters,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
this._strIds = ""; //初始化
if (oJSONResult.resultSet.length > 0) {
cc.find('BlankIcon', this.node).opacity = 0;
for (let i = 0; i < oJSONResult.resultSet.length; i++) {
if (oJSONResult.resultSet[i].media_id) {
this._strIds = this._strIds + "," + oJSONResult.resultSet[i].media_id;
}
}
// this.getCategoryList();
}
this.getCategoryList();
// else {
// cc.find('BlankIcon', this.node).opacity = 255;
// let lvCategoryList = this._nodeCategoryList.getComponent(ListView);
// lvCategoryList.renderInitData(strResponse); //将ListView数据置空
// this._oSceneContext.focusPath = "app";
// }
cc.log("Success GET ListBookmark...");
} else {
cc.log("Error GET ListBookmark..." + oJSONResult.description);
}
} catch (error) {
cc.log("Exception GET ListBookmark..." + error);
}
},
function (strResponse) {
cc.log("Communication Error : Get ListBookmark Information..." + strResponse + "\r\n");
}, this, "uuid"
);
},
/**
* 用当前typeid拿到id
*/
getDefaultCollection: function () {
// this._strAppId = this._aNavList[this._oSceneContext._iCurrentTypeIndex].appId;
let oDefaultCollectionParameters = {
"view": "json",
// "appId": this._aTypeAppId[this._oSceneContext._iCurrentTypeIndex],
"token": Common.TEST_API_TOKEN_EDU,
};
Network.ajax('GET', Common.TOPDRAW_API_SERVER_EDU + "User/GetDefaultCollection", null, oDefaultCollectionParameters,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
if (oJSONResult.resultSet.length > 0) {
this._iDefaultCollectionId = oJSONResult.resultSet[0].id;
// this.getCategoryList();
} else {
this._oSceneContext.focusPath = "app";
}
cc.log("Success GET DefaultCollection...");
} else {
cc.log("Error GET DefaultCollection..." + oJSONResult.description);
}
} catch (error) {
cc.log("Exception GET DefaultCollection..." + error);
}
},
function (strResponse) {
cc.log("Communication Error : Get DefaultCollection Information..." + strResponse + "\r\n");
}, this, "uuid"
);
},
getCategoryList: function () {
//把之前的东西删掉
let nodeCategoryList = this.node.getChildByName('CategoryList');
// nodeCategoryList.getChildByName('DataContainerMask').getChildByName('DataContainer').removeAllChildren();
nodeCategoryList.getChildByName('DataContainerMask').getChildByName('DataContainer').destroyAllChildren();
this._strSongListCellComponentName = "HistoryOtherListCell";
this._iBeginPositionX = -450;
this._iBeginPositionY = 250;
this._iShowCellRows = 2;
this._iAlphaCellRows = 1;
this._iHiddenCellRows = 2;
this._iCellCountEachRow = 4;
this._fCellMarginTop = 0;
this._fCellMarginRight = 20;
this._fCellMarginBottom = 60;
this._fCellMarginLeft = 0;
// break;
// }
//重新开始
let lvCategoryList = nodeCategoryList.getComponent(ListView);
if (!lvCategoryList) {
lvCategoryList = nodeCategoryList.addComponent(ListView);
}
var ids = this._strIds.substring(1, this._strIds.length);
lvCategoryList.init(this, this._iShowCellRows, this._iAlphaCellRows, this._iHiddenCellRows, this._iCellCountEachRow, this._strSongListCellComponentName,
this._iBeginPositionX, this._iBeginPositionY,//起始位置
this._fCellMarginTop, this._fCellMarginRight, this._fCellMarginBottom, this._fCellMarginLeft,
1, 1, //0-横向 1-纵向
function () {
//请求列表
let oMediaParas = {};
oMediaParas.ids = ids;
// oMediaParas.appId = strAppId;
oMediaParas.sortField = "update_time";
oMediaParas.sortDirection = "desc";
let iStart1 = 0;
if (null != this._oSceneContext.categoryRecordIndexOfFirstCell) {
iStart1 = this._oSceneContext.categoryRecordIndexOfFirstCell;
}
//函数默认取一页数据,但是第一次显示需要加上Alpha的部分
lvCategoryList.setDataSource(
"GET",
Common.TOPDRAW_API_SERVER_EDU + "Media/List",
oMediaParas,
iStart1, (lvCategoryList.getShowCellRows() + lvCategoryList.getAlphaCellRows()) * lvCategoryList.getCellCountEachRow(),
null, null
);
lvCategoryList.loadData(
function (strResponse) {
lvCategoryList.renderInitData(strResponse, function () {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.resultSet.length <= 0) { //没有数据就显示占位图
cc.find('BlankIcon', this.node).opacity = 255
} else {
cc.find('BlankIcon', this.node).opacity = 0
}
// this.lvCategoryList.renderInitData(strResponse);
this._bIsCategoryListDataInit = true;
this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
this.checkDataReadyAndInitFocus();
// for (var key in this._aFocusTargets[0]) {
// cc.log(key + "=====current focus========" + this._aFocusTargets[0][key].name + "==cc.isValid==" + cc.isValid(this._aFocusTargets[0][key]));
// }
});
},
null,
this
);
}
);
},
/**
* 改变管理的状态
*/
changeEditorStatus: function () {
var fiFocusTarget = null;
if (!this._bIsFocusInit) return; //还未初始化焦点
var nodeContainer = cc.find('CategoryList/DataContainerMask/DataContainer', this.node);
var aNodeChildren = nodeContainer.children;
if (this._bEditorStatus) {
fiFocusTarget = cc.find('BackEditorIcon', this.node).getComponent(FocusInfo);
cc.find('EditorIcon', this.node).getComponent(FocusInfo).setEnable(false);
cc.find('IndexIcon', this.node).getComponent(FocusInfo).setEnable(false);
cc.find('ClearIcon', this.node).getComponent(FocusInfo).setEnable(true);
cc.find('BackEditorIcon', this.node).getComponent(FocusInfo).setEnable(true);
cc.find('EditorIcon', this.node).opacity = 0;
cc.find('IndexIcon', this.node).opacity = 0;
cc.find('BackEditorIcon', this.node).opacity = 255;
cc.find('ClearIcon', this.node).opacity = 255;
// for (let i = 0; i < aNodeChildren.length; i++) {
// cc.find('GrayMask', aNodeChildren[i]).opacity = 255;
// }
} else {
fiFocusTarget = cc.find('EditorIcon', this.node).getComponent(FocusInfo);
cc.find('EditorIcon', this.node).getComponent(FocusInfo).setEnable(true);
cc.find('IndexIcon', this.node).getComponent(FocusInfo).setEnable(true);
cc.find('ClearIcon', this.node).getComponent(FocusInfo).setEnable(false);
cc.find('BackEditorIcon', this.node).getComponent(FocusInfo).setEnable(false);
cc.find('EditorIcon', this.node).opacity = 255;
cc.find('IndexIcon', this.node).opacity = 255;
cc.find('BackEditorIcon', this.node).opacity = 0;
cc.find('ClearIcon', this.node).opacity = 0;
// for (let i = 0; i < aNodeChildren.length; i++) {
// cc.find('GrayMask', aNodeChildren[i]).opacity = 0;
// }
}
// this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_RIGHT, null, null);//TODO:焦点跳转一次,不然按钮状态无法改变
},
//删除ListView条目
requestRemoveProgram: function () {
let id = this._fiCurrentFocus.node.getChildByName('Id').getComponent(cc.Label).string;
var oRemoveProgramPara = {
'view': "json",
"collectionId": this._iDefaultCollectionId,
'mediaIds': id,
// "appId": this._aTypeAppId[this._oSceneContext._iCurrentTypeIndex],
"token": Common.TEST_API_TOKEN,
}
Network.ajax('GET', Common.TOPDRAW_API_SERVER + "User/RemoveMediaFromCollection", null, oRemoveProgramPara,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
cc.log("删除成功");
this.getCategoryList();
let fiFocusTarget = cc.find("BackEditorIcon", this.node).getComponent(FocusInfo); //处理焦点跳转
setTimeout(function () {
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_UP, null, null);
}.bind(this), 300);
cc.log("Success GET RemoveProgram...");
} else {
cc.log("Error GET RemoveProgram..." + oJSONResult.description);
}
} catch (error) {
cc.log("Exception GET RemoveProgram..." + error);
}
},
function (strResponse) {
cc.log("Communication Error : Get RemoveProgram Information..." + strResponse + "\r\n");
}, this, "uuid"
);
},
//清空所有条目
requestRemoveAllProgram: function () {
var oRemoveAllProgramPara = {
'view': "json",
"collectionId": this._iDefaultCollectionId,
// "appId": this._aTypeAppId[this._oSceneContext._iCurrentTypeIndex],
"token": Common.TEST_API_TOKEN_EDU,
}
Network.ajax('GET', Common.TOPDRAW_API_SERVER_EDU + "User/RemoveAllMediaFromCollection", null, oRemoveAllProgramPara,
function (strResponse) {
try {
var oJSONResult = JSON.parse(strResponse);
if (oJSONResult.businessCode == 'success') {
cc.log("删除所有成功");
let nodeContainer = cc.find('CategoryList/DataContainerMask/DataContainer', this.node);
nodeContainer.destroyAllChildren();
this.getCategoryList();
cc.log("Success GET RemoveAllProgram...");
} else {
cc.log("Error GET RemoveAllProgram..." + oJSONResult.description);
}
} catch (error) {
cc.log("Exception GET RemoveAllProgram..." + error);
}
},
function (strResponse) {
cc.log("Communication Error : Get RemoveAllProgram Information..." + strResponse + "\r\n");
}, this, "uuid"
);
},
checkDataReadyAndInitFocus: function () {
if (this._bIsCategoryListDataInit && !this._bIsFocusInit) {
// this.scheduleOnce(() => { //指定0让回调函数在下一帧立即执行
this.initFocus();
// }, 0);
this._bIsFocusInit = true;
this.changeEditorStatus();
}
},
initFocus: function () {
var self = this;
//----------------Creator2.1.0-rc2版本有毒--------------------------
//动态加载这几张引起黑屏的罪魁祸首
// cc.loader.loadRes("Texture/scroll/pageIncon", cc.SpriteFrame, function (err, spriteFrame) {
// self.spriteScrollBarBlock.spriteFrame = spriteFrame;
// });
// cc.loader.loadRes("Texture/scroll/up_arrow", cc.SpriteFrame, function (err, spriteFrame) {
// self.spriteScrollBarUp.spriteFrame = spriteFrame;
// });
// cc.loader.loadRes("Texture/scroll/down_arrow", cc.SpriteFrame, function (err, spriteFrame) {
// self.spriteScrollBarDown.spriteFrame = spriteFrame;
// });
//-----------------------------------------------------------------
var fiCollection = this.spriteCollect.addComponent(FocusInfo);
this._aFocusTargets[0]['to_collection_index'] = this.spriteCollect;
fiCollection.init('{"click": [{"action": "ChangeScene","parameters": {"sceneName":"sceneDiary","appId":"' + this._strAppId + '"}}]}', true);
// self.spriteEditor.spriteFrame.setRect(cc.rect(0, 0, 142, 54));
var fiEditor = this.spriteEditor.addComponent(FocusInfo);
this._aFocusTargets[0]['to_editor_index'] = this.spriteEditor;
fiEditor.init(null, true);
// self.spriteClear.spriteFrame.setRect(cc.rect(0, 0, 142, 54));
var fiClearEditor = this.spriteClear.addComponent(FocusInfo);
this._aFocusTargets[0]['to_clear_index'] = this.spriteClear;
fiClearEditor.init(null, false);
// self.spriteBackEditor.spriteFrame.setRect(cc.rect(0, 0, 142, 54));
var fiBackEditor = this.spriteBackEditor.addComponent(FocusInfo);
this._aFocusTargets[0]['to_exit_editor_index'] = this.spriteBackEditor;
fiBackEditor.init(null, false);
var fiIndex = this.spriteIndex.addComponent(FocusInfo);
this._aFocusTargets[0]['to_home_index'] = this.spriteIndex;
fiIndex.init('{"click": [{"action": "ChangeScene","parameters": {"sceneName":"sceneRecommend"}}]}', true);
// var nodeInitFocus = cc.find(this._oSceneContext.focusPath, this.node);
var nodeInitFocus = cc.find("CollectionIcon", this.node); //从其他界面回退回来错乱,强制使用死路径
var nodeFocus = new cc.Node('nodeFocus');
this.node.addChild(nodeFocus, 10);
this._cFocus = this.node.getChildByName('nodeFocus').addComponent(TVFocus);
this._cFocus.init('focusContainer', this,
nodeInitFocus.getComponent(FocusInfo),
Common.SCREEN_WIDTH, Common.SCREEN_HEIGHT, 0, 0, 1.0);
if (0 == nodeInitFocus.name.indexOf('CollectionIcon')) {
cc.loader.loadRes('button/collection_button', cc.Texture2D, function (err, texture) {
nodeInitFocus.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 64, 176, 64));
});
}
},
onKeyDown: function (event) {
this._super(event);
var fiFocusTarget = null;
var fiCurrentFocus = this._fiCurrentFocus;
var oScrollParameter = null;
let aCheckResult;
//TODO:给ListView传值,使其可以让滑块跟随滚动
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList) {
lvCategoryList.setCurrentFocus(this._fiCurrentFocus);
}
// this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPageAdvance();
if (event.keyCode == cc.macro.KEY.up || event.keyCode == Common.ANDROID_KEY.up) {
// if (0 == this._fiCurrentFocus.node.getName().indexOf('ScrollBarBlock')) { //如果滚动条
// let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
// if (lvCategoryList.scrollAPageUp()) {
// return;
// }
// }
if (0 == this._fiCurrentFocus.node.getName().indexOf('OtherListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('OtherListCell', ''));
// let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowUp(index)) {
return;
}
}
fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, 0, Common.MOVE_DIRECTION_UP);
if (!fiFocusTarget) { return; }
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_UP, null, oScrollParameter);
}
if (event.keyCode == cc.macro.KEY.right || event.keyCode == Common.ANDROID_KEY.right) {
fiFocusTarget = this._cFocus.findTarget(this._fiCurrentFocus, this._aFocusTargets, 0, Common.MOVE_DIRECTION_RIGHT);
if (!fiFocusTarget) { return; }
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_RIGHT, null, oScrollParameter);
}
if (event.keyCode == cc.macro.KEY.down || event.keyCode == Common.ANDROID_KEY.down) {
// if (!this._iScrollGroupStatus) {
// if (0 == this._fiCurrentFocus.node.getName().indexOf('ScrollBarBlock')) { //如果是滚动条
// let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
// if (lvCategoryList.scrollAPageDown()) {
// }
// return;
// }
if (0 == this._fiCurrentFocus.node.getName().indexOf('OtherListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('OtherListCell', ''));
// let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowDown(null, index)) {
// cc.log("line feed!");
return;
}
}
fiFocusTarget = this._cFocus.findTarget(this._fiCurrentFocus, this._aFocusTargets, 0, Common.MOVE_DIRECTION_DOWN);
if (!fiFocusTarget) { return; }
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_DOWN, null, oScrollParameter);
// }
}
if (event.keyCode == cc.macro.KEY.left || event.keyCode == Common.ANDROID_KEY.left) {
fiFocusTarget = this._cFocus.findTarget(this._fiCurrentFocus, this._aFocusTargets, 0, Common.MOVE_DIRECTION_LEFT);
if (!fiFocusTarget) { return; }
aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
fiFocusTarget = aCheckResult[0];
oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Common.MOVE_DIRECTION_LEFT, null, oScrollParameter);
}
if (event.keyCode == cc.macro.KEY.enter || event.keyCode == Common.ANDROID_KEY.enter) {
if (0 == fiCurrentFocus.node.name.indexOf('EditorIcon') || 0 == fiCurrentFocus.node.name.indexOf('BackEditorIcon')) {
this._bEditorStatus = !this._bEditorStatus;
// this.getCategoryList();
this.changeEditorStatus();
} else if (0 == fiCurrentFocus.node.name.indexOf('DiaryListCell')) { //进入详情或删除该条目
if (this._bEditorStatus) { //删除
this.requestRemoveProgram();
} else { //进入详情(这里要先设置焦点)注意:有些不需要进入详情是直接播放的
let id = fiCurrentFocus.node.getChildByName('Id').getComponent(cc.Label).string;
let fiBlock = fiCurrentFocus.node.getComponent(FocusInfo);
fiBlock.init(
'{"click": [{"action": "ChangeScene","parameters": {"sceneName":"sceneCartoonDetail","appId":"' + this._strAppId + '","id":"' + id + '"}}]}'
);
this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
}
} else if (this._bEditorStatus && 0 == fiCurrentFocus.node.name.indexOf('ClearIcon')) { //清空
this.requestRemoveAllProgram();
} else { //观看历史
this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
}
}
if (event.keyCode == cc.macro.KEY.space) { }
if (event.keyCode == cc.macro.KEY.backspace || event.keyCode == Common.ANDROID_KEY.back) {
this.backAScene();
}
//记录CategoryList滚动位置
this._oSceneContext.categoryRecordIndexOfFirstCell = lvCategoryList.getRecordIndexOfFirstCellInPage();
},
checkFocusTarget: function (fiFocusTarget, oScrollParameter) {
return [fiFocusTarget, oScrollParameter];
},
onBeforeFocusChange: function (event) {
let fiFrom = event.detail.from;
let fiTo = event.detail.to;
if (0 == fiFrom.node.getName().indexOf('CollectionIcon')) {
cc.loader.loadRes('button/collection_button', cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 176, 64));
});
}
if (0 == fiFrom.node.getName().indexOf('EditorIcon')) {
cc.loader.loadRes('button/editor_button', cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 137, 65));
});
}
if (0 == fiFrom.node.getName().indexOf('ClearIcon')) {
cc.loader.loadRes('button/clear_button', cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 137, 65));
});
}
if (0 == fiFrom.node.getName().indexOf('BackEditorIcon')) {
cc.loader.loadRes('button/exitEditor_button', cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 137, 65));
});
}
if (0 == fiFrom.node.getName().indexOf('IndexIcon')) {
cc.loader.loadRes('button/index_button', cc.Texture2D, function (err, texture) {
fiFrom.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 0, 137, 65));
});
}
},
onAfterFocusChange: function (event) {
let fiTo = event.detail.to;
if (0 == fiTo.node.getName().indexOf('CollectionIcon')) {
cc.loader.loadRes('button/collection_button', cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 64, 176, 64));
});
}
if (0 == fiTo.node.getName().indexOf('EditorIcon')) {
cc.loader.loadRes('button/editor_button', cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 65, 137, 65));
});
}
if (0 == fiTo.node.getName().indexOf('ClearIcon')) {
cc.loader.loadRes('button/clear_button', cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 65, 137, 65));
});
}
if (0 == fiTo.node.getName().indexOf('BackEditorIcon')) {
cc.loader.loadRes('button/exitEditor_button', cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 65, 137, 65));
});
}
if (0 == fiTo.node.getName().indexOf('IndexIcon')) {
cc.loader.loadRes('button/index_button', cc.Texture2D, function (err, texture) {
fiTo.node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture, cc.rect(0, 65, 137, 65));
});
}
},
doCurrentFocusTVLinkAction: function (strAction) {
let strTVLink = this._fiCurrentFocus.getTVLink();
var joTVLink = null;
try {
joTVLink = JSON.parse(strTVLink);
let jaOperationList = joTVLink.click;
for (let i = 0; i < jaOperationList.length; i++) {
switch (jaOperationList[i].action) {
default:
this.doTVLinkAction(jaOperationList[i]);
break;
}
}
} catch (error) {
cc.log("runTVLinkAction Exception..." + error);
}
},
onDestroy: function () {
cc.director.emit('stop_render'); //分发事件
},
});