From a72fca3dfb9e0e0c2d53f03c10589ead5b50231c Mon Sep 17 00:00:00 2001 From: tarsin Date: Mon, 25 Jul 2022 10:16:54 +0800 Subject: [PATCH] Fix a lag --- .../gallery/ArchiveGalleryProvider.java | 6 ++- .../java/com/hippo/ehviewer/gallery/Pipe.java | 52 ------------------- 2 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 app/src/main/java/com/hippo/ehviewer/gallery/Pipe.java diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/ArchiveGalleryProvider.java b/app/src/main/java/com/hippo/ehviewer/gallery/ArchiveGalleryProvider.java index a54b8a6ad..996512ca9 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/ArchiveGalleryProvider.java +++ b/app/src/main/java/com/hippo/ehviewer/gallery/ArchiveGalleryProvider.java @@ -257,7 +257,11 @@ public class ArchiveGalleryProvider extends GalleryProvider2 { if (streams.get(index) != null) { continue; } - long addr = archiveAccessor.extracttoOutputStream(index); + } + + long addr = archiveAccessor.extracttoOutputStream(index); + + synchronized (streams) { streams.put(index, addr); streams.notify(); } diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/Pipe.java b/app/src/main/java/com/hippo/ehviewer/gallery/Pipe.java deleted file mode 100644 index 1b9d275e9..000000000 --- a/app/src/main/java/com/hippo/ehviewer/gallery/Pipe.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2019 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer.gallery; - -import android.os.ParcelFileDescriptor; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -class Pipe { - private ParcelFileDescriptor[] fd; - { - try { - fd = ParcelFileDescriptor.createPipe(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private final InputStream inputStream = new FileInputStream(fd[0].getFileDescriptor()); - - InputStream getInputStream() { - return inputStream; - } - - int getOutputFd() { - return fd[1].getFd(); - } - - void closeOutputFd() { - try { - fd[1].close(); - } catch (IOException e) { - e.printStackTrace(); - } - } -}