androidx.navigation.NavController Java Examples
The following examples show how to use
androidx.navigation.NavController.
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 File: MainActivity.java From webrtc_android with MIT License | 11 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView navView = findViewById(R.id.nav_view); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( R.id.navigation_user, R.id.navigation_room, R.id.navigation_setting) .build(); // 設置ActionBar跟随联动 NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); // 设置Nav跟随联动 NavigationUI.setupWithNavController(navView, navController); // 设置登录状态回调 SocketManager.getInstance().addUserStateCallback(this); }
Example #2
Source File: BaseNavControllerTest.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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 #3
Source File: MailboxQueryFragment.java From lttrs-android with Apache License 2.0 | 6 votes |
@Override public void onThreadClicked(ThreadOverviewItem threadOverviewItem, boolean important) { MailboxOverviewItem mailbox = mailboxQueryViewModel.getMailbox().getValue(); final NavController navController = Navigation.findNavController( requireActivity(), R.id.nav_host_fragment ); final String label = mailbox != null && mailbox.role == null ? mailbox.name : null; navController.navigate(LttrsNavigationDirections.actionToThread( threadOverviewItem.threadId, label, threadOverviewItem.getSubject(), threadOverviewItem.getKeywords(), important )); }
Example #4
Source File: ThreadFragment.java From lttrs-android with Apache License 2.0 | 6 votes |
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { LOGGER.info("on activity result code={}, result={}, intent={}", requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data); if (requestCode == ComposeActivity.REQUEST_EDIT_DRAFT && resultCode == ComposeActivity.RESULT_OK) { final UUID uuid = (UUID) data.getSerializableExtra(ComposeActivity.EDITING_TASK_ID_EXTRA); final boolean threadDiscarded = data.getBooleanExtra(ComposeActivity.DISCARDED_THREAD_EXTRA, false); if (uuid != null) { threadViewModel.waitForEdit(uuid); } else if (threadDiscarded) { final NavController navController = Navigation.findNavController( requireActivity(), R.id.nav_host_fragment ); navController.popBackStack(); } } }
Example #5
Source File: NavigationUI.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static boolean onNavDestinationSelected(@NonNull MenuItem item, @NonNull NavController navController, boolean popUp) { NavOptions.Builder builder = new NavOptions.Builder() .setLaunchSingleTop(true) .setEnterAnim(R.anim.nav_default_enter_anim) .setExitAnim(R.anim.nav_default_exit_anim) .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) .setPopExitAnim(R.anim.nav_default_pop_exit_anim); if (popUp) { builder.setPopUpTo(findStartDestination(navController.getGraph()).getId(), false); } NavOptions options = builder.build(); try { //TODO provide proper API instead of using Exceptions as Control-Flow. navController.navigate(item.getItemId(), null, options); return true; } catch (IllegalArgumentException e) { return false; } }
Example #6
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); final NavDestination currentDestination = navController.getCurrentDestination(); if (currentDestination != null && MAIN_DESTINATIONS.contains(currentDestination.getId())) { binding.drawerLayout.openDrawer(GravityCompat.START); return true; } else { onBackPressed(); } } return super.onOptionsItemSelected(item); }
Example #7
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 6 votes |
public void onNewIntent(Intent intent) { super.onNewIntent(intent); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); if (mSearchView != null) { mSearchView.setQuery(query, false); mSearchView.clearFocus(); //this does not work on all phones / android versions; therefor we have this followed by a requestFocus() on the list } binding.mailboxList.requestFocus(); lttrsViewModel.insertSearchSuggestion(query); final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); navController.navigate(LttrsNavigationDirections.actionSearch(query)); } }
Example #8
Source File: BaseNavControllerTest.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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 #9
Source File: BaseNavControllerTest.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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 #10
Source File: BaseNavControllerTest.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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 #11
Source File: MainActivity.java From android-accessibility with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); NavController navController = Navigation.findNavController(this, R.id.my_nav_host_fragment); AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build(); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration); }
Example #12
Source File: NavHostFragment.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Find a {@link NavController} given a local {@link Fragment}. * * <p>This method will locate the {@link NavController} associated with this Fragment, * looking first for a {@link NavHostFragment} along the given Fragment's parent chain. * If a {@link NavController} is not found, this method will look for one along this * Fragment's {@link Fragment#getView() view hierarchy} as specified by * {@link Navigation#findNavController(View)}.</p> * * @param fragment the locally scoped Fragment for navigation * @return the locally scoped {@link NavController} for navigating from this {@link Fragment} * @throws IllegalStateException if the given Fragment does not correspond with a * {@link NavHost} or is not within a NavHost. */ @NonNull public static NavController findNavController(@NonNull Fragment fragment) { Fragment findFragment = fragment; while (findFragment != null) { if (findFragment instanceof NavHostFragment) { return ((NavHostFragment) findFragment).getNavController(); } Fragment primaryNavFragment = findFragment.requireFragmentManager() .getPrimaryNavigationFragment(); if (primaryNavFragment instanceof NavHostFragment) { return ((NavHostFragment) primaryNavFragment).getNavController(); } findFragment = findFragment.getParentFragment(); } // Try looking for one associated with the view instead, if applicable View view = fragment.getView(); if (view != null) { return Navigation.findNavController(view); } throw new IllegalStateException("Fragment " + fragment + " does not have a NavController set"); }
Example #13
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override public boolean onMenuItemActionCollapse(MenuItem item) { if (item.isActionViewExpanded()) { animateCloseSearchToolbar(); } if (getCurrentDestinationId() == R.id.search) { final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); navController.navigateUp(); } return true; }
Example #14
Source File: AbstractQueryFragment.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override public void onThreadClicked(ThreadOverviewItem threadOverviewItem, boolean important) { final NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment); navController.navigate(LttrsNavigationDirections.actionToThread( threadOverviewItem.threadId, null, threadOverviewItem.getSubject(), threadOverviewItem.getKeywords(), important )); }
Example #15
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override public void onDestinationChanged(@NonNull NavController controller, @NonNull NavDestination destination, @Nullable Bundle arguments) { LOGGER.debug("onDestinationChanged({})", destination.getLabel()); if (destination.getId() == R.id.thread) { endActionMode(); } configureActionBarForDestination(destination); }
Example #16
Source File: MainActivity.java From Android-Dev-Box with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); DrawerLayout drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); // Passing each menu ID as a set of Ids because each // menu should be considered as top level destinations. mAppBarConfiguration = new AppBarConfiguration.Builder( R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow, R.id.nav_tools, R.id.nav_share, R.id.nav_send) .setDrawerLayout(drawer) .build(); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); NavigationUI.setupWithNavController(navigationView, navController); }
Example #17
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override public void onStop() { super.onStop(); final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); navController.removeOnDestinationChangedListener(this); }
Example #18
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override public void onStart() { final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); navController.addOnDestinationChangedListener(this); super.onStart(); }
Example #19
Source File: LttrsActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
private int getCurrentDestinationId() { final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); final NavDestination currentDestination = navController.getCurrentDestination(); return currentDestination == null ? 0 : currentDestination.getId(); }
Example #20
Source File: SetupActivity.java From lttrs-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ActivitySetupBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_setup); final NavController navController = Navigation.findNavController( this, R.id.nav_host_fragment ); final ViewModelProvider viewModelProvider = new ViewModelProvider( this, getDefaultViewModelProviderFactory() ); final SetupViewModel setupViewModel = viewModelProvider.get(SetupViewModel.class); setupViewModel.getRedirection().observe(this, targetEvent -> { if (targetEvent.isConsumable()) { final SetupViewModel.Target target = targetEvent.consume(); switch (target) { case LTTRS: redirectToLttrs(); break; case ENTER_PASSWORD: navController.navigate(SetupNavigationDirections.enterPassword()); break; case ENTER_URL: navController.navigate(SetupNavigationDirections.enterSessionResource()); break; default: throw new IllegalStateException(String.format("Unable to navigate to target %s", target)); } } }); setupViewModel.getWarningMessage().observe(this, event -> { if (event.isConsumable()) { Snackbar.make(binding.getRoot(), event.consume(), Snackbar.LENGTH_LONG).show(); } }); }
Example #21
Source File: BottomNavigationUtils.java From PagerBottomTabStrip with Apache License 2.0 | 5 votes |
private static void onNavDestinationSelected(int id, @NonNull NavController navController) { NavOptions options = new NavOptions.Builder() .setLaunchSingleTop(true) .setEnterAnim(R.anim.nav_default_enter_anim) .setExitAnim(R.anim.nav_default_exit_anim) .setPopEnterAnim(R.anim.nav_default_pop_enter_anim) .setPopExitAnim(R.anim.nav_default_pop_exit_anim) .setPopUpTo(navController.getGraph().getStartDestination(), false) .build(); try { navController.navigate(id, null, options); } catch (IllegalArgumentException e) { e.printStackTrace(); } }
Example #22
Source File: MainActivity.java From ui with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); BottomNavigationView navView = findViewById(R.id.nav_view); /* if not using arch navigation, then you need to implement this. navView.setOnNavigationItemSelectedListener( new BottomNavigationView.OnNavigationItemSelectedListener() { public boolean onNavigationItemSelected(MenuItem item) { return false; } } ); */ // Passing each menu ID as a set of Ids because each menu should be considered as top level destinations. //Note for this to work with arch Navigation, these id must be the same id in menu.xml and the nav_graph. AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder( R.id.action_first, R.id.action_second, R.id.action_third) .build(); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); NavigationUI.setupWithNavController(navView, navController); //In order to have badges, you need to use the Theme.MaterialComponents.DayNight (doesn't have to daynight, but materialcompents). BadgeDrawable badge = navView.getOrCreateBadge(R.id.action_second); badge.setNumber(12); //should show a 12 in the "badge" for the second one. badge.setVisible(true); }
Example #23
Source File: EnterCodeFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void handlePhoneCallRequest() { callMeCountDown.startCountDown(RegistrationConstants.SUBSEQUENT_CALL_AVAILABLE_AFTER); RegistrationViewModel model = getModel(); String captcha = model.getCaptchaToken(); model.clearCaptchaResponse(); NavController navController = Navigation.findNavController(callMeCountDown); RegistrationService registrationService = RegistrationService.getInstance(model.getNumber().getE164Number(), model.getRegistrationSecret()); registrationService.requestVerificationCode(requireActivity(), RegistrationCodeRequest.Mode.PHONE_CALL, captcha, new RegistrationCodeRequest.SmsVerificationCodeCallback() { @Override public void onNeedCaptcha() { navController.navigate(EnterCodeFragmentDirections.actionRequestCaptcha()); } @Override public void requestSent(@Nullable String fcmToken) { model.setFcmToken(fcmToken); model.markASuccessfulAttempt(); } @Override public void onError() { Toast.makeText(requireContext(), R.string.RegistrationActivity_unable_to_connect_to_service, Toast.LENGTH_LONG).show(); } }); }
Example #24
Source File: ThreadFragment.java From lttrs-android with Apache License 2.0 | 5 votes |
private void onThreadViewRedirect(final Event<String> event) { if (event.isConsumable()) { final String threadId = event.consume(); final NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment); //TODO once draft worker copies over flags and mailboxes we might want to put them in here as well navController.navigate(LttrsNavigationDirections.actionToThread( threadId, null, null, new String[0], false )); } }
Example #25
Source File: NavigationUI.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onNavigated(@NonNull NavController controller, @NonNull NavDestination destination) { ActionBar actionBar = mActivity.getSupportActionBar(); CharSequence title = destination.getLabel(); if (!TextUtils.isEmpty(title)) { actionBar.setTitle(title); } boolean isStartDestination = findStartDestination(controller.getGraph()) == destination; actionBar.setDisplayHomeAsUpEnabled(mDrawerLayout != null || !isStartDestination); setActionBarUpIndicator(mDrawerLayout != null && isStartDestination); }
Example #26
Source File: NavHostFragment.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Returns the {@link NavController navigation controller} for this navigation host. * This method will return null until this host fragment's {@link #onCreate(Bundle)} * has been called and it has had an opportunity to restore from a previous instance state. * * @return this host's navigation controller * @throws IllegalStateException if called before {@link #onCreate(Bundle)} */ @NonNull @Override public NavController getNavController() { if (mNavController == null) { throw new IllegalStateException("NavController is not available before onCreate()"); } return mNavController; }
Example #27
Source File: NavHostFragment.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = requireContext(); mNavController = new NavController(context); mNavController.getNavigatorProvider().addNavigator(createFragmentNavigator()); Bundle navState = null; if (savedInstanceState != null) { navState = savedInstanceState.getBundle(KEY_NAV_CONTROLLER_STATE); if (savedInstanceState.getBoolean(KEY_DEFAULT_NAV_HOST, false)) { mDefaultNavHost = true; requireFragmentManager().beginTransaction() .setPrimaryNavigationFragment(this) .commit(); } } if (navState != null) { // Navigation controller state overrides arguments mNavController.restoreState(navState); } else { final Bundle args = getArguments(); final int graphId = args != null ? args.getInt(KEY_GRAPH_ID) : 0; if (graphId != 0) { mNavController.setGraph(graphId); } else { mNavController.setMetadataGraph(); } } }
Example #28
Source File: ImmediateNavigationTest.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Test public void testNavigateInOnResume() throws Throwable { Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); Intent intent = new Intent(instrumentation.getContext(), ImmediateNavigationActivity.class); final ImmediateNavigationActivity activity = mActivityRule.launchActivity(intent); instrumentation.waitForIdleSync(); NavController navController = activity.getNavController(); assertThat(navController.getCurrentDestination().getId(), is(R.id.deep_link_test)); }
Example #29
Source File: BaseNavControllerTest.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private BaseNavigationActivity launchActivity(Intent intent) throws Throwable { BaseNavigationActivity activity = mActivityRule.launchActivity(intent); mInstrumentation.waitForIdleSync(); NavController navController = activity.getNavController(); assertThat(navController, is(notNullValue(NavController.class))); TestNavigator navigator = new TestNavigator(); navController.getNavigatorProvider().addNavigator(navigator); return activity; }
Example #30
Source File: EnterPhoneNumberFragment.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private void requestVerificationCode(String e164number, @NonNull RegistrationCodeRequest.Mode mode) { RegistrationViewModel model = getModel(); String captcha = model.getCaptchaToken(); model.clearCaptchaResponse(); NavController navController = Navigation.findNavController(register); if (!model.getRequestLimiter().canRequest(mode, e164number, System.currentTimeMillis())) { Log.i(TAG, "Local rate limited"); navController.navigate(EnterPhoneNumberFragmentDirections.actionEnterVerificationCode()); cancelSpinning(register); enableAllEntries(); return; } RegistrationService registrationService = RegistrationService.getInstance(e164number, model.getRegistrationSecret()); registrationService.requestVerificationCode(requireActivity(), mode, captcha, new RegistrationCodeRequest.SmsVerificationCodeCallback() { @Override public void onNeedCaptcha() { if (getContext() == null) { Log.i(TAG, "Got onNeedCaptcha response, but fragment is no longer attached."); return; } navController.navigate(EnterPhoneNumberFragmentDirections.actionRequestCaptcha()); cancelSpinning(register); enableAllEntries(); model.getRequestLimiter().onUnsuccessfulRequest(); model.updateLimiter(); } @Override public void requestSent(@Nullable String fcmToken) { if (getContext() == null) { Log.i(TAG, "Got requestSent response, but fragment is no longer attached."); return; } model.setFcmToken(fcmToken); model.markASuccessfulAttempt(); navController.navigate(EnterPhoneNumberFragmentDirections.actionEnterVerificationCode()); cancelSpinning(register); enableAllEntries(); model.getRequestLimiter().onSuccessfulRequest(mode, e164number, System.currentTimeMillis()); model.updateLimiter(); } @Override public void onError() { Toast.makeText(register.getContext(), R.string.RegistrationActivity_unable_to_connect_to_service, Toast.LENGTH_LONG).show(); cancelSpinning(register); enableAllEntries(); model.getRequestLimiter().onUnsuccessfulRequest(); model.updateLimiter(); } }); }