Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.01 KB | None | 0 0
  1. class ComponentBase {
  2.     public function handleCreate(native:Bool) {
  3.         trace('handleCreate ${Type.getClassName(Type.getClass(this))} - native: ${native}, context: ${MainActivity.context}');
  4.        
  5.         var className:String = Type.getClassName(Type.getClass(this));
  6.         var nativeComponentClass:String = Toolkit.nativeConfig.query('component[id=${className}].@class', 'android.widget.RelativeLayout');
  7.         trace(nativeComponentClass);
  8.         view = Type.createInstance(Type.resolveClass(nativeComponentClass), [MainActivity.context]);
  9.         trace(view);
  10.     }
  11.  
  12.     private function handlePosition(left:Null<Float>, top:Null<Float>, style:Style) {
  13.         trace('handlePosition ${Type.getClassName(Type.getClass(this))} - left: ${left}, top: ${top}');
  14.         var params:RelativeLayout_LayoutParams = cast(view.getLayoutParams(), RelativeLayout_LayoutParams);
  15.         if (params == null) {
  16.             params = new RelativeLayout_LayoutParams(ViewGroup_LayoutParams.WRAP_CONTENT, ViewGroup_LayoutParams.WRAP_CONTENT);
  17.         }
  18.        
  19.         params.leftMargin = Std.int(left);
  20.         params.topMargin = Std.int(top);
  21.         view.setLayoutParams(params);
  22.     }
  23.  
  24.     private function handleSize(width:Null<Float>, height:Null<Float>, style:Style) {
  25.         trace('handleSize ${Type.getClassName(Type.getClass(this))} - width: ${width}, height: ${height}');
  26.         var params:RelativeLayout_LayoutParams = cast(view.getLayoutParams(), RelativeLayout_LayoutParams);
  27.         if (params == null) {
  28.             params = new RelativeLayout_LayoutParams(ViewGroup_LayoutParams.WRAP_CONTENT, ViewGroup_LayoutParams.WRAP_CONTENT);
  29.         }
  30.        
  31.         params.width = Std.int(width);
  32.         params.height = Std.int(height);
  33.         view.setLayoutParams(params);
  34.     }
  35.  
  36.     private function handleAddComponent(child:Component):Component {
  37.         if (Std.is(view, android.view.ViewGroup)) {
  38.             cast(view, android.view.ViewGroup).addView(child.view);
  39.         }
  40.         return child;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement