Example #1
1
  @Override
  public void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    log("onLayout (%d, %d, %d, %d)", left, top, right, bottom);

    mHeight = bottom - top;
    mWidth = right - left;

    mLongSide = (int) (mImageRatio * Math.max(mWidth, mHeight));
    mShortSide = (int) (mImageRatio * Math.min(mWidth, mHeight));

    boolean isLandscape = mWidth > mHeight;
    if (mIsLandscape != isLandscape) {
      for (View photo : mOnTable) {
        if (photo != getSelection()) {
          dropOnTable(photo);
        }
      }
      if (hasSelection()) {
        pickUp(getSelection());
        for (int slot = 0; slot < mOnDeck.length; slot++) {
          if (mOnDeck[slot] != null) {
            placeOnDeck(mOnDeck[slot], slot);
          }
        }
      }
      mIsLandscape = isLandscape;
    }
    start();
  }
Example #2
0
 private void promoteSelection() {
   if (hasSelection()) {
     scheduleSelectionReaper(mMaxSelectionTime);
     mSelection.animate().cancel();
     mSelection.setAlpha(1f);
     moveToTopOfPile(mSelection);
     pickUp(mSelection);
     if (mStoryModeEnabled) {
       for (int slot = 0; slot < mOnDeck.length; slot++) {
         if (mLoadOnDeckTasks[slot] != null
             && mLoadOnDeckTasks[slot].getStatus() != AsyncTask.Status.FINISHED) {
           mLoadOnDeckTasks[slot].cancel(true);
         }
         if (mOnDeck[slot] == null) {
           mLoadOnDeckTasks[slot] = new LoadNaturalSiblingTask(slot);
           mLoadOnDeckTasks[slot].execute(mSelection);
         }
       }
     }
   }
 }