mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 18:19:18 +01:00
Address minor Kotlin compiler warnings
This commit is contained in:
parent
c349fb0e37
commit
c339bd49d0
@ -60,7 +60,7 @@ class CoverCache(private val context: Context) {
|
|||||||
return false
|
return false
|
||||||
|
|
||||||
// Remove file.
|
// Remove file.
|
||||||
val file = getCoverFile(thumbnailUrl!!)
|
val file = getCoverFile(thumbnailUrl)
|
||||||
return file.exists() && file.delete()
|
return file.exists() && file.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class SharedPreferencesDataStore(private val prefs: SharedPreferences) : Prefere
|
|||||||
prefs.edit().putString(key, value).apply()
|
prefs.edit().putString(key, value).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStringSet(key: String?, defValues: MutableSet<String>?): MutableSet<String> {
|
override fun getStringSet(key: String?, defValues: MutableSet<String>?): MutableSet<String>? {
|
||||||
return prefs.getStringSet(key, defValues)
|
return prefs.getStringSet(key, defValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,12 @@ class KitsuSearchManga(obj: JsonObject) {
|
|||||||
private val synopsis by obj.byString
|
private val synopsis by obj.byString
|
||||||
private var startDate = obj.get("startDate").nullString?.let {
|
private var startDate = obj.get("startDate").nullString?.let {
|
||||||
val outputDf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
val outputDf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||||
outputDf.format(Date(it!!.toLong() * 1000))
|
outputDf.format(Date(it.toLong() * 1000))
|
||||||
}
|
}
|
||||||
private val endDate = obj.get("endDate").nullString
|
private val endDate = obj.get("endDate").nullString
|
||||||
|
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
open fun toTrack() = TrackSearch.create(TrackManager.KITSU).apply {
|
fun toTrack() = TrackSearch.create(TrackManager.KITSU).apply {
|
||||||
media_id = this@KitsuSearchManga.id
|
media_id = this@KitsuSearchManga.id
|
||||||
title = canonicalTitle
|
title = canonicalTitle
|
||||||
total_chapters = chapterCount ?: 0
|
total_chapters = chapterCount ?: 0
|
||||||
@ -55,7 +54,7 @@ class KitsuLibManga(obj: JsonObject, manga: JsonObject) {
|
|||||||
private val ratingTwenty = obj["attributes"].obj.get("ratingTwenty").nullString
|
private val ratingTwenty = obj["attributes"].obj.get("ratingTwenty").nullString
|
||||||
val progress by obj["attributes"].byInt
|
val progress by obj["attributes"].byInt
|
||||||
|
|
||||||
open fun toTrack() = TrackSearch.create(TrackManager.KITSU).apply {
|
fun toTrack() = TrackSearch.create(TrackManager.KITSU).apply {
|
||||||
media_id = libraryId
|
media_id = libraryId
|
||||||
title = canonicalTitle
|
title = canonicalTitle
|
||||||
total_chapters = chapterCount ?: 0
|
total_chapters = chapterCount ?: 0
|
||||||
|
@ -39,7 +39,7 @@ class ExtensionInstallActivity : Activity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkInstallationResult(resultCode: Int) {
|
private fun checkInstallationResult(resultCode: Int) {
|
||||||
val downloadId = intent.extras.getLong(ExtensionInstaller.EXTRA_DOWNLOAD_ID)
|
val downloadId = intent.extras!!.getLong(ExtensionInstaller.EXTRA_DOWNLOAD_ID)
|
||||||
val success = resultCode == RESULT_OK
|
val success = resultCode == RESULT_OK
|
||||||
|
|
||||||
val extensionManager = Injekt.get<ExtensionManager>()
|
val extensionManager = Injekt.get<ExtensionManager>()
|
||||||
|
@ -121,7 +121,7 @@ internal object ExtensionLoader {
|
|||||||
|
|
||||||
val classLoader = PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
val classLoader = PathClassLoader(appInfo.sourceDir, null, context.classLoader)
|
||||||
|
|
||||||
val sources = appInfo.metaData.getString(METADATA_SOURCE_CLASS)
|
val sources = appInfo.metaData.getString(METADATA_SOURCE_CLASS)!!
|
||||||
.split(";")
|
.split(";")
|
||||||
.map {
|
.map {
|
||||||
val sourceClass = it.trim()
|
val sourceClass = it.trim()
|
||||||
|
@ -13,7 +13,7 @@ class SourceDividerItemDecoration(context: Context) : RecyclerView.ItemDecoratio
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val a = context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider))
|
val a = context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider))
|
||||||
divider = a.getDrawable(0)
|
divider = a.getDrawable(0)!!
|
||||||
a.recycle()
|
a.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs:
|
|||||||
val view = inflate(R.layout.catalogue_drawer_content)
|
val view = inflate(R.layout.catalogue_drawer_content)
|
||||||
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
|
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
|
||||||
addView(view)
|
addView(view)
|
||||||
title.text = context?.getString(R.string.source_search_options)
|
title.text = context.getString(R.string.source_search_options)
|
||||||
search_btn.setOnClickListener { onSearchClicked() }
|
search_btn.setOnClickListener { onSearchClicked() }
|
||||||
reset_btn.setOnClickListener { onResetClicked() }
|
reset_btn.setOnClickListener { onResetClicked() }
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class CatalogueSearchAdapter(val controller: CatalogueSearchController) :
|
|||||||
|
|
||||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onRestoreInstanceState(savedInstanceState)
|
super.onRestoreInstanceState(savedInstanceState)
|
||||||
bundle = savedInstanceState.getBundle(HOLDER_BUNDLE_KEY)
|
bundle = savedInstanceState.getBundle(HOLDER_BUNDLE_KEY)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun createPresenter(): ExtensionDetailsPresenter {
|
override fun createPresenter(): ExtensionDetailsPresenter {
|
||||||
return ExtensionDetailsPresenter(args.getString(PKGNAME_KEY))
|
return ExtensionDetailsPresenter(args.getString(PKGNAME_KEY)!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTitle(): String? {
|
override fun getTitle(): String? {
|
||||||
|
@ -13,7 +13,7 @@ class ExtensionDividerItemDecoration(context: Context) : RecyclerView.ItemDecora
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val a = context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider))
|
val a = context.obtainStyledAttributes(intArrayOf(android.R.attr.listDivider))
|
||||||
divider = a.getDrawable(0)
|
divider = a.getDrawable(0)!!
|
||||||
a.recycle()
|
a.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ class ExtensionTrustDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
|||||||
.positiveText(R.string.ext_trust)
|
.positiveText(R.string.ext_trust)
|
||||||
.negativeText(R.string.ext_uninstall)
|
.negativeText(R.string.ext_uninstall)
|
||||||
.onPositive { _, _ ->
|
.onPositive { _, _ ->
|
||||||
(targetController as? Listener)?.trustSignature(args.getString(SIGNATURE_KEY))
|
(targetController as? Listener)?.trustSignature(args.getString(SIGNATURE_KEY)!!)
|
||||||
}
|
}
|
||||||
.onNegative { _, _ ->
|
.onNegative { _, _ ->
|
||||||
(targetController as? Listener)?.uninstallExtension(args.getString(PKGNAME_KEY))
|
(targetController as? Listener)?.uninstallExtension(args.getString(PKGNAME_KEY)!!)
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
@ -119,8 +119,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
setContentView(R.layout.reader_activity)
|
setContentView(R.layout.reader_activity)
|
||||||
|
|
||||||
if (presenter.needsInit()) {
|
if (presenter.needsInit()) {
|
||||||
val manga = intent.extras.getLong("manga", -1)
|
val manga = intent.extras!!.getLong("manga", -1)
|
||||||
val chapter = intent.extras.getLong("chapter", -1)
|
val chapter = intent.extras!!.getLong("chapter", -1)
|
||||||
|
|
||||||
if (manga == -1L || chapter == -1L) {
|
if (manga == -1L || chapter == -1L) {
|
||||||
finish()
|
finish()
|
||||||
|
@ -498,7 +498,7 @@ class ReaderPresenter(
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribeFirst(
|
.subscribeFirst(
|
||||||
{ view, file -> view.onShareImageResult(file) },
|
{ view, file -> view.onShareImageResult(file) },
|
||||||
{ view, error -> /* Empty */ }
|
{ _, _ -> /* Empty */ }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ class DownloadPageLoader(
|
|||||||
return downloadManager.buildPageList(source, manga, chapter.chapter)
|
return downloadManager.buildPageList(source, manga, chapter.chapter)
|
||||||
.map { pages ->
|
.map { pages ->
|
||||||
pages.map { page ->
|
pages.map { page ->
|
||||||
ReaderPage(page.index, page.url, page.imageUrl, {
|
ReaderPage(page.index, page.url, page.imageUrl) {
|
||||||
context.contentResolver.openInputStream(page.uri)
|
context.contentResolver.openInputStream(page.uri)
|
||||||
}).apply {
|
}.apply {
|
||||||
status = Page.READY
|
status = Page.READY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ object ChapterRecognition {
|
|||||||
* @param chapter chapter object
|
* @param chapter chapter object
|
||||||
* @return true if volume is found
|
* @return true if volume is found
|
||||||
*/
|
*/
|
||||||
fun updateChapter(match: MatchResult?, chapter: SChapter): Boolean {
|
private fun updateChapter(match: MatchResult?, chapter: SChapter): Boolean {
|
||||||
match?.let {
|
match?.let {
|
||||||
val initial = it.groups[1]?.value?.toFloat()!!
|
val initial = it.groups[1]?.value?.toFloat()!!
|
||||||
val subChapterDecimal = it.groups[2]?.value
|
val subChapterDecimal = it.groups[2]?.value
|
||||||
@ -109,12 +109,12 @@ object ChapterRecognition {
|
|||||||
* @param alpha alpha value of regex
|
* @param alpha alpha value of regex
|
||||||
* @return decimal/alpha float value
|
* @return decimal/alpha float value
|
||||||
*/
|
*/
|
||||||
fun checkForDecimal(decimal: String?, alpha: String?): Float {
|
private fun checkForDecimal(decimal: String?, alpha: String?): Float {
|
||||||
if (!decimal.isNullOrEmpty())
|
if (!decimal.isNullOrEmpty())
|
||||||
return decimal?.toFloat()!!
|
return decimal.toFloat()
|
||||||
|
|
||||||
if (!alpha.isNullOrEmpty()) {
|
if (!alpha.isNullOrEmpty()) {
|
||||||
if (alpha!!.contains("extra"))
|
if (alpha.contains("extra"))
|
||||||
return .99f
|
return .99f
|
||||||
|
|
||||||
if (alpha.contains("omake"))
|
if (alpha.contains("omake"))
|
||||||
@ -138,7 +138,7 @@ object ChapterRecognition {
|
|||||||
* x.a -> x.1, x.b -> x.2, etc
|
* x.a -> x.1, x.b -> x.2, etc
|
||||||
*/
|
*/
|
||||||
private fun parseAlphaPostFix(alpha: Char): Float {
|
private fun parseAlphaPostFix(alpha: Char): Float {
|
||||||
return ("0." + Integer.toString(alpha.toInt() - 96)).toFloat()
|
return ("0." + (alpha.toInt() - 96).toString()).toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -172,11 +172,11 @@ fun Context.isServiceRunning(serviceClass: Class<*>): Boolean {
|
|||||||
*/
|
*/
|
||||||
fun Context.openInBrowser(url: String) {
|
fun Context.openInBrowser(url: String) {
|
||||||
try {
|
try {
|
||||||
val url = Uri.parse(url)
|
val parsedUrl = Uri.parse(url)
|
||||||
val intent = CustomTabsIntent.Builder()
|
val intent = CustomTabsIntent.Builder()
|
||||||
.setToolbarColor(getResourceColor(R.attr.colorPrimary))
|
.setToolbarColor(getResourceColor(R.attr.colorPrimary))
|
||||||
.build()
|
.build()
|
||||||
intent.launchUrl(this, url)
|
intent.launchUrl(this, parsedUrl)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toast(e.message)
|
toast(e.message)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user