Skip to content

Commit 9b14638

Browse files
MiaMia
authored andcommitted
🐛 Resolve Conflict between collabortaive and public
1 parent 4b88800 commit 9b14638

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

app/src/main/java/com/smojify/smojify/EmojiUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ protected void onPostExecute(String emojiName) {
6060
listener.onEmojiNameFetched(emojiName);
6161
}
6262
};
63-
6463
task.execute(urlString);
6564
return emojiSlugName;
6665
}

app/src/main/java/com/smojify/smojify/SpotifyUtil.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,16 @@ public void createPlaylist(String webToken, String playlistName, Bitmap cover, b
186186
byte[] byteArr = stream.toByteArray();
187187
String base64Cover = Base64.encodeToString(byteArr, Base64.NO_WRAP);
188188
base64Cover = base64Cover.trim().replace("\n", "");
189-
189+
String bodyContent;
190+
if (isCollaborative) {
191+
if (isPublic) {
192+
Log.w("Spotify API", "Collaborative playlists can only be private.");
193+
}
194+
bodyContent = "{\n\"name\":\"" + playlistName + "\",\n\"public\":" + false + ",\n\"collaborative\":" + true + "\n}";
195+
} else {
196+
bodyContent = "{\n\"name\":\"" + playlistName + "\",\n\"public\":" + isPublic + ",\n\"collaborative\":" + false + "\n}";
197+
}
190198
MediaType mediaType = MediaType.parse("application/json");
191-
String bodyContent = "{\n\"name\":\"" + playlistName + "\",\n\"public\":" + isPublic + ",\n\"collaborative\":" + isCollaborative + "\n}";
192199
RequestBody body = RequestBody.create(mediaType, bodyContent);
193200
Log.e("SpotifyUtil", "Creating Playlist: " + bodyContent);
194201
Request request = new Request.Builder()
@@ -219,6 +226,7 @@ public void createPlaylist(String webToken, String playlistName, Bitmap cover, b
219226
// Extract the playlist ID from the response
220227
String responseBody = response.body().string();
221228
JSONObject jsonResponse = new JSONObject(responseBody);
229+
Log.w("SpotifyUtil", jsonResponse.toString());
222230
String playlistUri = jsonResponse.getString("uri");
223231
String playlistId = playlistUri.split(":")[2];
224232

0 commit comments

Comments
 (0)