コード例 #1
0
 @Override
 public TiUIView createView(Activity activity) {
   TiUIView view = new ExampleView(this);
   view.getLayoutParams().autoFillsHeight = true;
   view.getLayoutParams().autoFillsWidth = true;
   return view;
 }
コード例 #2
0
 @Override
 public Object instantiateItem(View container, int position) {
   synchronized (viewsLock) {
     ViewGroup pager = (ViewGroup) container;
     TiViewProxy tiProxy = mViews.get(position);
     TiUIView tiView = tiProxy.getOrCreateView();
     View view = tiView.getOuterView();
     ViewGroup.LayoutParams params =
         new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
     TiCompositeLayout layout = new TiCompositeLayout(tiProxy.getActivity());
     ViewParent parent = view.getParent();
     if (parent instanceof ViewGroup) {
       pager.removeView((View) parent);
       ViewGroup group = (ViewGroup) parent;
       group.removeView(view);
     }
     layout.addView(view, tiView.getLayoutParams());
     if (position < pager.getChildCount()) {
       pager.addView(layout, position, params);
     } else {
       pager.addView(layout, params);
     }
     return tiProxy;
   }
 }
 @Override
 public TiUIView createView(Activity activity) {
   TiUIView view = new BranchUniversalObjectView(this);
   view.getLayoutParams().autoFillsHeight = true;
   view.getLayoutParams().autoFillsWidth = true;
   return view;
 }
コード例 #4
0
 public View layoutHeaderOrFooterView(TiViewProxy viewProxy) {
   TiUIView tiView = viewProxy.peekView();
   if (tiView != null) {
     TiViewProxy parentProxy = viewProxy.getParent();
     // Remove parent view if possible
     if (parentProxy != null) {
       TiUIView parentView = parentProxy.peekView();
       if (parentView != null) {
         parentView.remove(tiView);
       }
     }
   } else {
     tiView = viewProxy.forceCreateView();
   }
   View outerView = tiView.getOuterView();
   ViewGroup parentView = (ViewGroup) outerView.getParent();
   if (parentView != null && parentView.getId() == HEADER_FOOTER_WRAP_ID) {
     return parentView;
   } else {
     // add a wrapper so layout params such as height, width takes in effect.
     TiCompositeLayout wrapper =
         new TiCompositeLayout(viewProxy.getActivity(), LayoutArrangement.DEFAULT, null);
     AbsListView.LayoutParams params =
         new AbsListView.LayoutParams(
             AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
     wrapper.setLayoutParams(params);
     outerView = tiView.getOuterView();
     wrapper.addView(outerView, tiView.getLayoutParams());
     wrapper.setId(HEADER_FOOTER_WRAP_ID);
     return wrapper;
   }
 }
コード例 #5
0
ファイル: TiUIView.java プロジェクト: RIAwolf/titanium_mobile
 public void add(TiUIView child) {
   if (child != null) {
     View cv = child.getNativeView();
     if (cv != null) {
       View nv = getNativeView();
       if (nv instanceof ViewGroup) {
         if (cv.getParent() == null) {
           ((ViewGroup) nv).addView(cv, child.getLayoutParams());
         }
       }
     }
   }
 }
コード例 #6
0
  protected void refreshControls() {
    ArrayList<TiViewProxy> proxies = getRowProxy().getControls();
    int len = proxies.size();

    if (views == null) {
      views = new ArrayList<TiUIView>(len);
    } else if (views.size() != len) {
      for (TiUIView view : views) {
        View v = view.getNativeView();
        if (v != null && v.getParent().equals(content)) {
          content.removeView(v);
        }
      }
      views = new ArrayList<TiUIView>(len);
    }

    for (int i = 0; i < len; i++) {
      TiUIView view = views.size() > i ? views.get(i) : null;
      TiViewProxy proxy = proxies.get(i);
      if (view != null && view.getProxy() instanceof TableViewRowProxy) {
        proxy = addViewToOldRow(i, view, proxy);
        len++;
      }
      if (view == null) {
        // In some cases the TiUIView for this proxy has been reassigned to another proxy
        // We don't want to actually release it though, just reassign by creating a new view
        view = proxy.forceCreateView(tiContext.getActivity());
        clearChildViews(proxy);
        if (i >= views.size()) {
          views.add(view);
        } else {
          views.set(i, view);
        }
      }

      View v = view.getNativeView();
      view.setProxy(proxy);
      view.processProperties(proxy.getProperties());
      applyChildProxies(proxy, view);
      if (v != null && v.getParent() == null) {
        content.addView(v, view.getLayoutParams());
      }
    }
  }
コード例 #7
0
  public void generateChildContentViews(
      DataItem item, TiUIView parentContent, TiBaseListViewItem rootItem, boolean root) {

    ArrayList<DataItem> childrenItem = item.getChildren();
    for (int i = 0; i < childrenItem.size(); i++) {
      DataItem child = childrenItem.get(i);
      TiViewProxy proxy = child.getViewProxy();
      TiUIView view = proxy.createView(proxy.getActivity());
      view.registerForTouch();
      generateChildContentViews(child, view, rootItem, false);
      // Bind view to root.

      ViewItem viewItem = new ViewItem(view, new KrollDict());
      rootItem.bindView(child.getBindingId(), viewItem);
      // Add it to view hierarchy
      if (root) {
        rootItem.addView(view.getNativeView(), view.getLayoutParams());
      } else {
        parentContent.add(view);
      }
    }
  }