コード例 #1
0
  // equivalent to document.ready in jQuery
  private final void initViewReady() {
    /*
    		View root = getWindow().getDecorView().getRootView();

    		if (root != null) {
    			final VaporView<View, ?> vaporRoot = $.View(root);

    			ViewTreeObserver vto = vaporRoot.treeObserver();
    			vto.addOnGlobalLayoutListener(new $$layout() {

    				@Override
    				public void onGlobalLayout() {
    					// When the layout has been calculated we fire this event to
    					// show the View is ready
    					$.hook(VIEW_READY).fire(ACT_HOOK_ADMIN, baseHookArgs);
    					// delete this hook after we fire it, it is only fired once
    					// per activity

    					//$.hook(VIEW_READY).delete(ACT_HOOK_ADMIN);
    					vaporRoot.treeObserver().removeOnGlobalLayoutListener(this);
    				}
    			});
    		}
    */

    // Create the View ready hook
    $.hook(
        VIEW_READY,
        $.Bundle()
            .put(VaporHook.ADMIN_AUTH, ACT_HOOK_ADMIN) // password protect
            // against admin changes
            // to these hooks
            .put(VaporHook.AUTO_DELETE, false) // these hooks will not be auto
            // deleted when hookeeCount
            // drops to 0
            .put(VaporHook.DELETEABLE, true) // this hook is deleted when fired
        );

    View root = getWindow().getDecorView().getRootView();

    if (root != null) {
      final VaporView<View, ?> vaporRoot = $.View(root);
      ViewTreeObserver vto = vaporRoot.treeObserver();
      vto.addOnGlobalLayoutListener(
          new $$layout() {

            @Override
            public void onGlobalLayout() {
              // When the layout has been calculated we fire this event to
              // show the View is ready
              $.hook(VIEW_READY).fire(ACT_HOOK_ADMIN, baseHookArgs);
              // delete this hook after we fire it, it is only fired once
              // per activity
              $.hook(VIEW_READY).delete(ACT_HOOK_ADMIN);
              vaporRoot.treeObserver().removeOnGlobalLayoutListener(this);
            }
          });
    }
  }
コード例 #2
0
 /**
  * Fluent equivalent Vapor method for invoking onFocusChange(View,boolean), called when the focus
  * state of a view has changed.
  *
  * @param view The view whose state has changed.
  * @param hasFocus The new focus state of v.
  * @return this
  */
 public self focusChange(VaporView<? extends View, ?> view, boolean hasFocus) {
   this.view.onFocusChange(view.view(), hasFocus);
   return (self) this;
 }
コード例 #3
0
 /**
  * Set the activity content to an explicit view. This view is placed directly into the activity's
  * view hierarchy. It can itself be a complex view hierarchy.
  *
  * @param view The desired content to display
  * @param layoutParams Layout parameters for the view
  */
 protected final void contentView(
     VaporView<? extends View, ?> view, ViewGroup.LayoutParams layoutParams) {
   setContentView(view.view(), layoutParams);
 }
コード例 #4
0
 /**
  * Set the activity content to an explicit view. This view is placed directly into the activity's
  * view hierarchy. It can itself be a complex view hierarchy. When calling this method, the layout
  * parameters of the specified view are ignored. Both the width and the height of the view are set
  * by default to MATCH_PARENT. To use your own layout parameters, invoke cntentView(VaporView<?
  * extends View,?>, android.view.ViewGroup.LayoutParams) instead.
  *
  * @param view The desired content to display
  */
 protected final void contentView(VaporView<? extends View, ?> view) {
   setContentView(view.view());
 }