com.facebook.react.modules.core.DefaultHardwareBackBtnHandler Java Examples

The following examples show how to use com.facebook.react.modules.core.DefaultHardwareBackBtnHandler. 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: QtalkServiceRNActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
            @Override
            public void invokeDefaultOnBackPressed() {
                finish();
            }
        });
    }
}
 
Example #2
Source File: QTalkSearchActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
            @Override
            public void invokeDefaultOnBackPressed() {
                finish();
            }
        });
    }
}
 
Example #3
Source File: QtalkServiceExternalRNActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
            @Override
            public void invokeDefaultOnBackPressed() {
                finish();
            }
        });
    }
}
 
Example #4
Source File: QtalkOpenTravelCalendar.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
            @Override
            public void invokeDefaultOnBackPressed() {
                finish();
            }
        });
    }
}
 
Example #5
Source File: ReactActivityDelegate.java    From react-native-GPay with MIT License 5 votes vote down vote up
protected void onResume() {
  if (getReactNativeHost().hasInstance()) {
    getReactNativeHost().getReactInstanceManager().onHostResume(
      getPlainActivity(),
      (DefaultHardwareBackBtnHandler) getPlainActivity());
  }

  if (mPermissionsCallback != null) {
    mPermissionsCallback.invoke();
    mPermissionsCallback = null;
  }
}
 
Example #6
Source File: CoreModulesPackage.java    From react-native-GPay with MIT License 5 votes vote down vote up
CoreModulesPackage(
    ReactInstanceManager reactInstanceManager,
    DefaultHardwareBackBtnHandler hardwareBackBtnHandler,
    @Nullable UIImplementationProvider uiImplementationProvider,
    boolean lazyViewManagersEnabled,
    int minTimeLeftInFrameForNonBatchedOperationMs) {
  mReactInstanceManager = reactInstanceManager;
  mHardwareBackBtnHandler = hardwareBackBtnHandler;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
  mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
}
 
Example #7
Source File: ReactFragment.java    From react-native-android-fragment with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (getReactNativeHost().hasInstance()) {
        getReactNativeHost().getReactInstanceManager().onHostResume(getActivity(), (DefaultHardwareBackBtnHandler) getActivity());
    }
}
 
Example #8
Source File: VinciActivityDelegate.java    From vinci with Apache License 2.0 5 votes vote down vote up
protected void onResume() {
    if (getReactNativeHost().hasInstance()) {
        getReactNativeHost().getReactInstanceManager().onHostResume(
                getPlainActivity(),
                (DefaultHardwareBackBtnHandler) getPlainActivity());
    }

    if (mPermissionsCallback != null) {
        mPermissionsCallback.invoke();
        mPermissionsCallback = null;
    }
}
 
Example #9
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  JavaScriptExecutorFactory javaScriptExecutorFactory,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModulePath,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  @Nullable UIImplementationProvider mUIImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyViewManagersEnabled,
  @Nullable DevBundleDownloadListener devBundleDownloadListener,
  int minNumShakes,
  int minTimeLeftInFrameForNonBatchedOperationMs,
  @Nullable JSIModulePackage jsiModulePackage,
  @Nullable Map<String, RequestHandler> customPackagerCommandHandlers) {
  Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()");
  initializeSoLoaderIfNecessary(applicationContext);

  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mJavaScriptExecutorFactory = javaScriptExecutorFactory;
  mBundleLoader = bundleLoader;
  mJSMainModulePath = jsMainModulePath;
  mPackages = new ArrayList<>();
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager =
      DevSupportManagerFactory.create(
          applicationContext,
          createDevHelperInterface(),
          mJSMainModulePath,
          useDeveloperSupport,
          redBoxHandler,
          devBundleDownloadListener,
          minNumShakes,
          customPackagerCommandHandlers);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  synchronized (mPackages) {
    PrinterHolder.getPrinter()
        .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages");
    mPackages.add(
        new CoreModulesPackage(
            this,
            new DefaultHardwareBackBtnHandler() {
              @Override
              public void invokeDefaultOnBackPressed() {
                ReactInstanceManager.this.invokeDefaultOnBackPressed();
              }
            },
            mUIImplementationProvider,
            lazyViewManagersEnabled,
            minTimeLeftInFrameForNonBatchedOperationMs));
    if (mUseDeveloperSupport) {
      mPackages.add(new DebugCorePackage());
    }
    mPackages.addAll(packages);
  }
  mJSIModulePackage = jsiModulePackage;

  // Instantiate ReactChoreographer in UI thread.
  ReactChoreographer.initialize();
  if (mUseDeveloperSupport) {
    mDevSupportManager.startInspector();
  }
}
 
Example #10
Source File: ReactInstanceManagerBuilder.java    From react-native-GPay with MIT License 4 votes vote down vote up
public ReactInstanceManagerBuilder setDefaultHardwareBackBtnHandler(
  DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler) {
  mDefaultHardwareBackBtnHandler = defaultHardwareBackBtnHandler;
  return this;
}
 
Example #11
Source File: ReactInstanceManager.java    From react-native-GPay with MIT License 3 votes vote down vote up
/**
 * Use this method when the activity resumes to enable invoking the back button directly from JS.
 *
 * This method retains an instance to provided mDefaultBackButtonImpl. Thus it's important to pass
 * from the activity instance that owns this particular instance of {@link
 * ReactInstanceManager}, so that once this instance receive {@link #onHostDestroy} event it
 * will clear the reference to that defaultBackButtonImpl.
 *
 * @param defaultBackButtonImpl a {@link DefaultHardwareBackBtnHandler} from an Activity that owns
 * this instance of {@link ReactInstanceManager}.
 */
@ThreadConfined(UI)
public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
  UiThreadUtil.assertOnUiThread();

  mDefaultBackButtonImpl = defaultBackButtonImpl;
  onHostResume(activity);
}