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:
parent
eed44b3231
commit
ad605e2c5a
3 changed files with 5 additions and 4 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue