예제 #1
0
  @Override
  protected void unregisterAllModelChangedObserversInDescendants() {
    if (mRootLayout != null) {
      mRootLayout.unregisterAllModelChangedObservers();
    }

    if (mImageRegion != null) {
      mImageRegion.unregisterAllModelChangedObservers();
    }

    if (mTextRegion != null) {
      mTextRegion.unregisterAllModelChangedObservers();
    }
  }
예제 #2
0
  @Override
  protected void registerModelChangedObserverInDescendants(IModelChangedObserver observer) {
    if (mRootLayout != null) {
      mRootLayout.registerModelChangedObserver(observer);
    }

    if (mImageRegion != null) {
      mImageRegion.registerModelChangedObserver(observer);
    }

    if (mTextRegion != null) {
      mTextRegion.registerModelChangedObserver(observer);
    }
  }
예제 #3
0
  private void createDefaultImageRegion() {
    if (mRootLayout == null) {
      throw new IllegalStateException("Root-Layout uninitialized.");
    }

    mImageRegion =
        new RegionModel(
            IMAGE_REGION_ID, 0, 0, mRootLayout.getWidth(), mLayoutParams.getImageHeight());
  }
예제 #4
0
  public RegionModel findRegionById(String rId) {
    if (IMAGE_REGION_ID.equals(rId)) {
      return mImageRegion;
    } else if (TEXT_REGION_ID.equals(rId)) {
      return mTextRegion;
    } else {
      for (RegionModel r : mNonStdRegions) {
        if (r.getRegionId().equals(rId)) {
          return r;
        }
      }

      if (LOCAL_LOGV) {
        Log.v(TAG, "Region not found: " + rId);
      }
      return null;
    }
  }
예제 #5
0
  public LayoutModel(RegionModel rootLayout, ArrayList<RegionModel> regions) {
    mLayoutParams = LayoutManager.getInstance().getLayoutParameters();
    mRootLayout = rootLayout;
    mNonStdRegions = new ArrayList<RegionModel>();

    for (RegionModel r : regions) {
      String rId = r.getRegionId();
      if (rId.equals(IMAGE_REGION_ID)) {
        mImageRegion = r;
      } else if (rId.equals(TEXT_REGION_ID)) {
        mTextRegion = r;
      } else {
        if (LOCAL_LOGV) {
          Log.v(TAG, "Found non-standard region: " + rId);
        }
        mNonStdRegions.add(r);
      }
    }

    validateLayouts();
  }
예제 #6
0
  public void changeTo(int layout) {
    if (mRootLayout == null) {
      throw new IllegalStateException("Root-Layout uninitialized.");
    }

    if (mLayoutParams == null) {
      mLayoutParams = LayoutManager.getInstance().getLayoutParameters();
    }

    if (mLayoutType != layout) {
      switch (layout) {
        case LAYOUT_BOTTOM_TEXT:
          {
            mImageRegion.setTop(0);
            mTextRegion.setTop(mLayoutParams.getImageHeight());
            mLayoutType = layout;
            notifyModelChanged(true);
          }
          break;
        case LAYOUT_TOP_TEXT:
          {
            mImageRegion.setTop(mLayoutParams.getTextHeight());
            mTextRegion.setTop(0);
            mLayoutType = layout;
            notifyModelChanged(true);
          }
          break;
        default:
          {
            Log.w(TAG, "Unknown layout type: " + layout);
          }
      }
    } else {
      if (LOCAL_LOGV) {
        Log.v(TAG, "Skip changing layout.");
      }
    }
  }
예제 #7
0
  private void validateLayouts() {
    if (mRootLayout == null) {
      createDefaultRootLayout();
    }

    if (mImageRegion == null) {
      createDefaultImageRegion();
    }

    if (mTextRegion == null) {
      createDefaultTextRegion();
    }
    // LayoutModel will re-construct when orientation changes, so we need to
    // initialize mLayoutType here. Otherwise, the mLayoutType is alway default
    // value (LAYOUT_BOTTOM_TEXT) after LayoutModel re-construct.
    mLayoutType = (mImageRegion.getTop() == 0) ? LAYOUT_BOTTOM_TEXT : LAYOUT_TOP_TEXT;
  }
예제 #8
0
 public String getBackgroundColor() {
   return mRootLayout.getBackgroundColor();
 }
예제 #9
0
 public int getLayoutHeight() {
   return mRootLayout.getHeight();
 }
예제 #10
0
 public int getLayoutWidth() {
   return mRootLayout.getWidth();
 }