1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package com.reactnativenavigation.viewcontrollers;
-
- import android.app.Activity;
- import android.support.annotation.NonNull;
-
- import com.reactnativenavigation.parse.Options;
- import com.reactnativenavigation.presentation.OptionsPresenter;
- import com.reactnativenavigation.views.ComponentLayout;
- import com.reactnativenavigation.views.ReactComponent;
-
- public class ComponentViewController extends ChildController<ComponentLayout> {
-
- private final String componentName;
-
- private final ReactViewCreator viewCreator;
-
- public ComponentViewController(final Activity activity,
- final ChildControllersRegistry childRegistry,
- final String id,
- final String componentName,
- final ReactViewCreator viewCreator,
- final Options initialOptions,
- final OptionsPresenter presenter) {
- super(activity, childRegistry, id, presenter, initialOptions);
- this.componentName = componentName;
- this.viewCreator = viewCreator;
- }
-
- @Override
- public void onViewAppeared() {
- super.onViewAppeared();
- view.sendComponentStart();
- }
-
- @Override
- public void onViewDisappear() {
- view.sendComponentStop();
- super.onViewDisappear();
- }
-
- @Override
- public void sendOnNavigationButtonPressed(String buttonId) {
- getView().sendOnNavigationButtonPressed(buttonId);
- }
-
- @Override
- public void applyOptions(Options options) {
- super.applyOptions(options);
- view.applyOptions(options);
- }
-
- @Override
- protected boolean isViewShown() {
- return super.isViewShown() && view.isReady();
- }
-
- @NonNull
- @Override
- protected ComponentLayout createView() {
- view = (ComponentLayout) viewCreator.create(getActivity(), getId(), componentName);
- return (ComponentLayout) view.asView();
- }
-
- @Override
- public void mergeOptions(Options options) {
- applyOnParentController(parentController -> parentController.mergeChildOptions(options, getView()));
- super.mergeOptions(options);
- }
-
- ReactComponent getComponent() {
- return view;
- }
- }
|