下载文件卡住安卓应用程序:工作灯
Downloading files stuck android application: worklight
我在工作灯上实现了一个应用程序,我需要从服务器下载文件,它在 Iphone5 上运行良好意味着文件下载流畅而不会卡住应用程序流.但是当我在我的三星 galaxy s2 (V 4.1) 上运行应用程序并使用 for 循环开始下载文件时,我的应用程序会卡住直到下载完成。 但是,当我只有一个文件要下载但计数为以上 3 或 4 个应用程序卡住。
if(networkInfo.networkConnectionType=='WIFI'){
$(brandClassDis).addClass('ui-disabled'); // Disabling the Brand.
$(".lms_loadernew").css("display", "block");
var syncProgBar = "#syncProgressBar"+result[0].json.BrandID;
var syncProgLabel = "#syncLoadingLabel"+result[0].json.BrandID;
$(syncProgBar).progressbar({
value: 0,
}).show();
$(syncProgLabel).text(parseInt(0, 10)+"%").show();
localStorage.setItem("download"+result[0].json.BrandID,0);
localStorage.setItem("downloadSucc"+result[0].json.BrandID,0);
for(var i=0; i<result.length; i++){
var obj = {VideoID:result[i].json.VideoID,BrandID:result[i].json.BrandID,CourseID:result[i].json.CourseID,LoadingStatus:"0"};
VideosList.add(obj,{push:false});
result[i].json.IsDownload = 2;
Videos.replace(result);
**downloadFolder(result[i],result.length)**
}
}
函数下载文件夹(结果,数字视频品牌){
try{
var loaderPer = 0;
var courseId ="#sync_"+result.json.CourseID.replace(/ /g,'');
var courseLabelId ="#loadingLabel"+result.json.CourseID.replace(/ /g,'');
var syncProgBar = "#syncProgressBar"+result.json.BrandID.replace(/ /g,'');
var syncProgLabel = "#syncLoadingLabel"+result.json.BrandID.replace(/ /g,'');
var serverLoc = encodeURI(result.json.DownloadName);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("LMS_APP", {create: true, exclusive: false}, function(directory){
var localPath = directory.fullPath+"/"+"Videos"+"/"+zipFileName;
var ft = new FileTransfer();
ft.download(serverLoc,localPath, function(entry) {
entry.file(function(file) {
WL.Logger.debug("File size: " + file.size);
if(file.size<=854){
downloadFail("",result,numVideoBrand);
entry.remove(successRemove, failRemove);
}else{
if(localStorage.getItem("download"+result.json.BrandID) == null || localStorage.getItem("download"+result.json.BrandID) =="" || localStorage.getItem("download"+result.json.BrandID) == undefined){
localStorage.setItem("download"+result.json.BrandID,1);
}else{
localStorage.setItem("download"+result.json.BrandID,(localStorage.getItem("download"+result.json.BrandID)-(-1)));
}
localStorage.setItem("downloadSucc"+result.json.BrandID,(localStorage.getItem("downloadSucc"+result.json.BrandID)-(-1)));
WL.Logger.debug("Folder is:---->"+directory.fullPath+"/"+zipFileName);
WL.Logger.debug("download"+localStorage.getItem("download"+result.json.BrandID)+"..."+numVideoBrand+"........"+ localStorage.getItem("downloadSucc"+result.json.BrandID));
var loadedVideoPer = (( localStorage.getItem("download"+result.json.BrandID)/numVideoBrand)* 100);
$(syncProgBar).progressbar({
value: loadedVideoPer,
});
$(syncProgLabel).text(parseInt(loadedVideoPer, 10)+"%");
$(courseId).hide();
$(courseLabelId).hide();
}
}, function(error){downloadFail(error,result,numVideoBrand);});
}, function(error) {
});
$(courseId).progressbar({
value: loaderPer,
}).show();
$(courseLabelId).text(parseInt(loaderPer, 10)+"%").show();
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
loaderPer = ((progressEvent.loaded / progressEvent.total)*100);
$(courseId).progressbar({
value: loaderPer,
});
$(courseLabelId).text(parseInt(loaderPer, 10)+"%");
//courseLabelId.text(parseInt(loaderPer, 10) + "%" );
loadingStatus(result);
}
};
},function(error){
downloadFail(error,result,numVideoBrand);
});
}, function(error){
downloadFail(error,result,numVideoBrand);
});
}catch(e){
WL.Logger.debug("exp in downloadFile: "+e);
//alert("exp "+videoLoader);
}
}
从评论中,解决方案是:
在队列中下载文件,因为一次下载所有文件会导致 应用程序卡住...
相关文章:
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- firefox插件:退出不工作的应用程序观察器
- 为什么Turbolinks不能正常工作?Rails应用程序
- 谷歌表单-根据分配给谷歌应用程序的工作为商业用户预先填充多项选择列表
- angular js应用程序不工作
- 应用程序在“关闭”之后停止工作(控制台中没有错误);咕哝的构造”;
- 只需添加一个'允许跨来源请求'到我的节点应用程序工作
- 我应该将哪些数据传递给 Spotify 应用程序才能使分页工作
- 如何修复网络中的屏幕大小为BB 10应用程序工作
- 下载文件卡住安卓应用程序:工作灯
- 超薄的开机自检呼叫无法从 Ionic 应用程序工作
- 为什么获胜'这不是我简单的Angular.js应用程序工作
- 我需要使网络应用程序作为窗口全屏应用程序工作.在IE-11(最后一个)为PC(WIN-7),全屏模式,用一个按钮关闭它
- 应用程序工作,但其中的第一个控制器出现故障
- REST请求从应用程序工作,但不是从javascript
- 试图获得一个示例Node.js应用程序工作
- 如何保持应用程序工作,即使模型未能加载烬
- IndexeDB不为chrome打包应用程序工作
- Rx.js和应用程序工作流
- AngularJs 项目不能作为单页 Web 应用程序工作