mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Address some build warnings
This commit is contained in:
@@ -20,17 +20,20 @@ class BackupDecoder(
|
||||
* Decode a potentially-gzipped backup.
|
||||
*/
|
||||
fun decode(uri: Uri): Backup {
|
||||
val backupStringSource = context.contentResolver.openInputStream(uri)!!.source().buffer()
|
||||
return context.contentResolver.openInputStream(uri)!!.use { inputStream ->
|
||||
val source = inputStream.source().buffer()
|
||||
|
||||
val peeked = backupStringSource.peek()
|
||||
peeked.require(2)
|
||||
val id1id2 = peeked.readShort()
|
||||
val backupString = if (id1id2.toInt() == 0x1f8b) { // 0x1f8b is gzip magic bytes
|
||||
backupStringSource.gzip().buffer()
|
||||
} else {
|
||||
backupStringSource
|
||||
}.use { it.readByteArray() }
|
||||
val peeked = source.peek().apply {
|
||||
require(2)
|
||||
}
|
||||
val id1id2 = peeked.readShort()
|
||||
val backupString = if (id1id2.toInt() == 0x1f8b) { // 0x1f8b is gzip magic bytes
|
||||
source.gzip().buffer()
|
||||
} else {
|
||||
source
|
||||
}.use { it.readByteArray() }
|
||||
|
||||
return parser.decodeFromByteArray(BackupSerializer, backupString)
|
||||
parser.decodeFromByteArray(BackupSerializer, backupString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class BackupCreator(
|
||||
.forEach { it.delete() }
|
||||
|
||||
// Create new file to place backup
|
||||
dir?.createFile(BackupCreator.getFilename())
|
||||
dir?.createFile(getFilename())
|
||||
} else {
|
||||
UniFile.fromUri(context, uri)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class DownloadProvider(
|
||||
private val storageManager: StorageManager = Injekt.get(),
|
||||
) {
|
||||
|
||||
val downloadsDir: UniFile?
|
||||
private val downloadsDir: UniFile?
|
||||
get() = storageManager.getDownloadsDirectory()
|
||||
|
||||
/**
|
||||
|
||||
@@ -246,7 +246,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||
|
||||
// Mark chapters as read action
|
||||
addAction(
|
||||
R.drawable.ic_glasses_24dp,
|
||||
R.drawable.ic_done_24dp,
|
||||
context.stringResource(MR.strings.action_mark_as_read),
|
||||
NotificationReceiver.markAsReadPendingBroadcast(
|
||||
context,
|
||||
|
||||
@@ -235,7 +235,6 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
private const val NAME = "NotificationReceiver"
|
||||
|
||||
private const val ACTION_SHARE_IMAGE = "$ID.$NAME.SHARE_IMAGE"
|
||||
private const val ACTION_DELETE_IMAGE = "$ID.$NAME.DELETE_IMAGE"
|
||||
|
||||
private const val ACTION_SHARE_BACKUP = "$ID.$NAME.SEND_BACKUP"
|
||||
|
||||
@@ -256,7 +255,6 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
|
||||
private const val ACTION_DISMISS_NOTIFICATION = "$ID.$NAME.ACTION_DISMISS_NOTIFICATION"
|
||||
|
||||
private const val EXTRA_FILE_LOCATION = "$ID.$NAME.FILE_LOCATION"
|
||||
private const val EXTRA_URI = "$ID.$NAME.URI"
|
||||
private const val EXTRA_NOTIFICATION_ID = "$ID.$NAME.NOTIFICATION_ID"
|
||||
private const val EXTRA_GROUP_ID = "$ID.$NAME.EXTRA_GROUP_ID"
|
||||
@@ -361,7 +359,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
it.id == notificationId
|
||||
}?.groupKey
|
||||
|
||||
if (groupId != null && groupId != 0 && groupKey != null && groupKey.isNotEmpty()) {
|
||||
if (groupId != null && groupId != 0 && !groupKey.isNullOrEmpty()) {
|
||||
val notifications = context.notificationManager.activeNotifications.filter {
|
||||
it.groupKey == groupKey
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class BangumiInterceptor(val bangumi: Bangumi) : Interceptor {
|
||||
class BangumiInterceptor(private val bangumi: Bangumi) : Interceptor {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
|
||||
@@ -62,12 +62,3 @@ fun Track.toBangumiStatus() = when (status) {
|
||||
Bangumi.PLAN_TO_READ -> "wish"
|
||||
else -> throw NotImplementedError("Unknown status: $status")
|
||||
}
|
||||
|
||||
fun toTrackStatus(status: String) = when (status) {
|
||||
"do" -> Bangumi.READING
|
||||
"collect" -> Bangumi.COMPLETED
|
||||
"on_hold" -> Bangumi.ON_HOLD
|
||||
"dropped" -> Bangumi.DROPPED
|
||||
"wish" -> Bangumi.PLAN_TO_READ
|
||||
else -> throw NotImplementedError("Unknown status: $status")
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class KitsuInterceptor(val kitsu: Kitsu) : Interceptor {
|
||||
class KitsuInterceptor(private val kitsu: Kitsu) : Interceptor {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class ShikimoriInterceptor(val shikimori: Shikimori) : Interceptor {
|
||||
class ShikimoriInterceptor(private val shikimori: Shikimori) : Interceptor {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user