android.support.annotation.IdRes Java Examples

The following examples show how to use android.support.annotation.IdRes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: BmapLite   Author: gfuil   File: SettingActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
    ConfigInteracter interacter = new ConfigInteracter(this);
    if (group.getId() == R.id.group_zoom) {
        if (checkedId == R.id.radio_zoom_left) {
            interacter.setZoomControlsPosition(false);
        } else if (checkedId == R.id.radio_zoom_right) {
            interacter.setZoomControlsPosition(true);
        }
    } else if (group.getId() == R.id.group_mode) {
        if (checkedId == R.id.radio_white) {
            interacter.setNightMode(1);
        } else if (checkedId == R.id.radio_black) {
            if (BApp.TYPE_MAP == TypeMap.TYPE_BAIDU) {
                Toast.makeText(this, "夜间模式下百度地图可能需要重启应用后生效", Toast.LENGTH_LONG).show();
            }
            interacter.setNightMode(2);
        } else {
            interacter.setNightMode(0);
        }
        ((BApp) getApplication()).setNightMode();
    }

}
 
Example #2
Source Project: android_9.0.0_r45   Author: lulululbj   File: BaseNavControllerTest.java    License: Apache License 2.0 6 votes vote down vote up
private void assertDeeplink(@IdRes int destId, int expectedStackSize) throws Throwable {
    BaseNavigationActivity activity = launchDeepLink(R.navigation.nav_deep_link,
            destId, null);
    NavController navController = activity.getNavController();

    assertThat(navController.getCurrentDestination().getId(), is(destId));
    TestNavigator navigator = navController.getNavigatorProvider()
            .getNavigator(TestNavigator.class);
    assertThat(navigator.mBackStack.size(), is(expectedStackSize));

    // Test that the deep link Intent was passed through even though we don't pass in any args
    //noinspection ConstantConditions
    Intent deepLinkIntent = navigator.mBackStack.peekLast().second
            .getParcelable(NavController.KEY_DEEP_LINK_INTENT);
    assertThat(deepLinkIntent, is(notNullValue(Intent.class)));
    assertThat(deepLinkIntent.getAction(), is(TEST_DEEP_LINK_ACTION));
}
 
Example #3
Source Project: android_9.0.0_r45   Author: lulululbj   File: BaseNavControllerTest.java    License: Apache License 2.0 6 votes vote down vote up
private void assertDeepLinkWithArgs(@IdRes int destId, int expectedStackSize) throws Throwable {
    Bundle args = new Bundle();
    args.putString(TEST_ARG, TEST_ARG_VALUE);
    BaseNavigationActivity activity = launchDeepLink(R.navigation.nav_deep_link,
            destId, args);
    NavController navController = activity.getNavController();

    assertThat(navController.getCurrentDestination().getId(), is(destId));
    TestNavigator navigator = navController.getNavigatorProvider()
            .getNavigator(TestNavigator.class);
    assertThat(navigator.mBackStack.size(), is(expectedStackSize));
    //noinspection ConstantConditions
    assertThat(navigator.mBackStack.peekLast().second.getString(TEST_ARG), is(TEST_ARG_VALUE));

    // Test that the deep link Intent was passed in alongside our args
    //noinspection ConstantConditions
    Intent deepLinkIntent = navigator.mBackStack.peekLast().second
            .getParcelable(NavController.KEY_DEEP_LINK_INTENT);
    assertThat(deepLinkIntent, is(notNullValue(Intent.class)));
    assertThat(deepLinkIntent.getAction(), is(TEST_DEEP_LINK_ACTION));
}
 
Example #4
Source Project: android_9.0.0_r45   Author: lulululbj   File: BaseNavControllerTest.java    License: Apache License 2.0 6 votes vote down vote up
private void assertUriDeepLink(String path, @IdRes int destId, int expectedStackSize)
        throws Throwable {
    Uri deepLinkUri = Uri.parse("http://www.example.com/" + path + "/" + TEST_ARG_VALUE);
    Intent intent = new Intent(Intent.ACTION_VIEW, deepLinkUri)
            .setComponent(new ComponentName(mInstrumentation.getContext(),
                    getActivityClass()))
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    BaseNavigationActivity activity = launchActivity(intent);
    NavController navController = activity.getNavController();
    navController.setGraph(R.navigation.nav_deep_link);

    assertThat(navController.getCurrentDestination().getId(), is(destId));
    TestNavigator navigator = navController.getNavigatorProvider()
            .getNavigator(TestNavigator.class);
    assertThat(navigator.mBackStack.size(), is(expectedStackSize));
    //noinspection ConstantConditions
    assertThat(navigator.mBackStack.peekLast().second.getString(TEST_ARG), is(TEST_ARG_VALUE));

    // Test that the deep link Intent was passed in alongside our args
    //noinspection ConstantConditions
    Intent deepLinkIntent = navigator.mBackStack.peekLast().second
            .getParcelable(NavController.KEY_DEEP_LINK_INTENT);
    assertThat(deepLinkIntent, is(notNullValue(Intent.class)));
    assertThat(deepLinkIntent.getData(), is(deepLinkUri));
}
 
Example #5
Source Project: android_9.0.0_r45   Author: lulululbj   File: BaseNavControllerTest.java    License: Apache License 2.0 6 votes vote down vote up
private BaseNavigationActivity launchDeepLink(@NavigationRes int graphId, @IdRes int destId,
        Bundle args) throws Throwable {
    TaskStackBuilder intents = new NavDeepLinkBuilder(mInstrumentation.getTargetContext())
            .setGraph(graphId)
            .setDestination(destId)
            .setArguments(args)
            .createTaskStackBuilder();
    Intent intent = intents.editIntentAt(0);
    intent.setAction(TEST_DEEP_LINK_ACTION);

    // Now launch the deeplink Intent
    BaseNavigationActivity deeplinkActivity = launchActivity(intent);
    NavController navController = deeplinkActivity.getNavController();
    navController.setGraph(graphId);

    return deeplinkActivity;
}
 
Example #6
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavGraph.java    License: Apache License 2.0 5 votes vote down vote up
NavDestination findNode(@IdRes int resid, boolean searchParents) {
    NavDestination destination = mNodes.get(resid);
    // Search the parent for the NavDestination if it is not a child of this navigation graph
    // and searchParents is true
    return destination != null
            ? destination
            : searchParents && getParent() != null ? getParent().findNode(resid) : null;
}
 
Example #7
Source Project: Focus   Author: ihewro   File: PostDetailView.java    License: GNU General Public License v3.0 5 votes vote down vote up
private <T extends View> T getChildView(@IdRes int viewId) {
    View childView = null;
    if (view == null) {
        childView = view.findViewById(viewId);
    }
    return (T) childView;
}
 
Example #8
Source Project: scene   Author: bytedance   File: NavigationSceneCompatUtility.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * use {@link #setupWithFragment(Fragment, Class, int)} instead
 */
@Deprecated
@NonNull
public static SceneDelegate setupWithFragment(@NonNull final Fragment fragment,
                                              @IdRes int containerId,
                                              @Nullable Bundle savedInstanceState,
                                              @NonNull Class<? extends Scene> rootScene,
                                              @Nullable Bundle bundle,
                                              boolean supportRestore) {
    return setupWithFragment(fragment, containerId, savedInstanceState,
            new NavigationSceneOptions(rootScene, bundle),
            null,
            supportRestore);
}
 
Example #9
Source Project: scene   Author: bytedance   File: NavigationSceneCompatUtility.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * use {@link #setupWithFragment(Fragment, Class, int)} instead
 */
@Deprecated
@NonNull
public static SceneDelegate setupWithFragment(@NonNull final Fragment fragment,
                                              @IdRes int containerId,
                                              @Nullable Bundle savedInstanceState,
                                              @NonNull NavigationSceneOptions navigationSceneOptions,
                                              @Nullable SceneComponentFactory rootSceneComponentFactory,
                                              final boolean supportRestore,
                                              @NonNull final String tag,
                                              final boolean immediate) {
    return setupWithFragment(fragment, containerId, navigationSceneOptions, rootSceneComponentFactory, supportRestore, tag, immediate);
}
 
Example #10
Source Project: scene   Author: bytedance   File: FragmentViewFinder.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public <T extends View> T requireViewById(@IdRes int viewId) {
    T view = mFragment.getView().findViewById(viewId);
    if (view == null) {
        try {
            String viewIdName = mFragment.getResources().getResourceName(viewId);
            throw new IllegalArgumentException(" " + viewIdName + " view not found");
        } catch (Resources.NotFoundException exception) {
            throw new IllegalArgumentException(" " + viewId + " view not found");
        }
    }
    return view;
}
 
Example #11
Source Project: scene   Author: bytedance   File: SceneLifecycleDispatcher.java    License: Apache License 2.0 5 votes vote down vote up
public SceneLifecycleDispatcher(@IdRes int sceneContainerViewId,
                                ViewFinder viewFinder,
                                T rootScene,
                                Scope.RootScopeFactory rootScopeFactory,
                                boolean supportRestore) {
    this.mSceneContainerViewId = sceneContainerViewId;
    this.mViewFinder = viewFinder;
    this.mScene = rootScene;
    this.mRootScopeFactory = rootScopeFactory;
    this.mSupportRestore = supportRestore;
}
 
Example #12
Source Project: scene   Author: bytedance   File: NavigationSceneUtility.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * use {@link #setupWithActivity(Activity, Class)} instead
 */
@Deprecated
@NonNull
public static SceneDelegate setupWithActivity(@NonNull final Activity activity,
                                              @IdRes int idRes,
                                              @Nullable Bundle savedInstanceState,
                                              @NonNull NavigationSceneOptions navigationSceneOptions,
                                              @Nullable SceneComponentFactory rootSceneComponentFactory,
                                              final boolean supportRestore) {
    return setupWithActivity(activity, idRes, savedInstanceState, navigationSceneOptions,
            rootSceneComponentFactory, supportRestore, LIFE_CYCLE_FRAGMENT_TAG, true);
}
 
Example #13
Source Project: android_9.0.0_r45   Author: lulululbj   File: Navigation.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create an {@link android.view.View.OnClickListener} for navigating
 * to a destination. This supports both navigating via an
 * {@link NavDestination#getAction(int) action} and directly navigating to a destination.
 *
 * @param resId an {@link NavDestination#getAction(int) action} id or a destination id to
 *              navigate to when the view is clicked
 * @param args arguments to pass to the final destination
 * @return a new click listener for setting on an arbitrary view
 */
@NonNull
public static View.OnClickListener createNavigateOnClickListener(@IdRes final int resId,
        @Nullable final Bundle args) {
    return new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            findNavController(view).navigate(resId, args);
        }
    };
}
 
Example #14
Source Project: scene   Author: bytedance   File: GroupSceneManager.java    License: Apache License 2.0 5 votes vote down vote up
MoveStateOperation(@NonNull Scene scene, @IdRes int viewId, @Nullable String tag, @NonNull State dstState, boolean forceShow, boolean forceHide, boolean forceRemove) {
    super(scene, dstState, forceShow, forceHide, forceRemove);
    if (forceShow && forceHide) {
        throw new IllegalArgumentException("cant forceShow with forceHide");
    }

    this.viewId = viewId;
    this.tag = tag;
    this.dstState = dstState;
}
 
Example #15
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavOptions.java    License: Apache License 2.0 5 votes vote down vote up
NavOptions(int launchMode, @IdRes int popUpTo, boolean popUpToInclusive,
        @AnimRes @AnimatorRes int enterAnim, @AnimRes @AnimatorRes int exitAnim,
        @AnimRes @AnimatorRes int popEnterAnim, @AnimRes @AnimatorRes int popExitAnim) {
    mLaunchMode = launchMode;
    mPopUpTo = popUpTo;
    mPopUpToInclusive = popUpToInclusive;
    mEnterAnim = enterAnim;
    mExitAnim = exitAnim;
    mPopEnterAnim = popEnterAnim;
    mPopExitAnim = popExitAnim;
}
 
Example #16
Source Project: AndroidWallet   Author: Cocos-BCX   File: ViewAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@BindingAdapter(value = {"onCheckedChangedCommand"}, requireAll = false)
public static void onCheckedChangedCommand(final RadioGroup radioGroup, final BindingCommand<String> bindingCommand) {
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
            bindingCommand.execute(radioButton.getText().toString());
        }
    });
}
 
Example #17
Source Project: SimpleAdapterDemo   Author: JustinRoom   File: BaseHeaderFooterAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public <V extends View> V findViewById(@IdRes int id) {
    View child = childrenCache.get(id);
    if (child == null) {
        child = itemView.findViewById(id);
        if (child != null)
            childrenCache.put(id, child);
    }
    return (V) child;
}
 
Example #18
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavDestination.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets a destination ID for an action ID.
 *
 * @param actionId action ID to bind
 * @param action action to associate with this action ID
 */
public void putAction(@IdRes int actionId, @NonNull NavAction action) {
    if (actionId == 0) {
        throw new IllegalArgumentException("Cannot have an action with actionId 0");
    }
    if (mActions == null) {
        mActions = new SparseArrayCompat<>();
    }
    mActions.put(actionId, action);
}
 
Example #19
Source Project: FloatWindow   Author: SunJenry   File: AbsFloatBase.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected <T extends View> T findView(@IdRes int id) {
    if (mInflate != null) {
        return (T) mInflate.findViewById(id);
    }
    return null;
}
 
Example #20
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavDeepLinkBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the destination id to deep link to.
 *
 * @param destId destination ID to deep link to.
 * @return this object for chaining
 */
@NonNull
public NavDeepLinkBuilder setDestination(@IdRes int destId) {
    mDestId = destId;
    if (mGraph != null) {
        fillInIntent();
    }
    return this;
}
 
Example #21
Source Project: SimpleAdapterDemo   Author: JustinRoom   File: BaseHeaderFooterAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public BaseViewHolder setCompoundDrawables(@IdRes int id,
                                           @Nullable Drawable left,
                                           @Nullable Drawable top,
                                           @Nullable Drawable right,
                                           @Nullable Drawable bottom) {
    View view = findViewById(id);
    if (view instanceof TextView)
        ((TextView) view).setCompoundDrawables(left, top, right, bottom);
    return this;
}
 
Example #22
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onNavigatorNavigated(@NonNull Navigator navigator, @IdRes int destId,
        @Navigator.BackStackEffect int backStackEffect) {
    if (destId != 0) {
        // First remove popped destinations off the back stack
        if (backStackEffect == Navigator.BACK_STACK_DESTINATION_POPPED) {
            while (!mBackStack.isEmpty()
                    && mBackStack.peekLast().getId() != destId) {
                mBackStack.removeLast();
            }
        }
        NavDestination newDest = findDestination(destId);
        if (newDest == null) {
            throw new IllegalArgumentException("Navigator " + navigator
                    + " reported navigation to unknown destination id "
                    + NavDestination.getDisplayName(mContext, destId));
        }
        if (backStackEffect == Navigator.BACK_STACK_DESTINATION_ADDED) {
            // Add the new destination to the back stack
            mBackStack.add(newDest);
        }
        // Don't dispatchOnNavigated if nothing changed
        if (backStackEffect != Navigator.BACK_STACK_UNCHANGED) {
            dispatchOnNavigated(newDest);
        }
    }
}
 
Example #23
Source Project: landlord_client   Author: GramYang   File: BaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 根据resid隐藏view
 */
protected void gone(@IdRes int... id) {
    if(id != null && id.length > 0) {
        for(int resId : id) {
            View view = findViewById(resId);
            if(view != null) gone(view);
        }
    }
}
 
Example #24
Source Project: android_9.0.0_r45   Author: lulululbj   File: FragmentNavigator.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
private String getBackStackName(@IdRes int destinationId) {
    // This gives us the resource name if it exists,
    // or just the destinationId if it doesn't exist
    try {
        return mContext.getResources().getResourceName(destinationId);
    } catch (Resources.NotFoundException e) {
        return Integer.toString(destinationId);
    }
}
 
Example #25
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavigationUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Determines whether the given <code>destId</code> matches the NavDestination. This handles
 * both the default case (the destination's id matches the given id) and the nested case where
 * the given id is a parent/grandparent/etc of the destination.
 */
private static boolean matchDestination(@NonNull NavDestination destination,
        @IdRes int destId) {
    NavDestination currentDestination = destination;
    while (currentDestination.getId() != destId && currentDestination.getParent() != null) {
        currentDestination = currentDestination.getParent();
    }
    return currentDestination.getId() == destId;
}
 
Example #26
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavDestination.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the destination ID for a given action. This will recursively check the
 * {@link #getParent() parent} of this destination if the action destination is not found in
 * this destination.
 *
 * @param id action ID to fetch
 * @return destination ID mapped to the given action id, or 0 if none
 */
@Nullable
public NavAction getAction(@IdRes int id) {
    NavAction destination = mActions == null ? null : mActions.get(id);
    // Search the parent for the given action if it is not found in this destination
    return destination != null
            ? destination
            : getParent() != null ? getParent().getAction(id) : null;
}
 
Example #27
Source Project: android_9.0.0_r45   Author: lulululbj   File: NavController.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Navigate to a destination from the current navigation graph. This supports both navigating
 * via an {@link NavDestination#getAction(int) action} and directly navigating to a destination.
 *
 * @param resId an {@link NavDestination#getAction(int) action} id or a destination id to
 *              navigate to
 * @param args arguments to pass to the destination
 * @param navOptions special options for this navigation operation
 */
@SuppressWarnings("deprecation")
public void navigate(@IdRes int resId, @Nullable Bundle args, @Nullable NavOptions navOptions) {
    NavDestination currentNode = mBackStack.isEmpty() ? mGraph : mBackStack.peekLast();
    if (currentNode == null) {
        throw new IllegalStateException("no current navigation node");
    }
    @IdRes int destId = resId;
    final NavAction navAction = currentNode.getAction(resId);
    if (navAction != null) {
        if (navOptions == null) {
            navOptions = navAction.getNavOptions();
        }
        destId = navAction.getDestinationId();
    }
    if (destId == 0 && navOptions != null && navOptions.getPopUpTo() != 0) {
        popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
        return;
    }

    if (destId == 0) {
        throw new IllegalArgumentException("Destination id == 0 can only be used"
                + " in conjunction with navOptions.popUpTo != 0");
    }

    NavDestination node = findDestination(destId);
    if (node == null) {
        final String dest = NavDestination.getDisplayName(mContext, destId);
        throw new IllegalArgumentException("navigation destination " + dest
                + (navAction != null
                ? " referenced from action " + NavDestination.getDisplayName(mContext, resId)
                : "")
                + " is unknown to this NavController");
    }
    if (navOptions != null) {
        if (navOptions.shouldClearTask()) {
            // Start with a clean slate
            popBackStack(mGraph.getId(), true);
        } else if (navOptions.getPopUpTo() != 0) {
            popBackStack(navOptions.getPopUpTo(), navOptions.isPopUpToInclusive());
        }
    }
    node.navigate(args, navOptions);
}
 
Example #28
Source Project: star-zone-android   Author: bootsrc   File: BaseActivity.java    License: Apache License 2.0 4 votes vote down vote up
protected <T extends View> T findView(@IdRes int id) {
    return (T) super.findViewById(id);
}
 
Example #29
Source Project: scene   Author: bytedance   File: NavigationSceneCompatUtility.java    License: Apache License 2.0 4 votes vote down vote up
private Builder(@NonNull Fragment fragment, @NonNull Class<? extends Scene> rootSceneClazz, @IdRes int containerId) {
    this.mFragment = Utility.requireNonNull(fragment, "Fragment can't be null");
    this.mRootSceneClazz = Utility.requireNonNull(rootSceneClazz, "Root Scene class can't be null");
    this.mIdRes = containerId;
}
 
Example #30
Source Project: scene   Author: bytedance   File: NavigationSceneCompatUtility.java    License: Apache License 2.0 4 votes vote down vote up
@NonNull
public static Builder setupWithFragment(@NonNull final Fragment fragment,
                                        @NonNull Class<? extends Scene> rootScene,
                                        @IdRes int containerId) {
    return new Builder(fragment, rootScene, containerId);
}