Fix tab handling and enable ignored tests again#2742
Conversation
Does this imply that now when the user changes i.e. the language, the views do not reload? |
Do you mean changes like language of the phone? If you are referring to this, yes, the fragments will reload like any other in the app. Android will recreate and give the correct resources when the fragment is starting up again. But if you meant the language that is the settings of the app, no, it will not because there is no check to see if it changed or anything. Notice that this isn't the result of this PR, it doesn't work in the current version either. This is a flaw in the current design, things are mixed up in the fragment and the layers (view, data source) are not separated optimally. And speaking of the language selector, it was decided that pages will be fetched only in english (or whatever the service offer by default), as we don't have to take in account every little change when parsing the page. The content country selector is very useful though. I will push a commit fixing that in a second. |
|
OK, thank you |
app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Looks good to me. There are only two things:
- Can you please rebase and address my comment above?
- Unfortunately you cause a NPE when loading a soundcloud kiosk page which has not the current
kioskId. No error with mediaCCC. This does not happen with 0.17.4
Exception
- User Action: requested kiosk
- Request: https://soundcloud.com/charts/new
- Content Language: GB
- Service: SoundCloud
- Version: 0.17.3
- OS: Linux ,release-keys 6.0 - 23
Crash log
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.jsoup.nodes.Element.attr(java.lang.String)' on a null object reference
at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.clientId(SoundcloudParsingHelper.java:49)
at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudChartsExtractor.computNextPageAndStreams(SoundcloudChartsExtractor.java:56)
at org.schabi.newpipe.extractor.services.soundcloud.SoundcloudChartsExtractor.getInitialPage(SoundcloudChartsExtractor.java:85)
at org.schabi.newpipe.extractor.utils.ExtractorHelper.getItemsPageOrLogError(ExtractorHelper.java:20)
at org.schabi.newpipe.extractor.kiosk.KioskInfo.getInfo(KioskInfo.java:69)
at org.schabi.newpipe.extractor.kiosk.KioskInfo.getInfo(KioskInfo.java:55)
at org.schabi.newpipe.util.ExtractorHelper.lambda$getKioskInfo$10(ExtractorHelper.java:170)
at org.schabi.newpipe.util.-$$Lambda$ExtractorHelper$TneUC77tEl15twhVz-_2huMZ3Ck.call(lambda)
at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
at io.reactivex.Single.subscribe(Single.java:3438)
at io.reactivex.internal.operators.single.SingleDoOnSuccess.subscribeActual(SingleDoOnSuccess.java:35)
at io.reactivex.Single.subscribe(Single.java:3438)
at io.reactivex.internal.operators.maybe.MaybeFromSingle.subscribeActual(MaybeFromSingle.java:41)
at io.reactivex.Maybe.subscribe(Maybe.java:4154)
at io.reactivex.internal.operators.maybe.MaybeConcatArray$ConcatMaybeObserver.drain(MaybeConcatArray.java:153)
at io.reactivex.internal.operators.maybe.MaybeConcatArray$ConcatMaybeObserver.request(MaybeConcatArray.java:78)
at io.reactivex.internal.operators.flowable.FlowableElementAtMaybe$ElementAtSubscriber.onSubscribe(FlowableElementAtMaybe.java:66)
at io.reactivex.internal.operators.maybe.MaybeConcatArray.subscribeActual(MaybeConcatArray.java:42)
at io.reactivex.Flowable.subscribe(Flowable.java:14479)
at io.reactivex.internal.operators.flowable.FlowableElementAtMaybe.subscribeActual(FlowableElementAtMaybe.java:36)
at io.reactivex.Maybe.subscribe(Maybe.java:4154)
at io.reactivex.internal.operators.maybe.MaybeToSingle.subscribeActual(MaybeToSingle.java:46)
at io.reactivex.Single.subscribe(Single.java:3438)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
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:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
- Fix typo in a string resource - Reorder tabs so the default kiosk is on top of the others
- Fragments were being recreated from scratch (losing their state) every time some configuration change occurred (e.g. screen rotation). - Use `FragmentStatePagerAdapter` instead, as it is built to work with them and manage their states.
101f3be to
bc283bc
Compare
The stack trace points to the client id extraction function of the SoundCloud extractor, leading to where the problem is: this branch is outdated so it's still using an old version of the extractor (also in the crash report:
Done, fixes the other issue as well. |
All right, my bad.
Perfect |
Was testing some other PRs and noticed that the main fragment had some problems, the most important one being the way the view pager was being handled.
FragmentStatePagerAdapterinstead, as it is built to work with them and manage their states.KioskFragmentaware of changes in the preferred content country.