Code refactor
This commit is contained in:
parent
2634c11896
commit
df225e179f
3 changed files with 31 additions and 37 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019 Google LLC
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
package code.name.monkey.retromusic.adapter
|
package code.name.monkey.retromusic.adapter
|
||||||
|
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package code.name.monkey.retromusic.data
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.model.Contributor
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import retrofit2.Retrofit
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
|
||||||
import retrofit2.http.GET
|
|
||||||
|
|
||||||
private const val BASE_URL = "https://github.com/h4h13/RetroMusicPlayer/blob/dev/data/"
|
|
||||||
|
|
||||||
interface RetroDataService {
|
|
||||||
|
|
||||||
@GET("translators.json")
|
|
||||||
suspend fun getContributors(): List<Contributor>
|
|
||||||
|
|
||||||
@GET("translators.json")
|
|
||||||
suspend fun getTranslators(): List<Contributor>
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val retoService: RetroDataService = Retrofit.Builder()
|
|
||||||
.baseUrl(BASE_URL)
|
|
||||||
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create()))
|
|
||||||
.build()
|
|
||||||
.create(RetroDataService::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -304,19 +304,24 @@ public class MusicUtil {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static String getSectionName(@Nullable String musicMediaTitle) {
|
public static String getSectionName(@Nullable String musicMediaTitle) {
|
||||||
if (TextUtils.isEmpty(musicMediaTitle)) {
|
try {
|
||||||
|
if (TextUtils.isEmpty(musicMediaTitle)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
musicMediaTitle = musicMediaTitle.trim().toLowerCase();
|
||||||
|
if (musicMediaTitle.startsWith("the ")) {
|
||||||
|
musicMediaTitle = musicMediaTitle.substring(4);
|
||||||
|
} else if (musicMediaTitle.startsWith("a ")) {
|
||||||
|
musicMediaTitle = musicMediaTitle.substring(2);
|
||||||
|
}
|
||||||
|
if (musicMediaTitle.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return musicMediaTitle.substring(0, 1).toUpperCase();
|
||||||
|
} catch (Exception e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
musicMediaTitle = musicMediaTitle.trim().toLowerCase();
|
|
||||||
if (musicMediaTitle.startsWith("the ")) {
|
|
||||||
musicMediaTitle = musicMediaTitle.substring(4);
|
|
||||||
} else if (musicMediaTitle.startsWith("a ")) {
|
|
||||||
musicMediaTitle = musicMediaTitle.substring(2);
|
|
||||||
}
|
|
||||||
if (musicMediaTitle.isEmpty()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return musicMediaTitle.substring(0, 1).toUpperCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
Loading…
Reference in a new issue