react-native-navigation的迁移库

SingleScreen.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.reactnativenavigation.screens;
  2. import android.support.v7.app.AppCompatActivity;
  3. import com.reactnativenavigation.params.ScreenParams;
  4. import com.reactnativenavigation.views.ContentView;
  5. import com.reactnativenavigation.views.LeftButtonOnClickListener;
  6. import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
  7. public class SingleScreen extends Screen {
  8. protected ContentView contentView;
  9. public SingleScreen(AppCompatActivity activity, ScreenParams screenParams,
  10. LeftButtonOnClickListener titleBarBarBackButtonListener) {
  11. super(activity, screenParams, titleBarBarBackButtonListener);
  12. }
  13. @Override
  14. protected void createContent() {
  15. contentView = new ContentView(getContext(), screenParams.screenId, screenParams.navigationParams);
  16. addView(contentView, 0, createLayoutParams());
  17. }
  18. protected LayoutParams createLayoutParams() {
  19. LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
  20. if (screenParams.styleParams.drawScreenBelowTopBar) {
  21. params.addRule(BELOW, topBar.getId());
  22. }
  23. return params;
  24. }
  25. @Override
  26. public void unmountReactView() {
  27. contentView.unmountReactView();
  28. }
  29. @Override
  30. public String getNavigatorEventId() {
  31. return screenParams.getNavigatorEventId();
  32. }
  33. @Override
  34. public void setOnDisplayListener(OnDisplayListener onContentViewDisplayedListener) {
  35. contentView.setOnDisplayListener(onContentViewDisplayedListener);
  36. }
  37. }