Skip to content

Commit

Permalink
Merge pull request #155 from deepueg/fix-nav-route-handling
Browse files Browse the repository at this point in the history
Fix nav route handling
  • Loading branch information
deepueg authored Sep 24, 2020
2 parents ce6fe32 + 8e00be4 commit cf3a4a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ public void onDestroy() {
mElectrodeActivityListener.removeReactNativeView(mMiniAppComponentName, (ReactRootView) mMiniAppView);
mMiniAppView = null;
}
if (mFragment.getArguments() != null) {
mFragment.getArguments().remove(KEY_UNIQUE_VIEW_IDENTIFIER);
}
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,30 @@ private void registerNavRequestHandler() {
mNavViewModel.getRouteLiveData().observe(mFragmentActivity, new Observer<Route>() {
@Override
public void onChanged(Route route) {
Logger.d(TAG, "Navigation request handled by Activity(%s)", mFragmentActivity);
NavigationRouteHandler routeHandler = null;
if (mDefaultLaunchConfig.mRouteHandlerProvider != null && mDefaultLaunchConfig.mRouteHandlerProvider.getRouteHandler() != null) {
Logger.v(TAG, "Getting route handler via RouteHandlerProvider");
routeHandler = mDefaultLaunchConfig.mRouteHandlerProvider.getRouteHandler();
} else {
Fragment f = mFragmentActivity.getSupportFragmentManager().findFragmentById(mDefaultLaunchConfig.getFragmentContainerId());
if (f instanceof NavigationRouteHandler) {
Logger.v(TAG, "Getting fragment(route handler) hosted inside getFragmentContainer of activity");
routeHandler = (NavigationRouteHandler) f;
if (route != null && !route.isCompleted()) {
Logger.d(TAG, "Navigation request handled by Activity(%s)", mFragmentActivity);
NavigationRouteHandler routeHandler = null;
if (mDefaultLaunchConfig.mRouteHandlerProvider != null && mDefaultLaunchConfig.mRouteHandlerProvider.getRouteHandler() != null) {
Logger.v(TAG, "Getting route handler via RouteHandlerProvider");
routeHandler = mDefaultLaunchConfig.mRouteHandlerProvider.getRouteHandler();
} else {
Logger.w(TAG, "Fragment: %s is not a NavigationRouteHandler", f);
Fragment f = mFragmentActivity.getSupportFragmentManager().findFragmentById(mDefaultLaunchConfig.getFragmentContainerId());
if (f instanceof NavigationRouteHandler) {
Logger.v(TAG, "Getting fragment(route handler) hosted inside getFragmentContainer of activity");
routeHandler = (NavigationRouteHandler) f;
} else {
Logger.w(TAG, "Fragment: %s is not a NavigationRouteHandler", f);
}
}
}

if (routeHandler != null) {
routeHandler.handleRoute(route);
if (routeHandler != null) {
routeHandler.handleRoute(route);
} else {
Logger.w(TAG, "Request handler is not able to find a RouteHandler for this request: " + route.getArguments());
route.setResult(false, "Failed to handle request, missing route handler");
}
} else {
Logger.w(TAG, "Request handler is not able to find a RouteHandler for this request: " + route.getArguments());
route.setResult(false, "Failed to handle request, missing route handler");
Logger.d(TAG, "Delegate: %s has ignored an already handled route: %s, ", ElectrodeNavigationActivityDelegate.this, route != null ? route.getArguments() : null);
}
}
});
Expand Down

0 comments on commit cf3a4a6

Please sign in to comment.