mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-15 02:18:04 -04:00
#2385 Online Library is just loading and loading - make serialiser strict
This commit is contained in:
parent
17b71ab75c
commit
cdcc45cf92
@ -73,7 +73,6 @@ import org.kiwix.kiwixmobile.zim_manager.library_view.adapter.LibraryListItem.Li
|
|||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||||
import java.util.concurrent.TimeUnit.SECONDS
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ZimManageViewModel @Inject constructor(
|
class ZimManageViewModel @Inject constructor(
|
||||||
@ -218,18 +217,15 @@ class ZimManageViewModel @Inject constructor(
|
|||||||
connectivityBroadcastReceiver.networkStates.distinctUntilChanged().filter(
|
connectivityBroadcastReceiver.networkStates.distinctUntilChanged().filter(
|
||||||
CONNECTED::equals
|
CONNECTED::equals
|
||||||
),
|
),
|
||||||
BiFunction<Unit, NetworkState, Unit> { _, _ -> Unit }
|
BiFunction<Unit, NetworkState, Unit> { _, _ -> }
|
||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{
|
{
|
||||||
kiwixService.library
|
kiwixService.library
|
||||||
.timeout(60, SECONDS)
|
|
||||||
.retry(5)
|
.retry(5)
|
||||||
.subscribe(
|
.subscribe(library::onNext) {
|
||||||
library::onNext
|
|
||||||
) {
|
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
|
library.onNext(LibraryNetworkEntity().apply { book = LinkedList() })
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,19 @@ import javax.inject.Singleton
|
|||||||
|
|
||||||
private const val CONNECTION_TIMEOUT = 10L
|
private const val CONNECTION_TIMEOUT = 10L
|
||||||
private const val READ_TIMEOUT = 60L
|
private const val READ_TIMEOUT = 60L
|
||||||
|
private const val CALL_TIMEOUT = 60L
|
||||||
private const val USER_AGENT = "kiwix-android-version:${BuildConfig.VERSION_CODE}"
|
private const val USER_AGENT = "kiwix-android-version:${BuildConfig.VERSION_CODE}"
|
||||||
private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/"
|
private const val KIWIX_DOWNLOAD_URL = "http://mirror.download.kiwix.org/"
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
class NetworkModule {
|
class NetworkModule {
|
||||||
@Provides @Singleton fun provideOkHttpClient(): OkHttpClient {
|
@Provides @Singleton fun provideOkHttpClient(): OkHttpClient {
|
||||||
return OkHttpClient().newBuilder().followRedirects(true).followSslRedirects(true)
|
return OkHttpClient().newBuilder()
|
||||||
|
.followRedirects(true)
|
||||||
|
.followSslRedirects(true)
|
||||||
.connectTimeout(CONNECTION_TIMEOUT, SECONDS)
|
.connectTimeout(CONNECTION_TIMEOUT, SECONDS)
|
||||||
.readTimeout(READ_TIMEOUT, SECONDS)
|
.readTimeout(READ_TIMEOUT, SECONDS)
|
||||||
|
.callTimeout(CALL_TIMEOUT, SECONDS)
|
||||||
.addNetworkInterceptor(HttpLoggingInterceptor().apply {
|
.addNetworkInterceptor(HttpLoggingInterceptor().apply {
|
||||||
level = if (BuildConfig.DEBUG) BASIC else NONE
|
level = if (BuildConfig.DEBUG) BASIC else NONE
|
||||||
})
|
})
|
||||||
|
@ -25,7 +25,7 @@ import org.simpleframework.xml.Attribute;
|
|||||||
import org.simpleframework.xml.ElementList;
|
import org.simpleframework.xml.ElementList;
|
||||||
import org.simpleframework.xml.Root;
|
import org.simpleframework.xml.Root;
|
||||||
|
|
||||||
@Root(name = "library", strict = false)
|
@Root(name = "library")
|
||||||
public class LibraryNetworkEntity {
|
public class LibraryNetworkEntity {
|
||||||
|
|
||||||
@ElementList(name = "book", inline = true, required = false)
|
@ElementList(name = "book", inline = true, required = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user