Convert newpipe/util/KioskTranslator.java to kotlin
Cherry picked from #12947 / 4649e46d1ee4c691f2923c9b5c35c154c77b29a4
This commit is contained in:
parent
f6691a5a87
commit
6efc3afa48
2 changed files with 69 additions and 100 deletions
|
|
@ -1,100 +0,0 @@
|
||||||
package org.schabi.newpipe.util;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Christian Schabesberger on 28.09.17.
|
|
||||||
* KioskTranslator.java is part of NewPipe.
|
|
||||||
* <p>
|
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* NewPipe is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
|
|
||||||
public final class KioskTranslator {
|
|
||||||
private KioskTranslator() { }
|
|
||||||
|
|
||||||
public static String getTranslatedKioskName(final String kioskId, final Context c) {
|
|
||||||
switch (kioskId) {
|
|
||||||
case "Trending":
|
|
||||||
return c.getString(R.string.trending);
|
|
||||||
case "Top 50":
|
|
||||||
return c.getString(R.string.top_50);
|
|
||||||
case "New & hot":
|
|
||||||
return c.getString(R.string.new_and_hot);
|
|
||||||
case "Local":
|
|
||||||
return c.getString(R.string.local);
|
|
||||||
case "Recently added":
|
|
||||||
return c.getString(R.string.recently_added);
|
|
||||||
case "Most liked":
|
|
||||||
return c.getString(R.string.most_liked);
|
|
||||||
case "conferences":
|
|
||||||
return c.getString(R.string.conferences);
|
|
||||||
case "recent":
|
|
||||||
return c.getString(R.string.recent);
|
|
||||||
case "live":
|
|
||||||
return c.getString(R.string.duration_live);
|
|
||||||
case "Featured":
|
|
||||||
return c.getString(R.string.featured);
|
|
||||||
case "Radio":
|
|
||||||
return c.getString(R.string.radio);
|
|
||||||
case "trending_gaming":
|
|
||||||
return c.getString(R.string.trending_gaming);
|
|
||||||
case "trending_music":
|
|
||||||
return c.getString(R.string.trending_music);
|
|
||||||
case "trending_movies_and_shows":
|
|
||||||
return c.getString(R.string.trending_movies);
|
|
||||||
case "trending_podcasts_episodes":
|
|
||||||
return c.getString(R.string.trending_podcasts);
|
|
||||||
default:
|
|
||||||
return kioskId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getKioskIcon(final String kioskId) {
|
|
||||||
switch (kioskId) {
|
|
||||||
case "Trending":
|
|
||||||
case "Top 50":
|
|
||||||
case "New & hot":
|
|
||||||
case "conferences":
|
|
||||||
return R.drawable.ic_whatshot;
|
|
||||||
case "Local":
|
|
||||||
return R.drawable.ic_home;
|
|
||||||
case "Recently added":
|
|
||||||
case "recent":
|
|
||||||
return R.drawable.ic_add_circle_outline;
|
|
||||||
case "Most liked":
|
|
||||||
return R.drawable.ic_thumb_up;
|
|
||||||
case "live":
|
|
||||||
return R.drawable.ic_live_tv;
|
|
||||||
case "Featured":
|
|
||||||
return R.drawable.ic_stars;
|
|
||||||
case "Radio":
|
|
||||||
return R.drawable.ic_radio;
|
|
||||||
case "trending_gaming":
|
|
||||||
return R.drawable.ic_videogame_asset;
|
|
||||||
case "trending_music":
|
|
||||||
return R.drawable.ic_music_note;
|
|
||||||
case "trending_movies_and_shows":
|
|
||||||
return R.drawable.ic_movie;
|
|
||||||
case "trending_podcasts_episodes":
|
|
||||||
return R.drawable.ic_podcasts;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
69
app/src/main/java/org/schabi/newpipe/util/KioskTranslator.kt
Normal file
69
app/src/main/java/org/schabi/newpipe/util/KioskTranslator.kt
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.schabi.newpipe.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import org.schabi.newpipe.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Christian Schabesberger on 28.09.17.
|
||||||
|
* KioskTranslator.java is part of NewPipe.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NewPipe is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with NewPipe. If not, see <http:></http:>//www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
object KioskTranslator {
|
||||||
|
@JvmStatic
|
||||||
|
fun getTranslatedKioskName(kioskId: String, c: Context): String {
|
||||||
|
return when (kioskId) {
|
||||||
|
"Trending" -> c.getString(R.string.trending)
|
||||||
|
"Top 50" -> c.getString(R.string.top_50)
|
||||||
|
"New & hot" -> c.getString(R.string.new_and_hot)
|
||||||
|
"Local" -> c.getString(R.string.local)
|
||||||
|
"Recently added" -> c.getString(R.string.recently_added)
|
||||||
|
"Most liked" -> c.getString(R.string.most_liked)
|
||||||
|
"conferences" -> c.getString(R.string.conferences)
|
||||||
|
"recent" -> c.getString(R.string.recent)
|
||||||
|
"live" -> c.getString(R.string.duration_live)
|
||||||
|
"Featured" -> c.getString(R.string.featured)
|
||||||
|
"Radio" -> c.getString(R.string.radio)
|
||||||
|
"trending_gaming" -> c.getString(R.string.trending_gaming)
|
||||||
|
"trending_music" -> c.getString(R.string.trending_music)
|
||||||
|
"trending_movies_and_shows" -> c.getString(R.string.trending_movies)
|
||||||
|
"trending_podcasts_episodes" -> c.getString(R.string.trending_podcasts)
|
||||||
|
else -> kioskId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getKioskIcon(kioskId: String): Int {
|
||||||
|
return when (kioskId) {
|
||||||
|
"Trending", "Top 50", "New & hot", "conferences" -> R.drawable.ic_whatshot
|
||||||
|
"Local" -> R.drawable.ic_home
|
||||||
|
"Recently added", "recent" -> R.drawable.ic_add_circle_outline
|
||||||
|
"Most liked" -> R.drawable.ic_thumb_up
|
||||||
|
"live" -> R.drawable.ic_live_tv
|
||||||
|
"Featured" -> R.drawable.ic_stars
|
||||||
|
"Radio" -> R.drawable.ic_radio
|
||||||
|
"trending_gaming" -> R.drawable.ic_videogame_asset
|
||||||
|
"trending_music" -> R.drawable.ic_music_note
|
||||||
|
"trending_movies_and_shows" -> R.drawable.ic_movie
|
||||||
|
"trending_podcasts_episodes" -> R.drawable.ic_podcasts
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue