diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt index bb1d0422e..5b3ecc5cd 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt @@ -15,13 +15,12 @@ */ package com.hippo.ehviewer.client.data -import android.os.Parcelable import kotlinx.parcelize.Parcelize -@Parcelize -class GalleryDetail @JvmOverloads constructor( - @JvmField - val galleryInfo: GalleryInfoImpl, +// @Parcelize +class GalleryDetail( + // @JvmField + // val galleryInfo: GalleryInfo, @JvmField var apiUid: Long = -1L, @@ -42,7 +41,7 @@ class GalleryDetail @JvmOverloads constructor( var parent: String? = null, @JvmField - var newerVersions: ArrayList = ArrayList(), + var newerVersions: ArrayList = ArrayList(), @JvmField var visible: String? = null, @@ -73,4 +72,8 @@ class GalleryDetail @JvmOverloads constructor( @JvmField var previewSet: PreviewSet? = null, -) : GalleryInfo by galleryInfo, Parcelable +) : GalleryInfoImpl() +// ) : GalleryInfo by galleryInfo + +// Delegating 'Parcelable' is not allowed +// Fuck you Jetbrains! \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt index aa5c77408..410ab35d4 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt @@ -15,9 +15,10 @@ */ package com.hippo.ehviewer.client.data +import android.os.Parcelable import java.util.regex.Pattern -interface GalleryInfo { +interface GalleryInfo : Parcelable { var gid: Long var token: String? var title: String? diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfoImpl.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfoImpl.kt index 41f6d7788..d0690eca3 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfoImpl.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfoImpl.kt @@ -15,14 +15,13 @@ */ package com.hippo.ehviewer.client.data -import android.os.Parcelable import androidx.room.ColumnInfo import androidx.room.Ignore import androidx.room.PrimaryKey import kotlinx.parcelize.Parcelize @Parcelize -open class GalleryInfoImpl @JvmOverloads constructor( +open class GalleryInfoImpl( @PrimaryKey @ColumnInfo(name = "GID") override var gid: Long = 0, @@ -87,4 +86,4 @@ open class GalleryInfoImpl @JvmOverloads constructor( @Ignore override var favoriteName: String? = null -) : GalleryInfo, Parcelable \ No newline at end of file +) : GalleryInfo \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java index fc5c8124e..cabb416c8 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java @@ -16,8 +16,6 @@ package com.hippo.ehviewer.client.parser; -import android.os.Parcelable; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -116,7 +114,7 @@ public class GalleryDetailParser { throw new EhException(m.group(1)); } - GalleryDetail galleryDetail = new GalleryDetail(new GalleryInfoImpl()); + GalleryDetail galleryDetail = new GalleryDetail(); Document document = Jsoup.parse(body); parseDetail(galleryDetail, document, body); galleryDetail.tags = parseTagGroups(document); @@ -299,7 +297,7 @@ public class GalleryDetailParser { gi.setToken(result.token); gi.setTitle(StringUtils.trim(element.text())); gi.setPosted(dates.get(i)); - gd.newerVersions.add((Parcelable) gi); + gd.newerVersions.add(gi); } } } diff --git a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt index 83722fbc7..4184e2346 100644 --- a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt +++ b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt @@ -22,7 +22,6 @@ import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle import android.os.IBinder -import android.os.Parcelable import android.os.SystemClock import android.util.Log import androidx.annotation.IntDef @@ -101,8 +100,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { action = intent.action } if (ACTION_START == action) { - val gi = intent!!.getParcelableExtra(KEY_GALLERY_INFO) - check(gi is GalleryInfo) + val gi = intent!!.getParcelableExtra(KEY_GALLERY_INFO) val label = intent.getStringExtra(KEY_LABEL) if (gi != null && mDownloadManager != null) { mDownloadManager!!.startDownload(gi, label) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.java b/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.java index 9f35806c7..a7a856da3 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.java @@ -19,7 +19,6 @@ package com.hippo.ehviewer.ui; import android.app.Activity; import android.content.Intent; import android.os.Build; -import android.os.Parcelable; import androidx.core.content.ContextCompat; @@ -164,7 +163,7 @@ public final class CommonOperations { Intent intent = new Intent(activity, DownloadService.class); intent.setAction(DownloadService.ACTION_START); intent.putExtra(DownloadService.KEY_LABEL, label); - intent.putExtra(DownloadService.KEY_GALLERY_INFO, (Parcelable) gi); + intent.putExtra(DownloadService.KEY_GALLERY_INFO, gi); ContextCompat.startForegroundService(activity, intent); } // Notify @@ -194,7 +193,7 @@ public final class CommonOperations { Intent intent = new Intent(activity, DownloadService.class); intent.setAction(DownloadService.ACTION_START); intent.putExtra(DownloadService.KEY_LABEL, label1); - intent.putExtra(DownloadService.KEY_GALLERY_INFO, (Parcelable) gi); + intent.putExtra(DownloadService.KEY_GALLERY_INFO, gi); ContextCompat.startForegroundService(activity, intent); } // Save settings diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java index a999e48db..f5bc84116 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Resources; import android.os.Bundle; -import android.os.Parcelable; import android.text.TextUtils; import android.util.SparseBooleanArray; import android.view.LayoutInflater; @@ -460,7 +459,7 @@ public class FavoritesScene extends SearchBarScene implements } Bundle args = new Bundle(); args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO); - args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, (Parcelable) gi); + args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi); Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args); startScene(announcer); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java index af9ba0826..a24c0016c 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java @@ -35,7 +35,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Environment; -import android.os.Parcelable; import android.text.Html; import android.text.TextUtils; import android.view.LayoutInflater; @@ -449,7 +448,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O outState.putString(KEY_ACTION, mAction); } if (mGalleryInfo != null) { - outState.putParcelable(KEY_GALLERY_INFO, (Parcelable) mGalleryInfo); + outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo); } outState.putLong(KEY_GID, mGid); if (mToken != null) { @@ -1105,19 +1104,18 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O if (galleryInfo != null) { Intent intent = new Intent(activity, ReaderActivity.class); intent.setAction(ReaderActivity.ACTION_EH); - intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) galleryInfo); + intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, galleryInfo); startActivity(intent); } } else if (mNewerVersion == v) { if (mGalleryDetail != null) { ArrayList titles = new ArrayList<>(); - for (Parcelable newerVersion : mGalleryDetail.newerVersions) { - var gi = (GalleryInfo) newerVersion; - titles.add(getString(R.string.newer_version_title, gi.getTitle(), gi.getPosted())); + for (GalleryInfo newerVersion : mGalleryDetail.newerVersions) { + titles.add(getString(R.string.newer_version_title, newerVersion.getTitle(), newerVersion.getPosted())); } new BaseDialogBuilder(requireContext()) .setItems(titles.toArray(new CharSequence[0]), (dialog, which) -> { - GalleryInfo newerVersion = (GalleryInfo) mGalleryDetail.newerVersions.get(which); + GalleryInfo newerVersion = mGalleryDetail.newerVersions.get(which); Bundle args = new Bundle(); args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN); args.putLong(GalleryDetailScene.KEY_GID, newerVersion.getGid()); @@ -1240,7 +1238,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O int index = (Integer) o; Intent intent = new Intent(context, ReaderActivity.class); intent.setAction(ReaderActivity.ACTION_EH); - intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) galleryInfo); + intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, galleryInfo); intent.putExtra(ReaderActivity.KEY_PAGE, index); startActivity(intent); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 4237f01da..a9aa9d3c4 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -24,7 +24,6 @@ import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.os.Parcelable; import android.text.InputType; import android.text.Spannable; import android.text.SpannableStringBuilder; @@ -794,7 +793,7 @@ public final class GalleryListScene extends SearchBarScene Bundle args = new Bundle(); args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO); - args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, (Parcelable) gi); + args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi); Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args); startScene(announcer); } @@ -966,7 +965,7 @@ public final class GalleryListScene extends SearchBarScene case 0: // Read Intent intent = new Intent(activity, ReaderActivity.class); intent.setAction(ReaderActivity.ACTION_EH); - intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) gi); + intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, gi); startActivity(intent); break; case 1: // Download diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java index 1e649f8d9..97dec7913 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; -import android.os.Parcelable; import android.util.Pair; import android.view.LayoutInflater; import android.view.MenuItem; @@ -124,7 +123,7 @@ public class GalleryPreviewsScene extends BaseToolbarScene { hasFirstRefresh = mHasFirstRefresh; } outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh); - outState.putParcelable(KEY_GALLERY_INFO, (Parcelable) mGalleryInfo); + outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo); } @NonNull @@ -225,7 +224,7 @@ public class GalleryPreviewsScene extends BaseToolbarScene { if (p != null) { Intent intent = new Intent(context, ReaderActivity.class); intent.setAction(ReaderActivity.ACTION_EH); - intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) mGalleryInfo); + intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, mGalleryInfo); intent.putExtra(ReaderActivity.KEY_PAGE, p.position); startActivity(intent); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt index 4f5308c09..6d7a839e6 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt @@ -20,7 +20,6 @@ import android.content.Context import android.content.DialogInterface import android.content.Intent import android.os.Bundle -import android.os.Parcelable import android.text.TextUtils import android.view.* import android.widget.ImageView @@ -217,7 +216,6 @@ class HistoryScene : BaseToolbarScene() { fun onItemClick(gi: GalleryInfo): Boolean { val args = Bundle() args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO) - check(gi is Parcelable) args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi) val announcer = Announcer(GalleryDetailScene::class.java).setArgs(args) startScene(announcer) @@ -262,7 +260,6 @@ class HistoryScene : BaseToolbarScene() { 0 -> { val intent = Intent(activity, ReaderActivity::class.java) intent.action = ReaderActivity.ACTION_EH - check(gi is Parcelable) intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, gi) startActivity(intent) } diff --git a/app/src/main/java/com/hippo/widget/ContentLayout.java b/app/src/main/java/com/hippo/widget/ContentLayout.java index ac17d08e4..722d232f6 100644 --- a/app/src/main/java/com/hippo/widget/ContentLayout.java +++ b/app/src/main/java/com/hippo/widget/ContentLayout.java @@ -170,7 +170,7 @@ public class ContentLayout extends FrameLayout { super.onRestoreInstanceState(mContentHelper.restoreInstanceState(state)); } - public abstract static class ContentHelper implements ViewTransition.OnShowViewListener { + public abstract static class ContentHelper implements ViewTransition.OnShowViewListener { public static final int TYPE_REFRESH = 0; public static final int TYPE_PRE_PAGE = 1; diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 5dffd7532..2a0bf7d51 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -35,7 +35,6 @@ import android.os.Bundle import android.os.Environment import android.os.Handler import android.os.Message -import android.os.Parcelable import android.provider.MediaStore import android.text.TextUtils import android.view.HapticFeedbackConstants @@ -244,9 +243,7 @@ class ReaderActivity : EhActivity() { outState.putString(KEY_FILENAME, mFilename) outState.putParcelable(KEY_URI, mUri) if (mGalleryInfo != null) { - val info = mGalleryInfo - check(info is Parcelable) - outState.putParcelable(KEY_GALLERY_INFO, info) + outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo) } outState.putInt(KEY_PAGE, mPage) outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex)