Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
soulfood
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charley.punshon
soulfood
Commits
633d7922
Commit
633d7922
authored
May 16, 2019
by
jake.ejraee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge remote-tracking branch 'origin/master'"
This reverts commit
f05f316a
parent
f05f316a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
39 deletions
+20
-39
databaseInterface.java
...a/com/example/soulfood_assignment2/databaseInterface.java
+20
-39
No files found.
app/src/main/java/com/example/soulfood_assignment2/databaseInterface.java
View file @
633d7922
...
...
@@ -32,7 +32,7 @@ public class databaseInterface {
chill
,
happy
,
energetic
,
calming
,
busy
,
any
}
public
enum
Time
{
...
...
@@ -100,40 +100,6 @@ public class databaseInterface {
return
ids
;
}
/*
* takes in an array list of spotify ids and a title for the playlist
* makes a new playlist in the database
* adds the songs to the playlist
* returns true if the playlist was made correctly
* returns false if something went wrong
*/
public
Boolean
savePlaylist
(
String
title
,
ArrayList
<
String
>
spotifyIDs
){
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"title"
,
title
);
String
url
=
"https://cs2s.yorkdc.net/~jade.woodward/mobile-app-development/newPlaylist.php"
;
String
playlistid
=
getFromDatabase
(
url
,
params
);
String
url2
=
"https://cs2s.yorkdc.net/~jade.woodward/mobile-app-development/getsongbyspotify.php"
;
String
url3
=
"https://cs2s.yorkdc.net/~jade.woodward/mobile-app-development/addplaylistsongbyids.php"
;
for
(
String
s:
spotifyIDs
)
{
HashMap
<
String
,
String
>
param2
=
new
HashMap
<>();
param2
.
put
(
"id"
,
s
);
String
id
=
getFromDatabase
(
url2
,
param2
);
HashMap
<
String
,
String
>
param3
=
new
HashMap
<>();
param3
.
put
(
"song"
,
id
);
param3
.
put
(
"playlist"
,
playlistid
);
if
(!
getFromDatabase
(
url3
,
param3
).
equals
(
"added a song to playlist"
)){
return
false
;
}
}
return
true
;
}
/*
* one string input - should still be in 123 format though
* gets a list of song ids from the database
...
...
@@ -165,17 +131,21 @@ public class databaseInterface {
i
++;
}
String
spotify
=
"failed to
connect to
database"
;
String
spotify
=
"failed to
fetch from
database"
;
try
{
String
url
=
"https://cs2s.yorkdc.net/~jade.woodward/mobile-app-development/getplaylistbyid.php"
;
URL
urlObj
=
new
URL
(
url
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
urlObj
.
openConnection
();
conn
.
setDoOutput
(
true
);
conn
.
setRequestMethod
(
"POST"
);
conn
.
setRequestProperty
(
"Accept-Charset"
,
"UTF-8"
);
conn
.
setReadTimeout
(
10000
);
conn
.
setConnectTimeout
(
15000
);
conn
.
connect
();
String
paramsString
=
sbParams
.
toString
();
...
...
@@ -213,10 +183,20 @@ public class databaseInterface {
return
spotify
;
}
public
ArrayList
<
String
>
getPlaylistByID
(
String
id
)
{
String
songids
=
getPlaylistSongIDsByID
(
id
);
ArrayList
<
String
>
ids
=
parseOutSpaces
(
songids
);
ArrayList
<
String
>
spotifys
=
new
ArrayList
<>();
for
(
String
indv:
ids
)
{
String
spotty
=
getSongByID
(
indv
);
spotifys
.
add
(
spotty
);
}
return
spotifys
;
}
/*
* splits a string into words by splitting at spaces.
*/
private
ArrayList
<
String
>
parseOutSpaces
(
String
original
)
{
ArrayList
<
String
>
results
=
new
ArrayList
<>();
...
...
@@ -226,4 +206,5 @@ public class databaseInterface {
return
results
;
}
}
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