extension fix
This commit is contained in:
parent
d0fd62abf2
commit
b4093b0c47
4 changed files with 34 additions and 8 deletions
|
@ -72,9 +72,9 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
|
|||
|
||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
LangSet.setLocale(this)
|
||||
ThemeManager(this).applyTheme()
|
||||
ThemeManager(this).applyTheme()
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityMediaBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
screenWidth = resources.displayMetrics.widthPixels.toFloat()
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package ani.dantotsu.media.anime
|
||||
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class AnimeNameAdapter {
|
||||
companion object {
|
||||
fun findSeasonNumber(text: String): Int? {
|
||||
val seasonRegex = "(season|s)[\\s:.\\-]*(\\d+)"
|
||||
val seasonPattern: Pattern = Pattern.compile(seasonRegex, Pattern.CASE_INSENSITIVE)
|
||||
val seasonMatcher: Matcher = seasonPattern.matcher(text)
|
||||
|
||||
return if (seasonMatcher.find()) {
|
||||
seasonMatcher.group(2)?.toInt()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import ani.dantotsu.currContext
|
|||
import ani.dantotsu.download.manga.MangaDownloaderService
|
||||
import ani.dantotsu.download.manga.ServiceDataSingleton
|
||||
import ani.dantotsu.logger
|
||||
import ani.dantotsu.media.anime.AnimeNameAdapter
|
||||
import ani.dantotsu.media.manga.ImageData
|
||||
import ani.dantotsu.media.manga.MangaCache
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
|
@ -115,12 +116,18 @@ class DynamicAnimeParser(extension: AnimeExtension.Installed) : AnimeParser() {
|
|||
it
|
||||
}
|
||||
} else {
|
||||
// Sort by the episode_number field
|
||||
res.sortedBy { it.episode_number }
|
||||
var episodeCounter = 1f
|
||||
// Group by season, sort within each season, and then renumber while keeping episode number 0 as is
|
||||
val seasonGroups = res.groupBy { AnimeNameAdapter.findSeasonNumber(it.name) ?: 0 }
|
||||
seasonGroups.keys.sorted().flatMap { season ->
|
||||
seasonGroups[season]?.sortedBy { it.episode_number }?.map { episode ->
|
||||
if (episode.episode_number != 0f) { // Skip renumbering for episode number 0
|
||||
episode.episode_number = episodeCounter++
|
||||
}
|
||||
episode
|
||||
} ?: emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
// Transform SEpisode objects to Episode objects
|
||||
|
||||
return sortedEpisodes.map { SEpisodeToEpisode(it) }
|
||||
} catch (e: Exception) {
|
||||
println("Exception: $e")
|
||||
|
|
|
@ -17,7 +17,6 @@ class ThemeManager(private val context: Context) {
|
|||
val options = DynamicColorsOptions.Builder()
|
||||
.setThemeOverlay(R.style.AppTheme_Amoled)
|
||||
.build()
|
||||
//need activity from context
|
||||
val activity = context as Activity
|
||||
DynamicColors.applyToActivityIfAvailable(activity, options)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue