faster loading of movie list (done by initially not loading the file length and updat...
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 3 Apr 2006 08:12:07 +0000 (08:12 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 3 Apr 2006 08:12:07 +0000 (08:12 +0000)
(timer driven))

lib/python/Components/MovieList.py
lib/python/Screens/MovieSelection.py

index a921b8d..681dec2 100644 (file)
@@ -13,7 +13,7 @@ from enigma import eServiceReference, eServiceCenter, \
 #
 # | name of movie              |
 #
-def MovieListEntry(serviceref, serviceHandler):
+def MovieListEntry(serviceref, serviceHandler, withLength = False):
        if serviceref.flags & eServiceReference.mustDescent:
                return None
 
@@ -23,7 +23,10 @@ def MovieListEntry(serviceref, serviceHandler):
                # ignore service which refuse to info
                return None
        
-       len = info.getLength(serviceref)
+       if withLength:
+               len = info.getLength(serviceref)
+       else:
+               len = 0
        if len > 0:
                len = "%d:%02d" % (len / 60, len % 60)
        else:
@@ -91,6 +94,14 @@ class MovieList(HTMLComponent, GUIComponent):
                                self.list.remove(l)
                self.l.setList(self.list)
 
+       def __len__(self):
+               return len(self.list)
+
+       def updateLengthOfIndex(self, index):
+               serviceHandler = eServiceCenter.getInstance()
+               self.list[index] = MovieListEntry(self.list[index][0][0], serviceHandler, True)
+               self.l.invalidateEntry(index)
+
        def load(self, root):
                # this lists our root service, then building a 
                # nice list
index 17da5ff..91620ea 100644 (file)
@@ -77,6 +77,7 @@ class MovieSelection(Screen):
                self["waitingtext"] = Label(_("Please wait... Loading list..."))
                
                self["list"] = MovieList(None)
+               self.list = self["list"]
                self.selectedmovie = selectedmovie
                
                #self["okbutton"] = Button("ok", [self.channelSelected])
@@ -91,6 +92,9 @@ class MovieSelection(Screen):
                self["actions"].csel = self
                self.onShown.append(self.go)
                
+               self.lengthTimer = eTimer()
+               self.lengthTimer.timeout.get().append(self.updateLengthData)
+               
        def go(self):
                # ouch. this should redraw our "Please wait..."-text.
                # this is of course not the right way to do this.
@@ -103,6 +107,16 @@ class MovieSelection(Screen):
                self["waitingtext"].instance.hide()
                                                
                self["freeDiskSpace"].update()
+               
+               self.lengthTimer.start(10, 1)
+               self.lengthPosition = 0
+               self.lengthLength = len(self["list"])
+               
+       def updateLengthData(self):
+               self.list.updateLengthOfIndex(self.lengthPosition)
+               self.lengthPosition += 1
+               if self.lengthPosition < self.lengthLength:
+                       self.lengthTimer.start(10, 1)
 
        def moveTo(self):
                self["list"].moveTo(self.selectedmovie)