1
0
Fork 0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2025-10-05 10:49:26 +02:00

Actually there is no need to use flatMap

`null` values returned in the lambda are converted to empty `Optional`s in the `map` method: https://developer.android.com/reference/java/util/Optional#map(java.util.function.Function%3C?%20super%20T,%20?%20extends%20U%3E)
This commit is contained in:
Stypox 2023-01-11 15:26:46 +01:00
parent eed44b3231
commit ad605e2c5a
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
3 changed files with 5 additions and 4 deletions

View file

@ -87,6 +87,7 @@ import org.schabi.newpipe.util.urlfinder.UrlFinder;
import org.schabi.newpipe.views.FocusOverlayView;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
@ -748,7 +749,7 @@ public class RouterActivity extends AppCompatActivity {
*/
private Optional<AppCompatActivity> getActivityContext() {
return Optional.ofNullable(weakContext)
.flatMap(context -> Optional.ofNullable(context.get()))
.map(Reference::get)
.filter(context -> !context.isFinishing());
}