public class

NoOpNavigator

extends Navigator<NavDestination>

 java.lang.Object

androidx.navigation.Navigator<NavDestination>

↳androidx.navigation.NoOpNavigator

Overview

A Navigator that only supports creating destinations.

Summary

Constructors
publicNoOpNavigator()

Methods
public abstract NavDestinationcreateDestination()

Construct a new NavDestination associated with this Navigator.

public abstract NavDestinationnavigate(NavDestination destination, Bundle args, NavOptions navOptions, Navigator.Extras navigatorExtras)

Navigate to a destination.

public abstract booleanpopBackStack()

Attempt to pop this navigator's back stack, performing the appropriate navigation.

from Navigator<D>onRestoreState, onSaveState
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public NoOpNavigator()

Methods

public abstract NavDestination createDestination()

Construct a new NavDestination associated with this Navigator.

Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.

Returns:

a new NavDestination

public abstract NavDestination navigate(NavDestination destination, Bundle args, NavOptions navOptions, Navigator.Extras navigatorExtras)

Navigate to a destination.

Requests navigation to a given destination associated with this navigator in the navigation graph. This method generally should not be called directly; NavController will delegate to it when appropriate.

Parameters:

destination: destination node to navigate to
args: arguments to use for navigation
navOptions: additional options for navigation
navigatorExtras: extras unique to your Navigator.

Returns:

The NavDestination that should be added to the back stack or null if no change was made to the back stack (i.e., in cases of single top operations where the destination is already on top of the back stack).

public abstract boolean popBackStack()

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Implementations should return true if navigation was successful. Implementations should return false if navigation could not be performed, for example if the navigator's back stack was empty.

Returns:

true if pop was successful

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.navigation;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

/**
 * A {@link Navigator} that only supports creating destinations.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Navigator.Name("NoOp")
public class NoOpNavigator extends Navigator<NavDestination> {
    @NonNull
    @Override
    public NavDestination createDestination() {
        return new NavDestination(this);
    }

    @Nullable
    @Override
    public NavDestination navigate(@NonNull NavDestination destination, @Nullable Bundle args,
            @Nullable NavOptions navOptions, @Nullable Extras navigatorExtras) {
        return destination;
    }

    @Override
    public boolean popBackStack() {
        return true;
    }
}