-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogic of player.rtf
74 lines (73 loc) · 2.03 KB
/
logic of player.rtf
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
{\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww19860\viewh11660\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\f0\fs24 \cf0 // data assets\
1. request url, chapterid - > item in downQ\
2. chpaterid -> item in chapters\
1 and 2 are different sort order and count\
eventInChapters(chapter)->asset->eventIndownQ\
eventindownq->asset->inchapters\
\
onReceiveFromDownQ:chapterid\
index = chapters.findChapter(chapterid)\
progress = viewWithId(1000+index)\
\
onClickInChapters:chapterId\
\
\
static downQ; // in gs\
\
click on Download chapter // in cell\
\{\
downQ.append(chapterurl);\
downloadButton = cancelButton;\
playerView.startDownloadingIfNoActiveRequests()\
\}\
\
click on Cancel download chapter // in cell\
\{\
if(downloadInProgress)\
cancelRequestIfInProcess;\
downQ.remove(chapter);\
setButtonState(\uc0\u1079 \u1072 \u1082 \u1072 \u1095 \u1072 \u1090 \u1100 /\u1076 \u1086 \u1082 \u1072 \u1095 \u1072 \u1090 \u1100 )\
\}\
\
onNewRequest:\
\{\
if(downQ.exists(chapterToDown))\
downQ.moveToTop(chapterToDown)\
else\
downQ.insertFirst(chapterToDown)\
\
chapterController.activateProgressFor(currentChapter)\
\}\
\
onRequestFinished or Failed\
\{\
downQ.remove(finishedChapter);\
chapterController.hide(progressForTheFinishedChapter);\
download(downQ.next());\
\}\
\
cellForRowAtIndexPath:\
\{\
if(downFull)\
progress.hide();\
setButtonState(\uc0\u1087 \u1077 \u1088 \u1077 \u1079 \u1072 \u1075 \u1088 \u1091 \u1079 \u1080 \u1090 \u1100 \u1075 \u1083 \u1072 \u1074 \u1091 )\
else\
setProgress(val)\
setButtonState(\uc0\u1079 \u1072 \u1082 \u1072 \u1095 \u1072 \u1090 \u1100 /\u1076 \u1086 \u1082 \u1072 \u1095 \u1072 \u1090 \u1100 )\
\}\
\
onClickInChapterTable\
\{\
if(theresCurrentDownload)\
currentDownload.cancel()\
downQ.first() = newChapter; // previous downloading chapter becomes second in a queue\
startRequest(newChapter)\
\}\
\
\
}