mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	| @@ -246,28 +246,30 @@ class WebtoonPageHolder( | ||||
|         unsubscribeReadImageHeader() | ||||
|         val streamFn = page?.stream ?: return | ||||
|  | ||||
|         var openStream: InputStream? = null | ||||
|         readImageHeaderSubscription = Observable | ||||
|             .fromCallable { | ||||
|                 val stream = streamFn().buffered(16) | ||||
|                 val imageStream = process(stream) | ||||
|                 val isAnimated = ImageUtil.isAnimatedAndSupported(stream) | ||||
|                 Pair(imageStream, isAnimated) | ||||
|                 openStream = process(stream) | ||||
|  | ||||
|                 ImageUtil.isAnimatedAndSupported(stream) | ||||
|             } | ||||
|             .subscribeOn(Schedulers.io()) | ||||
|             .observeOn(AndroidSchedulers.mainThread()) | ||||
|             .doOnNext { (imageStream, isAnimated) -> | ||||
|                 imageStream.use { | ||||
|                     frame.setImage( | ||||
|                         it, | ||||
|                         isAnimated, | ||||
|                         ReaderPageImageView.Config( | ||||
|                             zoomDuration = viewer.config.doubleTapAnimDuration, | ||||
|                             minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH, | ||||
|                             cropBorders = viewer.config.imageCropBorders, | ||||
|                         ), | ||||
|                     ) | ||||
|                 } | ||||
|             .doOnNext { isAnimated -> | ||||
|                 frame.setImage( | ||||
|                     openStream!!, | ||||
|                     isAnimated, | ||||
|                     ReaderPageImageView.Config( | ||||
|                         zoomDuration = viewer.config.doubleTapAnimDuration, | ||||
|                         minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH, | ||||
|                         cropBorders = viewer.config.imageCropBorders, | ||||
|                     ), | ||||
|                 ) | ||||
|             } | ||||
|             // Keep the Rx stream alive to close the input stream only when unsubscribed | ||||
|             .flatMap { Observable.never<Unit>() } | ||||
|             .doOnUnsubscribe { openStream?.close() } | ||||
|             .subscribe({}, {}) | ||||
|  | ||||
|         addSubscription(readImageHeaderSubscription) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user