bugfix
This commit is contained in:
parent
ddc20bedac
commit
a965743913
@ -320,7 +320,7 @@ class Blocks(EventDispatcher):
|
||||
return self.methodAction(widget, desc)
|
||||
alert("actiontype(%s) invalid" % acttype,title='error')
|
||||
|
||||
def blocksAction(widget,desc):
|
||||
def blocksAction(self,widget,desc):
|
||||
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
||||
add_mode = desc.get('mode','replace')
|
||||
opts = desc.get('options')
|
||||
|
@ -45,17 +45,22 @@ class BoxViewer(BoxLayout):
|
||||
self.dataloader.bind(on_deletepage=self.deleteWidgets)
|
||||
self.dataloader.bind(on_pageloaded=self.addPageWidgets)
|
||||
self.dataloader.bind(on_newbegin=self.deleteAllWidgets)
|
||||
self.params = self.options['dataloader']['options'].get('params',{})
|
||||
|
||||
if self.toolbar:
|
||||
self.add_widget(self.toolbar)
|
||||
if self.dataloader.widget:
|
||||
self.add_widget(self.dataloader.widget)
|
||||
self.dataloader.bind(on_submit=self.getParams)
|
||||
self.add_widget(self.viewContainer)
|
||||
self.register_event_type('on_selected')
|
||||
self.viewContainer.bind(size=self.resetCols,
|
||||
pos=self.resetCols)
|
||||
self.viewContainer.bind(on_scroll_stop=self.on_scroll_stop)
|
||||
|
||||
def getParams(self,o,p):
|
||||
self.params = p
|
||||
|
||||
def deleteAllWidgets(self,o):
|
||||
self.viewContainer.clear_widgets()
|
||||
|
||||
@ -129,8 +134,20 @@ class BoxViewer(BoxLayout):
|
||||
|
||||
def select_record(self,o,v=None):
|
||||
self.selected_data = o.getRecord()
|
||||
self.dispatch('on_selected',o.getRecord())
|
||||
d = {
|
||||
"page_rows":1,
|
||||
"page":self.selected_data['__posInSet__'],
|
||||
"dataurl":self.options['dataloader']['options']['dataurl'],
|
||||
"params":self.params
|
||||
}
|
||||
self.dispatch('on_selected',d)
|
||||
|
||||
def getData(self):
|
||||
self.selected_data['__dataloader__'] = self.dataloader
|
||||
return self.selected_data
|
||||
d = {
|
||||
"caller":self,
|
||||
"page_rows":1,
|
||||
"page":self.selected_data['__posInSet__'],
|
||||
"dataurl":self.options['dataloader']['options']['dataurl'],
|
||||
"params":self.params
|
||||
}
|
||||
return d
|
||||
|
@ -55,8 +55,13 @@ class PageLoader(EventDispatcher):
|
||||
self.dir = 'down'
|
||||
self.register_event_type('on_newbegin')
|
||||
self.register_event_type('on_pageloaded')
|
||||
self.newbegin = True
|
||||
|
||||
def getLocater(self):
|
||||
if self.newbegin:
|
||||
self.newbegin = False
|
||||
return 1
|
||||
|
||||
x = 1 / self.MaxbufferPage
|
||||
if self.dir != 'down':
|
||||
x = 1 - x
|
||||
@ -78,6 +83,7 @@ class PageLoader(EventDispatcher):
|
||||
|
||||
def do_search(self,o,params):
|
||||
print('PageLoader().do_search(), on_submit handle....',params)
|
||||
self.newbegin = True
|
||||
self.dispatch('on_newbegin')
|
||||
self.params.update(params)
|
||||
self.loadPage(1)
|
||||
@ -118,6 +124,18 @@ class PageLoader(EventDispatcher):
|
||||
traceback.print_exc()
|
||||
alert(str(e),title='alert')
|
||||
|
||||
def loadNextPage(self):
|
||||
if self.total_page > 0 and self.curpage >=self.total_page:
|
||||
return
|
||||
p = self.curpage + 1
|
||||
self.loadPage(p)
|
||||
|
||||
def loadPreviousPage(self):
|
||||
if self.curpage <= 1:
|
||||
return
|
||||
p = self.curpage - 1
|
||||
self.loadPage(p)
|
||||
|
||||
def loadPage(self,p):
|
||||
if not self.url:
|
||||
raise Exception('dataurl must be present:options=%s' % str(options))
|
||||
|
@ -1,9 +1,9 @@
|
||||
import time
|
||||
from kivy.logger import Logger
|
||||
from kivy.event import EventDispatcher
|
||||
|
||||
class SwipeBehavior(EventDispatcher):
|
||||
class SwipeBehavior(object):
|
||||
def __init__(self, **kwargs):
|
||||
object.__init__(self)
|
||||
self.register_event_type('on_context_menu')
|
||||
self.register_event_type('on_swipe_left')
|
||||
self.register_event_type('on_swipe_right')
|
||||
@ -15,42 +15,43 @@ class SwipeBehavior(EventDispatcher):
|
||||
self.sb_end_time = None
|
||||
self.threshold=20
|
||||
self.threshold_time = 1.5
|
||||
self.bind(on_touch_down=self.on_touchdown)
|
||||
self.bind(on_touch_move=self.on_touchmove)
|
||||
self.bind(on_touch_up=self.on_touchup)
|
||||
|
||||
def on_context_menu(self):
|
||||
Logger.info('SwipeBehavior:on_context_menu fired')
|
||||
|
||||
def on_swipe_left(self):
|
||||
Logger.info('SwipeBehavior:on_swipe_left fired')
|
||||
pass
|
||||
|
||||
def on_swipe_right(self):
|
||||
Logger.info('SwipeBehavior:on_swipe_right fired')
|
||||
pass
|
||||
|
||||
def on_swipe_up(self):
|
||||
Logger.info('SwipeBehavior:on_swipe_up fired')
|
||||
pass
|
||||
|
||||
def on_swipe_down(self):
|
||||
Logger.info('SwipeBehavior:on_swipe_down fired')
|
||||
pass
|
||||
|
||||
def on_touch_down(self,touch):
|
||||
def on_touchdown(self,o,touch):
|
||||
Logger.info('SwipeBehavior:touch_down fired')
|
||||
if self.collide_point(*touch.pos):
|
||||
self.sb_start_point = pos
|
||||
Logger.info('SwipeBehavior:touch_down fired')
|
||||
self.sb_start_point = touch.pos
|
||||
self.sb_start_time = time.time()
|
||||
return super().on_touch_down(touch)
|
||||
|
||||
def on_touch_move(self,touch):
|
||||
def on_touchmove(self,o,touch):
|
||||
if self.collide_point(*touch.pos):
|
||||
Logger.info('SwipeBehavior:touch_move fired')
|
||||
if self.sb_start_point is None:
|
||||
self.sb_start_point = touch.pos
|
||||
else:
|
||||
self.sb_end_point = touch.pos
|
||||
return super().on_touch_move()
|
||||
|
||||
def on_touch_up(self,touch):
|
||||
def on_touchup(self,o,touch):
|
||||
if self.collide_point(*touch.pos):
|
||||
Logger.info('SwipeBehavior:touch_up fired')
|
||||
self.sb_end_point = touch.pos
|
||||
self.sb_end_time = time.time()
|
||||
self.check_context_menu()
|
||||
@ -59,7 +60,6 @@ class SwipeBehavior(EventDispatcher):
|
||||
self.sb_end_point = None
|
||||
self.sb_start_time = None
|
||||
self.sb_end_time = None
|
||||
super().on_touch_up()
|
||||
|
||||
def check_context_menu(self):
|
||||
if not self.sb_start_time:
|
||||
@ -70,14 +70,20 @@ class SwipeBehavior(EventDispatcher):
|
||||
self.dispatch('on_context_menu')
|
||||
|
||||
def check_swipe(self):
|
||||
if abs(self.sb_end_point.x - self.sb_start_point.x) > \
|
||||
abs(self.sb_end_point.y - self.sb_start_point.y):
|
||||
if self.sb_end_point.x - self.sb_start_point.x > self.threshold:
|
||||
if abs(self.sb_end_point[0] - self.sb_start_point[0]) > \
|
||||
abs(self.sb_end_point[1] - self.sb_start_point[1]):
|
||||
Logger.info('SwipeBehavior:check_swipe x>y')
|
||||
if self.sb_end_point[0] - self.sb_start_point[0] >= \
|
||||
self.threshold:
|
||||
self.dispatch('on_swipe_right')
|
||||
elif self.sb_start_point.x - self.sb_end_point.x > self.threshold:
|
||||
elif self.sb_start_point[0] - self.sb_end_point[0] >= \
|
||||
self.threshold:
|
||||
self.dispatch('on_swipe_left')
|
||||
else:
|
||||
if self.sb_end_point.y - self.sb_start_point.y > self.threshold:
|
||||
Logger.info('SwipeBehavior:check_swipe x<y')
|
||||
if self.sb_end_point[1] - self.sb_start_point[1] >= \
|
||||
self.threshold:
|
||||
self.dispatch('on_swipe_up')
|
||||
elif self.sb_start_point.y - self.sb_end_point.x > self.threshold:
|
||||
elif self.sb_start_point[1] - self.sb_end_point[1] >= \
|
||||
self.threshold:
|
||||
self.dispatch('on_swipe_down')
|
||||
|
@ -38,16 +38,6 @@ logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
|
||||
|
||||
othersplatforms=['ios','android']
|
||||
|
||||
class UrlPlayList(PageLoader):
|
||||
def __init__(self, player, **options):
|
||||
self.player = player
|
||||
PageLoader.__init__(self,**options)
|
||||
|
||||
def show_page(self,o,d):
|
||||
super().show_page(o,d)
|
||||
id = d['rows'][0].id
|
||||
self.player.play(id)
|
||||
|
||||
class BaseVPlayer(FloatLayout, SwipeBehavior):
|
||||
fullscreen = BooleanProperty(False)
|
||||
def __init__(self,vfile=None,playlist=[]):
|
||||
@ -67,23 +57,13 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
|
||||
self.old_volume = 0
|
||||
self._video.bind(eos=self.next)
|
||||
self._video.bind(state=self.on_state)
|
||||
self.bind(on_swipe_down=self.previous)
|
||||
self.bind( on_swipe_up=self.next)
|
||||
set_log_callback(self.ffplayerLog)
|
||||
self.play()
|
||||
if hasattr(self._video._video, '_ffplayer'):
|
||||
self.ffplayer = self._video._video._ffplayer
|
||||
|
||||
def on_swipe_down(self):
|
||||
self.stop()
|
||||
self.dispatch('on_next')
|
||||
|
||||
on_swipe_right = on_swipe_down
|
||||
|
||||
def on_swipe_up(self):
|
||||
self.stop()
|
||||
self.dispatch('on_previous')
|
||||
|
||||
on_swipe_left = on_swipe_up
|
||||
|
||||
def setSource(self,s):
|
||||
self.stop()
|
||||
self.curplay = 0
|
||||
@ -213,7 +193,8 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
|
||||
self._video.volume = self.old_volume
|
||||
|
||||
def stop(self):
|
||||
self._video.state = 'stop'
|
||||
self._video.state = 'pause'
|
||||
# self._video.state = 'stop'
|
||||
|
||||
def pause(self,t=None):
|
||||
if self._video.state == 'play':
|
||||
@ -222,7 +203,7 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
|
||||
self._video.state = 'play'
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
self.stop()
|
||||
|
||||
class OSCController:
|
||||
def __init__(self,ip,port,vfile=None):
|
||||
@ -330,7 +311,7 @@ class VPlayer(BaseVPlayer):
|
||||
super().stop()
|
||||
|
||||
def __del__(self):
|
||||
self.beforeDestroy()
|
||||
self.stop()
|
||||
|
||||
def beforeDestroy(self):
|
||||
print('beforeDestroy() called')
|
||||
|
Loading…
Reference in New Issue
Block a user