Commit 74e4a3d7 74e4a3d7a144cda8c34faf3ee95b38ffca9d9c81 by 金学艇

1.解决列表页Android端加载数据异步问题

1 parent 2b6708fb
......@@ -39,32 +39,6 @@ cc.Class({
// fiScrollBtn.init(null, true);
this.getNavList(); //获取导航栏信息
this.getCategoryListJsonRequest();
},
getCategoryListJsonRequest: function () {
var self = this;
var aJsonList = ["catetory_jtdr_list.json", "catetory_all_list.json", "catetory_nlbz_list.json", "catetory_3dyx_list.json", "catetory_xyx_list.json", "catetory_tyjj_list.json"];
this.aCategoryListJson = [];
if (this.aCategoryListJson && this.aCategoryListJson.length > 0) {
return;
}
for (let i = 0; i < aJsonList.length; i++) { //这里可能会导致对应导航错乱,改为同步请求
CCNetwork.ajax("GET", Common.TOPDRAW_API_SERVER + "main/" + aJsonList[i], null, null,
function (strResponse) {
try {
// cc.log("远程数据:"+strResponse);
var oJSONResult = JSON.parse(strResponse);
this.aCategoryListJson.push(strResponse);
// cc.log("请求数据返回:" + oJSONResult.count);
} catch (error) {
cc.log("Business Exception:Get getCategoryListJsonRequest..." + error);
}
},
function (strResponse) {
cc.log("Business Error:Get getCategoryListJsonRequest..." + strResponse);
}, this, "uuid");
}
},
getNavList: function () {
......@@ -138,7 +112,8 @@ cc.Class({
}
this._oSceneContext.focusPath = "TypeListArea/TypeListWrapper/TypeList/topNavi" + this._oSceneContext._iCurrentLeftIndex;
this.checkDataReadyAndInitFocus();
this.requestMediaList(1);
// this.requestMediaList(1);
this.getSimulateRequest();
} else {
cc.log("Business Error:getNavList..." + oJSONResult.description);
}
......@@ -151,6 +126,29 @@ cc.Class({
}, this, "uuid");
},
getSimulateRequest: function () {
var self = this;
var aJsonList = ["catetory_jtdr_list.json", "catetory_all_list.json", "catetory_nlbz_list.json", "catetory_3dyx_list.json", "catetory_xyx_list.json", "catetory_tyjj_list.json"];
if (this._oInit[this._oSceneContext._iCurrentLeftIndex]) { //已经加载过数据直接取
self.requestMediaList(1);
} else {
Network.ajax("GET", Common.TOPDRAW_API_SERVER + "main/" + aJsonList[this._oSceneContext._iCurrentLeftIndex], null, null,
function (strResponse) {
try {
this._oInit[this._oSceneContext._iCurrentLeftIndex] = strResponse;
this.scheduleOnce(function () {
self.requestMediaList(1); //重新渲染CategoryList
}, 0);
} catch (error) {
cc.log("Business Exception:Get getSimulateRequest..." + error);
}
},
function (strResponse) {
cc.log("Business Error:Get getSimulateRequest..." + strResponse);
}, this, "uuid");
}
},
requestMediaList: function (cId) {
var self = this;
if (cId) {
......@@ -262,8 +260,9 @@ cc.Class({
);
// lvCategoryList.loadData(
// function (strResponse) {
// cc.log("/////" + JSON.stringify(this.test_list_json1.json));
let strResponse = this.aCategoryListJson[this._oSceneContext._iCurrentLeftIndex];
// cc.log("/////" + this._oInit[this._oSceneContext._iCurrentLeftIndex]);
// let strResponse = this.aCategoryListJson[this._oSceneContext._iCurrentLeftIndex];
let strResponse = this._oInit[this._oSceneContext._iCurrentLeftIndex];
lvCategoryList.renderInitData(strResponse, function () {
// cc.log("InitCategoryList-------------------->");
var oJSONResult = JSON.parse(strResponse);
......@@ -378,7 +377,7 @@ cc.Class({
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryListCell', ''));
// cc.log("当前时多少条目:" + index);
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowUp(index, this.aCategoryListJson[this._oSceneContext._iCurrentLeftIndex])) {
if (lvCategoryList.scrollARowUp(index, this._oInit[this._oSceneContext._iCurrentLeftIndex])) {
return;
}
}
......@@ -396,7 +395,7 @@ cc.Class({
if (0 == this._fiCurrentFocus.node.getName().indexOf('CategoryListCell')) {
var index = parseInt(this._fiCurrentFocus.node.getName().replace('CategoryListCell', ''));
let lvCategoryList = this.node.getChildByName('CategoryList').getComponent(ListView);
if (lvCategoryList.scrollARowDown(null, index, this.aCategoryListJson[this._oSceneContext._iCurrentLeftIndex])) {
if (lvCategoryList.scrollARowDown(null, index, this._oInit[this._oSceneContext._iCurrentLeftIndex])) {
return;
}
}
......@@ -536,7 +535,8 @@ cc.Class({
this._oSceneContext._iCurrentLeftIndex = iIndex;
this.scheduleOnce(function () {
this.requestMediaList(1); //重新渲染CategoryList
// this.requestMediaList(1); //重新渲染CategoryList
this.getSimulateRequest();
}, 0);
}
......
......@@ -457,9 +457,9 @@ cc.Class({
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "startOBiGame", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", Common.TOPDRAW_API_SERVER + this._oSceneContext._downloadUrl, this._oSceneContext._packageName, this._oSceneContext._className, "");
} else {
//这里应该转圈圈等待加载游戏
cc.find("LoadingLabel", this.node).opacity = 255;
cc.find("Loading/LoadingIcon", this.node).opacity = 255;
cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).play();
// cc.find("LoadingLabel", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).play();
jsb.reflection.callStaticMethod("com/topdraw/melody/TopdrawSDKWrapper", "startGame", "(Ljava/lang/String;Ljava/lang/String;)V", this._oSceneContext._packageName, "");
}
} else {
......
......@@ -58,6 +58,51 @@ cc.Class({
}
},
keyDownDirection: function (Direct) {
var fiFocusTarget = null;
var fiCurrentFocus = this._fiCurrentFocus;
var oScrollParameter = null;
let aCheckResult;
fiFocusTarget = this._cFocus.findTarget(fiCurrentFocus, this._aFocusTargets, this._iSceneStatus, Direct);
if (!fiFocusTarget) { return; }
// aCheckResult = this.checkFocusTarget(fiFocusTarget, oScrollParameter);
// fiFocusTarget = aCheckResult[0];
// oScrollParameter = aCheckResult[1];
this._cFocus.flyFocus(this._fiCurrentFocus, fiFocusTarget, Direct, null, oScrollParameter);
},
onKeyDown: function (event) {
this._super(event);
switch (event.keyCode) {
case cc.macro.KEY.up:
case Common.ANDROID_KEY.up:
this.keyDownDirection(Common.MOVE_DIRECTION_UP);
break;
case cc.macro.KEY.right:
case Common.ANDROID_KEY.right:
this.keyDownDirection(Common.MOVE_DIRECTION_RIGHT);
break;
case cc.macro.KEY.down:
case Common.ANDROID_KEY.down:
this.keyDownDirection(Common.MOVE_DIRECTION_DOWN);
break;
case cc.macro.KEY.left:
case Common.ANDROID_KEY.left:
this.keyDownDirection(Common.MOVE_DIRECTION_LEFT);
break;
case cc.macro.KEY.enter:
case cc.macro.KEY.space:
case Common.ANDROID_KEY.enter:
// this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
break;
case cc.macro.KEY.backspace:
case Common.ANDROID_KEY.back:
this._bIsFocusInit = true;
this.backAScene();
break;
}
},
// hideLoadingIcon: function () {
// cc.log("隐藏LoadingIcon...");
// cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).pause();
......
......@@ -24,23 +24,23 @@
"__id__": 6
},
{
"__id__": 40
"__id__": 41
}
],
"_active": true,
"_components": [
{
"__id__": 50
},
{
"__id__": 51
},
{
"__id__": 52
},
{
"__id__": 53
}
],
"_prefab": {
"__id__": 53
"__id__": 54
},
"_opacity": 255,
"_color": {
......@@ -120,7 +120,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 53.83,
"height": 50.4
"height": 37.8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -173,7 +173,7 @@
"_string": "Label",
"_N$string": "Label",
"_fontSize": 22,
"_lineHeight": 40,
"_lineHeight": 30,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
......@@ -199,7 +199,7 @@
"_alignFlags": 8,
"_left": 24,
"_right": 0,
"_top": 0,
"_top": 24.1,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
......@@ -242,11 +242,11 @@
"_active": false,
"_components": [
{
"__id__": 38
"__id__": 39
}
],
"_prefab": {
"__id__": 39
"__id__": 40
},
"_opacity": 255,
"_color": {
......@@ -326,7 +326,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 200,
"height": 34
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -378,8 +378,8 @@
"_useOriginalSize": false,
"_string": "脑力训练",
"_N$string": "脑力训练",
"_fontSize": 24,
"_lineHeight": 34,
"_fontSize": 22,
"_lineHeight": 30,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
......@@ -405,9 +405,9 @@
"__id__": 1
},
"_alignFlags": 9,
"_left": 26,
"_left": 24,
"_right": 0,
"_top": 17,
"_top": 15,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
......@@ -450,14 +450,14 @@
"_active": true,
"_components": [
{
"__id__": 35
"__id__": 36
},
{
"__id__": 36
"__id__": 37
}
],
"_prefab": {
"__id__": 37
"__id__": 38
},
"_opacity": 255,
"_color": {
......@@ -740,7 +740,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 69,
"height": 31.5
"height": 22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -792,8 +792,8 @@
"_useOriginalSize": false,
"_string": "载入中...",
"_N$string": "载入中...",
"_fontSize": 18,
"_lineHeight": 25,
"_fontSize": 16,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
......@@ -875,7 +875,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 69,
"height": 31.5
"height": 22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -927,8 +927,8 @@
"_useOriginalSize": false,
"_string": "载入中...",
"_N$string": "载入中...",
"_fontSize": 18,
"_lineHeight": 25,
"_fontSize": 16,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
......@@ -989,11 +989,11 @@
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": 26,
"_alignFlags": 12,
"_left": 24,
"_right": 0,
"_top": 56,
"_bottom": 0,
"_top": 51,
"_bottom": 15,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
......@@ -1074,14 +1074,14 @@
"_active": true,
"_components": [
{
"__id__": 32
"__id__": 33
},
{
"__id__": 33
"__id__": 34
}
],
"_prefab": {
"__id__": 34
"__id__": 35
},
"_opacity": 255,
"_color": {
......@@ -1142,10 +1142,13 @@
"_components": [
{
"__id__": 30
},
{
"__id__": 31
}
],
"_prefab": {
"__id__": 31
"__id__": 32
},
"_opacity": 255,
"_color": {
......@@ -1158,7 +1161,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 72,
"height": 31.5
"height": 22
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -1210,8 +1213,8 @@
"_useOriginalSize": false,
"_string": "游戏名称",
"_N$string": "游戏名称",
"_fontSize": 18,
"_lineHeight": 25,
"_fontSize": 16,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
......@@ -1225,6 +1228,33 @@
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 29
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
......@@ -1265,11 +1295,11 @@
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 9,
"_left": 26,
"_alignFlags": 12,
"_left": 24,
"_right": 0,
"_top": 56,
"_bottom": 0,
"_top": 51,
"_bottom": 15,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
......@@ -1409,16 +1439,16 @@
},
"_children": [
{
"__id__": 41
"__id__": 42
},
{
"__id__": 45
"__id__": 46
}
],
"_active": false,
"_components": [],
"_prefab": {
"__id__": 49
"__id__": 50
},
"_opacity": 255,
"_color": {
......@@ -1472,20 +1502,20 @@
"_name": "Title",
"_objFlags": 0,
"_parent": {
"__id__": 40
"__id__": 41
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 42
"__id__": 43
},
{
"__id__": 43
"__id__": 44
}
],
"_prefab": {
"__id__": 44
"__id__": 45
},
"_opacity": 255,
"_color": {
......@@ -1539,7 +1569,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 41
"__id__": 42
},
"_enabled": true,
"_materials": [
......@@ -1569,7 +1599,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 41
"__id__": 42
},
"_enabled": true,
"alignMode": 1,
......@@ -1607,20 +1637,20 @@
"_name": "Name",
"_objFlags": 0,
"_parent": {
"__id__": 40
"__id__": 41
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 46
"__id__": 47
},
{
"__id__": 47
"__id__": 48
}
],
"_prefab": {
"__id__": 48
"__id__": 49
},
"_opacity": 255,
"_color": {
......@@ -1674,7 +1704,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 45
"__id__": 46
},
"_enabled": true,
"_materials": [
......@@ -1704,7 +1734,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 45
"__id__": 46
},
"_enabled": true,
"alignMode": 1,
......@@ -1832,10 +1862,10 @@
"__id__": 30
},
"afterTitle": {
"__id__": 42
"__id__": 43
},
"afterName": {
"__id__": 46
"__id__": 47
},
"_id": ""
},
......