mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Address some build warnings
This commit is contained in:
parent
7c23212850
commit
71d225c562
@ -1,7 +1,7 @@
|
||||
package eu.kanade.tachiyomi
|
||||
|
||||
import android.app.Application
|
||||
import android.os.Handler
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -44,7 +44,7 @@ class AppModule(val app: Application) : InjektModule {
|
||||
addSingletonFactory { Json { ignoreUnknownKeys = true } }
|
||||
|
||||
// Asynchronously init expensive components for a faster cold start
|
||||
Handler().post {
|
||||
ContextCompat.getMainExecutor(app).execute {
|
||||
get<PreferencesHelper>()
|
||||
|
||||
get<NetworkHelper>()
|
||||
|
@ -96,7 +96,7 @@ class BackupRestoreService : Service() {
|
||||
|
||||
private fun destroyJob() {
|
||||
backupRestore?.job?.cancel()
|
||||
ioScope?.cancel()
|
||||
ioScope.cancel()
|
||||
if (wakeLock.isHeld) {
|
||||
wakeLock.release()
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
@ -143,7 +143,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
*/
|
||||
private fun shareFile(context: Context, uri: Uri, fileMimeType: String, notificationId: Int) {
|
||||
dismissNotification(context, notificationId)
|
||||
context.startActivity(uri.toShareIntent())
|
||||
context.startActivity(uri.toShareIntent(fileMimeType))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +192,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
*/
|
||||
private fun cancelRestore(context: Context, notificationId: Int) {
|
||||
BackupRestoreService.stop(context)
|
||||
Handler().post { dismissNotification(context, notificationId) }
|
||||
ContextCompat.getMainExecutor(context).execute { dismissNotification(context, notificationId) }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
*/
|
||||
private fun cancelLibraryUpdate(context: Context, notificationId: Int) {
|
||||
LibraryUpdateService.stop(context)
|
||||
Handler().post { dismissNotification(context, notificationId) }
|
||||
ContextCompat.getMainExecutor(context).execute { dismissNotification(context, notificationId) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class Komga(private val context: Context, id: Int) : TrackService(id), Unattende
|
||||
}
|
||||
|
||||
override suspend fun refresh(track: Track): Track {
|
||||
val remoteTrack = api.getTrackSearch(track.tracking_url)!!
|
||||
val remoteTrack = api.getTrackSearch(track.tracking_url)
|
||||
track.copyPersonalFrom(remoteTrack)
|
||||
track.total_chapters = remoteTrack.total_chapters
|
||||
return track
|
||||
|
@ -2,11 +2,10 @@ package eu.kanade.tachiyomi.network.interceptor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
@ -28,7 +27,7 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
class CloudflareInterceptor(private val context: Context) : Interceptor {
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val executor = ContextCompat.getMainExecutor(context)
|
||||
|
||||
private val networkHelper: NetworkHelper by injectLazy()
|
||||
|
||||
@ -92,7 +91,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
||||
val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap()
|
||||
headers["X-Requested-With"] = WebViewUtil.REQUESTED_WITH
|
||||
|
||||
handler.post {
|
||||
executor.execute {
|
||||
val webview = WebView(context)
|
||||
webView = webview
|
||||
webview.setDefaultSettings()
|
||||
@ -146,7 +145,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
||||
// around 4 seconds but it can take more due to slow networks or server issues.
|
||||
latch.await(12, TimeUnit.SECONDS)
|
||||
|
||||
handler.post {
|
||||
executor.execute {
|
||||
if (!cloudflareBypassed) {
|
||||
isWebViewOutdated = webView?.isOutdated() == true
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ class SearchController(
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val prefValue = preferences.migrateFlags().get()
|
||||
|
||||
|
@ -188,6 +188,7 @@ class DownloadController :
|
||||
onUpdateDownloadedPages(download)
|
||||
}
|
||||
Download.State.ERROR -> unsubscribeProgress(download)
|
||||
else -> { /* unused */ }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ class ChangeMangaCoverDialog<T>(bundle: Bundle? = null) :
|
||||
this.manga = manga
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.action_edit_cover)
|
||||
|
@ -357,11 +357,12 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
return true
|
||||
}
|
||||
|
||||
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
// Binding sometimes isn't actually instantiated yet somehow
|
||||
nav.setOnItemSelectedListener(null)
|
||||
nav?.setOnItemSelectedListener(null)
|
||||
binding?.toolbar.setNavigationOnClickListener(null)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
|
||||
|
||||
class WhatsNewDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog(activity!!)
|
||||
.title(text = activity!!.getString(R.string.updated_version, BuildConfig.VERSION_NAME))
|
||||
|
@ -40,6 +40,7 @@ class SetTrackReadingDatesDialog<T> : DialogController
|
||||
dateToUpdate = ReadingDate.Start
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog(activity!!)
|
||||
.title(
|
||||
@ -49,10 +50,10 @@ class SetTrackReadingDatesDialog<T> : DialogController
|
||||
}
|
||||
)
|
||||
.datePicker(currentDate = getCurrentDate()) { _, date ->
|
||||
listener?.setReadingDate(item, dateToUpdate, date.timeInMillis)
|
||||
listener.setReadingDate(item, dateToUpdate, date.timeInMillis)
|
||||
}
|
||||
.neutralButton(R.string.action_remove) {
|
||||
listener?.setReadingDate(item, dateToUpdate, 0L)
|
||||
listener.setReadingDate(item, dateToUpdate, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ class TrackSearchDialog : DialogController {
|
||||
service = Injekt.get<TrackManager>().getService(bundle.getInt(KEY_SERVICE))!!
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
binding = TrackSearchDialogBinding.inflate(LayoutInflater.from(activity!!))
|
||||
val dialog = MaterialDialog(activity!!)
|
||||
|
@ -19,9 +19,9 @@ class DirectoryPageLoader(val file: File) : PageLoader() {
|
||||
*/
|
||||
override fun getPages(): Observable<List<ReaderPage>> {
|
||||
return file.listFiles()
|
||||
.filter { !it.isDirectory && ImageUtil.isImage(it.name) { FileInputStream(it) } }
|
||||
.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
||||
.mapIndexed { i, file ->
|
||||
?.filter { !it.isDirectory && ImageUtil.isImage(it.name) { FileInputStream(it) } }
|
||||
?.sortedWith { f1, f2 -> f1.name.compareToCaseInsensitiveNaturalOrder(f2.name) }
|
||||
?.mapIndexed { i, file ->
|
||||
val streamFn = { FileInputStream(file) }
|
||||
ReaderPage(i).apply {
|
||||
stream = streamFn
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
@ -16,7 +17,7 @@ open class GestureDetectorWithLongTap(
|
||||
listener: Listener
|
||||
) : GestureDetector(context, listener) {
|
||||
|
||||
private val handler = Handler()
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val slop = ViewConfiguration.get(context).scaledTouchSlop
|
||||
private val longTapTime = ViewConfiguration.getLongPressTimeout().toLong()
|
||||
private val doubleTapTime = ViewConfiguration.getDoubleTapTimeout().toLong()
|
||||
|
@ -2,8 +2,8 @@ package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
@ -171,7 +171,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
|
||||
onChange {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
Handler().post { LibraryUpdateJob.setupTask(context) }
|
||||
ContextCompat.getMainExecutor(context).execute { LibraryUpdateJob.setupTask(context) }
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,7 @@ class WebViewActivity : BaseViewBindingActivity<WebviewActivityBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
|
@ -21,7 +21,7 @@ object DiskUtil {
|
||||
fun getDirectorySize(f: File): Long {
|
||||
var size: Long = 0
|
||||
if (f.isDirectory) {
|
||||
for (file in f.listFiles()) {
|
||||
for (file in f.listFiles().orEmpty()) {
|
||||
size += getDirectorySize(file)
|
||||
}
|
||||
} else {
|
||||
|
@ -14,7 +14,7 @@ import java.io.OutputStream
|
||||
fun BufferedSource.saveTo(file: File) {
|
||||
try {
|
||||
// Create parent dirs if needed
|
||||
file.parentFile.mkdirs()
|
||||
file.parentFile?.mkdirs()
|
||||
|
||||
// Copy to destination
|
||||
saveTo(file.outputStream())
|
||||
|
@ -4,12 +4,12 @@ import android.content.ClipData
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
|
||||
fun Uri.toShareIntent(): Intent {
|
||||
fun Uri.toShareIntent(type: String = "image/*"): Intent {
|
||||
val uri = this
|
||||
return Intent(Intent.ACTION_SEND).apply {
|
||||
putExtra(Intent.EXTRA_STREAM, uri)
|
||||
clipData = ClipData.newRawUri(null, uri)
|
||||
type = "image/*"
|
||||
setType(type)
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user