Exemplo n.º 1
0
 public LayoutModel() {
   mLayoutParams = LayoutManager.getInstance().getLayoutParameters();
   // Create default root-layout and regions.
   createDefaultRootLayout();
   createDefaultImageRegion();
   createDefaultTextRegion();
 }
Exemplo n.º 2
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();
  }
Exemplo n.º 3
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.");
      }
    }
  }