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