1 parent
52dc699ee2
commit
7af40f0cd7
13 files changed
+32
-45
No files matched your search
@@ -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<Parcelable> = ArrayList(),
|
||||
var newerVersions: ArrayList<GalleryInfo> = 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!
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
) : GalleryInfo
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Parcelable>(KEY_GALLERY_INFO)
|
||||
check(gi is GalleryInfo)
|
||||
val gi = intent!!.getParcelableExtra<GalleryInfo>(KEY_GALLERY_INFO)
|
||||
val label = intent.getStringExtra(KEY_LABEL)
|
||||
if (gi != null && mDownloadManager != null) {
|
||||
mDownloadManager!!.startDownload(gi, label)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<CharSequence> 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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class ContentLayout extends FrameLayout {
|
||||
super.onRestoreInstanceState(mContentHelper.restoreInstanceState(state));
|
||||
}
|
||||
|
||||
public abstract static class ContentHelper<E> implements ViewTransition.OnShowViewListener {
|
||||
public abstract static class ContentHelper<E extends Parcelable> implements ViewTransition.OnShowViewListener {
|
||||
|
||||
public static final int TYPE_REFRESH = 0;
|
||||
public static final int TYPE_PRE_PAGE = 1;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user