MangaMutiny: chapter number in chapter name improvement (#6343)
- small change to make chapter numbers in chapter names lose trailing .0 - don't recreate the SimpleDateFormatter for every parsed chapter. Declaring and initializing it once is enough.
This commit is contained in:
		
							parent
							
								
									3c106cfb35
								
							
						
					
					
						commit
						d9b0633efd
					
				| @ -5,7 +5,7 @@ ext { | |||||||
|     extName = 'Manga Mutiny' |     extName = 'Manga Mutiny' | ||||||
|     pkgNameSuffix = "en.mangamutiny" |     pkgNameSuffix = "en.mangamutiny" | ||||||
|     extClass = '.MangaMutiny' |     extClass = '.MangaMutiny' | ||||||
|     extVersionCode = 6 |     extVersionCode = 7 | ||||||
|     libVersion = '1.2' |     libVersion = '1.2' | ||||||
|     containsNsfw = true |     containsNsfw = true | ||||||
| } | } | ||||||
|  | |||||||
| @ -33,6 +33,11 @@ fun JsonObject.getNullable(key: String): JsonElement? { | |||||||
|     return value |     return value | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | fun Float.toStringWithoutDotZero(): String = when (this % 1) { | ||||||
|  |     0F -> this.toInt().toString() | ||||||
|  |     else -> this.toString() | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class MangaMutiny : HttpSource() { | class MangaMutiny : HttpSource() { | ||||||
| 
 | 
 | ||||||
|     override val name = "Manga Mutiny" |     override val name = "Manga Mutiny" | ||||||
| @ -109,7 +114,7 @@ class MangaMutiny : HttpSource() { | |||||||
|     private fun chapterTitleBuilder(rootNode: JsonObject): String { |     private fun chapterTitleBuilder(rootNode: JsonObject): String { | ||||||
|         val volume = rootNode.getNullable("volume")?.asInt |         val volume = rootNode.getNullable("volume")?.asInt | ||||||
| 
 | 
 | ||||||
|         val chapter = rootNode.getNullable("chapter")?.asFloat |         val chapter = rootNode.getNullable("chapter")?.asFloat?.toStringWithoutDotZero() | ||||||
| 
 | 
 | ||||||
|         val textTitle = rootNode.getNullable("title")?.asString |         val textTitle = rootNode.getNullable("title")?.asString | ||||||
| 
 | 
 | ||||||
| @ -120,19 +125,18 @@ class MangaMutiny : HttpSource() { | |||||||
|             chapterTitle.append("Chapter $chapter") |             chapterTitle.append("Chapter $chapter") | ||||||
|         } |         } | ||||||
|         if (textTitle != null && textTitle != "") { |         if (textTitle != null && textTitle != "") { | ||||||
|             if (volume != null || chapter != null) chapterTitle.append(" ") |             if (volume != null || chapter != null) chapterTitle.append(": ") | ||||||
|             chapterTitle.append(textTitle) |             chapterTitle.append(textTitle) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return chapterTitle.toString() |         return chapterTitle.toString() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private fun parseDate(dateAsString: String): Long { |     private val dateFormatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH) | ||||||
|         val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH) |         .apply { timeZone = TimeZone.getTimeZone("UTC") } | ||||||
|         format.timeZone = TimeZone.getTimeZone("UTC") |  | ||||||
| 
 | 
 | ||||||
|         return format.parse(dateAsString)?.time ?: 0 |     private fun parseDate(dateAsString: String): Long = | ||||||
|     } |         dateFormatter.parse(dateAsString)?.time ?: 0 | ||||||
| 
 | 
 | ||||||
|     // latest |     // latest | ||||||
|     override fun latestUpdatesRequest(page: Int): Request = |     override fun latestUpdatesRequest(page: Int): Request = | ||||||
| @ -541,7 +545,7 @@ class MangaMutiny : HttpSource() { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private class AuthorFilter() : Filter.Text("Manga Author & Artist"), UriFilter { |     private class AuthorFilter : Filter.Text("Manga Author & Artist"), UriFilter { | ||||||
|         override val uriParam = fun() = "creator" |         override val uriParam = fun() = "creator" | ||||||
| 
 | 
 | ||||||
|         override val shouldAdd = fun() = state.isNotEmpty() |         override val shouldAdd = fun() = state.isNotEmpty() | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 E3FxGaming
						E3FxGaming