Convert all PageLoader to kotlin
This commit is contained in:
1 parent
a80f41a89a
commit
6b0f8bc325
3 files changed
+23
-36
No files matched your search
@@ -39,9 +39,8 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi
|
||||
SimpleHandler.getInstance().postDelayed(ReleaseTask(mSpiderQueen), 3000)
|
||||
}
|
||||
|
||||
override fun getStartPage(): Int {
|
||||
return mSpiderQueen.startPage
|
||||
}
|
||||
override val startPage
|
||||
get() = mSpiderQueen.startPage
|
||||
|
||||
override fun getImageFilename(index: Int): String {
|
||||
return String.format(
|
||||
|
||||
@@ -13,49 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hippo.ehviewer.gallery
|
||||
|
||||
package com.hippo.ehviewer.gallery;
|
||||
import com.hippo.unifile.UniFile
|
||||
import eu.kanade.tachiyomi.ui.reader.loader.PageLoader
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
abstract class PageLoader2 : PageLoader() {
|
||||
open val startPage: Int
|
||||
get() = 0
|
||||
|
||||
import com.hippo.unifile.UniFile;
|
||||
|
||||
import eu.kanade.tachiyomi.ui.reader.loader.PageLoader;
|
||||
|
||||
public abstract class PageLoader2 extends PageLoader {
|
||||
|
||||
// With dot
|
||||
public static final String[] SUPPORT_IMAGE_EXTENSIONS = {
|
||||
".jpg", // Joint Photographic Experts Group
|
||||
".png", // Portable Network Graphics
|
||||
".gif", // Graphics Interchange Format
|
||||
};
|
||||
|
||||
public int getStartPage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void putStartPage(int page) {
|
||||
}
|
||||
open fun putStartPage(page: Int) {}
|
||||
|
||||
/**
|
||||
* @return without extension
|
||||
*/
|
||||
@NonNull
|
||||
public abstract String getImageFilename(int index);
|
||||
abstract fun getImageFilename(index: Int): String
|
||||
|
||||
/**
|
||||
* @return with extension
|
||||
*/
|
||||
@NonNull
|
||||
public abstract String getImageFilenameWithExtension(int index);
|
||||
|
||||
public abstract boolean save(int index, @NonNull UniFile file);
|
||||
abstract fun getImageFilenameWithExtension(index: Int): String
|
||||
abstract fun save(index: Int, file: UniFile): Boolean
|
||||
|
||||
/**
|
||||
* @param filename without extension
|
||||
*/
|
||||
@Nullable
|
||||
public abstract UniFile save(int index, @NonNull UniFile dir, @NonNull String filename);
|
||||
abstract fun save(index: Int, dir: UniFile, filename: String): UniFile?
|
||||
}
|
||||
|
||||
val SUPPORT_IMAGE_EXTENSIONS = arrayOf(
|
||||
".jpg", // Joint Photographic Experts Group
|
||||
".png", // Portable Network Graphics
|
||||
".gif"
|
||||
)
|
||||
@@ -31,6 +31,7 @@ import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.coil.edit
|
||||
import com.hippo.ehviewer.coil.read
|
||||
import com.hippo.ehviewer.gallery.PageLoader2
|
||||
import com.hippo.ehviewer.gallery.SUPPORT_IMAGE_EXTENSIONS
|
||||
import com.hippo.image.Image.CloseableSource
|
||||
import com.hippo.unifile.RawFile
|
||||
import com.hippo.unifile.UniFile
|
||||
@@ -103,8 +104,8 @@ class SpiderDen(private val mGalleryInfo: GalleryInfo) {
|
||||
* @param extension with dot
|
||||
*/
|
||||
private fun fixExtension(extension: String): String {
|
||||
return extension.takeIf { PageLoader2.SUPPORT_IMAGE_EXTENSIONS.contains(it) }
|
||||
?: PageLoader2.SUPPORT_IMAGE_EXTENSIONS[0]
|
||||
return extension.takeIf { SUPPORT_IMAGE_EXTENSIONS.contains(it) }
|
||||
?: SUPPORT_IMAGE_EXTENSIONS[0]
|
||||
}
|
||||
|
||||
private fun copyFromCacheToDownloadDir(index: Int): Boolean {
|
||||
@@ -335,7 +336,7 @@ class SpiderDen(private val mGalleryInfo: GalleryInfo) {
|
||||
).build()
|
||||
}
|
||||
|
||||
private val COMPAT_IMAGE_EXTENSIONS = PageLoader2.SUPPORT_IMAGE_EXTENSIONS + ".jpeg"
|
||||
private val COMPAT_IMAGE_EXTENSIONS = SUPPORT_IMAGE_EXTENSIONS + ".jpeg"
|
||||
|
||||
fun getGalleryDownloadDir(gid: Long): UniFile? {
|
||||
val dir = Settings.getDownloadLocation()
|
||||
|
||||
Reference in new issue
Block a user