Changed to log fetchGallery exceptions
This commit is contained in:
@@ -57,9 +57,6 @@ dependencies {
|
|||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'androidx.preference:preference:1.1.0'
|
implementation 'androidx.preference:preference:1.1.0'
|
||||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
|
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
|
||||||
implementation "androidx.biometric:biometric:1.0.1"
|
implementation "androidx.biometric:biometric:1.0.1"
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||||
@@ -73,6 +70,8 @@ dependencies {
|
|||||||
implementation ("com.github.bumptech.glide:recyclerview-integration:4.10.0") {
|
implementation ("com.github.bumptech.glide:recyclerview-integration:4.10.0") {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
implementation 'net.rdrei.android.dirchooser:library:3.2@aar'
|
||||||
|
implementation 'com.gu:option:1.3'
|
||||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||||
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
|
implementation 'com.andrognito.patternlockview:patternlockview:1.0.0'
|
||||||
implementation "ru.noties.markwon:core:${markwonVersion}"
|
implementation "ru.noties.markwon:core:${markwonVersion}"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import androidx.preference.PreferenceManager
|
|||||||
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
|
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
|
||||||
import com.google.android.gms.common.GooglePlayServicesRepairableException
|
import com.google.android.gms.common.GooglePlayServicesRepairableException
|
||||||
import com.google.android.gms.security.ProviderInstaller
|
import com.google.android.gms.security.ProviderInstaller
|
||||||
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import xyz.quaver.pupil.util.Histories
|
import xyz.quaver.pupil.util.Histories
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -54,6 +55,9 @@ class Pupil : MultiDexApplication() {
|
|||||||
histories = Histories(File(ContextCompat.getDataDir(this), "histories.json"))
|
histories = Histories(File(ContextCompat.getDataDir(this), "histories.json"))
|
||||||
favorites = Histories(File(ContextCompat.getDataDir(this), "favorites.json"))
|
favorites = Histories(File(ContextCompat.getDataDir(this), "favorites.json"))
|
||||||
|
|
||||||
|
if (BuildConfig.DEBUG)
|
||||||
|
FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false)
|
||||||
|
|
||||||
val file = preference.getString("dl_location", null)
|
val file = preference.getString("dl_location", null)
|
||||||
|
|
||||||
if (file?.startsWith("content") == true)
|
if (file?.startsWith("content") == true)
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
|||||||
import com.arlib.floatingsearchview.FloatingSearchView
|
import com.arlib.floatingsearchview.FloatingSearchView
|
||||||
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion
|
import com.arlib.floatingsearchview.suggestions.model.SearchSuggestion
|
||||||
import com.arlib.floatingsearchview.util.view.SearchInputView
|
import com.arlib.floatingsearchview.util.view.SearchInputView
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
import com.google.android.material.appbar.AppBarLayout
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
|
import io.fabric.sdk.android.Fabric
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.activity_main_content.*
|
import kotlinx.android.synthetic.main.activity_main_content.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@@ -1004,9 +1006,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val perPage = preference.getString("per_page", "25")?.toInt() ?: 25
|
val perPage = preference.getString("per_page", "25")?.toInt() ?: 25
|
||||||
|
|
||||||
loadingJob = CoroutineScope(Dispatchers.IO).launch {
|
loadingJob = CoroutineScope(Dispatchers.IO).launch {
|
||||||
val galleryIDs = galleryIDs?.await()
|
val galleryIDs = try {
|
||||||
|
galleryIDs!!.await()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
|
||||||
|
if (Fabric.isInitialized())
|
||||||
|
Crashlytics.logException(e)
|
||||||
|
|
||||||
if (galleryIDs.isNullOrEmpty()) { //No result
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
main_noresult.visibility = View.VISIBLE
|
main_noresult.visibility = View.VISIBLE
|
||||||
main_progressbar.hide()
|
main_progressbar.hide()
|
||||||
|
|||||||
@@ -34,35 +34,31 @@ fun fetchNozomi(area: String? = null, tag: String = "index", language: String =
|
|||||||
else -> "$protocol//$domain/$area/$tag-$language$nozomiextension"
|
else -> "$protocol//$domain/$area/$tag-$language$nozomiextension"
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
with(URL(url).openConnection() as HttpsURLConnection) {
|
||||||
with(URL(url).openConnection() as HttpsURLConnection) {
|
requestMethod = "GET"
|
||||||
requestMethod = "GET"
|
|
||||||
|
|
||||||
if (start != -1 && count != -1) {
|
if (start != -1 && count != -1) {
|
||||||
val startByte = start*4
|
val startByte = start*4
|
||||||
val endByte = (start+count)*4-1
|
val endByte = (start+count)*4-1
|
||||||
|
|
||||||
setRequestProperty("Range", "bytes=$startByte-$endByte")
|
setRequestProperty("Range", "bytes=$startByte-$endByte")
|
||||||
}
|
|
||||||
|
|
||||||
connect()
|
|
||||||
|
|
||||||
val totalItems = getHeaderField("Content-Range")
|
|
||||||
.replace(Regex("^[Bb]ytes \\d+-\\d+/"), "").toInt() / 4
|
|
||||||
|
|
||||||
val nozomi = ArrayList<Int>()
|
|
||||||
|
|
||||||
val arrayBuffer = ByteBuffer
|
|
||||||
.wrap(inputStream.readBytes())
|
|
||||||
.order(ByteOrder.BIG_ENDIAN)
|
|
||||||
|
|
||||||
while (arrayBuffer.hasRemaining())
|
|
||||||
nozomi.add(arrayBuffer.int)
|
|
||||||
|
|
||||||
return Pair(nozomi, totalItems)
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
return Pair(emptyList(), 0)
|
connect()
|
||||||
|
|
||||||
|
val totalItems = getHeaderField("Content-Range")
|
||||||
|
.replace(Regex("^[Bb]ytes \\d+-\\d+/"), "").toInt() / 4
|
||||||
|
|
||||||
|
val nozomi = ArrayList<Int>()
|
||||||
|
|
||||||
|
val arrayBuffer = ByteBuffer
|
||||||
|
.wrap(inputStream.readBytes())
|
||||||
|
.order(ByteOrder.BIG_ENDIAN)
|
||||||
|
|
||||||
|
while (arrayBuffer.hasRemaining())
|
||||||
|
nozomi.add(arrayBuffer.int)
|
||||||
|
|
||||||
|
return Pair(nozomi, totalItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,30 +78,26 @@ data class GalleryBlock(
|
|||||||
fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
|
fun getGalleryBlock(galleryID: Int) : GalleryBlock? {
|
||||||
val url = "$protocol//$domain/$galleryblockdir/$galleryID$extension"
|
val url = "$protocol//$domain/$galleryblockdir/$galleryID$extension"
|
||||||
|
|
||||||
try {
|
val doc = Jsoup.connect(url).get()
|
||||||
val doc = Jsoup.connect(url).get()
|
|
||||||
|
|
||||||
val galleryUrl = doc.selectFirst(".lillie").attr("href")
|
val galleryUrl = doc.selectFirst(".lillie").attr("href")
|
||||||
|
|
||||||
val thumbnails = doc.select("img").map { protocol + it.attr("data-src") }
|
val thumbnails = doc.select("img").map { protocol + it.attr("data-src") }
|
||||||
|
|
||||||
val title = doc.selectFirst("h1.lillie > a").text()
|
val title = doc.selectFirst("h1.lillie > a").text()
|
||||||
val artists = doc.select("div.artist-list a").map{ it.text() }
|
val artists = doc.select("div.artist-list a").map{ it.text() }
|
||||||
val series = doc.select("a[href~=^/series/]").map { it.text() }
|
val series = doc.select("a[href~=^/series/]").map { it.text() }
|
||||||
val type = doc.selectFirst("a[href~=^/type/]").text()
|
val type = doc.selectFirst("a[href~=^/type/]").text()
|
||||||
|
|
||||||
val language = {
|
val language = {
|
||||||
val href = doc.select("a[href~=^/index-.+-1.html]").attr("href")
|
val href = doc.select("a[href~=^/index-.+-1.html]").attr("href")
|
||||||
href.slice(7 until href.indexOf("-1"))
|
href.slice(7 until href.indexOf("-1"))
|
||||||
}.invoke()
|
}.invoke()
|
||||||
|
|
||||||
val relatedTags = doc.select(".relatedtags a").map {
|
val relatedTags = doc.select(".relatedtags a").map {
|
||||||
val href = URLDecoder.decode(it.attr("href"), "UTF-8")
|
val href = URLDecoder.decode(it.attr("href"), "UTF-8")
|
||||||
href.slice(5 until href.indexOf("-all"))
|
href.slice(5 until href.indexOf("-all"))
|
||||||
}
|
|
||||||
|
|
||||||
return GalleryBlock(Code.HITOMI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return GalleryBlock(Code.HITOMI, galleryID, galleryUrl, thumbnails, title, artists, series, type, language, relatedTags)
|
||||||
}
|
}
|
||||||
@@ -173,22 +173,18 @@ fun getGalleryIDsFromNozomi(area: String?, tag: String, language: String) : List
|
|||||||
else -> "$protocol//$domain/$compressed_nozomi_prefix/$area/$tag-$language$nozomiextension"
|
else -> "$protocol//$domain/$compressed_nozomi_prefix/$area/$tag-$language$nozomiextension"
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
val bytes = URL(nozomiAddress).readBytes()
|
||||||
val bytes = URL(nozomiAddress).readBytes()
|
|
||||||
|
|
||||||
val nozomi = ArrayList<Int>()
|
val nozomi = ArrayList<Int>()
|
||||||
|
|
||||||
val arrayBuffer = ByteBuffer
|
val arrayBuffer = ByteBuffer
|
||||||
.wrap(bytes)
|
.wrap(bytes)
|
||||||
.order(ByteOrder.BIG_ENDIAN)
|
.order(ByteOrder.BIG_ENDIAN)
|
||||||
|
|
||||||
while (arrayBuffer.hasRemaining())
|
while (arrayBuffer.hasRemaining())
|
||||||
nozomi.add(arrayBuffer.int)
|
nozomi.add(arrayBuffer.int)
|
||||||
|
|
||||||
return nozomi
|
return nozomi
|
||||||
} catch (e: Exception) {
|
|
||||||
return emptyList()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGalleryIDsFromData(data: Pair<Long, Int>) : List<Int> {
|
fun getGalleryIDsFromData(data: Pair<Long, Int>) : List<Int> {
|
||||||
|
|||||||
Reference in New Issue
Block a user