Пример #1
0
    def _update_view_playlists(self, playlist_id):
        """
            Update current view with playlist view
            @param playlist id as int
        """

        def load():
            sql = Lp.db.get_cursor()
            if playlist_id == Lp.player.get_user_playlist_id():
                tracks = [t.id for t in Lp.player.get_user_playlist()]
            elif playlist_id == Type.POPULARS:
                tracks = Lp.tracks.get_populars(sql)
            elif playlist_id == Type.RECENTS:
                tracks = Lp.tracks.get_recently_listened_to(sql)
            elif playlist_id == Type.NEVER:
                tracks = Lp.tracks.get_never_listened_to(sql)
            elif playlist_id == Type.RANDOMS:
                tracks = Lp.tracks.get_randoms(sql)
            else:
                tracks = Lp.playlists.get_tracks_id(name, sql)
            sql.close()
            return tracks

        view = None
        if playlist_id is not None:
            name = self._list_two.get_value(playlist_id)
            view = PlaylistView(playlist_id, name, self._stack)
        else:
            view = PlaylistsManageView(-1, None, False)
        if view:
            # Management or user playlist
            if playlist_id is None:
                view.populate()
            else:
                loader = Loader(target=load, view=view)
                loader.start()
            view.show()
            self._stack.add(view)
            self._stack.set_visible_child(view)
            self._stack.clean_old_views(view)
Пример #2
0
    def _update_view_playlists(self, playlist_id):
        """
            Update current view with playlist view
            @param playlist id as int
        """
        def load():
            sql = Lp.db.get_cursor()
            if playlist_id == Lp.player.get_user_playlist_id():
                tracks = [t.id for t in Lp.player.get_user_playlist()]
            elif playlist_id == Type.POPULARS:
                tracks = Lp.tracks.get_populars(sql)
            elif playlist_id == Type.RECENTS:
                tracks = Lp.tracks.get_recently_listened_to(sql)
            elif playlist_id == Type.NEVER:
                tracks = Lp.tracks.get_never_listened_to(sql)
            elif playlist_id == Type.RANDOMS:
                tracks = Lp.tracks.get_randoms(sql)
            sql.close()
            return tracks

        view = None
        if playlist_id is not None:
            name = self._list_two.get_value(playlist_id)
            view = PlaylistView(playlist_id, name, self._stack)
        else:
            view = PlaylistsManageView(-1, None, False,
                                       self._stack.get_allocated_width()/2)
        if view:
            # Management or user playlist
            if playlist_id is None or playlist_id >= 0 or\
                    playlist_id == Type.LOVED:
                view.populate()
            else:
                loader = Loader(target=load, view=view)
                loader.start()
            view.show()
            self._stack.add(view)
            self._stack.set_visible_child(view)
            self._stack.clean_old_views(view)
Пример #3
0
    def _update_view_playlists(self, playlist_id):
        """
            Update current view with playlist view
            @param playlist id as int
        """
        def load():
            if playlist_id == Lp().player.get_user_playlist_id():
                tracks = [t.id for t in Lp().player.get_user_playlist()]
            elif playlist_id == Type.POPULARS:
                tracks = Lp().tracks.get_populars()
            elif playlist_id == Type.RECENTS:
                tracks = Lp().tracks.get_recently_listened_to()
            elif playlist_id == Type.NEVER:
                tracks = Lp().tracks.get_never_listened_to()
            elif playlist_id == Type.RANDOMS:
                tracks = Lp().tracks.get_randoms()
            else:
                tracks = Lp().playlists.get_tracks_ids(playlist_id)
            return tracks

        view = None
        if playlist_id is not None:
            view = PlaylistView(playlist_id)
        else:
            view = PlaylistsManageView(Type.NONE, None, False)
        if view:
            # Management or user playlist
            if playlist_id is None:
                view.populate()
            else:
                loader = Loader(target=load, view=view)
                loader.start()
            view.show()
            self._stack.add(view)
            self._stack.set_visible_child(view)
            self._stack.clean_old_views(view)