Ejemplo n.º 1
0
  @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);
  }
Ejemplo n.º 2
0
 @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);
   }
 }