[Ru] Remanga. Fix paid manga pages with parallel requests (#4568)
[Ru] Remanga. Fix paid manga pages with parallel requests
This commit is contained in:
		
							parent
							
								
									3fa83fe574
								
							
						
					
					
						commit
						e05cea22d3
					
				@ -5,7 +5,7 @@ ext {
 | 
			
		||||
    extName = 'Remanga'
 | 
			
		||||
    pkgNameSuffix = 'ru.remanga'
 | 
			
		||||
    extClass = '.Remanga'
 | 
			
		||||
    extVersionCode = 7
 | 
			
		||||
    extVersionCode = 8
 | 
			
		||||
    libVersion = '1.2'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -40,8 +40,6 @@ import eu.kanade.tachiyomi.source.model.Page
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.SChapter
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.SManga
 | 
			
		||||
import eu.kanade.tachiyomi.source.online.HttpSource
 | 
			
		||||
import okhttp3.Call
 | 
			
		||||
import okhttp3.Callback
 | 
			
		||||
import okhttp3.Headers
 | 
			
		||||
import okhttp3.HttpUrl
 | 
			
		||||
import okhttp3.Interceptor
 | 
			
		||||
@ -56,7 +54,6 @@ import rx.Observable
 | 
			
		||||
import uy.kohesive.injekt.Injekt
 | 
			
		||||
import uy.kohesive.injekt.api.get
 | 
			
		||||
import java.io.ByteArrayOutputStream
 | 
			
		||||
import java.io.IOException
 | 
			
		||||
import java.text.SimpleDateFormat
 | 
			
		||||
import java.util.Date
 | 
			
		||||
import java.util.Locale
 | 
			
		||||
@ -345,28 +342,11 @@ class Remanga : ConfigurableSource, HttpSource() {
 | 
			
		||||
        val cs = Bitmap.createBitmap(b.width, b.height * pages.size, Bitmap.Config.ARGB_8888)
 | 
			
		||||
        val comboImage = Canvas(cs)
 | 
			
		||||
        comboImage.drawBitmap(b, 0f, 0f, null)
 | 
			
		||||
        var completeSize = pages.size - 2
 | 
			
		||||
        for (i in 1 until pages.size) {
 | 
			
		||||
            client.newCall(GET(pages[i], refererHeaders)).enqueue(
 | 
			
		||||
                object : Callback {
 | 
			
		||||
                    override fun onResponse(call: Call, response: Response) {
 | 
			
		||||
                        val bytes = response.body()!!.bytes()
 | 
			
		||||
 | 
			
		||||
                        val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
 | 
			
		||||
                        comboImage.drawBitmap(bitmap, 0f, (b.height * i).toFloat(), null)
 | 
			
		||||
                        completeSize -= 1
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    override fun onFailure(call: Call, e: IOException) {
 | 
			
		||||
                        throw e
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            )
 | 
			
		||||
            val bytes = client.newCall(GET(pages[i], refererHeaders)).execute().body()!!.bytes()
 | 
			
		||||
            val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
 | 
			
		||||
            comboImage.drawBitmap(bitmap, 0f, (b.height * i).toFloat(), null)
 | 
			
		||||
        }
 | 
			
		||||
        while (completeSize > 0) {
 | 
			
		||||
            Thread.sleep(100)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val output = ByteArrayOutputStream()
 | 
			
		||||
        cs.compress(Bitmap.CompressFormat.PNG, 100, output)
 | 
			
		||||
        return Base64.encodeToString(output.toByteArray(), Base64.DEFAULT)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user