From e21943db22fd523f6450f0c1c27c3b983abaff37 Mon Sep 17 00:00:00 2001 From: xiaojie Date: Mon, 2 Dec 2024 15:37:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E5=9B=A0?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E5=AF=BC=E8=87=B4=E7=9A=84=E5=A5=94?= =?UTF-8?q?=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../com/hippo/ehviewer/ui/MyTagsActivity.java | 109 +++++++++--------- .../detail/GetGalleryDetailListener.kt | 5 +- 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d92752b35..d7a6e3948 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ if (file('google-services.json').exists()) { android { namespace 'com.hippo.ehviewer' testNamespace 'com.hippo.ehviewer.debug' - compileSdk 35 + compileSdk 34 // buildToolsVersion "30.0.3" // ndkVersion '25.1.8937393' diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java index 7a1d07e13..07d85c39d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MyTagsActivity.java @@ -26,84 +26,79 @@ import android.webkit.CookieSyncManager; import android.webkit.WebView; import android.webkit.WebViewClient; + import androidx.annotation.Nullable; + import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.R; import com.hippo.ehviewer.client.EhCookieStore; import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.widget.DialogWebChromeClient; import com.hippo.widget.ProgressView; + import okhttp3.Cookie; import okhttp3.HttpUrl; public class MyTagsActivity extends ToolbarActivity { - private WebView webView; - private ProgressView progress; - private String url; + private WebView webView; + private ProgressView progress; + private String url; - @SuppressLint("SetJavaScriptEnabled") - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + @SuppressLint("SetJavaScriptEnabled") + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception - CookieManager cookieManager = CookieManager.getInstance(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - cookieManager.flush(); - cookieManager.removeAllCookies(null); - cookieManager.removeSessionCookies(null); - } else { - CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this); - cookieSyncManager.startSync(); - cookieManager.removeAllCookie(); - cookieManager.removeSessionCookie(); - cookieSyncManager.stopSync(); - } + // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception + CookieManager cookieManager = CookieManager.getInstance(); + cookieManager.flush(); + cookieManager.removeAllCookies(null); + cookieManager.removeSessionCookies(null); - // Copy cookies from okhttp cookie store to CookieManager - url = EhUrl.getMyTagsUrl(); - EhCookieStore store = EhApplication.getEhCookieStore(this); - for (Cookie cookie : store.getCookies(HttpUrl.parse(url))) { - cookieManager.setCookie(url, cookie.toString()); - } + // Copy cookies from okhttp cookie store to CookieManager + url = EhUrl.getMyTagsUrl(); + EhCookieStore store = EhApplication.getEhCookieStore(this); + for (Cookie cookie : store.getCookies(HttpUrl.parse(url))) { + cookieManager.setCookie(url, cookie.toString()); + } - setContentView(R.layout.activity_my_tags); - setNavigationIcon(R.drawable.v_arrow_left_dark_x24); - webView = findViewById(R.id.webview); - webView.getSettings().setJavaScriptEnabled(true); - webView.setWebViewClient(new MyTagsWebViewClient()); - webView.setWebChromeClient(new DialogWebChromeClient(this)); - webView.loadUrl(url); - progress = findViewById(R.id.progress); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; - default: - return super.onOptionsItemSelected(item); + setContentView(R.layout.activity_my_tags); + setNavigationIcon(R.drawable.v_arrow_left_dark_x24); + webView = findViewById(R.id.webview); + webView.getSettings().setJavaScriptEnabled(true); + webView.setWebViewClient(new MyTagsWebViewClient()); + webView.setWebChromeClient(new DialogWebChromeClient(this)); + webView.loadUrl(url); + progress = findViewById(R.id.progress); } - } - private class MyTagsWebViewClient extends WebViewClient { @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - // Never load other urls - return !url.equals(MyTagsActivity.this.url); + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } } - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - progress.setVisibility(View.VISIBLE); - } + private class MyTagsWebViewClient extends WebViewClient { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + // Never load other urls + return !url.equals(MyTagsActivity.this.url); + } - @Override - public void onPageFinished(WebView view, String url) { - progress.setVisibility(View.GONE); + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + progress.setVisibility(View.VISIBLE); + } + + @Override + public void onPageFinished(WebView view, String url) { + progress.setVisibility(View.GONE); + } } - } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/gallery/detail/GetGalleryDetailListener.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/gallery/detail/GetGalleryDetailListener.kt index 6ca1bd9b6..4d85e822a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/gallery/detail/GetGalleryDetailListener.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/gallery/detail/GetGalleryDetailListener.kt @@ -52,7 +52,10 @@ class GetGalleryDetailListener( application.removeGlobalStuff(this) } - override fun isInstance(scene: SceneFragment): Boolean { + override fun isInstance(scene: SceneFragment?): Boolean { + if (scene == null) { + return false; + } return scene is GalleryDetailScene }