1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Fix crash on startup caused by no implementation of onError() method

This commit is contained in:
TobiGr 2020-11-22 11:46:19 +01:00
parent 17866c29ae
commit fd4c37e9b3

View File

@ -198,24 +198,36 @@ public final class CheckForNewAppVersion {
}) })
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(response -> { .subscribe(
// Parse the json from the response. response -> {
try { // Parse the json from the response.
final JsonObject githubStableObject = JsonParser.object().from(response) try {
.getObject("flavors").getObject("github").getObject("stable"); final JsonObject githubStableObject = JsonParser.object()
.from(response).getObject("flavors").getObject("github")
.getObject("stable");
final String versionName = githubStableObject.getString("version"); final String versionName = githubStableObject
final int versionCode = githubStableObject.getInt("version_code"); .getString("version");
final String apkLocationUrl = githubStableObject.getString("apk"); final int versionCode = githubStableObject
.getInt("version_code");
final String apkLocationUrl = githubStableObject
.getString("apk");
compareAppVersionAndShowNotification(app, versionName, apkLocationUrl, compareAppVersionAndShowNotification(app, versionName,
versionCode); apkLocationUrl, versionCode);
} catch (final JsonParserException e) { } catch (final JsonParserException e) {
// connectivity problems, do not alarm user and fail silently // connectivity problems, do not alarm user and fail silently
if (DEBUG) { if (DEBUG) {
Log.w(TAG, Log.getStackTraceString(e)); Log.w(TAG, Log.getStackTraceString(e));
} }
} }
}); },
throwable -> {
// connectivity problems, do not alarm user and fail silently
if (DEBUG) {
Log.i(TAG, "Could not get NewPipe API: network problem");
Log.i(TAG, Log.getStackTraceString(throwable));
}
});
} }
} }