Java TransitionHelper Example

说明

java transitionhelper示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Java

命名空间/包名称: org.appcelerator.titanium.transition

示例#1
文件: TiUIScrollableView.java项目: Teomir/titanium_mobile

  @Override
  public void processProperties(KrollDict d) {

    if (d.containsKey(TiC.PROPERTY_PAGE_WIDTH)) {
      setPageWidth(d.get(TiC.PROPERTY_PAGE_WIDTH));
    }
    if (d.containsKey(TiC.PROPERTY_PAGE_OFFSET)) {
      setPageOffset(d.get(TiC.PROPERTY_PAGE_OFFSET));
    }

    if (d.containsKey(TiC.PROPERTY_VIEWS)) {
      setViews(d.get(TiC.PROPERTY_VIEWS));
    }

    if (d.containsKey(TiC.PROPERTY_CURRENT_PAGE)) {
      int page = d.optInt(TiC.PROPERTY_CURRENT_PAGE, 0);
      if (page > 0) {
        setCurrentPage(page);
      }
    }

    if (d.containsKey(TiC.PROPERTY_SHOW_PAGING_CONTROL)) {
      if (TiConvert.toBoolean(d, TiC.PROPERTY_SHOW_PAGING_CONTROL)) {
        showPager();
      }
    }

    if (d.containsKey(TiC.PROPERTY_SCROLLING_ENABLED)) {
      mEnabled = TiConvert.toBoolean(d, TiC.PROPERTY_SCROLLING_ENABLED);
    }

    if (d.containsKey(TiC.PROPERTY_OVER_SCROLL_MODE)) {
      if (Build.VERSION.SDK_INT >= 9) {
        mPager.setOverScrollMode(
            TiConvert.toInt(d.get(TiC.PROPERTY_OVER_SCROLL_MODE), View.OVER_SCROLL_ALWAYS));
      }
    }

    if (d.containsKey(TiC.PROPERTY_CACHE_SIZE)) {
      cacheSize = TiConvert.toInt(d, TiC.PROPERTY_CACHE_SIZE);
      if (cacheSize < 3) {
        // WHAT.  Let's make it something sensible.
        cacheSize = 3;
      }
      updateCacheSize();
    }

    if (d.containsKey(TiC.PROPERTY_TRANSITION)) {
      transition =
          TransitionHelper.transitionFromObject(
              (HashMap) d.get(TiC.PROPERTY_TRANSITION), null, null);
      mPager.updatePageTransformer();
    }
    super.processProperties(d);
  }

示例#2
文件: TiUIScrollableView.java项目: Teomir/titanium_mobile

    @Override
    public void updatePageTransformer() {
      if (transition != null) {
        setPageTransformer(
            !TransitionHelper.isPushSubType(transition.subType),
            new PageTransformer() {

              @Override
              public void transformPage(View page, float position) {
                if (transition != null) {
                  transition.transformView(page, position, true);
                }
              }
            });
        for (int i = 0; i < getChildCount(); i++) {
          final View child = getChildAt(i);
          TiViewHelper.resetValues(child);
          transition.transformView(child, i - mCurIndex, true);
        }
      } else {
        setPageTransformer(false, null);
      }
    }

示例#3
文件: TiUIScrollableView.java项目: Teomir/titanium_mobile

 @Override
 public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {
   if (TiC.PROPERTY_CURRENT_PAGE.equals(key)) {
     setCurrentPage(TiConvert.toInt(newValue));
   } else if (TiC.PROPERTY_SHOW_PAGING_CONTROL.equals(key)) {
     boolean show = TiConvert.toBoolean(newValue);
     if (show) {
       showPager();
     } else {
       hidePager();
     }
   } else if (TiC.PROPERTY_SCROLLING_ENABLED.equals(key)) {
     mEnabled = TiConvert.toBoolean(newValue);
   } else if (TiC.PROPERTY_OVER_SCROLL_MODE.equals(key)) {
     if (Build.VERSION.SDK_INT >= 9) {
       mPager.setOverScrollMode(TiConvert.toInt(newValue, View.OVER_SCROLL_ALWAYS));
     }
   } else if (TiC.PROPERTY_CACHE_SIZE.equals(key)) {
     cacheSize = TiConvert.toInt(newValue);
     if (cacheSize < 3) {
       // WHAT.  Let's make it something sensible.
       cacheSize = 3;
     }
     updateCacheSize();
   } else if (TiC.PROPERTY_PAGE_WIDTH.equals(key)) {
     setPageWidth(newValue);
   } else if (TiC.PROPERTY_PAGE_OFFSET.equals(key)) {
     setPageOffset(newValue);
   } else if (TiC.PROPERTY_TRANSITION.equals(key)) {
     transition = TransitionHelper.transitionFromObject((HashMap) newValue, null, null);
     mPager.updatePageTransformer();
     nativeView.invalidate();
   } else {
     super.propertyChanged(key, oldValue, newValue, proxy);
   }
 }

展开阅读全文