android.support.annotation.IdRes源码实例Demo

类android.support.annotation.IdRes源码实例Demo

下面列出了android.support.annotation.IdRes 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BmapLite   文件: SettingActivity.java
@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();
    }

}
 
源代码2 项目: android_9.0.0_r45   文件: BaseNavControllerTest.java
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));
}
 
源代码3 项目: android_9.0.0_r45   文件: BaseNavControllerTest.java
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));
}
 
源代码4 项目: android_9.0.0_r45   文件: BaseNavControllerTest.java
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));
}
 
源代码5 项目: android_9.0.0_r45   文件: BaseNavControllerTest.java
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;
}
 
源代码6 项目: android_9.0.0_r45   文件: NavGraph.java
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;
}
 
源代码7 项目: Focus   文件: PostDetailView.java
private <T extends View> T getChildView(@IdRes int viewId) {
    View childView = null;
    if (view == null) {
        childView = view.findViewById(viewId);
    }
    return (T) childView;
}
 
源代码8 项目: scene   文件: NavigationSceneCompatUtility.java
/**
 * 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);
}
 
源代码9 项目: scene   文件: NavigationSceneCompatUtility.java
/**
 * 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);
}
 
源代码10 项目: scene   文件: FragmentViewFinder.java
@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;
}
 
源代码11 项目: scene   文件: SceneLifecycleDispatcher.java
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;
}
 
源代码12 项目: scene   文件: NavigationSceneUtility.java
/**
 * 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);
}
 
源代码13 项目: android_9.0.0_r45   文件: Navigation.java
/**
 * 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);
        }
    };
}
 
源代码14 项目: scene   文件: GroupSceneManager.java
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;
}
 
源代码15 项目: android_9.0.0_r45   文件: NavOptions.java
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;
}
 
源代码16 项目: AndroidWallet   文件: ViewAdapter.java
@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());
        }
    });
}
 
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;
}
 
源代码18 项目: android_9.0.0_r45   文件: NavDestination.java
/**
 * 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);
}
 
源代码19 项目: FloatWindow   文件: AbsFloatBase.java
@SuppressWarnings("unchecked")
protected <T extends View> T findView(@IdRes int id) {
    if (mInflate != null) {
        return (T) mInflate.findViewById(id);
    }
    return null;
}
 
源代码20 项目: android_9.0.0_r45   文件: NavDeepLinkBuilder.java
/**
 * 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;
}
 
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;
}
 
源代码22 项目: android_9.0.0_r45   文件: NavController.java
@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);
        }
    }
}
 
源代码23 项目: landlord_client   文件: BaseActivity.java
/**
 * 根据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);
        }
    }
}
 
源代码24 项目: android_9.0.0_r45   文件: FragmentNavigator.java
@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);
    }
}
 
源代码25 项目: android_9.0.0_r45   文件: NavigationUI.java
/**
 * 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;
}
 
源代码26 项目: android_9.0.0_r45   文件: NavDestination.java
/**
 * 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;
}
 
源代码27 项目: android_9.0.0_r45   文件: NavController.java
/**
 * 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);
}
 
源代码28 项目: star-zone-android   文件: BaseActivity.java
protected <T extends View> T findView(@IdRes int id) {
    return (T) super.findViewById(id);
}
 
源代码29 项目: scene   文件: NavigationSceneCompatUtility.java
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;
}
 
源代码30 项目: scene   文件: NavigationSceneCompatUtility.java
@NonNull
public static Builder setupWithFragment(@NonNull final Fragment fragment,
                                        @NonNull Class<? extends Scene> rootScene,
                                        @IdRes int containerId) {
    return new Builder(fragment, rootScene, containerId);
}
 
源代码评论
动弹
沙发等你来抢
 类方法
 同包方法