Not good solution :(
This commit is contained in:
1 parent
ec5e0c7b25
commit
3283851dc4
13 files changed
+45
-32
No files matched your search
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.client.data
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
// @Parcelize
|
||||
class GalleryDetail(
|
||||
// @JvmField
|
||||
// val galleryInfo: GalleryInfo,
|
||||
@Parcelize
|
||||
class GalleryDetail @JvmOverloads constructor(
|
||||
@JvmField
|
||||
val galleryInfo: GalleryInfoImpl,
|
||||
|
||||
@JvmField
|
||||
var apiUid: Long = -1L,
|
||||
@@ -41,7 +42,7 @@ class GalleryDetail(
|
||||
var parent: String? = null,
|
||||
|
||||
@JvmField
|
||||
var newerVersions: ArrayList<GalleryInfo> = ArrayList(),
|
||||
var newerVersions: ArrayList<Parcelable> = ArrayList(),
|
||||
|
||||
@JvmField
|
||||
var visible: String? = null,
|
||||
@@ -72,8 +73,4 @@ class GalleryDetail(
|
||||
|
||||
@JvmField
|
||||
var previewSet: PreviewSet? = null,
|
||||
) : GalleryInfoImpl()
|
||||
// ) : GalleryInfo by galleryInfo
|
||||
|
||||
// Delegating 'Parcelable' is not allowed
|
||||
// Fuck you Jetbrains!
|
||||
) : GalleryInfo by galleryInfo, Parcelable
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.client.data
|
||||
|
||||
import android.os.Parcelable
|
||||
import java.util.regex.Pattern
|
||||
|
||||
interface GalleryInfo : Parcelable {
|
||||
interface GalleryInfo {
|
||||
var gid: Long
|
||||
var token: String?
|
||||
var title: String?
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
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(
|
||||
open class GalleryInfoImpl @JvmOverloads constructor(
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "GID")
|
||||
override var gid: Long = 0,
|
||||
@@ -86,4 +87,4 @@ open class GalleryInfoImpl(
|
||||
@Ignore
|
||||
override var favoriteName: String? = null
|
||||
|
||||
) : GalleryInfo
|
||||
) : GalleryInfo, Parcelable
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -114,7 +116,7 @@ public class GalleryDetailParser {
|
||||
throw new EhException(m.group(1));
|
||||
}
|
||||
|
||||
GalleryDetail galleryDetail = new GalleryDetail();
|
||||
GalleryDetail galleryDetail = new GalleryDetail(new GalleryInfoImpl());
|
||||
Document document = Jsoup.parse(body);
|
||||
parseDetail(galleryDetail, document, body);
|
||||
galleryDetail.tags = parseTagGroups(document);
|
||||
@@ -297,7 +299,7 @@ public class GalleryDetailParser {
|
||||
gi.setToken(result.token);
|
||||
gi.setTitle(StringUtils.trim(element.text()));
|
||||
gi.setPosted(dates.get(i));
|
||||
gd.newerVersions.add(gi);
|
||||
gd.newerVersions.add((Parcelable) gi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ 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
|
||||
@@ -100,7 +101,8 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
|
||||
action = intent.action
|
||||
}
|
||||
if (ACTION_START == action) {
|
||||
val gi = intent!!.getParcelableExtra<GalleryInfo>(KEY_GALLERY_INFO)
|
||||
val gi = intent!!.getParcelableExtra<Parcelable>(KEY_GALLERY_INFO)
|
||||
check(gi is GalleryInfo)
|
||||
val label = intent.getStringExtra(KEY_LABEL)
|
||||
if (gi != null && mDownloadManager != null) {
|
||||
mDownloadManager!!.startDownload(gi, label)
|
||||
|
||||
@@ -19,6 +19,7 @@ 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;
|
||||
|
||||
@@ -163,7 +164,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, gi);
|
||||
intent.putExtra(DownloadService.KEY_GALLERY_INFO, (Parcelable) gi);
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
}
|
||||
// Notify
|
||||
@@ -193,7 +194,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, gi);
|
||||
intent.putExtra(DownloadService.KEY_GALLERY_INFO, (Parcelable) gi);
|
||||
ContextCompat.startForegroundService(activity, intent);
|
||||
}
|
||||
// Save settings
|
||||
|
||||
@@ -22,6 +22,7 @@ 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;
|
||||
@@ -459,7 +460,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, gi);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, (Parcelable) gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
startScene(announcer);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ 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;
|
||||
@@ -448,7 +449,7 @@ public class GalleryDetailScene extends CollapsingToolbarScene implements View.O
|
||||
outState.putString(KEY_ACTION, mAction);
|
||||
}
|
||||
if (mGalleryInfo != null) {
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
|
||||
outState.putParcelable(KEY_GALLERY_INFO, (Parcelable) mGalleryInfo);
|
||||
}
|
||||
outState.putLong(KEY_GID, mGid);
|
||||
if (mToken != null) {
|
||||
@@ -1104,18 +1105,19 @@ 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, galleryInfo);
|
||||
intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) galleryInfo);
|
||||
startActivity(intent);
|
||||
}
|
||||
} else if (mNewerVersion == v) {
|
||||
if (mGalleryDetail != null) {
|
||||
ArrayList<CharSequence> titles = new ArrayList<>();
|
||||
for (GalleryInfo newerVersion : mGalleryDetail.newerVersions) {
|
||||
titles.add(getString(R.string.newer_version_title, newerVersion.getTitle(), newerVersion.getPosted()));
|
||||
for (Parcelable newerVersion : mGalleryDetail.newerVersions) {
|
||||
var gi = (GalleryInfo) newerVersion;
|
||||
titles.add(getString(R.string.newer_version_title, gi.getTitle(), gi.getPosted()));
|
||||
}
|
||||
new BaseDialogBuilder(requireContext())
|
||||
.setItems(titles.toArray(new CharSequence[0]), (dialog, which) -> {
|
||||
GalleryInfo newerVersion = mGalleryDetail.newerVersions.get(which);
|
||||
GalleryInfo newerVersion = (GalleryInfo) mGalleryDetail.newerVersions.get(which);
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN);
|
||||
args.putLong(GalleryDetailScene.KEY_GID, newerVersion.getGid());
|
||||
@@ -1238,7 +1240,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, galleryInfo);
|
||||
intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) galleryInfo);
|
||||
intent.putExtra(ReaderActivity.KEY_PAGE, index);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ 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;
|
||||
@@ -793,7 +794,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, gi);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, (Parcelable) gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
startScene(announcer);
|
||||
}
|
||||
@@ -965,7 +966,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, gi);
|
||||
intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) gi);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case 1: // Download
|
||||
|
||||
@@ -22,6 +22,7 @@ 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;
|
||||
@@ -123,7 +124,7 @@ public class GalleryPreviewsScene extends BaseToolbarScene {
|
||||
hasFirstRefresh = mHasFirstRefresh;
|
||||
}
|
||||
outState.putBoolean(KEY_HAS_FIRST_REFRESH, hasFirstRefresh);
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
|
||||
outState.putParcelable(KEY_GALLERY_INFO, (Parcelable) mGalleryInfo);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -224,7 +225,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, mGalleryInfo);
|
||||
intent.putExtra(ReaderActivity.KEY_GALLERY_INFO, (Parcelable) mGalleryInfo);
|
||||
intent.putExtra(ReaderActivity.KEY_PAGE, p.position);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ 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
|
||||
@@ -216,6 +217,7 @@ 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)
|
||||
@@ -260,6 +262,7 @@ 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)
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class ContentLayout extends FrameLayout {
|
||||
super.onRestoreInstanceState(mContentHelper.restoreInstanceState(state));
|
||||
}
|
||||
|
||||
public abstract static class ContentHelper<E extends Parcelable> implements ViewTransition.OnShowViewListener {
|
||||
public abstract static class ContentHelper<E> implements ViewTransition.OnShowViewListener {
|
||||
|
||||
public static final int TYPE_REFRESH = 0;
|
||||
public static final int TYPE_PRE_PAGE = 1;
|
||||
|
||||
@@ -35,6 +35,7 @@ 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
|
||||
@@ -243,7 +244,9 @@ class ReaderActivity : EhActivity() {
|
||||
outState.putString(KEY_FILENAME, mFilename)
|
||||
outState.putParcelable(KEY_URI, mUri)
|
||||
if (mGalleryInfo != null) {
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo)
|
||||
val info = mGalleryInfo
|
||||
check(info is Parcelable)
|
||||
outState.putParcelable(KEY_GALLERY_INFO, info)
|
||||
}
|
||||
outState.putInt(KEY_PAGE, mPage)
|
||||
outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex)
|
||||
|
||||
Reference in new issue
Block a user