Пример #1
0
    def on_start(self):
        Logger.debug("%s: on_start %s" % (APP, datetime.now()))

        from kivy.core.window import Window
        Window.bind(on_keyboard=self.on_keypress)

        if platform == 'android':
            android.map_key(android.KEYCODE_BACK, 1001)

            import android.activity as python_activity
            python_activity.bind(on_new_intent=self.on_new_intent)
            self.on_new_intent(activity.getIntent())

        self.server_url = self.config.get('general', 'server_url')

        self.root.bind(
            on_touch_down=lambda *a: setattr(self, 'delay_image_loading', True
                                             ),
            on_touch_up=lambda *a: setattr(self, 'delay_image_loading', False))

        imagedir = ImageDir(server_url=self.server_url)
        wp = 'with_previous'
        imagedir.bind(
            on_navigate_top=lambda *a: setattr(self.root, wp, False),
            on_navigate_down=lambda *a: setattr(self.root, wp, True),
            on_img_selected=self.load_carousel,
            path=lambda w, v: setattr(self.root, 'title', v),
            on_loading_start=lambda *a: setattr(self.root, 'loading', True),
            on_loading_stop=lambda *a: setattr(self.root, 'loading', False))
        self.imagedir = imagedir

        self.root.container.add_widget(imagedir)
        self.root.bind(on_touch_down=lambda *a: Loader.pause(),
                       on_touch_up=lambda *a: Loader.resume())
        Loader.max_upload_per_frame = 1  # Maximize interactivity
Пример #2
0
    def on_start(self):
        Logger.debug("%s: on_start %s" % (APP, datetime.now()))

        from kivy.core.window import Window
        Window.bind(on_keyboard=self.on_keypress)

        if platform == 'android':
            android.map_key(android.KEYCODE_BACK, 1001)

            import android.activity as python_activity
            python_activity.bind(on_new_intent=self.on_new_intent)
            self.on_new_intent(activity.getIntent())

        self.server_url = self.config.get('general', 'server_url')

        self.root.bind(
            on_touch_down=lambda *a: setattr(self, 'delay_image_loading', True),
            on_touch_up=lambda *a: setattr(self, 'delay_image_loading', False))

        imagedir = ImageDir(server_url=self.server_url)
        wp = 'with_previous'
        imagedir.bind(
            on_navigate_top=lambda *a: setattr(self.root, wp, False),
            on_navigate_down=lambda *a: setattr(self.root, wp, True),
            on_img_selected=self.load_carousel,
            path=lambda w,v: setattr(self.root, 'title', v),
            on_loading_start=lambda *a: setattr(self.root, 'loading', True),
            on_loading_stop=lambda *a: setattr(self.root, 'loading', False))
        self.imagedir = imagedir

        self.root.container.add_widget(imagedir)
        self.root.bind(on_touch_down=lambda *a: Loader.pause(),
                       on_touch_up=lambda *a: Loader.resume())
        Loader.max_upload_per_frame = 1  # Maximize interactivity
Пример #3
0
    def update(self, obj, value, delay=UPDATE_DELAY):
        """
        To prevent overuse of update_map, each change of position triggers an update of the map after UPDATE_DELAY sec.
        For instance, the position of the reticule has to be updated.
        """
        if self.map is None:
            return

        # Pause the Loader, to prevent ui blocking
        Loader.pause()

        # Reposition widgets that need to be repositioned
        self.reposition_executor.execute()

        # Trigger the map update
        if self.idle:
            self.idle = False
        else:
            Clock.unschedule(self.update_map)
        Clock.schedule_once(self.update_map, delay)

        # Resume the Loader after a short time
        Clock.schedule_once(MapViewer.resume_loading, 0.1)