Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
sailfish-apps
Received
Commits
f5479223
Commit
f5479223
authored
Jul 06, 2017
by
kempe
Browse files
Refactoring: moved getCategories to RadioAPI
parent
bb6c544c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
30 deletions
+13
-30
qml/components/RadioAPI.qml
qml/components/RadioAPI.qml
+8
-0
qml/components/python/api.py
qml/components/python/api.py
+1
-1
qml/pages/BrowseByCategory.qml
qml/pages/BrowseByCategory.qml
+4
-29
No files found.
qml/components/RadioAPI.qml
View file @
f5479223
...
...
@@ -48,6 +48,14 @@ Python {
FavoritesUtils
.
addFavorite
(
stationData
)
});
}
function
getCategories
(
cat
,
callback
)
{
loading
=
true
;
call
(
'
api.radio.getCategories
'
,
[
cat
],
function
(
response
)
{
callback
(
response
);
loading
=
false
});
}
onError
:
{
console
.
log
(
'
python error:
'
+
traceback
);
...
...
qml/components/python/api.py
View file @
f5479223
...
...
@@ -45,7 +45,7 @@ class Radio_API:
params
=
{
"category"
:
"_{0}"
.
format
(
category
)}
pyotherside
.
send
(
'log'
,
"getCategories for: {}"
.
format
(
params
))
response
=
self
.
doRequest
(
categoriesURL
,
params
)
pyotherside
.
send
(
'updateCategories'
,
response
)
return
response
def
getStationsByCategory
(
self
,
category
,
value
):
params
=
{
"category"
:
"_{0}"
.
format
(
category
),
"value"
:
value
}
...
...
qml/pages/BrowseByCategory.qml
View file @
f5479223
...
...
@@ -11,7 +11,7 @@ Page {
SilicaListView
{
id
:
browseByListView
VerticalScrollDecorator
{
flickable
:
browseBy
Page
ListView
}
VerticalScrollDecorator
{
flickable
:
browseByListView
}
anchors.fill
:
parent
NavigationMenu
{
...
...
@@ -57,33 +57,6 @@ Page {
}
}
Python
{
id
:
python
Component.onCompleted
:
{
addImportPath
(
Qt
.
resolvedUrl
(
'
../components/python
'
));
setHandler
(
'
updateCategories
'
,
function
(
stations
)
{
window
.
loading
=
false
;
populateList
(
stations
)
});
importModule
(
'
api
'
,
function
()
{});
}
function
getCategories
(
cat
)
{
window
.
loading
=
true
;
call
(
'
api.radio.getCategories
'
,
[
cat
],
function
()
{});
}
onError
:
{
console
.
log
(
'
python error:
'
+
traceback
);
}
onReceived
:
{
console
.
log
(
'
got message from python
'
);
}
}
function
populateList
(
cats
)
{
console
.
log
(
"
Number of results:
"
,
cats
.
length
)
browseByModel
.
clear
()
...
...
@@ -94,6 +67,8 @@ Page {
}
Component.onCompleted
:
{
python
.
getCategories
(
category
.
toLowerCase
())
radioAPI
.
getCategories
(
category
.
toLocaleLowerCase
(),
function
(
cats
)
{
populateList
(
cats
)
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment