Code refactor

This commit is contained in:
Hemanth S 2020-05-22 16:21:08 +05:30
parent 2634c11896
commit df225e179f
3 changed files with 31 additions and 37 deletions

View file

@ -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

View file

@ -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)
}
}

View file

@ -304,9 +304,11 @@ public class MusicUtil {
@NonNull @NonNull
public static String getSectionName(@Nullable String musicMediaTitle) { public static String getSectionName(@Nullable String musicMediaTitle) {
try {
if (TextUtils.isEmpty(musicMediaTitle)) { if (TextUtils.isEmpty(musicMediaTitle)) {
return ""; return "";
} }
musicMediaTitle = musicMediaTitle.trim().toLowerCase(); musicMediaTitle = musicMediaTitle.trim().toLowerCase();
if (musicMediaTitle.startsWith("the ")) { if (musicMediaTitle.startsWith("the ")) {
musicMediaTitle = musicMediaTitle.substring(4); musicMediaTitle = musicMediaTitle.substring(4);
@ -317,6 +319,9 @@ public class MusicUtil {
return ""; return "";
} }
return musicMediaTitle.substring(0, 1).toUpperCase(); return musicMediaTitle.substring(0, 1).toUpperCase();
} catch (Exception e) {
return "";
}
} }
@NonNull @NonNull