Add hiyobi image booster
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
package xyz.quaver.pupil
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.preference.PreferenceManager
|
||||
import kotlinx.android.synthetic.main.activity_gallery.*
|
||||
import kotlinx.coroutines.*
|
||||
import xyz.quaver.hitomi.Reader
|
||||
import xyz.quaver.hitomi.getReader
|
||||
import xyz.quaver.hitomi.getReferer
|
||||
import xyz.quaver.hiyobi.hiyobi
|
||||
import xyz.quaver.pupil.adapters.GalleryAdapter
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.lang.Exception
|
||||
import java.net.URL
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
|
||||
@@ -32,9 +36,20 @@ class GalleryActivity : AppCompatActivity() {
|
||||
|
||||
setContentView(R.layout.activity_gallery)
|
||||
|
||||
supportActionBar?.title = intent.getStringExtra("GALLERY_TITLE")
|
||||
|
||||
galleryID = intent.getIntExtra("GALLERY_ID", 0)
|
||||
CoroutineScope(Dispatchers.Unconfined).launch {
|
||||
reader = async(Dispatchers.IO) {
|
||||
val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryActivity)
|
||||
if (preference.getBoolean("use_hiyobi", false)) {
|
||||
try {
|
||||
xyz.quaver.hiyobi.getReader(galleryID)
|
||||
Log.d("Pupil", "Using Hiyobi.me")
|
||||
} catch (e: Exception) {
|
||||
getReader(galleryID)
|
||||
}
|
||||
}
|
||||
getReader(galleryID)
|
||||
}
|
||||
}
|
||||
@@ -78,17 +93,15 @@ class GalleryActivity : AppCompatActivity() {
|
||||
val reader = reader.await()
|
||||
|
||||
launch(Dispatchers.Main) {
|
||||
supportActionBar?.title = reader.title
|
||||
|
||||
with(gallery_progressbar) {
|
||||
max = reader.images.size
|
||||
max = reader.size
|
||||
progress = 0
|
||||
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
reader.images.chunked(8).forEach { chunked ->
|
||||
reader.chunked(8).forEach { chunked ->
|
||||
chunked.map {
|
||||
async(Dispatchers.IO) {
|
||||
val url = if (it.second?.haswebp == 1) webpUrlFromUrl(it.first) else it.first
|
||||
|
||||
@@ -176,9 +176,10 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun setupRecyclerView() {
|
||||
with(main_recyclerview) {
|
||||
adapter = GalleryBlockAdapter(galleries).apply {
|
||||
setClickListener {
|
||||
setClickListener { galleryID, title ->
|
||||
val intent = Intent(this@MainActivity, GalleryActivity::class.java)
|
||||
intent.putExtra("GALLERY_ID", it)
|
||||
intent.putExtra("GALLERY_ID", galleryID)
|
||||
intent.putExtra("GALLERY_TITLE", title)
|
||||
|
||||
//TODO: Maybe sprinke some transitions will be nice :D
|
||||
startActivity(intent)
|
||||
|
||||
@@ -33,8 +33,8 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Bitmap?
|
||||
class ViewHolder(val view: CardView) : RecyclerView.ViewHolder(view)
|
||||
class ProgressViewHolder(view: LinearLayout) : RecyclerView.ViewHolder(view)
|
||||
|
||||
private var callback: ((Int) -> Unit)? = null
|
||||
fun setClickListener(callback: ((Int) -> Unit)?) {
|
||||
private var callback: ((Int, String) -> Unit)? = null
|
||||
fun setClickListener(callback: ((Int, String) -> Unit)?) {
|
||||
this.callback = callback
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class GalleryBlockAdapter(private val galleries: List<Pair<GalleryBlock, Bitmap?
|
||||
val series = gallery.series.ifEmpty { listOf("N/A") }
|
||||
|
||||
setOnClickListener {
|
||||
callback?.invoke(gallery.id)
|
||||
callback?.invoke(gallery.id, gallery.title)
|
||||
}
|
||||
|
||||
galleryblock_thumbnail.setImageBitmap(thumbnail)
|
||||
|
||||
Reference in New Issue
Block a user