我的API 响应具有以下模型:
@Entity(tableName = TABLE_NAME)
class WeatherEntry {
@PrimaryKey(autoGenerate = true)
var wID: Long? = null
@SerializedName("dt")
@ColumnInfo(name = COLUMN_DATE)
var date: String = ""
@SerializedName("city")
@Embedded(prefix = "location_")
var location: Location? = null
@SerializedName("main")
@Embedded(prefix = "main_")
var main: Main? = null
@SerializedName("weather")
@TypeConverters(Converters::class)
@Embedded(prefix = "weather_")
var weather: ArrayList<Weather>? = null
@SerializedName("wind")
@Embedded(prefix = "wind_")
var wind: Wind? = null
}
Run Code Online (Sandbox Code Playgroud)
Weather Repo
从本地或远程数据源获取数据,我设置forceRemote为true,否则一开始就不会显示数据。
class WeatherRepository @Inject constructor(@Local var localDataSource: WeatherDataSource, @Remote …Run Code Online (Sandbox Code Playgroud) 如果我的应用程序在获取新的redditNews时更改了设备的方向,则会出现以下错误.
E/AndroidRuntime: FATAL EXCEPTION: RxCachedThreadScheduler-1
Process: com.spicywdev.schmeddit, PID: 26522
io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | null
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
at io.reactivex.internal.operators.observable.ObservableCreate$CreateEmitter.onError(ObservableCreate.java:73)
at io.reactivex.internal.operators.observable.ObservableCreate.subscribeActual(ObservableCreate.java:43)
at io.reactivex.Observable.subscribe(Observable.java:12090)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.io.InterruptedIOException
at okhttp3.internal.http2.Http2Stream.waitForIo(Http2Stream.java:579)
at okhttp3.internal.http2.Http2Stream.takeResponseHeaders(Http2Stream.java:143)
at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:125)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) …Run Code Online (Sandbox Code Playgroud)